Sensor Module for Mobile Robot

Róbert Spielmann, František Duchoň, Juraj Kostroš, Tomáš Fico, Richard Balog

  Open Access OPEN ACCESS  Peer Reviewed PEER-REVIEWED

Sensor Module for Mobile Robot

Róbert Spielmann1,, František Duchoň1, Juraj Kostroš1, Tomáš Fico1, Richard Balog1

1Institute of Control and Industrial Informatics, Faculty of Electrical Engineering, Slovak University of Technology, Bratislava, Slovakia


Sensor systems are very important in all kinds of robotics. In this article we describe physical principles of typical sensors, which can be used for small mobile robot. These sensors are compass, accelerometer, ultrasonic distance sensor and odometry. Each of the sensors has its own communication protocol, so there was created electrical module, which transforms each sensor’s communication to one type. USART and I2C bus are used for communication with master module. This module also allows making parallel measurements of the sensors, which allow shorter sampling period, than serial one. After the creation of this module, there were measured errors of each sensor and evaluated by STN EN 60 770 standard.

At a glance: Figures

Cite this article:

  • Spielmann, Róbert, et al. "Sensor Module for Mobile Robot." American Journal of Mechanical Engineering 1.7 (2013): 378-383.
  • Spielmann, R. , Duchoň, F. , Kostroš, J. , Fico, T. , & Balog, R. (2013). Sensor Module for Mobile Robot. American Journal of Mechanical Engineering, 1(7), 378-383.
  • Spielmann, Róbert, František Duchoň, Juraj Kostroš, Tomáš Fico, and Richard Balog. "Sensor Module for Mobile Robot." American Journal of Mechanical Engineering 1, no. 7 (2013): 378-383.

Import into BibTeX Import into EndNote Import into RefMan Import into RefWorks

1. Introduction

Measurement is a very important task in mobile robotics. Every mobile robot need to solve basic tasks in mobile robotics – localization and navigation. So it has to know its distance from other objects and angle of rotation in all three axes. There are several sensors and methods to successfully solve these tasks. For the measurement of the distances the ultrasonic rangefinder PING )))) was used. Accelemerometer Mx2124, compass HM55B and odometry was used for the localization of the mobile robot. Every sensor communicates by different protocol. These communication protocols were unified to one common protocol for all of these sensors. Sensors were connected to single-unit module. After this, measurement errors of each sensor were evaluated by STN EN 60 770 standard.

2. Description of Used Sensors and Physical Principles

2.1. Accelerometer Mx2125

Mx2125 is dual-axis acceleration measurement system, which uses physical principle of heat radiation [1, 2]. Inside of this accelerometer, there is a bubble of gas (type of gas is not specificated by manufacturer). In the middle of this bubble, there is a heat source. Around this bubble, there are four temperature sensors, as it is shown in Figure 1.

When the accelerometer is in the horizontal position, heat is transferred equally to all of temperature sensors. When the accelerometer is inclined, the heat is not transferred equally. From this difference of temperatures value of acceleration, which effects on the accelerometer, can be calculated. Schema of accelerometer is shown in Figure 2.

Output signal of the accelerometer is PWM modulated. It is shown in Figure 3. Frequency of output signal is 100Hz and duty 50% is equal to 0g.

Figure 1. Physical principle accelerometer Mx2125 [1]
2.2. Compass HM55B

Compass is one of the oldest instrument, which were used for the navigation. It uses Earth magnetic field for the measurement. Compass is created by two magnetometers, one for each axis. The compass HM55B [3] is dual axes magnetometrical system. This system measures components of magnetic vector which is straight to each axis, as it is shown in Figure 4.

The compass returns values as two eleven signed numbers. Unit of these numbers is μT. Positive orientation for both axes is to the north. Schema of the compass is shown Figure 5.

The compass communicates by serial synchronous link. The communication with compass consists of two parts. The first part is sending commands to the compass from master unit and the second is returning values from compass to master unit. The compass knows commands, which are shown in Table 1. Returned values from the compass are shown in Table 2.

2.3. Ultrasonic Distance Sensor PING)))

PING))) [4] is ultrasonic rangefinder from Parallax company. Generally, ultrasonic rangefinder measures distance by sending ultrasonic wave to object and it measures the reflection of this wave back to the sensor. When the sensor sends the wave, it starts the measurement of time, and when the reflected wave comes back to the sensor, the sensor stops the measurement of time. Distance of the object in the environment can be calculated following this measured time. Microcontroller, which is integrated to the sensor, describes the sequence of the measurement.

