Ping module question
James Armstrong
Posts: 3
Is there a way to modify the ping code to be able to start multiple ping sensor units at the same time and wait for all the responses and get the measured time before returning? I need to be able to monitor 4 or 5 sensors but don't want to use one cog per sensor or call one function per sensor in series because of the delays that would be added up. If the max wait time is ~50ms (max distance) and I am reading 5 of these in succession that would be about 250ms per ping cycle not allowing for more than 4 reads per second. I thought I saw a function somewhere that would start a timer that would measure a pulse on an input or multiple inputs, and wait for all of them to change before returning. I can't remember where I say that code.
- James
- James
Comments
I've been working on a robot project that uses the SRF05 sonar unit which is very similar to the PING unit. I had the same problem when I wanted to drive multiple sonars from the same cog. I wrote a new assembly driver that will monitor multiple sonar units simultaneously. It is currently written to drive 3 sonars although the code should scale up to 5 easily. I've also included·SPIN code that demonstrates using the driver.
One word of·caution, I'm using the DLP-PROP units which run at 96MHz instead of the 80Mhz that the demo board runs at. It should be obvious where to make the appropriate changes.
Hope it helps,
Chad
Post Edited (Chad George) : 12/11/2006 6:06:11 PM GMT
You're absolutely right.· Easiest way to fix this is to initialize the elapsed array to zero in the loop where started is initialized, then test for·"ina[noparse][[/noparse]4+x] == 0 and elapsed[noparse][[/noparse]x] == 0".· Sorry
Mike