Cruise control & push button 433 MHZ R/C on a live steam loco

dewintondave

Live Steam, Live Diesel
15 Nov 2009
181
22
New Zealand
Best answers
0
A fellow G1MRA member inspired me to have a go at building cruise control for my live steamer. His controllers are based purely on electronics with no software. I don't have much electronics know how. Then I discovered the excellent Picaxe system http://www.picaxe.com/ , and the rest is history...
The aforementioned G1MRA member also uses 433MHz radio control for his steamers. And I had a go at this as well.
433MHz is the garage door opener / wireless door bell type frequency. Keyfob size transmitters are freely available. I bought a Tx and Rx module from Ebay recently, here is the link:

http://www.ebay.com/itm/330734446785?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649
Seller: http://myworld.ebay.com/xyfs-us/
These are really good value with free worldwide shipping and the seller is excellent.
This is what the Tx and Rx look like, the transmitter even with classy woodgrain effect finish :)
433mhz4ChannelRFRadioWirelessControllerRemote.jpg

This system has 4 channels but I'm only using two at present. On my set-up, button D starts and stops the train and sounds the whistle at the same time. Pressing any other key will just sound the whistle.
The 433MHz system is very light on battery power compared to the usual model aircraft type controllers which are constantly transmitting instructions at a great rate, even when not appropriate. My 433MHz transmitter only transmits when a button is pressed, and the receiver only draws a few milliamps. As with the usual radio controllers current is being sent to the servos even when they are still, this is to maintain position. So I turn off the servos when they are not in use, like when the stop train button has been pressed and when the whistle is not being blown. The system is glitch-free and the range is adequate for my garden.
I have fitted the control system in a trailing truck, here is the rig:
DSC09355s.jpg

There are two servos in the bunker; a mini servo on the bottom controlling the regulator and a micro servo glued on top of it, this pulls the whistle cord. I've used a spring in the whistle cord to give the whistle lever a full pull without straining anything.
DSC09348.jpg

Here is a video of the loco doing a circuit of our track, the first minute or so deals with the loco preparations:
http://www.youtube.com/watch?v=3WKNQEL9_LY
To be continued...
 

dewintondave

Live Steam, Live Diesel
15 Nov 2009
181
22
New Zealand
Best answers
0
Here is the trailing car contents; all the control gear:-
DSC09230.jpg


I'm using Picaxe M08M2 chips on three of their excellent AXE021 Proto Board Kits. These proto boards and chips are inexpensive. As per the Picaxe recommendations I'm using separate power supplies for the Picaxe's and for the servo power. These are 4 AAA cell eneloop rechargeables. The Picaxe cannot take 6 volts, so if non-rechargeables were used only a 3 cell battery pack should be used.

Theres a lot of spaghetti wiring. All the PCBs, the IR sensor, the RC Rx, and the batteries need to be well grounded to each other, sharing common ground.

Here is the excellent Honeywell HOA7720-M22 IR sensor attached to the floor of the car:-
DSC09455.jpg


This sensor is really good as it has an in-built Schmitt trigger, this provides a nice fat high/low output. It only needs three connections, the two power lines and a signal out.

Here is a shot of the slotted-disc type counter wheel attached to the axle.
DSC09454.jpg


I'm using a 10-slot counter wheel, this worked out nicely for the diameter of wheel that I am using. This breaks the infrared beam from the sensor. The sensor converts this into the digital pulses. The picaxe counts the pulses over a preset time frame, and then outputs whether the count is high or low relative to the preset.

I'm using three Picaxe proto PCBs, the first counts the pulses and provides power for the IR sensor, the second is the regulator servo controller, the third is the whistle servo controller and provides power for the R/C receiver.

to be continued.
 

gregh

electronics, computers and scratchbuilding
1 Nov 2009
3,137
263
Sydney, Australia
www.members.optusnet.com.au
Best answers
0
Country flag
I'm enjoying your description. The IR sensor is a nifty gadget - where do you buy it and how much?
Did you really need 3 Picaxes?
I have run 2 servos from one 08M - using the SERVO command for the throttle (which runs in the background) and a PULSOUT command to run the 2nd one intermittently like your whistle. I've found you can go 200ms without issuing a pulse before the servo gets 'lost' ( compared to the 20ms 'standard'), so plenty of time to do other processing like checking Rx outputs and maybe even checking the speed pulses.

