Parallax ping sensor
SMA_X
Posts: 2
Hi all...
I am very much new to the field and I have a question on parallax ping ultrasonic sensor.
Hope you guyz can help me out...!
So my question is can I use the receiver and transmitter of the sensor separately?
I mean in our scenario we will be using multiple ping sensors and can I uniquely identify the signal transmitted from one ping sensor by a receiver of another ping sensor?
So what i want is using the transmitter and receiver of one ping sensor independent of each other?
pls be kind enough to leave an answer...
thanks in advance...!
I am very much new to the field and I have a question on parallax ping ultrasonic sensor.
Hope you guyz can help me out...!
So my question is can I use the receiver and transmitter of the sensor separately?
I mean in our scenario we will be using multiple ping sensors and can I uniquely identify the signal transmitted from one ping sensor by a receiver of another ping sensor?
So what i want is using the transmitter and receiver of one ping sensor independent of each other?
pls be kind enough to leave an answer...
thanks in advance...!
Comments
2) No - There's nothing unique about each PING's ultrasound burst
3) If you want multiple PINGs, you need to separate them in time. The maximum echo time is about 18.5ms and you really need to allow for more than that. Specifically, you need to allow time for room echos to die off before you create another pulse. How long you wait depends on the size of the space involved. I'd allow at least 2 to 3 times the time for sound to traverse the space.
PULSOUT 0, 5
PULSIN 0, 1, time
cmDistance = cmConstant ** time 'right
PAUSE 100
PULSOUT 1, 5
PULSIN 1, 1, time
cmDistance1 = cmConstant ** time 'left
PAUSE 100
IF (cmDistance1 <= 20) THEN TurnRight
IF(cmDistance <= 20) THEN TurnLeft
DEBUG HOME, DEC3 cmDistance1, " cm"
DEBUG CR, DEC3 cmDistance, " cm"
GOSUB walkfwd 'go to walkfwd subroutine
LOOP
this is a program using ping))) ultrasonic sensor to measure diatance using 2 sensor.
from my program here only port 0 will gave reading?
port 1 dont have output.what is my problem?
PULSOUT 0, 5
PULSIN 0, 1, time
cmDistance = cmConstant ** time 'right
PAUSE 100
PULSOUT 1, 5
PULSIN 1, 1, time 'change to pulsin 1, 1, time1
cmDistance1 = cmConstant ** time 'left change to cmDistance1 = cmConstant ** time1
PAUSE 100
IF (cmDistance1 <= 20) THEN TurnRight
IF(cmDistance <= 20) THEN TurnLeft
DEBUG HOME, DEC3 cmDistance1, " cm"
DEBUG CR, DEC3 cmDistance, " cm"
GOSUB walkfwd 'go to walkfwd subroutine
LOOP
be sure to declare time1 in your var's.
So please guide me in this.
Got little idea for finding distance but i have NO idea for finding the width of the object using SONAR!!!!
I'm using ArduinoMega and I'm having some problems with multiples ultrasonic ping sensors. When I connect only 1 Ultrasonic sensor, it works perfectly, but when I connect more than 2 , I got 0 values for the second sensors and so on. Can anybody help me? Here is my code for Arduino.
const int pingPin[2] = {8,10};
void setup() {
Serial.begin(9600);
}
void loop() {
for(int i =0; i<sizeof(pingPin)/sizeof(pingPin[0]); i++) {
int cm = ping(pingPin) ;
Serial.print(i); Serial.print(":"); Serial.print(cm); Serial.print(" ");
}
Serial.println();
delay(100 ); // each centimeter adds 10 milliseconds delay digitalWrite(ledPin, LOW);
}
int ping(int pingPin) {
long duration, cm;
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin, LOW);
pinMode(pingPin, INPUT);
duration = pulseIn(pingPin, HIGH);
cm = microsecondsToCentimeters(duration);
return cm ;
}
long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
}
I'd try renaming the pingPin variable in your ping function. Even though scoping says that it shouldn't use the global variable of the same name it's much less confusing just to give it a unique name. Note also that you are converting a long from the ping function call in your loop to an int.
Your issue is probably due to the second Ping hearing the echo from the first ping, and returning immediately. Try adding a 100ms delay to your loop. If it fixes the problem you can decrease the value until you find a minimum.
I'm not a genius at this, but I have done something similar to this. I used my Ping sensors to trigger a larger load like a 12v fan and lighter load like LEDs.
With the larger load I used a mosfet (Parallax's mosfet works great triggered from the logic of a Stamp with a resistor); the LED I used a resistor to the pin of the Stamp.
With the sensor I targeted a range/distance that I wanted it to activate or turn a high to turn on the device.
There are many ways to do that, you should start a new thread about it.