Sumobot + PING - Avoid pauses while waiting for ping
flowstate
Posts: 3
Hi,
I've got a sumobot using Ping sensors (a pair up front). Currently, the code works, and is pretty standard. If either of the sensors sees something closer than the radius of the ring, it's flag is set to 1, else 0.
I found that to avoid cross-chatter between the sensors, I'm having to introduce a pause. This, added to the natural pause on the PULSIN command, has given me a robot that stutters like Forrest Gump. I know we can't use threading in BASIC, but has anyone found a way around this? Below is the way that I'm reading the input from the Pings. I'm basically running the standard SumoWrestler code, substituting Pings in place of the IR pairs.
I do that twice (once for each Ping), and then go on about my business. However, the length of this function creates the servo stuttering I mentioned earlier. Any help would be appreciated.
Regards,
Eric
I've got a sumobot using Ping sensors (a pair up front). Currently, the code works, and is pretty standard. If either of the sensors sees something closer than the radius of the ring, it's flag is set to 1, else 0.
I found that to avoid cross-chatter between the sensors, I'm having to introduce a pause. This, added to the natural pause on the PULSIN command, has given me a robot that stutters like Forrest Gump. I know we can't use threading in BASIC, but has anyone found a way around this? Below is the way that I'm reading the input from the Pings. I'm basically running the standard SumoWrestler code, substituting Pings in place of the IR pairs.
PULSOUT Left_Ping_Pin, 5 PULSIN Left_Ping_Pin, 1, time inDistance = inConstant ** time ' not sure of the math on this one, but it's from the Parallax site PAUSE 50
I do that twice (once for each Ping), and then go on about my business. However, the length of this function creates the servo stuttering I mentioned earlier. Any help would be appreciated.
Regards,
Eric
Comments
So say I check the ping sensors, instead of putting
PAUSE 20
RETURN
just do
GOSUB Forward
RETURN