BS2p PULSIN Variable Units
paolo grigioni
Posts: 15
Hi,
I have a BS2p (firmware V 1.5) and I'm trying to measure distance with a Ping sensor.
In the reference Manual there is a table with Variable units: for BS2p it writes 0.8 usec but in the demo program example there is 0.75 usec in declarations. Which is the correct value?
Thanks
Paolo
I have a BS2p (firmware V 1.5) and I'm trying to measure distance with a Ping sensor.
In the reference Manual there is a table with Variable units: for BS2p it writes 0.8 usec but in the demo program example there is 0.75 usec in declarations. Which is the correct value?
Thanks
Paolo
Comments
if you take a lookat the thread "Pulsin for BS2P" linked below in "similar threads" you could read that older Firmware use 0.75 instead of 0.8.
So i think my BS2P should use 0.8, but (there is always a but) if I try to calculate Speed of sound from D= C* t (where t = Num_Impulse *0.8 /2) I get value of C of about 300 m/sec !!!
But my office room is not a freezer, it is at +21/+24 °C so I should get C about 342-345 m/sec. Why this? also using 0.75 I get C values lower than expected. It seems that a good value for scale should be about 0.72. What's going wrong?
PS: Zoot actually i'm at home and the prog is on office PC. tomorrow morning (here in Italy) i'll post but i'm using the standard "Get_Sonar" subroutine
tomorrow I'll try it. If the scale value will be 0.8 (as expected), could the problem i get come from Ping offset (D= C *t +D0)? I measure distance from the front of Ping sensor to the target.
thanks again to all
MLX_SHT_ping_DAQ.bs2
thanks for this idea, now I've a fixed starting point ...... but my problem is unsolved, too.
Get_Sonar:
Ping = IsLow
PULSOUT Ping, Trigger ' activate sensor
PULSIN Ping, 1, rawDist ' measure echo pulse
PAUSE 500
' rawDist2 = rawDist2 '*/ $0C0 ' convert to uS
' rawDist = rawDist / 2 ' remove return trip
RETURN
Ping pin is 12
It works with all varieties of BS2.
Ping_Demo.BS2
today I've made some test with BS2, BS2p, Ping and usb Oscilloscope. I get signal from SIG PING pin.
Distance from Ping face to target was 15,2 cm for BS2p test and 15,0 cm for BS2 test.
Results are in zip files attached. They contain:
*.bmp file showing oscilloscope incoming signal
*.txt and *. xls files with data coming from oscilloscope
*.txt file with data caming from debug terminal
1) In BS2p test, if we compare duration of returning impulse with the time of flight (Tof) calculated from rawDist */ Scale we get that the correct value for Scale should be 0,75 and not 0,8.
2) In both tests, Speed of sound (C=dist/(Tof/2)) is less than 331,45 (the value at 0°C). But my room is well above 0 °C. So I think that Ping distance have an offset i.e. dist=d0+C*Tof/2.
What do you think about?
thanks Paolo
Results are in attached file.
While pulsout creates an 800 usec impulse as expected (1000 units * 0.8usec/unit)
ping return echo has duration with a scale equal to 0.75 instead of 0.8 as in prevoious tests.
Does the problem come from Ping?
' {$STAMP BS2p}
' {$PBASIC 2.5}
'
' I/O Definitions
'
Ping PIN 0
'
' Constants
'
Trigger CON 13
'Scale1 CON $200
Scale1 CON $0CD ' raw x 0.80 = uS
Scale2 CON $0C0 ' raw x 0.75 = uS
IsLow CON 0
'
' Variables
'
rawDist VAR Word ' Ping raw measurement
tempo1 VAR Word
tempo2 VAR Word
'
[ Program Code ]
Main2:
GOSUB Get_Sonar ' get sensor value
DEBUG "Ping N° Impulse... ", DEC rawDist," Two way Tof usec (Scale=2)... ", DEC tempo1," Two way Tof usec (Scale=0.75)... ", DEC tempo2, CR
PAUSE 2000 ' minimum delay between readings
GOTO Main2
END
'
' Subroutines
'
Get_Sonar:
Ping = IsLow
PULSOUT Ping, Trigger ' activate sensor
PULSIN Ping, 1, rawDist ' measure echo pulse
PULSOUT 1, 1000
tempo1 = rawDist */ Scale1 ' convert to uS
tempo2 = rawDist */ Scale2 ' convert to uS
' tempo = tempo / 2
PAUSE 500
RETURN
ping_PULSOUT.zip
Hi PJ,
do you know a more accurate sonar that can be used with BS2p?
Could you define your accuracy requirements?
Ultrasonic, and even IR detectors have their limits. I'm sure you don't want to get into a laser interferometer setup.
I'm not trying to sell the product short, the datasheet states, "precise, non-contact distance measurements".
On page 3 [of 12] of the #28015 datasheet there is this note:
"The percent error over the sensor’s operating range of 0 to 70 ° C is significant, in the magnitude of 11 to 12 percent. The use of conversion constants to account for air temperature may be incorporated into
your program (as is the case in the example BS2 program given in the Example Programs section below).
Percent error and conversion constant calculations are introduced in Chapter 2 of Smart Sensors and
Applications..."
So, as you're trying to wring out every bit of accuracy that you can, you'll have to modify the "conversion constant" in the example program as your situation requires.
Post Edit -- > 2 days later and no follow up. Oh well.
thank you for your infos and datasheet, I've an old one (v1.3) that doesn't mention that error.
Stated that the formula is:
C=d/(k*N) where C=speed of sound, d=target distance, k=scale (0.8 for BS2p) and N=pulse number
I thought that if the target is at 1 m (at room temperature) I could get a % error for d about 10^-3 (1mm/1m) and for N about 3^10-4 (1 pulse/3600 counted pulses) in order to get an error on C less than 1 m/s that was my need.
Now i know (unfotunately) that this isn't possible with Ping, even if I don't understand where the problem arises: maybe in the timing sequence?
So probably I need another kind of ultrasonic sensor to get my target.
thanks again
Paolo