Looking forward to the rest of the story.
 

dewintondave

Live Steam, Live Diesel
15 Nov 2009
181
22
New Zealand
Best answers
0
gregh said:
I'm enjoying your description. The IR sensor is a nifty gadget - where do you buy it and how much?

Hi Greg, I'm glad you are enjoying it. I think the IR sensor is just perfect for the job. It's never missed a beat, rock-solid. I think it handles stray light well too, other wise we could have a runaway. RS online & Element14 / Farnell do them they are $15 - $30.

Did you really need 3 Picaxes?
It's what I used. I thought I'd just describe what I did and encourage others to have a go, and make any changes they like.

Looking forward to the rest of the story.

You'll just love the next section....:)
 

dewintondave

Live Steam, Live Diesel
15 Nov 2009
181
22
New Zealand
Best answers
0
Here's the counter board.
DSC09462.jpg


The power connector feeds in the 5V from the batteries. The sensor connector supplies +5V and Gnd from the board and receives the sensor signal from the central blue wire. The blue wire feeds through to port 4 on the Picaxe. The output from the Picaxe is on port 1. The output connects to the servo board.

Here's a shot of my Excel spreadsheet to calculate the timing.
Spreadsheet.jpg


The spreadsheet was used to calculate the Picaxe timer value for 10 slots of the counter wheel at a scale 10 mph.

I can email you a copy of my spreadsheet if you wish, please email me:
emailtiltedminimised.jpg


Here's a shot of the Picaxe programmer showing the simple instructions that I am using.
Picaxeprogrammer.jpg


The instruction states to count the pulses on port 4 for 0.335 seconds, and store the number as w1. Then if the number is less or more than 10 set the output port 1 high or low.

Picaxe starter kits AXE003/AXE003U contain the proto board, the chip, the programming cable, and all the software required.

To be continued.

Dave.
 

gregh

electronics, computers and scratchbuilding
1 Nov 2009
3,137
263
Sydney, Australia
www.members.optusnet.com.au
Best answers
0
Country flag
dewintondave said:
This sensor is really good as it has an in-built Schmitt trigger, this provides a nice fat high/low output. It only needs three connections, the two power lines and a signal out.

Here is a shot of the slotted-disc type counter wheel attached to the axle.
DSC09454.jpg
What is the big cylinder on the axle?
I've found that Jaycar have a photo-interrupter for $3.50. No schmidt trigger but will do me for experimenting
http://www.jaycar.com.au/products_uploaded/ZD1901.pdf < Link To http://www.jaycar.com.au/...ts_uploaded/ZD1901.pdf

Now I assume you have to ensure there is NO play in the axle so the slotted disk doesn't rub on the interrupter. The Jaycar 'slot' is 3mm wide so allowing a 1mm thick slotted disk, that only leaves +/1 1mm to play with. Obviously it's possible cause you've done it, but I would have though it quite difficult. comments?

I'm just thinking of using it to synchronise the chuff rate of my sound circuit, using the slotted disk on a tender axle. At present I just use an ADC with the motor volts as input to the Picaxe. I hope I can replace that input with a pulse train from the pickup, but may not have enough time between chuffs to do sound processing.
Keep the details coming......
 

dewintondave

Live Steam, Live Diesel
15 Nov 2009
181
22
New Zealand
Best answers
0
gregh said:
What is the big cylinder on the axle?

Hi Greg, It's just a large boss with a grub screw in it for positioning on the axle.

Now I assume you have to ensure there is NO play in the axle so the slotted disk doesn't rub on the interrupter. The Jaycar 'slot' is 3mm wide so allowing a 1mm thick slotted disk, that only leaves +/1 1mm to play with. Obviously it's possible cause you've done it, but I would have though it quite difficult. comments?

I went for minimal play to ensure the axle still runs freely.

Best wishes,
Dave.
 

dewintondave

Live Steam, Live Diesel
15 Nov 2009
181
22
New Zealand
Best answers
0
Here is the regulator servo board.

DSC09464s.jpg


