Using Picaxe to enhance 2.4 GHz radio control features

gregh

electronics, computers and scratchbuilding
Country flag
I?m a convert to using cheap 2.4 GHz radio control (from Hobbyking.com), and so far have 7 locos converted. The basic speed and direction control using this equipment is VERY simple. But I?ve been working on ?fancying? up some features using Picaxe microcontrollers.

Picaxe are small Programmable Interface Controllers (the PIC part) that can be programmed to do many useful things. I use the small 8-pin version (08M) which only costs about 6 AUD. It has 5 I/O pins.
Here?s the Picaxe website link: http://www.rev-ed.co.uk/picaxe/
And you can see my webpages for some ideas of how I have used them:
http://www.members.optusnet.com.au/satr/electronics.htm
http://www.members.optusnet.com.au/satr/2point4GHz.htm#picaxeESC

If you can solder and have a bit of electronics experience and can use BASIC programming, these things are the greatest. Sure, they take a bit of an investment in time learning how to use them, but no more integrated circuits and varying discrete components. Just change the program. I mount the picaxe in a 8 pin socket, for removal for programming on my desktop PC.

So here is the first of a few, very simple uses of PICAXE microcontrollers, - to create an inertia effect.

Using the Electronic speed control (ESC) with a 2.4 GHz receiver gives no scope to introduce inertia. There is no analogue signal, just the ?servo? type pulse train from the receiver to the ESC, where the pulse lengths represent the position of the Throttle stick on the transmitter, and so the motor voltage. The usual connection is like this:
d631e488d82d41f2a2c5f54cc8babced.gif

Here?s a quick explanation of the RC pulse system.
The receiver sends out a stream of pulses. The length of these pulses correspond to the position of a servo (ie it?s rotation angle) or the voltage (speed) output of an electronic speed controller, selected on the transmitter.
On my Hobbyking receiver, for servos, the mid position is a pulse of 1.5 ms. These pulses are repeated every 20ms or so but this time is not at all critical and can be up to a couple of hundred ms. Rotate full to the right is 1.0 ms and full left 2.0ms. Pulse lengths between these values move the servo by a lesser degree. For the ESC a pulse of 1.15ms means stopped and 1.8ms is full speed.

So I wondered if I could build a simple interface between the Rx and the ESC to create Inertia.
This is about the simplest Picaxe circuit possible ? no other components, just the Picaxe and its socket, and no power supply needed.
691e66dcb91c4ae4868d5aae777809b2.gif


I use the Picaxe to :
[*]?read? the servo type pulse train coming out of the throttle channel of the receiver, then[*]generate the inertia effect, then[*](re)generate the pulses to feed into the ESC representing the ?inertial? voltage.
I used the PULSIN command to decode the throttle pulse train, and the PULSOUT command to send the pulses out to the ESC every 100 ms or so. (I planned to use the SERVO command. But I found the motor speed was not constant but ?jittered?. From various Forums on Picaxe uses, I found that the SERVO command running in the background, interferes with the timing of the PULSIN command, so that the measured length of the input pulses varies. )

In total the program only uses 145 of the 255 bytes of memory in the chip. The rate of inertia is just a single variable.
The ESC generates the 5V supply for the RC receiver and it is used for the Picaxe as well, so there are NO OTHER components besides the Picaxe.
42e1d5a5d5e645ed8c77761d6641fc59.gif


This is what the whole RC circuitry looks like.
5cdbe009c7df43cc8e58dd632f8a7c40.jpg


Now having got this far, and with spare memory and I/O pins, it is really simple to add a few extra features at absolutely no cost:
So I made the inertia rate different for accelerating and slowing.
Then I removed the inertia effect as the loco slows below one third full speed, to make it easier to stop at a given spot.
The loco now takes 5 seconds to go from stopped to max speed and 2 secs to stop from full speed, if you ?bang? the throttle up or down (as small grandsons are wont to do!).

If anyone wants the code or circuit, send me a PM as I?m not sure it would reproduce correctly in the Forum layout.
 
Very clever! And the best bit is it's very simple. I've used a turnigy servo slower and splitter to control the servos that turn the knob on the power controller. I have no idea if it would work with an esc though, in theory it should. But your system looks alot more simple and cheaper. If I can find the bits over here and when I've finished wiring my rc loco I'll pm you for some info.
Tim :D
 
This is the second example of use of Picaxe to enhance 2.4 GHz RC.

If you listen to a real diesel loco on starting, you will hear the diesel engine ?wind up? and then the train starts to move. Model loco sounds don?t do this ? the diesel throb rate is driven by the motor voltage. Some sounds circuits introduce an inertia effect in the sound, but this is actually wrong. The loco moves off and then the diesel speeds up.

In the past, I have built analogue motor control / diesel sound system where the motor speed (volts) is delayed behind the diesel engine throb rate to simulate this. This was using my own RC control system and sound system and I love the effect. (see video link later)

The usual connection is like this...
ffa9a138a7fd43199c12152314575cb7.gif


But I want to do it like this?.
ec5f6b371ee64477868f0bc2686b6907.gif



Some of my mates use MyLocoSound cards, and Geof kindly allowed me to fit it to his latest diesel for testing my circuits and Picaxe program. http://www.trainweb.org/btr/Latest News.html

The MLS board needs a single transistor interface between the Picaxe and the diesel MyLocoSound board. It interfaces the 5V of the Picaxe to the higher voltage required by the sound card to produce max revs.
(The only problem with using the MLS board is that you have to insert 2 links on the MLS board to ?tell? it that it is like a ?track powered? setup and this causes the horn to blow every time you start.)

I use the Picaxe to :
?read? the servo type pulse train coming out of the throttle channel of the receiver, then
use it to instantly generate a voltage to drive the sound card to control the diesel throb rate, AND
generate a delay of about 2 seconds, add some inertia, then
(re)generate the pulses to feed into the ESC.

The delay in outputting the motor volts is obtained by storing the last 3 values of received throttle level and delaying each one, so that the throttle setting currently being sent is the one received 3 cycles ago.

The setup looks like this on the bench. The Picaxe interface is the small brown board centre bottom. It plugs into the Receiver throttle channel (right) and the speed controller (ESC) plugs into it at left There's just 2 wires to the MLS board.
f232ad98b7224dd5a30dd1147508c16e.jpg


Now having got this far, it is really simple to add a few extra features at absolutely no cost:

1. Real diesels have usually only 8 ?notch? speeds for the engine, so I have implemented this. There are still as many motor speed control steps as the throttle allows (32).
2. When a real driver shuts off a diesel to coast, the throb rate goes back to idle, and volume reduces. Since I?m storing the 3 last throttle settings, I can determine if the train is accelerating or slowing and adjust the volume and throb rate accordingly. Controlling the volume uses another output pin which drives a transistor (or a relay for the MLS card)
3. While a delayed start sounds good when accelerating it does make stopping at a set place difficult. So I reduce the delayed motor voltage effect when I?m slowing and at slow speed (<25% say), I remove it altogether.
4. Emergency stops are sometimes necessary, so returning the throttle to zero, causes an instant stop.


You can hear the effect of my original analogue circuit and this newer one using 2.4GHz and MyLocoSound on this short video. http://www.youtube.com/watch?v=rvowIeAymyI

If anyone wants the code or circuit, send me a PM as I?m not sure it would reproduce correctly in the Forum layout.
 
Back
Top Bottom