Speed of the sound in air depends especially on the air temperature, as it is shown in equation (1).


The sensor was connected to the microcontroller, as it is shown in Figure 6.

Figure 6. Schema of the connection between microcontroller and ultrasonic rangefinder Ping ))))

Ping))) returns value as the width of the pulses, as it is shown in Figure 7.

Figure 7. Time sequence of ultrasonic rangefinder Ping)))
2.4. Optical Sensor SHARP GP2A200LCS0F

SHARP GP2A200LCS0F [6] is a proximity sensor manufactured by Sharp. It works like PING))), but instead of sound, this sensor uses light. The sensor is not able to measure distance of the object. It is able only to detect the presence of the object. That is why this sensor’s output is defined as binary output. Sensitive element of the sensor is photodiode. The sensor consists of light modulating circuit, comparator and output modulator [5].

The sensor was connected to microcontroller, as it is shown in Figure 8.

This sensor was used in module as an odometry sensor [10]. To use such sensor as an odometry sensor, a code disk was added. Code disk consists of light and dark parts, which are deployed equally around the disc. This disc is connected to the shaft of the motor and the rotation of the motor cause the alternation of the light and dark parts. This alternation can be detected by optical sensor in the form of pulses. With the knowledge of the radius of the wheels, number of pulses per one rotation, detected number of pulses and some geometrical parameters of the robot, the position of the robot can be determined. The principle of the proposed odometry is shown in Figure 9.

3. Software Description

Software proposed for the module supplies handling of all signals from sensors, transforms these signals to unified form and sends measured values through UART and I2C to master unit [7].

3.1. Accelerometer Handling

Accelerometer communicates by two PWM modulated signals [9]. These signals can be evaluated by one timer. Only 8 bit timer can be used, but 11 bit resolution is needed. This is the reason why another 8 bit variable is used. By this way the timer with 16 bit resolution is created. This 16 bit timer consist of lower 8 bit hardware timer and upper 8 bit variable, which is increased, when 8 bit timer overflow.

When the rising edge comes, value in timer is recorded to temporary variable. When the falling edge comes, value in timer is transferred to variable Xvalue.

Value in this variable is modified in form of the equation (2).


For the Yvalue the same system is used as for the Xvalue.

3.2. Compass Handling

The compass communication protocol is similar to the SPI bus. However, the compass uses 4 bit values as commands and 22 bit value for return measured values. That is why the SPI bus cannot be used. Compass has to be handled by software. 8 bit timer is used to generate clock signal to the bus. Other signals are handled by general I/O ports.

As a part of initialization “Reset” command is sent to the compass. Then “Start measurement” command is sent to the compass at the beginning of the measurement. The compass does not indicate the end of measurement, so an asking system is used to detect it. However, this asking system takes a lot of processor time, so it is needed to minimalize this time. This is done by following way: start the timer after “Start measurement” command, reconfigure the timer to measure time to the end of compass measurement and detect this time period by oscilloscope measurement. While the timer counts this time period, there is quiet on the bus. This is shown in Figure 10.

3.3. Ultrasonic Distance Sensor Handling

Handling of this sensor consists of two parts. The first part is start of the measurement and the second is the return of values. All of these parts are done on one line. This situation is shown on Figure 7.

Start impulse is generated by the microcontroller [13]. Sensor responds by modulating width of impulse. So evaluating of this width is similar to evaluating the accelerometer values.

3.4. Odometry Handling

Used odometry sensor has very poor resolution, so such odometry has only informative value. The evaluation consists of two counters. Both counters are increased when falling or rising edge comes to the pin. Odometry information is calculated for both wheels of mobile robot.

3.5. UART Handling

Sensor module communicates with master unit by UART and I2C. A library was created for this communication. This library includes two buffers (transmit and receive). String which is needed to send is copied to the transmit buffer. There is also a receive buffer, which is used to record the string transferred to master unit by UART. Parameters of UART are shown in Table 3.

In normal operation mode of UART, typical transferred string is shown in Figure 11. This string is transferred every 100 ms by default. Sensor module knows commands, which are shown in Table 4.

Figure 11. String, which is returned from sensor module
3.6. I2C Handling

In normal operation mode, I2C bus works similar as UART. The module is slave on I2C bus. When the read command is sent, the module returns the same string as by UART. Default I2C address is 0x01, but it can be changed by command, which is shown in Table 4.

4. Measurement of Sensor’S Errors

Sensor’s errors were evaluated by STN EN 60 770 [8] technical norm. This norm defines the conditions of the measurements and the carrying-out of measurements. That is why a mutual comparison of the same parameters of various sensors can be carried-out.

