Turret RADAR using ))Ping
noobmuncher
Posts: 124
I am trying to modify the Ping Dar progam, the one that just acts as a sort of radar.· Ultimatley what i am trying to do is make it so that the second scan is compared to·the the first scan to detect large amounts of motion.· I need to tie this in so i can point an array of sensors in the direction of the motion.· I had thought about having it detect it in sort of quadrants, but i am open to ideas, because I am really stuck.· Any suggestions are great!· Code is even better : )·
Link to original page and code
http://forums.parallax.com/showthread.php?p=590115
Link to original page and code
http://forums.parallax.com/showthread.php?p=590115
Comments
Suppose you divide the servo search area of 180 degrees into 10 degree segments. Search each area, storing the results in an array, like...
array1 var byte(18)
array2 var byte(18)
for degrees = 0 to 180 step 18 ' First set of readings
...move servo to degrees
...store reading in array1(degrees / 18) ' degrees divided by 18 will give you the array elements 0 to 17
next
for degrees = 0 to 180 step 18 ' Second set of readings
...move servo to degrees
...store reading in array2(degrees / 18) ' degrees divided by 18 will give you the array elements 0 to 17
next
'Now subtract array1 from array2
·for i = 0 to 17
...array1(i) = array1(i) - array2(i)
next
If there was no movement, all the array1 elements should read close to zero. The highest (and lowest) numbers will tell you where there was the most change or possible movement.
If you want to do this with just one array instead of two, have the second scan pass just subtract its reading from what is already in the corresponding array1 element. Then you could have another array with the previous set of readings if you want to know which way the target is moving.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Richard Vannoy
Programming and Electronics Instructor
www.PICRobots.com
www.SailingStrategy.info
www.TeachingTechnicalTraders.com
·
I realize what you posted is just an example, but the PBASIC Stamps only have 26 bytes for variables in RAM. RAM is where you would be declaring those two arrays. Thus 18 X 2 = 36 bytes would be required, and that exceeds the size limit. If you can do with a NIB (4 bits), you've got it made!
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.