Professional Documents
Culture Documents
Sciencedirect Sciencedirect
Sciencedirect Sciencedirect
Systems Available
14th IFAC Conference on Programmable online
Devices at www.sciencedirect.com
and Embedded
14th IFAC5-7,
October
Systems Conference onCzech
2016. Brno, Programmable
Republic Devices and Embedded
Systems
October 5-7, 2016. Brno, Czech Republic
October 5-7, 2016. Brno, Czech Republic ScienceDirect
IFAC-PapersOnLine 49-25 (2016) 153–158
Distance Measuring by Ultrasonic Sensor
Distance Measuring by
Distance Measuring by Ultrasonic
Ultrasonic Sensor
Sensor
L. Koval*. J. Vaňuš**. P. Bilík***
L. Koval*. J. Vaňuš**.
P. Bilík***
L. Koval*. J. Vaňuš**.
P. Bilík***
*VŠB-TU Ostrava, FEI,
Ostrava-Poruba
CZ (Tel: *VŠB-TU Ostrava, FEI,
+420-59732-5958; Ostrava-Poruba
e-mail: ludvik.koval@ vsb.cz)
*VŠB-TU Ostrava, FEI, Ostrava-Poruba
CZ (Tel:**VŠB-TU
+420-59732-5958;
Ostrava, e-mail: ludvik.koval@ vsb.cz)
FEI, Ostrava-Poruba
CZ (Tel: +420-59732-5958; e-mail: ludvik.koval@ vsb.cz)
**VŠB-TU
CZ (Tel: Ostrava, FEI,
+420-59732-5856; Ostrava-Poruba
e-mail: jan.vanus@ vsb.cz)
**VŠB-TU Ostrava, FEI, Ostrava-Poruba
CZ (Tel: +420-59732-5856;
***VŠB-TU e-mail:
Ostrava, FEI, jan.vanus@ vsb.cz)
Ostrava-Poruba
CZ (Tel: +420-59732-5856; e-mail: jan.vanus@ vsb.cz)
***VŠB-TU Ostrava, FEI, Ostrava-Poruba
CZ (Tel: +420-59732-5955; e-mail: petr.bilik@ vsb.cz).
***VŠB-TU Ostrava, FEI, Ostrava-Poruba
CZ (Tel: +420-59732-5955; e-mail: petr.bilik@ vsb.cz).
CZ (Tel: +420-59732-5955; e-mail: petr.bilik@ vsb.cz).
Abstract: This presentation deals with the verification of the accuracy of measurement distance ultrasonic
Abstract: Thiscurrent
sensor in the presentation deals with
environment. As the verificationsensor
a measuring of the accuracy
chosenof measurement distance by
ultrasonic
an I2C
Abstract: This presentation deals with the verification of thewas accuracy ofSFR08 type equipped
measurement distance ultrasonic
sensor in the current
communication interfaceenvironment.
which allowsAs a measuringThis sensor was itchosen
simple SFR08
to createtype equipped an I2C
by Control
sensor in the current environment. Asaddressing.
a measuring fact makes
sensor was chosen SFR08 the sensor
type array.
equipped by an I2C
communication
and interface
also visualization whichwas
system allows
PC addressing. This fact makes card
based. As communication it simple
was to create
used NI the
USBsensor
8451.array.
The Control
goal of
communication interface which allows addressing. This fact makes it simple to create the sensor array. Control
and also visualization
verification measurementssystem
waswas
to PC based.
determine As
the communication
actual sensor card
accuracywas used NI
especially USB
when 8451. The goal
measuring of
longer
and also visualization system was PC based. As communication card was used NI USB 8451. The goal of
verificationWhen
distances. measurements
evaluating was to determine
the accuracy thesensor
of the actual sensor accuracy inespecially when measuring longer
verification measurements was to determine the actualwas not included
sensor temperature
accuracy especially compensation
when of the
measuring longer
distances. data.
measured When evaluating the accuracy of the sensor was not included in temperature compensation of the
distances. When evaluating the accuracy of the sensor was not included in temperature compensation of the
measured data.
© 2016, IFAC
measured data.(International Federation of Automatic Control) Hosting by Elsevier Ltd. All rights reserved.
Keywords: Ultrasonic sensors, I2C communication interface, virtual instrument
Keywords: Ultrasonic sensors, I2C communication interface, virtual instrument
Keywords: Ultrasonic sensors, I2C communication interface, virtual instrument
154
2016 IFAC PDES
October 5-7, 2016. Brno, Czech Republic L. Koval et al. / IFAC-PapersOnLine 49-25 (2016) 153–158 155
of the measurement is 65 ms. The first echo sonar captured Data SDA and SCL clock signals are bidirectional data lines.
after the completion of measurement is located at address 2 Signals are fixed to a logic HIGH level via pull-up resistor
(MSB) and address 3 (LSB), the second echo is at address 4 connected to the positive supply voltage. The outputs of all
and address 5, etc. Each measurement is also updated light devices connected to the I2C bus must be open collector type,
sensor, which is located at the address 1 Advantage of the so that it can be implemented logical function AND. [2]
record more reflection is the ability to detect more than one The speed of communication on the bus may be different in
object in the measured distance. Reading the measured values order to be connected to the bus also the slower device. One
is possible after 65 ms, as mentioned above, or by reading the of the limitation is also applied - the higher transmission rate
contents of registers. If the read value 255, it is a - the shorter maximum length of the bus. This limitation is
measurement result. due to the increase in parasitic capacitance conductor SDA
When you need to change the measuring range do this by and SCL at high wire lengths. [2]
changing the values in the register at address 0x2. A value of By default the communications bus speed is 100kbit/s
0x0 represents a distance of 43 mm, and the value 0xFF (Standard Mode) in other modes is the communication speed
represents a distance of 11 m. Dependence register values higher: Fast Mode - 400kbit/s, Fast Mode Plus 1Mbit/s, High
and the range contains the following formula: Speed Mode - 3,4Mbit/s. The highest baud rate (Ultra Fast
Mode) is 5Mbit/s. In this mode is no longer possible
𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 = [(𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅𝑅 2).43] + 43 (𝑚𝑚𝑚𝑚) (1) bidirectional transmission of conductors. [2]
Due to the connection of various devices operating at
The basic sensor address is 0xE0. It can be changed to one of different voltage levels on the I2C bus is not fixed level logic
the other 16 addresses (0xE0, 0xE2, 0xE4, 0xE6, 0xE8, 0 (LOW) and logic 1 (HIGH). Their value is the percentage
0xEA, 0xEC, 0xEE, 0xF0, 0xF2, 0xF4, 0xF6, 0xF8, 0xFA, derived from the supply voltage: VIL=0,3VCC a VIH=0,7 VCC.
0xFC, 0xFE). Said addresses can be used in case of [2]
communication over the I2C bus with multiple sensors.
Another possibility is the address 0x00. Using this address, 3.1 Communication protocol
you can write data to all connected sensors on the bus.
To change the I2C address on the bus must be connected to Beginning each I2C bus communication is started by start bit
only one sensor. For a change of address must be entered and terminated by stop bit. The beginning of communication
series of three consecutive commands (0xA0, 0xAA, 0xA5) is defined by changing the logic level H to L level of signal
which need to be reversed their order. As the fourth SDA, while SCL signal is at a logical level H. Ending
command is then registered a new sensor address. This communication is defined as the change of logic level L to
sequence must be written with the address 0x00. In the case the level H signal SDA when signal SCL is also at the logical
of ignorance of the new address of the sensor it is possible to level H.
deduce the number of LED blinks so that after connecting
with a long LED lights, followed by a sequence of short
flashes. The resulting address in decimal form can be
calculated by the following formula:
𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴 = 2. 𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛𝑛 𝑜𝑜𝑜𝑜 𝑓𝑓𝑓𝑓𝑓𝑓𝑓𝑓ℎ𝑒𝑒𝑒𝑒 + 224 (𝐷𝐷𝐷𝐷𝐷𝐷. ) (2) Fig. 3. Start and stop bits in the communication.
To change or discovery addresses must take place no Start and Stop the conditions of communication always
operation is reading or writing. generates Master. The bus is considered busy, when Start
condition. Conversely, the bus is considered free, when Stop
condition. The bus stays busy in case of generating Restart
3. COMMUNICATION WITH THE SENSOR condition instead a Stop condition. In this connection are
The entire communication system with sensor consists of a Start and Restart considered identical.
PC and of universal communication card NI USB-8451, Detection of Start and Stop conditions is very simple if a
which offers two interfaces SPI, and I2C. To communicate device connected to the bus, have the appropriate hardware.
with the sensor has been selected I2C interface. However microcontrollers without this equipment must check
I2C is a two-wire serial bus. One signal SDA is intended for the status of the bus at least 2 times/ period clock signal. [2]
data transmission and the second signal SCL is intended for Number of transmitted bytes when communication is not
synchronization of transmission. Every device connected to limited, however each byte transmitted on SDA must have
the bus has a 7 or 10 bit unique address which is set at the eight bits. Each transmitted byte must be followed by
factory. It is used to select a device. Each device must have a Acknowledge bit. Bit with the highest value (MSB) is sent
different address. On the bus can be connected device as the first. If the Slave is unable for any reason to receive or
master, slave and also the device as the Master / Slave. The transmit data (internal interrupt operation) can hold the SCL
bus is a Multi - Master means that to the bus can be wire on level L and thus to delay transmitting until it is ready.
connected to more than one master. Bus also has a facility for If the Slave can receive data, releases the SCL on L level and
detecting a collision during the transmission of multiple the data transfer can proceed. [2]
devices at the same time. [2]
155
2016 IFAC PDES
156
October 5-7, 2016. Brno, Czech Republic L. Koval et al. / IFAC-PapersOnLine 49-25 (2016) 153–158
1 17
2 18
3 19
Acknowledge Acknowledge 4 20
5 21
6 22
7 23
Start/ Stop/ 8 24
Restart Byte Complete, Releasing state L Repeated 9 NI-8451 25
10 26
SLAVE, state L SLAVE Stop 11 27
12 28 +5V
13 I2C SDA 29 R1 R2 SDA
C1 C2 SCL SFR08
Fig. 4. The Byte transmission via bus 14
15
I2C SCL
+5V
30
31
2k2 2k2
100F 100nF NC
16 GND 32 GND
Initialize
Parameters No
change?
Fig. 5. NI USB-8451card
Yes
The basic parameters of the NI USB-8451:
Power: USB (4.1 V to 5.25 V DC, max. 500 mA) Parameters
change
Number of pins: 32
Connection ports: Terminal
Dimensions: 8.18 cm x 8.51 cm x 2.31 cm (including Start
terminals)
Table 4. NI USB-8451connection
Wait
Signal Type Description
SPI CS output Chip Select
<0…7> Read
SPI MOSI output Master Output Slave Input
(SDO) for communication to Slave
SPI MISO output Master Input Slave Output
No
(SDI) for communication to Slave
SPI CLK output CLK signal Stop?
I2C SDA OC * Data on I2C Bus
2
I C SCL OC * CLK on I2C Bus
Yes
P <0…7> I/O General I/O
+5V output Power Voltage - USB Stop
GND Signal Ground
NC Not connected Fig. 7. Flowchart
* OC – open collector output
The application is developed in LabVIEW graphical
programming environment. For users has been created a
3.3 Communication scheme
graphical interface that allows you to specify the
The ultrasonic sensor is connected via I2C bus. There are 2 measurement, read the results and make adjustments as
pull - up resistors connected to power voltage. They are used needed.
to adjust the H logical level in the idle state of the bus. The application has an initialization part into which is made a
Furthermore on a plate are connected also two capacitors C, card selection and setting the voltage levels for
which stabilize the supply voltage at higher current communication. Another part is formed by a loop, which
consumption of the sensor during measurement. performs repeated communication with the sensor. Between
the start of measurement and reading of data must be loaded
waiting for the sensor to finish the measurement. This
156
2016 IFAC PDES
October 5-7, 2016. Brno, Czech Republic L. Koval et al. / IFAC-PapersOnLine 49-25 (2016) 153–158 157
waiting time was set to 100ms (65ms minimal). The Table 6. Up to 3m measuring
following flowchart illustrates measuring algorithm.
lM lS S M S CLK tp
5. VERIFICATION OF APPLICATION (cm) (cm) (cm) (mm) (cm) ()
Practical measurement was carried out for different distances 1 137 136,5 -0,5 ±0,7 ±0,57
up to a maximum distance of 750 cm in order to determine 2 156 155 -1 ±0,7 ±1,07
the measurement accuracy of the sensor. Further it also has
been verified a directional sensor characteristics. 3 174 173 -1 ±0,7 ±1,07
0,5
4 210,2 210 -0,2 ±0,9 ±0,29 (0,46)
5.1 Verification of the accuracy of distance
measurement 5 240,3 239 -1,3 ±0,9 ±1,39
6 284,5 284 -0,5 ±0,9 ±0,59
The first was realized to verify the accuracy distance
measurement, which was divided into 3 parts. In the first part
the distance up to 300 cm, and subsequently the distance up Where: lM distance measured by the tape-meter
to 600 cm, and finally the distance up to 750 cm. lS distance measured by the sensor
S sensor error
5.2 Method of Measurement M tape-meter error
S CLK total error (including error tape-meter)
The sensor was placed on the stand in a vertical position so tp sensor accuracy class
that it faces toward the ceiling. Such a location was chosen
because of possible reflections from other objects in space Total error ultrasonic sensor was calculated as the maximum
and easier identification of measured objects. deviation relative to the range of 3 m:
3m distance measuring by ultrasonic sensor took place in the
laboratory. Measurement procedure consisted in gradually max(|∆𝑆𝑆 |+|∆𝑀𝑀 |)
increasing the distance between the sensor and the ceiling ∆𝑆𝑆 𝐶𝐶𝐶𝐶𝐶𝐶 = ± . 100 (%) (4)
300
using adjustable height tripod. Sensor measured distance was
always checked using tape-measure to determine the 5.1 The measurement results up to 6m
reference distance. The accuracy of the reference meter was
in class II according to EG (notice MPO no. 339/2000 Sb). Procedure for distance measurement in the range of 6m was
Accuracy is given by the formula: carried out similarly as in the previous case. As the
corresponding room was chosen classroom with the required
∆= (0.3 + 0.2𝑙𝑙) (𝑚𝑚𝑚𝑚) (3) parameters classroom ceiling height (see Table 7).
As the last measurement was performed measurement over a
Where measurement error
l gauge length range of 6m. This measurement was carried out in the
entrance hall of the FEI, VSB-TU Ostrava. There was again
the required parameters of the ceiling (see Table 8).
The following table shows the maximum error meter for each Calculations class sensor accuracy in both cases were the
measured distance: same as in the case of determining the accuracy class for
basic sensor measuring range distances up to 3m.
Table 5. Measurement errors using a tape - measure
Table 7. Up to 6m measuring
Error limits according to EG II (mm)
lM lS S M S CLK tp
1m 2m 3m 5m 8m 10m
(cm) (cm) (cm) (mm) (cm) ()
±0,5 ±0,7 ±0,9 ±1,3 ±1,9 ±2,3 1 396 395 -1,00 ±1,3 ±1,13
2 422,8 425 2,20 ±1,3 ±2,33
5.3 The measurement results up to 3m
3 452,4 455 2,60 ±1,3 ±2,73
In the results table are measured values as their own meter
4 487,5 485 -2,50 ±1,3 ±2,63
length (measuring tape) and ultrasonic sensor is evaluated
and eventually total measurement error. In the column on the 5 517,5 515 -2,50 ±1,9 ±2,69 0,7
sensor accuracy tp is also included precision instrument, (0,62)
6 546,3 545 -1,30 ±1,9 ±1,49
which was verified by the ultrasonic sensor.
7 578,5 575 -3,50 ±1,9 ±3,69
8 607,5 605 -2,50 ±1,9 ±2,69
9 635 635 0,00 ±1,9 ±0,19
157
2016 IFAC PDES
158
October 5-7, 2016. Brno, Czech Republic L. Koval et al. / IFAC-PapersOnLine 49-25 (2016) 153–158
7. CONCLUSIONS
We can see from practical measurements [5] that the
ultrasonic sensor measures the distance with high accuracy.
In measurements distances up to 3m was accuracy class 0.5
, in case measurements distances up to 6m was accuracy class
0.7 and in case measurements distances over 6 meters the
accuracy class was even 0.4. The accuracy of the sensor
was in all cases related to the measurement range (including
the accuracy of the tape-meter). Manufacturer of the sensor
Fig. 8. Directional characteristics SRF08 indicates the maximum measurement error 3-4 cm in his data
Above the sensor was placed the path in along which was sheets. This accuracy was confirmed with reserve. When
displaced the plate (24 x 39 cm). The plate was moved in the verifying the directional characteristics the object was
four directions in the plane until was captured by sensor. detected approximately at the same angle, as determined by
Subsequently, from the known distance location above the the manufacturer. All measurements were realized
sensor plate and the length of the measured hypotenuse of the approximately under the same conditions (temperature T =
triangle was calculated angle. Measurements were performed 23C).
in two axes (in the plane of the four sides).
REFERENCES
158