Picaxe as rc failsafe

D396

Senior Member
I am currently in the process of making a robot. I am using a rc car as the chassis and already have the navigation up and running but I want someway to take control of the robot if something goes wrong. I want to use an extra 18x I have to detect when the rc transmitter is turned on (easy just have an int check for servo pulses) and then instead of taking the signals from the autopilot take them from the rc receiver but when the transmitter is turned off reroute the signal from the autopilot to the motor. Thank you for any help you can provide.
 

BeanieBots

Moderator
Not as simple as may first appear.
When the radio is off or out of range, most receivers will put noise out on the servo line.
Thus, to detect a switched off radio is not as simple as checking for a lack of pulses.
The most effective way is to check for pulses which are out of range.

If in range, then simply pass the value through to the servo command.
If out of range, then send a predefined value.
 

srnet

Senior Member
RC receivers vary a lot as to what they do when they gop out of range, I would check what your particular receiver does first.

I posted this in another thread;

Failure mode on link failure is dependant on the RC receiver, some types just go nuts as you describe, some stay where they (hold mode) are and others return to a 'fail safe' location.

Detecting link failure on reciviers which go nuts, is failrly easy, just measure the RC pulse and if its width is lower then about 750us or more than about 2250us, then assume the link is down.
 
Last edited:

BeanieBots

Moderator
I have been looking online a bit and I found most use a 74ls157. Why?
Most what use a 74LS157 to do what?
Please provide an example link.

As for how to switch between the two.

Define fixed value (for failsafe position)
Start
Read in pulse. (puslin)
If within range, then use value in servo command. (if/then/else)
else
Use fixed defined value for servo command (servo pin value)
endif
Goto Start
 

srnet

Senior Member
So give us a clue.

When you switch of the radio at the moment what happens to the servos ?

Do they stay where they are, go nuts or return to some set position ?
 

hippy

Technical Support
Staff member
As others have noted, in order to activate an 'out of range autopilot' or even an 'emergency stop' you need to have a means to determine when out of range. If using the RC signal to detect that you need to know how the RC signal behaves when out of range compared to in range. The PICAXE can then determine when the signal is valid or not, whether in range or not.

So that's the first place to start; what does the RC signal do when out of range ?
 

Andrew Cowan

Senior Member
So that's the first place to start; what does the RC signal do when out of range ?
That's what you need to find out. From my r/c experience:
- Cheap AM systems tend to output noise and rubbish when signal is lost.
- More expensive FM systems tend to output nothing when signal is lost
- My top end 2.4GHz systems vary - one has failsafe's built in to all channels, and one has failsafe on one channel. On all other channels, when signal is lost they carry on giving out the signal they were outputting before signal was lost.

A
 

srnet

Senior Member
That's what you need to find out. From my r/c experience:
- Cheap AM systems tend to output noise and rubbish when signal is lost.

- My top end 2.4GHz systems vary - one has failsafe's built in to all channels, and one has failsafe on one channel. On all other channels, when signal is lost they carry on giving out the signal they were outputting before signal was lost.

A
"- More expensive FM systems tend to output nothing when signal is lost"

Forgot about them, indeed some do.

And yes, all the 2.4Ghz ones I have come across go into hold mode.

The cheap Corona FM ones also go into hold mode, I prefer to use the 8 Channel synth FM receivers, thay have a failsafe mode you can set, but otherwise go into hold.
 

D396

Senior Member
Sorry for bringing this thread up again but I now have my transmitter and receiver hooked up to my picaxe (08m). I have attached scope readings when the device is off and also when it is on. What I want to do is be able to switch between this device and another by switching a switch connected to a picaxe. Do I need any other external hardware? Thanks.
 

Attachments

hippy

Technical Support
Staff member
With it on it looks fairly consistent, and inconsistent when off, so you could run a PICAXE program which checks the regularity of the input, looks for missing pulses, pulses arriving sooner than expected etc.

The only issue is how quickly you can tell you have an error and how you can avoid responding to an incorrect signal thinking there is no error. You might have to experiment to get behaviour as you like it but it could be fairly simple.
 

D396

Senior Member
Ok. I will try that. It would probably be alot easier to get a 3 channel TX that just has a switch.
 

hippy

Technical Support
Staff member
Untested and incomplete, but this should look for the occurance of a pulse every 20ms ( no sooner than 10ms after last, and no later than 30ms ). Positive going pulse expected on input pin 0 ...

Code:
PowerOnReset:

  Do : Loop while pin0 = 0
  Do : Loop while pin0 = 1

  Gosub InterruptEnable

  Do:
    b0 = 0 : Pause 10
    b0 = 1 : Pause 20
  Loop While b0 = 0

Failed:
  Goto Failed

Interrupt:
  If b0 = 0 Then Failed

  Do : Loop while pin0 = 1

InterruptEnable:
  SetInt %00000001, %00000001
  b0 = 0
  Return
 
Top