Hello, · ·· Due to the way the PING))) works you won’t be able to use just any input/output expander.· The BASIC Stamp activates the PING))) by pulsing the I/O pin HIGH that is connected to it.· That pin is then made an input and the BASIC Stamp measures the width of the return pulse using PULSIN.· Because of this a standard I/O expander won’t work.· What you would need is some kind of bidirectional ·mux switch…Something that will allow you to connect a pin to a BASIC Stamp pin.· This would likely still take 4 I/O pins on the BASIC Stamp to accomplish.· I hope this helps.· Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Chris Savage Parallax Tech Support
You could use one of the I2C I/O expanders like the Microchip MCP23016 or MCP23008 or MCP23017. These are all I/O expanders that allow you to set I/O pins as an input or output. The serial access does slow you down a little, but should be more than fast enough for use with a PING. Another choice is the Philips PCF8574 which uses a quasi-bidirectional I/O pin and might work out better with the PINGs (see the datasheet). There is a Nuts and Volts article on its use.
·· Would the I/O expander allow the BS2 to use the PULSIN command to measure the incoming pulse width?· For some reason I thought it was all handled through an SPI/I2C bus.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Chris Savage Parallax Tech Support
I guess I could use a servo, but I don't like the sound , nor the power requirements... I have also in the past made a little bot that used a Sharp IR Analog Range finder that was on top of a servo... it worked and is was cool... But now I'm using Sonar and will have an array of 8 Sonar sensors. Something different I guess. Anyhow thanks for the help it is much appreciated.
Yes, the way the 'ping' works is that you 'trigger' it, then do a 'PULSIN' on that I/O line. The length/width of the pulse you recieve indicates the distance the reflected sound traveled. Thus trying to 'outboard' it on some other I2C I/O chip would be hard, if not impossible, to make that work.
First let me say I have not used a ping sensor or and gates but here is an idea I think would work. I am assuming a voltage is set high to the ping sensor and the ping sensor responds with a high signal for a time, if its a PWM signal you could add caps to analogue the signal but..
The diagram I have used resistors and caps to simulate the response of 4 PING sensors, the switch on the bottom would be a stamp pin you ping all sensors with at the same time. The Logic pin input upper left would be tristate when you do this and then do a pulsin on that pin when your PING is finished. Now I am assuming you get a shorter signal back for a closer object than a farther object so the and gates simply measure the lowest return signal, so at that point you know that something is at a distance of X. Now you dont know the direction but...
If your bot is moving, you can accumulate readings and decipher if it is moving twards you or away from you, you could stop and spin around with a 9th sensor (or one of the sensors in the array of 8 connected at the resistor to ping junction with another pin seperate ping directly for that sensor course your up to 3 pins now) that is pointed in the forward direction till you find the object in its ping path.
That's my first glance at it, like I said never using these components it may not work at all and my assumptions may be wrong to boot!
As I look at it more perhaps a parrallel to serial chip instead of the and gates, you could ping all sensors and then read the state of all 8 PING sensors as one byte of data, all would initially be ON logic 1 but as each one drops below threshold your BYTE would change, storing the data as it comes in would yeald time pulses for each of the devices. Not sure how much time you are dealing with for longest and shortest so some math would be in order here.
Perhaps it's just too early in the morning, but the way I'm reading your schematic, it doesn't seem to make a lot of sense:
OUTPUTS -
5 x terminals grounded
1 x Output signal through gates
INPUTS -
1 x Vcc
NO input signal ????
Secondly, the PING is intended to be a distance sensor, and not the obstacle detection sensor which position it now seems to be relegated if hooked up as you propose, or as I understand it. If obstacle detection is all one needs, I/R detectors are a good deal less costly.
Lastly, reiterating or amplifying what you did say, one no longer has the ability to determine the direction where the obstacle exists. This lessens the value of the PING even further, IMHO. If a side wall was anywhere near the mobile platform, it would appear that an obstacle was present. Not very helpful from my POV.
Well... I was looking at another brand of Sonar... MaxBotics... It looks like a great solution and they can be hooked up in series when one pings and takes a reading it starts the Next one and so on until the end of then chain. Just a couple of descrete componets and some pulsin statements. And I should be good to go. [noparse]:)[/noparse]
First let me say I would just use the 8 pins or another $2.00 microcontroller to MUX the sensors Chris proposed but the OP asked if it could be done without the use of 8 input pins. Since I try to think in the abstract outside the normal circuit designs that work as an excercise in the concept of can it be done I will further try and relate the two concepts of reading an array of sensors to one input pin (actually 2 I need one for the ping driver, and a note on that, I don't know the current each PING sensor uses so you may need a fet or transistor to switch the load) the circuit is a simulation of electrical flow and shows the concept of 4 PING sensors holding their lines high for 4 different times (resistor bleed values in RC time circuit) Run the simulation by loading the code at the bottom of this post to the Applet.
Perhaps it was too late in the evening for me to fully explain the two concepts of reading an array of sensors and extrapolating from additional data, that being the robots current direction of movement or lack thereof.
The resistor/capacitor arrangement in the schematic is obviously not the circuit components you would use. I do not have a PING sensor component to place on the board (it's not a full spice simulator) so I simulated the PING sensor as a RC circuit. A high signal is generated from the switch at the bottom of the circuit (switch is a simulation of a stamp pin going from tri state to HIGH and back to tri state) the logic pin onthe left represents the INPUT pin on a stamp. The concept is to charge all sensors and then time the high signal feedback. The first sensor to drop off its high signal is what the stamp pin reads.
Now you say
Somebody said...
Secondly, the PING is intended to be a distance sensor, and not the obstacle detection sensor
I dare say distance to what! A sensor that reads distance of say 10 feet in the center of a 20 foot room will measure 10 feet put an obstacle in front of it at 3 feet and it reads 3 feet. So it measures the distance to an object.
Somebody said...
Lastly, reiterating or amplifying what you did say, one no longer has the ability to determine the direction where the obstacle exists.
Not on its own without additional data and some vector analysis.
What we are really talking about here is a sensor that senses the distance to any object in a 360 degree radius.
If your robot is standing still and a cat wakls twards it when it gets in the sensors range the bot will know something is approching, the cat can not sneak up on the bot in a circular pattern behind a servo controlled single direction sensor. Suppose you are in an F18 fighter and you get a missile aleart on your audio sensor, you don't know the direction but you sure do have a priority job to do in finding it's direction el pronto!
If your robot is moving forward and an object comes into range of the front sensor you can continue to read data while moving forward, if the didtance measurement is reducing you can deduct the distance to an object in front of you is getting closer. (it may be a cat comming in at a faster speed than your forward movement as well but how you use the data will depend on the problem you want to solve.
Somebody said...
even further, IMHO. If a side wall was anywhere near the mobile platform, it would appear that an obstacle was present. Not very helpful from my POV.
I would agree without further data it would not be usefull but as I said in the original post, swing the robot in a 360 degree pattern to find out just what direction the objects position is or wait for your 9th sensor on the servo (suggested in another post) to finish its sweep. It's not my job to design the whole thing just to come up with ideas to read an array of sensors with one input pin.
That being said, the Idea I had after posting the first one seems a better fit.
Imagine you have a data stream shifting in 8 bits of data every millisecond. Each bit represents a sensors output high or low.
You ping all 8 sensors, when your loop starts the first byte read will be 255 (%11111111) you poll the bytes untill the number changes from 255 to any other number, say it comes back after 3mS as 254 (%11111110) you now know sensor #0 has detected an object at a distance of whatever 3mS represents. Continuing to read the data and logging each transition until the byte is zero would yeald a distance on all 8 sensors.
The above assumes the reading of the data can be done with sufficient granularity to make use of the data. I dont know the pulse width of 1foot vs 3 foot reading for example but if the ping sensor is too fast for the stamp to read in this manner, additional rc holding circuits could be employed to hold the signals for a longer time allowing even the basic stamp to do the job but in that case a servo would do just as well.
So remember, it is just two ideas that have not been fully explored to answer can I read 8 sensors without using 8 pins. I think the answer is yes but experiments in circuit design to prove the two theories would have to be done.
Link to circuit simulator: Beware it opens a circuit simulation applet on entry to the link.
You can link to http://www.falstad.com and navigate to the circuit simulator as well.
Select File, Import and past this code into it. Switch the switch on and off at the bottom to simulate pinging 4 PING sensors.
Code for circuit simulator:
$ 1 5.0E-6 10.391409633455755 57 5.0 50
150 336 160 240 160 0 2 0.0
150 336 256 240 256 0 2 0.0
150 192 208 96 208 0 2 0.0
w 192 192 240 160 0
w 192 224 240 256 0
d 400 336 400 272 0
d 416 336 416 240 0
d 432 336 432 176 0
d 448 336 448 144 0
w 448 144 400 144 0
w 432 176 400 176 0
w 416 240 400 240 0
c 448 144 496 144 0 1.0E-5 0.009530006087824136
c 432 176 512 176 0 1.0E-5 0.0012359539712696339
c 416 240 528 240 0 1.0E-5 2.080865588781236E-5
c 400 272 528 272 0 1.0E-5 2.0808655887812356E-5
M 96 208 96 304 0 2.5
g 528 336 528 400 0
w 528 336 528 272 0
w 528 272 528 240 0
w 528 240 528 176 0
w 528 176 512 176 0
w 528 176 528 144 0
w 528 144 496 144 0
s 368 400 256 400 0 true false
w 448 336 432 336 0
w 432 336 416 336 0
w 416 336 400 336 0
w 400 336 400 400 0
w 400 400 368 400 0
R 256 400 192 400 0 0 40.0 5.0 0.0
w 400 144 336 144 0
w 400 176 336 176 0
w 400 240 336 240 0
w 400 272 336 272 0
w 448 144 448 96 0
w 432 176 432 96 0
w 416 240 416 96 0
w 400 272 400 96 0
r 448 96 528 96 0 2000.0
r 448 64 528 64 0 1500.0
r 448 32 528 32 0 1000.0
r 400 96 336 96 0 1000.0
w 432 96 432 64 0
w 432 64 448 64 0
w 416 96 416 32 0
w 416 32 448 32 0
g 528 32 592 32 0
g 528 64 576 64 0
g 528 96 576 96 0
g 336 96 272 96 0
Hope this makes my somewhat unconventional thinking a bit more clear. Let me reinterate, I think 8 pins would be better, better yet would be an IR 360 sensor array with a single PING sweep using a servo or stepper motor, or think of a way to eliminate the noise of the servo by using some other way of rotating the sensor if you don't like the noise, I could think of a few right now but I will leave that up to the OP.
Comments
·
·· Due to the way the PING))) works you won’t be able to use just any input/output expander.· The BASIC Stamp activates the PING))) by pulsing the I/O pin HIGH that is connected to it.· That pin is then made an input and the BASIC Stamp measures the width of the return pulse using PULSIN.· Because of this a standard I/O expander won’t work.· What you would need is some kind of bidirectional ·mux switch…Something that will allow you to connect a pin to a BASIC Stamp pin.· This would likely still take 4 I/O pins on the BASIC Stamp to accomplish.· I hope this helps.· Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Why not just rotate ONE PING with an R/C servo, rather than using 8 of them? It accomplishes the same thing at a MUCH LOWER cost!
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
·· Would the I/O expander allow the BS2 to use the PULSIN command to measure the incoming pulse width?· For some reason I thought it was all handled through an SPI/I2C bus.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Regards,
Eric
The diagram I have used resistors and caps to simulate the response of 4 PING sensors, the switch on the bottom would be a stamp pin you ping all sensors with at the same time. The Logic pin input upper left would be tristate when you do this and then do a pulsin on that pin when your PING is finished. Now I am assuming you get a shorter signal back for a closer object than a farther object so the and gates simply measure the lowest return signal, so at that point you know that something is at a distance of X. Now you dont know the direction but...
If your bot is moving, you can accumulate readings and decipher if it is moving twards you or away from you, you could stop and spin around with a 9th sensor (or one of the sensors in the array of 8 connected at the resistor to ping junction with another pin seperate ping directly for that sensor course your up to 3 pins now) that is pointed in the forward direction till you find the object in its ping path.
That's my first glance at it, like I said never using these components it may not work at all and my assumptions may be wrong to boot!
As I look at it more perhaps a parrallel to serial chip instead of the and gates, you could ping all sensors and then read the state of all 8 PING sensors as one byte of data, all would initially be ON logic 1 but as each one drops below threshold your BYTE would change, storing the data as it comes in would yeald time pulses for each of the devices. Not sure how much time you are dealing with for longest and shortest so some math would be in order here.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think outside the BOX!
Post Edited (metron9) : 9/28/2006 6:50:58 AM GMT
Perhaps it's just too early in the morning, but the way I'm reading your schematic, it doesn't seem to make a lot of sense:
OUTPUTS -
5 x terminals grounded
1 x Output signal through gates
INPUTS -
1 x Vcc
NO input signal ????
Secondly, the PING is intended to be a distance sensor, and not the obstacle detection sensor which position it now seems to be relegated if hooked up as you propose, or as I understand it. If obstacle detection is all one needs, I/R detectors are a good deal less costly.
Lastly, reiterating or amplifying what you did say, one no longer has the ability to determine the direction where the obstacle exists. This lessens the value of the PING even further, IMHO. If a side wall was anywhere near the mobile platform, it would appear that an obstacle was present. Not very helpful from my POV.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
·
Perhaps it was too late in the evening for me to fully explain the two concepts of reading an array of sensors and extrapolating from additional data, that being the robots current direction of movement or lack thereof.
The resistor/capacitor arrangement in the schematic is obviously not the circuit components you would use. I do not have a PING sensor component to place on the board (it's not a full spice simulator) so I simulated the PING sensor as a RC circuit. A high signal is generated from the switch at the bottom of the circuit (switch is a simulation of a stamp pin going from tri state to HIGH and back to tri state) the logic pin onthe left represents the INPUT pin on a stamp. The concept is to charge all sensors and then time the high signal feedback. The first sensor to drop off its high signal is what the stamp pin reads.
Now you say
I dare say distance to what! A sensor that reads distance of say 10 feet in the center of a 20 foot room will measure 10 feet put an obstacle in front of it at 3 feet and it reads 3 feet. So it measures the distance to an object.
Not on its own without additional data and some vector analysis.
What we are really talking about here is a sensor that senses the distance to any object in a 360 degree radius.
If your robot is standing still and a cat wakls twards it when it gets in the sensors range the bot will know something is approching, the cat can not sneak up on the bot in a circular pattern behind a servo controlled single direction sensor. Suppose you are in an F18 fighter and you get a missile aleart on your audio sensor, you don't know the direction but you sure do have a priority job to do in finding it's direction el pronto!
If your robot is moving forward and an object comes into range of the front sensor you can continue to read data while moving forward, if the didtance measurement is reducing you can deduct the distance to an object in front of you is getting closer. (it may be a cat comming in at a faster speed than your forward movement as well but how you use the data will depend on the problem you want to solve.
I would agree without further data it would not be usefull but as I said in the original post, swing the robot in a 360 degree pattern to find out just what direction the objects position is or wait for your 9th sensor on the servo (suggested in another post) to finish its sweep. It's not my job to design the whole thing just to come up with ideas to read an array of sensors with one input pin.
That being said, the Idea I had after posting the first one seems a better fit.
Imagine you have a data stream shifting in 8 bits of data every millisecond. Each bit represents a sensors output high or low.
You ping all 8 sensors, when your loop starts the first byte read will be 255 (%11111111) you poll the bytes untill the number changes from 255 to any other number, say it comes back after 3mS as 254 (%11111110) you now know sensor #0 has detected an object at a distance of whatever 3mS represents. Continuing to read the data and logging each transition until the byte is zero would yeald a distance on all 8 sensors.
The above assumes the reading of the data can be done with sufficient granularity to make use of the data. I dont know the pulse width of 1foot vs 3 foot reading for example but if the ping sensor is too fast for the stamp to read in this manner, additional rc holding circuits could be employed to hold the signals for a longer time allowing even the basic stamp to do the job but in that case a servo would do just as well.
So remember, it is just two ideas that have not been fully explored to answer can I read 8 sensors without using 8 pins. I think the answer is yes but experiments in circuit design to prove the two theories would have to be done.
Link to circuit simulator: Beware it opens a circuit simulation applet on entry to the link.
You can link to http://www.falstad.com and navigate to the circuit simulator as well.
http://www.falstad.com/circuit/ Java applet opens on entry to this link.
Select File, Import and past this code into it. Switch the switch on and off at the bottom to simulate pinging 4 PING sensors.
Code for circuit simulator:
Hope this makes my somewhat unconventional thinking a bit more clear. Let me reinterate, I think 8 pins would be better, better yet would be an IR 360 sensor array with a single PING sweep using a servo or stepper motor, or think of a way to eliminate the noise of the servo by using some other way of rotating the sensor if you don't like the noise, I could think of a few right now but I will leave that up to the OP.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think outside the BOX!