This board has a separate power supply for the servo, this was recommended to keep "noise" out of the Picaxe power supply. You can see the servo connect cable, it is now soldered direct to the board. The colour code of the cable is red for +5V, black Gnd, white is the signal from the picaxe. There is a 330 Ohm resistor between the Picaxe output on port 0 and the white servo lead.
The Gnd for both power supplies are connected on the boards - the lower track on the image below is the 0V track. It is essential that all the boards, the Rx, and the IR sensor all share a comon ground.

The other white connector has the signal from the receiver - Rx connected direct to Picaxe input port 4, and the signal from the counter board connected to Picaxe input port 3.

Here is another view of the regulator servo board with the Rx above it.

DSC09465s.jpg


Here is a screenshot of a Picaxe program that I have used.

Picaxeprogrammer-servoboard.jpg


This program at switch-on moves the regulator to the stop position if it isn't already. Then the program waits for the start button press on the transmitter. When the button is pressed the program shoots down to the more: section as the loco is stationary and applies the regulator, then waits for the loco to build-up speed, then returns to the main: section. In the main: section the program checks to see if the stop button has been pressed. Then the program proceeds to the move: section to check whether the loco is above or below speed. And so on.

I'm using a more complicated version now but this one explains the system easily and is one that I have used. I will be happy to share my latest program with anyone who builds the system.

Next I'll deal with the regulator servo positions.

To be continued.
 

dewintondave

Live Steam, Live Diesel
15 Nov 2009
181
22
New Zealand
Best answers
0
The regulator servo needs to be mounted to the loco and hooked-up to the regulator just like on a radio control set-up. I'm using a Futaba mini servo on mine glued to a piece of timber screwed to the footplate.

The next thing is to determine the required servo positions.

This little program can be loaded on to the Picaxe, it is using port 0 as the servo output. This program sets the servo swinging over its entire range of movement (position 75 to position 225). The program can be altered to hold the servo in any of the positions.
Picaxeprogrammer-servo.jpg

My set-up now has regulator fully closed at pos. 225 and my largest regulator opening is set to 80.

The trade secret to my set-up is the pre-set minimum regulator position for when the loco is running. This is the required regulator setting for my loco to cruise along my straight level sections at a steady close-to-required speed. This stops any annoying kangaroo hopping from shutting off the regulator too much.

These are my current regulator settings for running, they feature in my video of http://www.youtube.com/watch?v=Jq4MbCBAF6Y < Link To Albus hauling the heavy test train:

225 - Fully shut off (quit: position)
201 - Minimum setting for running
161 - 1st application of regulator after starting sequence
147 - Starting regulator position / 2nd application of regulator
100 - 3rd application of regulator
80 - 4th application of regulator (Never reached unless something is amiss)

Small amounts of regulator opening don't work so well on my loco, these large openings equate to regulator pumping, and are especially usefully after a period of coasting when the cylinders have cooled.

To be continued.
 

gregh

electronics, computers and scratchbuilding
1 Nov 2009
3,137
263
Sydney, Australia
www.members.optusnet.com.au
Best answers
0
Country flag
dewintondave said:
Here is a screenshot of a Picaxe program that I have used.

Picaxeprogrammer-servoboard.jpg
Must admit to be a bit confused.
Am I correct to assume the output of the receiver is latched. Ie you press D once and the Rx (pinC.4) goes high and stays high when you release D button; when press D again it goes low and stays low. (The receivers I use are not latched and the output only stays high while a button is pressed.)
Now to the output from the wheel rev counter into pinC.3 - 0=speed up (more:), 1=slowdown (less:). I would have though you need 3 states for this - speed up, slow down and do nothing (ie speed count=10). Is it just that you have a long pause time between reading the speed and that you let the servo go up and down when the speed is not changing?
It seems to me that if the speed is constant, then on one read of the counter you will do whatever the last speed was, (say increase throttle), then when the next read shows it has increased speed you will reduce throttle. So in effect the throttle is always going to move for each read of the speed.
Don't waste too much time explaining if I'm wrong - just tell me it works, and as usual I'll accept I can't figure out other peoples programs!
 

dewintondave