The measurements were mainly oriented to determine the precision of the sensors. There are several parameters to quantify the error of the sensors: measured error, nonlinearity, hysteresis and repeatability.

4.1. Accelerometer’s Errors

In fact that a constant acceleration cannot be achieved from the practical point of view, to evaluate the error of accelerometer, the gravity acceleration was measured. The value of gravity acceleration is equal to 9.80665 m.s-2 [11, 12]. Accelerometer was rotated as it is shown in Figure 12. In this way it was achieved that in the direction of both axes exact acceleration value is defined.

Measured results are shown in Figure 13 and Figure 14.

The average parameters of the measurement that were achieved are shown in Table 5 and Table 6.

4.2. Compass’s Errors

To evaluate the error of compass, the Earth magnetic field was measured. Exact value of Earth magnetic field cannot be determined. However, compass is usually used to determine angular deviation from this field. Accordingly, the measurements were conditioned to accurate determination of the sensor angle against the Earth magnetic field, because of which a rotary table was used. A secondary problem of the measurement was that anything made of ferromagnetic material (mostly iron and steel) also affects the magnetic field. Compass was rotated as it is shown in Figure 15.

Measured results are shown in Figure 16 and Figure 17.

The average parameters of the measurement that were achieved are shown in Table 7 and Table 8.

4.3. Ultrasonic Distance Sensor’S Errors

Measurement of the distance is not so technically complicated. To set the exact distance the feed lathe was used. The schema of measurement with ultrasonic rangefinder is shown in Figure 18.

Measured results are shown in Figure 19.

Figure 19. Ultrasonic rangefinder’s errors

The average parameters of the measurement that were achieved are shown in Table 9.

5. Conclusion

A sensor module for the small mobile robot was created. Such module consists of accelerometer, ultrasonic rangefinder, compass and odometry sensors. Sample period for each sensor is shown in Table 10. These values were achived without that the sensors influenced each other. This means that the sampling time of the accelerometer is always 10ms regardless of whether the compass is connected. Created module communicates with higher-level controller by bus UART and I2C bus. It acts as the device type slave on the bus. The module is designed to be connected to platform Acrob.


This paper was processed in the frame of the projects No. 1/0178/13 of VEGA agency and project No. APVV-0539-11 of APVV agency as the results of author’s research.


[1]  Mx2125 datasheet, Available:<>.
In article      
[2]  Mx2125 datasheet, Available:<>.
In article      
[3]  HM55B datasheet, Available:<>.
In article      
[4]  PING))) datasheet, Available<>.
In article      
[5]  Encoder module datasheet, Available:<>.
In article      
[6]  SHARP GP2A200LCS0F datasheet, Available <>.
In article      
[7]  ATmega328P datasheet, Available<>.
In article      
[8]  Balogh, R.2003. Vyhodnotenie merania podľa STN EN 60 770. Available:
In article      
[9]  Virgala Ivan, Vacková Martina, Kelemen Michal, “Robot designed on biomechanics principles of the human locomotion”, YBERC 2010: Young Biomedical Engineers and Researchers Conference: Košice: 1. - 3.7. 2010, TU Košice, pp. 1-4.
In article      
[10]  Kelemenová Tatiana, Kelemen Michal, “Calibration of the position sensor”, MMaMS 2011: Modelling of Mechanical and Mechatronical Systems, TU Košice, pp. 217-223.
In article      
[11]  Židek Kamil, Líška Ondrej, “Accelerometers usability for danger tilt off-highway vehicles and signal filtration with kalman filter”, Journal of Applied Science in the Thermodynamics and Fluid Mechanics, Vol 4, No.2, pp 1-6, 2010.
In article      
[12]  Židek Kamil, Dovica Miroslav, Líška Ondrej, “Angle Measuring by Mems Accelerometers”, Journal of Automation, Mobile Robotics & Intelligent Systems, Vol. 6, No. 4, pp. 3-6, 2012.
In article      
[13]  Hrianka Miroslav, Maslák Anton, Hargaš Libor, Koniar Dušan, Dobrucký Branislav, “Logical Circuits”, Žilinská univerzita, 2011, 287 p.
In article      
  • CiteULikeCiteULike
  • Digg ThisDigg
  • MendeleyMendeley
  • RedditReddit
  • Google+Google+
  • StumbleUponStumbleUpon
  • Add to DeliciousDelicious
  • FacebookFacebook
  • TwitterTwitter
  • LinkedInLinkedIn