Scribbler S2 & Ping question.
MarkPorter
Posts: 9
Hi all,
I've read much about the possibilities of hacking the S2, adding additional sensors etc, yet so far the only hack I've come across is the pen lifter?
I noticed from reading the Ping manual that the signal line requires a 1k ohm resistor on it when using with the Propellor, yet other threads I've read on this forum conflict with this information (although in fairness these were general propellor threads & not specific S2 threads)
Has anyone actually added a ping to an S2 yet? If so can you offer me some advice / guidance?
Cheers
Mark
I've read much about the possibilities of hacking the S2, adding additional sensors etc, yet so far the only hack I've come across is the pen lifter?
I noticed from reading the Ping manual that the signal line requires a 1k ohm resistor on it when using with the Propellor, yet other threads I've read on this forum conflict with this information (although in fairness these were general propellor threads & not specific S2 threads)
Has anyone actually added a ping to an S2 yet? If so can you offer me some advice / guidance?
Cheers
Mark
Comments
Ken, get an S2 to Mike and step on it!
Mark,
I just tried adding a Ping to my S2. It did not work. Darn!
I had just tested the Ping code and sensor with a QuickStart board and it worked fine. When I connected the Ping to the S2, nothing.
I'm pretty sure the level shifter is to blame.
I'll break out my oscilloscope and see if I can figure out a way of getting the Ping to work with the S2. I know from experience the level shifter can't transmit and receive signals as fast as a bare Prop IO pin. I'd bet a couple of delays in the Ping object should get things to work.
I'll report back here once I have some more info. It might take a couple of days to find the time to do this.
BTW, welcome to the forum!
I think the Ping's pulse low is too short to make it through the level shifter.
This is the code I used to trigger the Ping:
This is what it looked like with the oscilloscope. (The blue line is the channel connected to the Ping. The red channel wasn't connected to anything.)
The long low pulse is from the Prop. I think it's odd it wasn't pulled very low. It looks like it was low enough to trigger the Ping though. The short down blip is the Pings response (I assume). I think the low blip is too short to make it through the level shifter.
Anyone have any suggestions?
Hmm. Now that I think of it, that doesn't quite make sense either, given your program's timing. In any event, be sure to read the Ping))) documentation regarding how it responds to the start pulse and how long that pulse has to be.
-Phil
Looking at the Ping with a QuickStart board, I see the pulse from the Ping should be long enough. I just need to compensate for the S2's pull-up resistors (I think).
The Ping replies with a high pulse based on how long it takes for it to hear an echo.
How do I monitor the pin as an input watching for a high pulse when the signal line is pulled high?
Could I pull the line low harder than it's being pulled high?
This is what the oscilloscope saw (again, this is with a QuickStart board).
It looks like the Ping's reply is plenty long enough, I just don't know how to read it with the S2 since the S2 has pull-up resistors on the signal line.
Cheers
Mark
You're right. I've got a Ping))) connected to my S2 now, and it looks like more of a challenge with the level converter than I thought it would be. I'm sure it can be made to work, though.
-Phil
Just getting my head around the schematics now.
Give this code a try:
Here's what my output looks like on the scope (Ping side):
The level translator's internal pullups are the issue here, I believe. As a consequence, you have to hold the pin low before you pulse it to provide adequate setup time to the Ping))). At least I think that's what's happening. Also, you can't measure time beginning at the rising edge of the return pulse, since it goes high right away. So the echo times will all be too long by a constant amount (the part marked "normal low time", which my code above does not yet account for).
-Phil
Thanks for the suggestions and the code. It looks like it should work but so far it doesn't with my S2 and Ping.
It appears the waitpeq is never met. My logic analyzer makes it look like it should be work.
Edit: The logic analyzer does not detect the low pulse from the Ping. The pulses shown are all from the Prop.
I've got to help with dinner, so I'll need to look at this some more later. I don't know why my S2 isn't seeing the low signal? I bet this does the trick with just a bit more tweaking.
It wont be hard to figure out how much time to subtract. I'll just use the Ping with a different Propeller board and measure the delay.
@Mark, You're welcome. Yes, I've downloaded the schematics already. I've fiddled with the S2 a bit in the past. Now that Phil is helping out, I bet this gets figured out soon.
I had mislabeled the start pulse as "Pulse from Ping)))" in my scope trace. The label has now been corrected.
Part of the difficulty in interfacing the S2 to the Ping))) is that the level translator circuitry uses 4.7K pullup resistors on the open-drain +5V side. This works fine for low-true logic, but the Ping))) uses high-true logic, with a 10K pull-down resistor. That's why you see an intermediate value on the +5V side when it's not being driven high by the Ping))). Fortunately, at least with the unit I've tested, the Ping))) asserts the output low briefly, when the echo returns, before tri-stating the pin and having it pulled high again by the S2's pullups. This produces a very narrow low pulse that, theoretically, the Prop should be able to catch if it's waiting for it with a waitpeq. At least, that's how it works for me.
-Phil
Phil posted the datasheet to the level shifter here.
There are other S2 links in post #12 of my index thread in the test forum (link in signature).
Phil,
For some reason my S2 isn't seeing the low pulse. I'll try a few variation to see if I can get it to work.
The small dip on the right should be the pulse low from the Ping.
I'm guessing this might be Ping dependent. I don't know if it matters or not, but my Ping says REV A on it. I don't know if there are any later versions or not.
My ealier post (#15) with the logic analyzer only showed the pulse from the Propeller. It does not show the pulse from the Ping as I had originally thought. (I need to start measuring these time periods, so I can tell which pulse is which, better than I have been lately.)
Gotcha Chief! S2 to be dispatched to Mr. Green on Tuesday morning!
Thanks for keeping me on track erco!
Ken Gracey
I just took a look at the Ping))) webpage. It looks like there's a REV B. I'm curious, is yours a REV A or a REV B?
Duane
Duane, the difference [85% certain] is that Revision A uses the SX's internal oscillator and the Revision B uses an external clock.
Not sure if this will be useful to your research or not.
Ken Gracey
I'm curious to see if the version of Ping makes a difference in whether or not it will work with the Scribbler 2.
I'm hoping others will test their Pings with Phil's code in post #14 and let us know if their Ping works with their S2 and what revision their Ping is.
If I could be sure Revision B Pings will work with the S2, I'll probably add one or two on to my next Parallax order.
-Phil
It seems the minimum range is about 330 mm, I might have seen it drop to 320 mm, with my hand covering the ping,
but the numbers scroll very fast, other than that, the mid and max distance numbers seem reasonable...(whatever an mm is...)
-Tommy
As you can see, the low point of the pulse at the Propeller pin is right at the logic threshold, so it may or may not register.
This is not a design defect per se but, rather a conspiracy of otherwise good design objectives that appear to be at odds with each other:
2. From the S2 side: put a cap on the level shifter output to reduce the effects of noise and/or to increase rise times enough to pass FCC emissions requirements.
Frankly, I do not see a pure software fix for the problem on the S2 side. It could probably be "fixed" in the Ping))) firmware by holding the pin low longer before tri-stating it. Additional circuitry between the S2 and Ping))) is also a possibility. I tried additional pull-down resistance, though, without success.
-Phil
If you're comfortable doing some soldering on the Ping))), you can probably work around the problem. Here is what the circuitry looks like at the S2/Ping))) interface:
Notice that 510-ohm resistor in series with the Ping))) signal lead. That resistor, in combination with the 1nF cap on the S2, determines the fall time of the pulse from the Ping))) and, hence, how low it will go before the pin is tri-stated. I piggy-backed a 470-ohm resistor on top of the 510-ohm resistor (top of Ping))) PCB, next to the SIG pin), effectively halving the output pulse's fall time. Here's what the two signals look like now:
The signal at the Propeller pin goes all the way down to 0.5V now, rather than being on the hairy edge of the logic threshold.
-Phil
Many thanks for all the work you've done since I asked my original question, I had hoped it would be an easier task to hack the S2.
Although the side of S2 box states that the S2 is user-hackable & would allow you to add ultrasonic sensors etc, I hadn't imagined it would such 'mission'. Shame I drilled a hole in the upper case of my S2 & added nice grommet & red mini breadboard to the top of the chassis - LOL.
Part of me wishes I'd have purchased a Boe-Bot this Xmas, as making the jump from Arduino to the Propeller S2 hasn't been quite an easy transition as I had hoped for. The user guide included with the S2 is more of a guide to the Demo Programs, rather than a true user guide to the S2.
Don't get me wrong, so far I love the S2 for what it does with the demo program's, but I want to go beyond the demo programs & I'm finding that information regarding both programming & hacking the S2 is thin on the ground & I'm beginning to think I jumped in too deep before I knew what I was letting myself in for.
I need to go back to basics and play with the S2 GUI then learn to program in spin before I even consider hacking my S2. So sorry to have put to so much trouble.
I need to find both decent guide to both the S2 GUI & the Propeller tool code editor, can anyone point me in the right direction for resources?
Regards,
Mark
-Phil
Thanks Phil, had a minor issue as my default browser is Chrome & doesn't display. Switched my default browser back to IE8 & the help page is now working perfectly,
Thank you
Mark
Phil, Thanks for the new information. I'll likely try your mod with my Ping.
I notice there are four test points on the Ping. I'm guessing those can be used to update its firmware. I wonder how hard it would be to load new firmware into the Ping?
I still have some wires soldered directly to my S2's Prop chip. I might just use one of those to interface with the Ping. I'd rather use a method that would be easy for others to reproduce though (in case I come up with some cool application for using the Ping with the S2).
Thanks again for your help.
Yeah, I'm a bit disappointed not to be able to easily use a Ping with the S2. Your hole in the top is probably a good idea. I've stripped all the screw holes in my S2 from taking off the cover so many times.
There should be lots of other sensors that can be used with the S2. One of these ultrasonic sensors will likely work without modification. I have one and I'll try it with my S2 (as soon as I can find the sensor (I saw it a couple of days ago so I know it's somewhere around here)). Servos should be easy to use with the S2. If you have other sensors there's a good chance I'll also have one. I'll help you get any other sensors (if I have one) working with the S2. If you're thinking of purchasing a sensor, again, it's likely I already have one and I can try it out with my S2 before you purchase one yourself.
Mark, Make sure you download the full Propeller Tool. It's the first download on this page. It has the Propeller Education Kit (PEK) and Propeller Manual (and other stuff) under the help menu. I think the Propeller Tool that comes with the S2 GUI doesn't have all the help documents since it's just intended to show the Spin file generated by the GUI (which is very useful and cool).
The PEK walks your through using the Propeller. Not all of it will apply to the S2 though.
You might want to consider getting a QuickStart (QS) board as part of your Propeller education. It's an easy way to start programming the Propeller.
The Prop takes a bit of learning to use well, but it is really (IMO) the perfect microcontroller for robots.
Make sure and keep asking questions here or in the robot forum.