Multiple PING)) Code Logic Suggestions
Bill Chennault
Posts: 1,198
All--
I would like to upgrade my robot with multiple pings. It is my thought that if I had 8 PING)) units, I could easily cover the machine's entire "sight distance" out as far as necessary (36" is fine.) However, I can't get a handle on the logic to implement the code which will let me determine the sensor reporting the most distance ("most distance"·would be·a clear path: there are combinations of clear paths, ie; left-front, right-front, etc., but that makes it worse).
Other than a bunch of IF/THEN statements, how would you do it? Maybe it is simple and I am not seeing the forest through the trees.
Thanks!
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
I would like to upgrade my robot with multiple pings. It is my thought that if I had 8 PING)) units, I could easily cover the machine's entire "sight distance" out as far as necessary (36" is fine.) However, I can't get a handle on the logic to implement the code which will let me determine the sensor reporting the most distance ("most distance"·would be·a clear path: there are combinations of clear paths, ie; left-front, right-front, etc., but that makes it worse).
Other than a bunch of IF/THEN statements, how would you do it? Maybe it is simple and I am not seeing the forest through the trees.
Thanks!
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
Comments
If you want to change the search order, you could just rearrange the PING))) connections so they're scanned in the order you want.
If you have 8 PING)))s, that would take about 160ms to make a pass through all of them.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Mike, thanks for the logic. I am glad I quit thinking about it. I am going to attempt to poll the PING))s in a timed interrupt (SX/B) and return their distances to the main routine.
Zoot! Ha! Thanks for the code!
--Bill
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
You are what you write.
Post Edited (Bill Chennault) : 2/5/2010 8:48:04 PM GMT