RC switch

Discussions around autonomous, semi-automatic and intelligent robots and systems.

Moderators: BeligerAnt, petec, administrator

Post Reply
Andrew_Hibberd
Posts: 1134
Joined: Tue Jan 20, 2004 12:00 am
Location: London
Contact:

RC switch

Post by Andrew_Hibberd »

I have made a board using a PIC 08 chip which takes the pulse of the rx and gives an on/off/reverse output using a L293 motor control chip. I have put 2 leds on the output to check direction. However the output is picking up alot of noise. I have tried putting error detection in, however i have been unable to get a smoother output. The simple code i have atm is:

symbol Pulse_Lenth = b0

main:
pulsin 4,1,Pulse_Lenth
if Pulse_Lenth >= 145 and Pulse_Lenth <= 165 then Set_Off
if Pulse_Lenth >= 90 and Pulse_Lenth <= 144 then Set_For
if Pulse_Lenth <= 210 and Pulse_Lenth >= 166 then Set_Rev
if Pulse_Lenth > 210 or Pulse_Lenth < 90 then Set_Off
goto main

Set_Off:
high 2
high 1
goto main

Set_For:
high 1
low 2
goto main

Set_Rev:
high 2
low 1
goto main

I tried counting the number of out of range pulses, and if this was above 500 then stop, if the pulse was in range -50 from the counter. However there was no respoce from the output, the output continued its current direction until it got a valid signal or and error occured. Has anyone got any suggestions?

Thanks
TEAM GEEK!
User avatar
BeligerAnt
Posts: 1872
Joined: Wed May 15, 2002 12:00 am
Location: Brighton
Contact:

Post by BeligerAnt »

500 erroneous pulses seems a little high. At 50 pulses per second, that's 10 seconds without a single valid pulse! Reducing the count by 50 for every valid pulse received could easily lead to strange effects. What happens when the counter goes negative? Also only one valid pulse per second is enough to keep the counter at zero.

For RefAnt, I had a similar thing, detecting forward, mid or reverse. It is all available in PIC assembler if you want it. (Email me after the Bank Holiday)
Basically it disregarded all pulses outside 1-2ms. If the pulse was valid it decided whether it was low, medium or high. Then it applied a 5 cycle filter before switching modes. This means that when the stick moves from mid to forward, it has to stay there for 5 cycles (100ms) before the robot responds.

You may want to try disabling the "brownout detection" in the PIC, as this can cause it to reset itself if there's any noise on the supply rail. It's one of the options in the "configuration" word. I don't know how the Picaxe handles this.
Gary, Team BeligerAnt
Andrew_Hibberd
Posts: 1134
Joined: Tue Jan 20, 2004 12:00 am
Location: London
Contact:

Post by Andrew_Hibberd »

I removed the error detection completely and am just using the on off reverse parts and if out of range stop. This seems to work fine now, i was confused by the pulsin command. I was using the pin number not the input number. The only problem i have spotted with this is that there is a noticiable lag between the output going on from the tx moving, as much as 500ms. I am presuming this is to do with it having a slowish 4Mhz resonator.

Thanks Gary i will email you after the bank holiday to look at the assembler code, i may put in the 5 valid signals to respond into the code. I will be running this in anticide to control the axe at the next few events.

In the PICaxe programmer there is a check box to turn on brownout which i have not checked yet.

Also thanks to Adam.
TEAM GEEK!
Post Reply