Dose any one have a sample program for a Parallax ping sensor
I have code for a BS2 and have tried to convert but something not correct keep
getting the same measurement
Thanks
Ping sensor
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Ping sensor
I don't have a PING sensor, but I took a look at their spec and the code.
It should convert relatively easily, IF you account for some of the built in
delays in the Stamp code.
In the Stamp there is a lot of delay between the PULSOUT and PULSIN routines, in
the ARM that will be just a few microseconds. Are you seeing an immediate
output?
A scope would be nice, or you could just dump the output.
IO(pin) = 1 ' force to an output and high
start = TIMER
while (TIMER - start) < 5
loop
IO(pin) = 0
x = IO(pin) ' make it an input
start = TIMER
... may need to wait here
while IO(pin) = 0
loop
print TIMER-start
It should convert relatively easily, IF you account for some of the built in
delays in the Stamp code.
In the Stamp there is a lot of delay between the PULSOUT and PULSIN routines, in
the ARM that will be just a few microseconds. Are you seeing an immediate
output?
A scope would be nice, or you could just dump the output.
IO(pin) = 1 ' force to an output and high
start = TIMER
while (TIMER - start) < 5
loop
IO(pin) = 0
x = IO(pin) ' make it an input
start = TIMER
... may need to wait here
while IO(pin) = 0
loop
print TIMER-start
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Ping sensor
>I tried the code you included and it also gives me the same info varying from
716-718 no mater what the distance is
According to the Parallax spec, there is a required holdoff of 750 uS after the
input pulse.
The 715uS you are seeing is within that amount of time, I suspect its bleed
through of the transmitter. So after the pulse is sent you should wait 750 + 115
uS before looking for a pulse coming back.
The Stamp won't see this as its much much slower than the ARM (like a factor of
1300 times for the BS2).
So in the program below add
start = TIMER
while (TIMER-start)<865
loop
where it says "... may need to wait here"
716-718 no mater what the distance is
According to the Parallax spec, there is a required holdoff of 750 uS after the
input pulse.
The 715uS you are seeing is within that amount of time, I suspect its bleed
through of the transmitter. So after the pulse is sent you should wait 750 + 115
uS before looking for a pulse coming back.
The Stamp won't see this as its much much slower than the ARM (like a factor of
1300 times for the BS2).
So in the program below add
start = TIMER
while (TIMER-start)<865
loop
where it says "... may need to wait here"
-
- Posts: 1462
- Joined: Fri Oct 19, 2012 5:11 am
Re: Ping sensor
In addition this user admitted that the GND line was not connected in his setup as was causing the issue.
Even in my own setups, how many times has there been a wiring error?...
...too many to count
Even in my own setups, how many times has there been a wiring error?...
...too many to count
