S2 Ping))) Object and a FREE Offer
![Phil Pilgrim (PhiPi)](https://forums.parallax.com/uploads/userpics/612/nMG83RHE7MV61.gif)
I think I've figured out a way for the S2 to support Parallax's Ping))) distance sensor. The fact that the usual Ping))) code does not work with the S2 was discussed here:
In a nutshell, the reason the Ping)) does not work with the S2 is due to the S2's hacker-port level translator, combined with its filter caps and the Ping)))'s series I/O resistor. As a consequence, the S2 does not see the low pulse that terminates the Ping)))'s timing interval. My solution is to use a counter in DUTY mode to bias the input to the Prop a little bit lower so it can catch the low pulse. It's a bit surprising that this actually works, since the DUTY output is on the same pin that's being read via waitpeq to catch the pulse. One would think that the low pulses on the DUTY output would trigger the waitpeq before it even got to the return pulse form the Ping))). But, apparently, the Prop itself has enough internal capacitance that an isolated 12.5 ns low pulse is not enough in and of itself to be recognized by waitpeq without a little external help driving the same pin.
The attached archive includes an object and demo program for the S2 Ping))) combo. It starts by doing a self-calibration for the DUTY bias value, then continues pinging and outputting distance values.
Now for the FREE offer. I've designed a Ping))) bracket for the S2, which I will mail free of charge to the first six people who test this program with their Ping))) on an S2. To qualify, you will need to post a copy of the demo program's output in this thread and email me your mailing address.
Here's a photo of the Ping))) bracket installed in the S2:
![attachment.php?attachmentid=94899&d=1344971376](http://forums.parallax.com/attachment.php?attachmentid=94899&d=1344971376)
It does not use any fasteners. The Ping))) is held tightly in the acetal bracket by deformable grip rings.
BTW, the distance registered by the s2_ping object is the distance from the front of the S2, not the distance from the Ping))). Also, I have not bothered commenting anything yet. I need to know first whether the code works for everyone's particular S2/Ping))) combination.
-Phil
In a nutshell, the reason the Ping)) does not work with the S2 is due to the S2's hacker-port level translator, combined with its filter caps and the Ping)))'s series I/O resistor. As a consequence, the S2 does not see the low pulse that terminates the Ping)))'s timing interval. My solution is to use a counter in DUTY mode to bias the input to the Prop a little bit lower so it can catch the low pulse. It's a bit surprising that this actually works, since the DUTY output is on the same pin that's being read via waitpeq to catch the pulse. One would think that the low pulses on the DUTY output would trigger the waitpeq before it even got to the return pulse form the Ping))). But, apparently, the Prop itself has enough internal capacitance that an isolated 12.5 ns low pulse is not enough in and of itself to be recognized by waitpeq without a little external help driving the same pin.
The attached archive includes an object and demo program for the S2 Ping))) combo. It starts by doing a self-calibration for the DUTY bias value, then continues pinging and outputting distance values.
Now for the FREE offer. I've designed a Ping))) bracket for the S2, which I will mail free of charge to the first six people who test this program with their Ping))) on an S2. To qualify, you will need to post a copy of the demo program's output in this thread and email me your mailing address.
Here's a photo of the Ping))) bracket installed in the S2:
It does not use any fasteners. The Ping))) is held tightly in the acetal bracket by deformable grip rings.
BTW, the distance registered by the s2_ping object is the distance from the front of the S2, not the distance from the Ping))). Also, I have not bothered commenting anything yet. I need to know first whether the code works for everyone's particular S2/Ping))) combination.
-Phil
Comments
The Ping tries to calibrate for a seemingly random time, and then randomly sets the Bias: and dist: #s,
After calibration, the Ping stops reporting any new distance readings...(the dist # never changes).
-Tommy
The bias value looks right and is about what I get on mine. Try setting the second argument of png.start to 100 and see if the behavior changes. With this setting you should see the light on the Ping))) flash about ten times per second after calibration.
-Phil
but that only lasts a few seconds before the Ping light stays on. I get Distance updates while the Ping light flashes...
This is only after being turned off (power switch off) for a minute or so, and then reloading the eeprom using F11.
If I just turn off the S2 and then back on, the Ping light flashes maybe 5 times, then stays on, and no Dist updates..
-Tommy
-Phil
Your new code (from this thread) does return distance values, but only for a short while, then freezes up,
Just wish I could be of more help..
-Tommy
Nose of S2 200mm from monitor screen
Program as provided
Bias: BE000000
Dist: 186mm (most consistent distance - sometimes 6mm, 9mm or 55245mm)
My PING light stays on constantly
Changed png.start 2nd argument to 100 - no real change in results. Ping light never flashes.
For a short moment, it measures distance but then picks a number top display and sticks with that.
I removed the cursor positioning so it just kept printing lines - I was curious what actually was hanging up - it kept printing but the numbers never changed.
I switched to a different PING (rev.
My distances were consistently 15-20mm short of the actual nose to target distance when they were reported and looked reasonable.
On the bright side, it was real easy to open up the S2 and add the PING to it!
Ready for any other testing you require!
I'd be interested in seeing what the last 30 or so lines look like.
Thanks,
-Phil
And steady as a rock too, ran for five minutes, twice...:thumb::thumb:
-Tommy
Thanks,
-Phil
all though I can't vouch for the accuracy of distance, as I don't know from mm's,
IIRC 1/2 inch is pretty close to 12mm's and that is close to what the Ping((( was reporting,
and at 6 inches from the bumper, the Ping reported about 175 mm or so.. +/- some spastic hand movements...
Here is the reading at the front bumper...
-Tommy
Hey you guys, email me your postal addresses, and I'll send you each a laser-cut Ping))) bracket for your S2.
-Phil
I would love to have one of your laser cut Ping((( brackets Phil, Especially since erco doesn't have one...
Thanks for your time with this.
-Tommy
It was good to within 10-15mm (short of actual distance) with my jury rigged holder. This will be so sweet to have a working Ping((( on an S2! I can't wait to tune it up with a rigid support!
I'd love to have a bracket, thank you!
{The cat left just long enough for me to test. He's back now, tired out again after snacking!}
Maybe I can find one made of plywood on Ebay.
I tried to run the latest version this afternoon and it froze up within seconds, tried a couple of times with same results.
Figured it might have something to do with ambient temperature, it was about 80 degrees when I turned the S2 on,
So I thought I might wait till the fog rolled in and cooled everything down to about 68 or so.
Success! I tried the program again, and it ran as advertised for at least ten minutes, then I rebooted the S2, and
the program froze within maybe twenty seconds, so I reboot again, and it freezes in about 5 seconds,
Reboot again, and it freezes almost instantly...:frown:
I waited 30 minutes and tried again, The program ran for thirty seconds then froze, Reboot and it ran for 5 seconds,
Reboot again, and she freezes instantly again...
I was curious, and so I reloaded the Debug code from post #10
Unfortunately, it also froze after about thirty seconds or so...
I offer An uneducated guess that something heats up and changes the bias thingy into some kind of monster...
I did receive the S2 Ping((( mounting bracket (that erco does not have), and wanted to thank you again Phil.
don't think ebay is going to have these in plywood anytime soon...
Anyways, let me know what how I can help to test the next version of the S2 Ping((( Object, when you get around to it...
-Tommy
A lot depends upon what the Ping))) is aiming at during calibration. From your debug output, it looks as if there may be two objects in its field of view, one closer than the other. Try aiming it away from any objects during calibration, or else place a flat, hard surface about six inches away or so.
-Phil
Hopefully reporting news tomorrow.
P.S. I also received my Ping mount too. Excellent work! Thanks, Phil!
-Phil
Then I tried to duplicate the symptoms I described earlier, but I could not get the program to freeze no matter what I tried...
I was just about to declare success again and reached over to turn off the S2, and the program froze, I then went thru several cycles
of rebooting and freezing... So just to make sure, I again started the Ping((( while it was facing the hard surface six inches away.
but... the program froze anyway... so now I wonder if I am not so far off when I say "Something gets warmed up and throws the bias off"
I will pull out a stop watch and thermometer tomorrow morning and try to be more precise..
-Tommy
First test lasted 40 minutes continuous running with no obvious defects.
I.E, Min dist at bumper =0, Max dist =3630, and all ranges in between measured accurately for many minutes at a time.
Started the S2 NOT facing a wall and the Bias # was: BE800000, the Dist # varied as expected.
I figured 40 minutes was long enough, So I turned off the S2, faced it toward a wall 6 inches away, and turned it back on.
Poof, Instant freeze... the Bias # was: BF800000, the Dist # was: 55245.
Test 3, the S2 was again NOT facing the wall, and the program worked as expected until I reset after 2 minutes,
The Bias # : B5800000, and Dist # varied as expected.
Test 4 thru 10, the S2 was facing the wall, and froze within one second after reporting various Bias #s
BF000000, B5000000, and (BF800000 << always associated with a Dist reading of 55245 for what it's worth...)
Test 11 thru 16, the S2 was NOT facing the wall, and the program worked as expected for at least 2 minutes
before I would reset the power...
So this morning I've come to the conclusion: "Don't have any obstacles in front of the Ping((( when you power up".
This afternoon I will test again, and most likely will come to the conclusion: "My head hurts..."
-Tommy
-Phil
20 minutes no problems with start from about 1360mm from object. Appears to be accurately measuring.
Restarted with object at nose (0mm) - running fine like that for about 5 minutes so far. Distances changing and settling down to be pretty accurate.
My S2 will not reset, I need to turn on/off. Not sure if related, I may just have a hardware issue on this one.
I haven't had mine hang up. I may let this run for a while and then switch to a different PING)))
I think my S2 needs a 2 PING))) turret to sit in the center, driven by a servo.......if only I knew someone with a laser cutter......
Uh, oh. My testers are getting restless -- and demanding.
-Phil
Shortly after I hit "post" on the last message it hung up.
Now it's acting flakey. I'll recycle it again and see how it does.
....maybe I don't need that turret after all!
On the good side, I've found out that cats don't absorb high frequency as much as I thought they would!!!
Beats me!
Time for some field trials!