I finally converted "PING)))DAR -A RADAR STYLE DISPLY" to spin (from BS2)... if anyone is interested. I have added some bullets about the program below.
- I originally was going to use FLOAT32 math for the polar to Cartesian procedure, but found that integer math (using scaling) prove to be faster (BIG THANKS TO LOCALROGER). Understand, if you want to use FLOAT32, it will still work. If you want more info on using scaling, see the post I started in the "propeller" forum. Title is "Debug, and plotting a "*" at a specific location". Look for a post by LOCALROGER. The beginning of this thread also explains it very well (THANKS JESSICA AND ANDY).
- If you want, you can use the scan routine for a robot.
- All math and plotting is done in the top object and the scanning/ranging is done in a cog. I use pointers to read the values from the cog ("RANGE AND PINGDIR").
- Ensure you power ping and ping_servo with a good +5 volt supply. Otherwise ping might just stop scanning without explanation.
- The whole project consists of 4 objects; "radar1", "FullDuplexSerialPlus", "ping_sweep_range", and "ping".
- There are a few constants that you will have to modify... the first is in "radar1"... the value of "410", which is the value that corresponds to 1 msec and moves MY servo to 0 degrees, you will have to change to match your 0 degrees. Just plug in some values around 410 and see which one gets you closest to 0 degrees.
- The second change is in the object "ping_sweep_range". Change the con "LimitRight" to the value you used to replace my value of 410 (above). You will also have to change "LimitLeft = 2330". This is the value that corresponds to 2 msec and moves MY servo to 180 degrees. Once again, plug in some values (around 2330), and see which value gets you closest to 180 degrees.
- THIS IS IMPORTANT... YOU WILL ALSO HAVE TO CHANGE YOUR INCRIMENT VALUE (AND ANY VALUE of 1920 IN "radar1") IF THE DIFFERENCE BETWEEN LIMITRIGHT AND LIMIT LEFT DOES NOT EQUAL 1920. If you have questions about this, please PM me, but you should be able to figure it out if you think about it.
- Schmatic is in top object ("radar1"). I used P0(servo) and P1(ping). If you use different values, ensure you change them in both "radar1" and "ping_sweep_range"
- One last thing... when you press F10 (or F11), you have a few seconds to press enable on PST. Don't for get to "ENLARGE" the display (top right).
- I intend to use the scanning procedure on my bot. I would not have been able to do this if previous documentation had not been complete. Thanks again Jessica and Andy.
Have a good one.
Bob
File Attachment : radar1 - Archive [Date 2009.10.14 Time 21.01].zip 11KB (application/x-zip-compressed)This file has been downloaded 10 time(s). |