Live Steam, Live Diesel
15 Nov 2009
181
22
New Zealand
Best answers
0
gregh said:
Am I correct to assume the output of the receiver is latched. Ie you press D once and the Rx (pinC.4) goes high and stays high when you release D button; when press D again it goes low and stays low. (The receivers I use are not latched and the output only stays high while a button is pressed.)
Yes the receiver outputs are latched on this receiver. I recently bought another but found it was a momentary type by plugging it into the cruise control wagon, I pressed the start button "D" the servo did its usual thing then promptly went into slow down and stop mode. The auction number I have on my first post is for a latched receiver.

Now to the output from the wheel rev counter into pinC.3 - 0=speed up (more:), 1=slowdown (less:). I would have though you need 3 states for this - speed up, slow down and do nothing (ie speed count=10). Is it just that you have a long pause time between reading the speed and that you let the servo go up and down when the speed is not changing?

Good points Greg. I am missing the "do what if the speed is correct" part.

It seems to me that if the speed is constant, then on one read of the counter you will do whatever the last speed was, (say increase throttle), then when the next read shows it has increased speed you will reduce throttle. So in effect the throttle is always going to move for each read of the speed.

The reality is that when the regulator closes the loco is still going overspeed. So mainly the loco runs with the servo in the closed position (running position). My latest version of the program closes the regulator further by one servo step every second the loco is still over-speed. Then the loco goes on to a curve or gradient then goes underspeed then the speed up routine kicks in. The speed-ups now have a 2 second delay before checking for under-speed, but every 1/3rd second it checks for over-speed. The control closes the regulator in one fell swoop now to the running position as soon as an over-speed is detected.

Don't waste too much time explaining if I'm wrong - just tell me it works, and as usual I'll accept I can't figure out other peoples programs!
It does work ;) And, you are right. In a higher speed set-up like the G1MRA boys use - scale 60mph or so, I would need to address the "do what if the speed is correct" part.

Best wishes,
Dave.
 

dewintondave

Live Steam, Live Diesel
15 Nov 2009
181
22
New Zealand
Best answers
0
It's time for the whistle servo board and the receiver.

Here is the whistle servo board. The receiver connector is also visible.
DSC09468s.jpg


The whistle servo board provides power for the reciever, and takes the whistle signal from the Rx on input port 4.

This image shows the Rx and the regulator servo board. The whistle board is under Rx.
DSC09467s.jpg


Here is the reciever with the connector in place. I've labeled the connector with + (VCC) and - (Gnd) for the 5V power coming from the picaxe board. The "W" (VT) is the whistle signal going to the whistle board, and "S" (D0) is the start/stop train signal going to the regulator servo board. The VT connection on the receiver is interesting because when any of the Tx buttons are pressed the VT goes momentarily high to 5V, this allows the whistle to sound whenever the train is starting or stopping. The RX outputs are D0 to D3 and when the corresponding Tx button is pressed the output goes high to 5V and stays high until the button is pressed again.

I ran the Rx without an aeriel for quite a while, it was only when I bought another Rx from Ebay that came with an aeriel attached that I realised mine was missing. The range wasn't too bad but I had to lift the Tx over my head to get the whistle to work at the furthest point of my line. Now with the Rx aeriel installed I don't need to extend the Tx aeriel, it truely is a pocket sized transmitter.


There are three channels that aren't being used
DSC09466s.jpg


Here's the program for the current "peep-pip-pip" whistle sequence.

Picaxeprogrammer-whistleboard.jpg


This program switches off the whistle servo when not in use, and hopefully saves plenty of power.
There are pauses in the sequence to allow time for the servo to return to the whistle off position (position 95). Servos aren't too fast on 5V. I'm using a cheap micro servo for the whistle.

Dave.
 

dewintondave

Live Steam, Live Diesel
15 Nov 2009
181
22
New Zealand
Best answers
0
A couple of weeks ago I tweaked the code below.

Picaxeprogrammer.jpg


After an application of the throttle the loco overshoots the desired speed, and that the above code sends port c.1 high when 11 mph is reached and exceeded which is higher than my desired 10 mph.

I changed the fourth line of code to "if w1 > 9 then high c.1"

Last weekend I ran exactly the same train as previously shown on: http://www.youtube.com/watch?v=Jq4MbCBAF6Y

This time, the elapsed time for the circuit rose to 3' 45" making for an average speed of 10.4 mph. The previous speed was 10.8 mph as shown on the video.

The regulator servo moves about more now, certainly on the slowing down side of things.

Best wishes,
Dave.