Вы находитесь на странице: 1из 23

Report Study of Wireless Car-Robot Control

Huynh, Dang Khoa


Supervisor: Pro.Dr.-Ing.Gernot Zimmer.
Supervisor 2: Dipl.-Ing.Mansooji
27/04/2014
Contents
1 Introduction 1
2 Theoretical Background 2
2.1 UART Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1.1 The concept of UART interfaces . . . . . . . . . . . . . . 2
2.1.2 UART in MSP430G2553 . . . . . . . . . . . . . . . . . . . 3
2.2 Timer and Capture Mode . . . . . . . . . . . . . . . . . . . . . . 4
2.2.1 Timer Introduction . . . . . . . . . . . . . . . . . . . . . . 4
2.2.2 Timer in Capture Mode . . . . . . . . . . . . . . . . . . . 4
3 Devices used 6
3.1 Distance sensor - SRF05 Ultrasonic Ranger . . . . . . . . . . . . 6
3.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1.2 Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.3 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2 Motor Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.1 Full Bridge . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.2 L298 Dual Full Bridge Module . . . . . . . . . . . . . . . 10
3.3 Wireless module JZ871 . . . . . . . . . . . . . . . . . . . . . . . . 10
3.3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.3.2 operation . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.4 Car-Robot Platform . . . . . . . . . . . . . . . . . . . . . . . . . 12
4 Design and Coding 13
4.1 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.1.1 Schematic Diagram . . . . . . . . . . . . . . . . . . . . . . 14
4.1.2 Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.1.3 Further Developments . . . . . . . . . . . . . . . . . . . . 19
5 Reference 21
ii
Chapter 1
Introduction
Microcontrollers are now powerful tools with variable applications in real
life. The MSP430 family of ultra-low-power microcontrollers of Texas Instru-
ments consists of several devices featuring dierent sets of peripherals. The
ultra-low-power feature is especially suitable for my purpose to build a low
power cost Car-Robot sensor.
The purpose of this project is to build up a Car-Robot attached with ultra
sonic sensor which can be controlled by a computer through a wireless module.
In this project I have use:
Tools provided in the laboratory of FH Frankfurt am Main
Code Compose Studio from TI company
Car-Robot platform
Motor Driver module L298 H-Bridge from Thien Minh Company
Wireless module JZ871 from SHEN JIZHUO TECHNOLOGY CO
MSP430 Lauchpad from TI company
Multisim 13.0 Software
Thanks for the help and supporting from Mr.Mansooji and Mrs.Hepp that
I could nish this project. I also want to express my gratitude for Mr.Huynh
because of the precious experiences that he has taught me.
Lastly I want to give my thanks to Professor Gernot Zimmer for giving me
a chance to participate in this interesting project, and the TI Contest.
1
Chapter 2
Theoretical Background
2.1 UART Interface
2.1.1 The concept of UART interfaces
Universal Asynchronous Receiver Transmitter (UART) is an integrated cir-
cuit used for communication over a computer or peripheral device serial port.
UART can be used in serial communication. The UART devices take bytes of
data and transmit the individual bits through a transmitter pin (TXD). For
receiving, the UART devices receive data through receiver pin (RXD) and re-
assemble the bits into complete bytes.
The devices transmit rst one start bit, followed by a sequence of data bit
that usually the least signicant bit is transmitted rst, and ended with one
or two stop bit(s). The sequence of data can be chosen from 5 bits to 8 bits.
Parity bit can be present for error checking and is transmitted after data bit
but before stop bit(s).
Figure 2.1: UART framing
2
2.1.2 UART in MSP430G2553
The MSP430G2553 has a universal serial communication interface (USCI)
modules support multiple serial communication modes included UART.
In asynchronous mode, the USCI Ax modules connect the MSP430 to an
external system via two external pins, UCAxRXD and UCAxTXD. UART mode
is selected when the UCSYNC bit is cleared.
UART mode features include:
7- or 8-bit data with odd, even, or non-parity
Independent transmit and receive shift registers
Separate transmit and receive buer registers
LSB-rst or MSB-rst data transmit and receive
Built-in idle-line and address-bit communication protocols for multipro-
cessor systems
Receiver start-edge detection for auto-wake up from LPMx modes
Programmable baud rate with modulation for fractional baud rate support
Status ags for error detection and suppression
Status ags for address detection
Independent interrupt capability for receive and transmit
UART mode operation
In UART mode, the USCI will transmit and receive data bits asynchronous
with others devices. Users can also adjust the baud rate of USCI (transmission
speed of a frame). The same baud rate has to be used between transmitter and
receiver for operation.
Initialization and Reset
The USCI is reset by a PUC or by setting the UCSWRST bit. After a PUC,
the UCSWRST bit is automatically set, keeping the USCI in a reset condition.
When set, the UCSWRST bit resets the UCAxRXIE, UCAxTXIE, UCAxRX-
IFG, UCRXERR, UCBRK, UCPE, UCOE, UCFE, UCSTOE and UCBTOE
bits and sets the UCAxTXIFG bit. Clearing UCSWRST releases the USCI for
operation.
3
Common register used in UART mode
Figure 2.2: UART common register
2.2 Timer and Capture Mode
2.2.1 Timer Introduction
The MSP430G2553 provides a 16 bit timer/counter module ( Timer A ) with
various features. Timer A can support multiple capture/compares, PWM out-
puts, and interval timing. Timer A also has extensive interrupt capabilities.
Interrupt can be triggered by external signal conditions or inner conditions for
further programmable uses.
2.2.2 Timer in Capture Mode
There are two registers present in Timer A : TACCR0 and TACCR1. Any of
the blocks may be used to capture the timer data, or to generate time intervals.
Capture mode is used to record time event. In this project, I use Capture
mode to record the pulse length of external signal. A capture occurs on the
selected edge (can be rising, falling, or both as user choice) of the input. If a
capture occurs:
- The timer value is copied into the TACCR0 or TACCR1 register.
- The interrupt ag CCIFG is set
4
Figure 2.3: Timer couting in Continuous Mode
When timer is set at capture and continuos mode, the timer will count
continuosly each machine cycle from 0 to 65535 (FFFFh). As soon as the
compare conditions (rising edge, falling edge or both) are satised, the timer
will copy its couting value at that time into TACCR0 register.
5
Chapter 3
Devices used
3.1 Distance sensor - SRF05 Ultrasonic Ranger
3.1.1 Introduction
Figure 3.1: SRF05 ultra-sonic wave ranger
Reference: www.robo-electronics.co.uk/htm/srf05tech.htm
SRF05 is a distance sensor module, which use ultra-sonic wave, produced
by Robot Electronics. The module consists of 2 beamers: one for generating
ultra-sonic wave and the other listening to the bounced back wave.
6
3.1.2 Operation
Figure 3.2: SRF05 pin conguration
Reference: www.robo-electronics.co.uk/htm/srf05tech.htm
At rst, 10uS pulse on trigger pin is needed to start the ranging. Then
the SRF05 will send out an 8 cycle burst of ultrasound at 40kHz and raise its
echo line high and listen for an echo back of the sound. After receiving the
echo, the SRF05 will lower the echo line. Therefore the pulse on echo line is
proportional to the distance between the ranger and the object. If nothing is
detected then the SRF05 will lower its echo line anyway after about 30mS.
Figure 3.3: SRF05 timing diagram
Reference: www.robo-electronics.co.uk/htm/srf05tech.htm
According to the manufacturer, dividing the pulse taken in uS by 58 will
result in the distance value in centimeter.
7
3.1.3 Testing
Figure 3.4: SRF05 test with simple transmitter
In this testing procedure, I use a simple transmitter PT2262 to transmit
the output data of the SRF05. Placing a notebook (A4 size) in front of the
module and gradually move the object away. The output data from SRF05 is
feed into the oscilloscope. The length of pulses generated by the module can be
measured and compared with the distance.
Figure 3.5: SRF05 measurement experiment setup
8
The table below shows the measurement values:
Table 3.1: Measurement values of SRF05
Distance (cm) Pulse length (uS)
1 4 200
2 8 400
3 12 600
4 16 800
5 20 1000
Conclusion: The pulses length and distance values are linear. But the
relationship between them is actually divided by 50 not 58 according to the
datasheet.
3.2 Motor Driver
In this project the Dual Full Bridge Driver L298N from STElectronics is used.
3.2.1 Full Bridge
Figure 3.6: principle full bridge
Full Bridge is a circuits that help to change the direction of current go
through any desired object. The NPN transistors work as electronic switches.
When voltage exists on Base gate, the current can go through transistor from
Collector to Emitter. Switch Q1 and Q4 closed, motor will go in one direction.
When switch Q2 and Q3 closed, motor will go in the other direction.
9
3.2.2 L298 Dual Full Bridge Module
For testing purpose I use the motor driver module L298. L298 is a module
from Thien Minh Company which use IC L298N motor driver.
Figure 3.7: L298 Dual Full Bridge Module
Reference: www.tme.vn
The module can be used to control 2 separate motor, with 2 output pins, 1
enable pin and 1 direction changing pin for each motor.
When applying voltage to the enable pins (E1, E2) the bridges are enable
and current go through motors. By default, pins M1 and M2 if not have voltage,
the motor will rotate in clockwise. When applying voltage to pins M1 and M2,
the motors will rotate in counter-clockwise.
3.3 Wireless module JZ871
3.3.1 Introduction
Figure 3.8: JZ871 Wireless module
Reference: jizhuo.e.tradeee.com
10
JZ871, a Mini power wireless module produced by SHEN JIZHUO TECH-
NOLOGY Company, is used as the wireless data transmission in short distance.
JZ871 operate at 915MHz and has 5 pins
Figure 3.9: Denition of connecting pins and connection method
3.3.2 operation
JZ871 uses UART interface for receiving data and sending data. When
incoming data arrive at RXD line, the module will encode and send out data
by RF wave with 915MHz carrier wave. Another JZ871 will receive the data,
decode them and send to TXD line.
11
3.4 Car-Robot Platform
The Robot platform RP5 provided by Conrad is used in this project.
Figure 3.10: RP5 Car-Robot platform
Reference: www.conrad.de
The platform consists of 2 DC motor which operation voltage at 6V, and
the measured operation current is 0.3A each motor. RP5 also has plastic chasis
and mechanical parts for the car operation.
12
Chapter 4
Design and Coding
4.1 Design
Figure 4.1: Design Overview of the Project operation
There are two main parts in this project: Controller and Car.
The Controller will receive commands from computer and send them to the
car. The car part will then receive the commands and execute them.
13
4.1.1 Schematic Diagram
Blocks included in the Schematic Diagram:
Controller with Transmitter block
Motor Driver block
Distance Sensor and Receiver block
Controller block
Figure 4.2: MSP430G2553 Microcontroller with Wireless module JZ871
The MSP-EXP430G2 LauchPad is a low-cost experimenter board, which
designed for a complete development solution of Texas Instrument MSP430G2xx
series. It provides a 9600-Baud UART serial connection from the MSP430G2xx
device to the host PC through a USB port, which can be used in order for the
microcontroller to be able to receive commands from the computer.
UART Transmitter pin (pin 1.2) of the microcontroller is connected to the
receiver pin (RXD) of the JZ871 Wireless module. UART Receiver pin (pin 1.1)
is connected to the transmitter pin (TXD). The microcontroller sends command
signals through its transmitter pin and the signal will be arrived at receiver pin
of the Wireless module. The Wireless module will then encode the signals into
RF signals (915MHz), and send them.
14
Car block
Figure 4.3: MSP430G2553 microcontroller with Wireless module, Distances
Sensor and Motor Driver
The microcontroller MSP430G2553 in the car is connected with wireless
module JZ871 the same as above. Pin 2.0 is provided with timer function.
Therefore it can be set as Capture mode which measures the pulse length of
Echo signals from Distance sensor SRF05.
15
4.1.2 Coding
Algorithm Flow Charts
Controller
Figure 4.4: Flow Chart of the Controller
Explanation:
When power on, the microcontroller will generate an Interrupt Service
Routine which waits for the commands from computer arrive at UART
Receiver register (UCA0RXBUF). As soon as the character arrive, the
microcontroller will check if UART Transmitter register (UCA0TXIBUF)
ready (ag UCA0TXIFG on) and push that character to UCA0TXIBUF
register, which will then be sent to wireless module. After that, the mi-
crocontroller will make this process again.
16
Car
Figure 4.5: Flow Chart of microcontroller in Car part
Explanation:
When power on, the microcontroller will trigger the sensor and then gen-
erate an Interrupt Service Routine which waits for the commands from
wireless module arrive at UART Receiver register. The microcontroller
captures signal from sensor and calculates distance between the car in ob-
jects in the front continuously. When command signals arrive, it jump into
interrupt routine and read the signal. Base on the commands, the micro-
controller will then output pin 1.7 to turn on motor or changing voltage
level of pin 2.1, pin 1.5 to control the direction ( turn left, right...).
However if the calculated distance value is lower than 8 centimeter, the
voltage level of pin 1.7 will return to 0V and stop the motor from running,
prevent the car to hit the objects in front of it.
17
Code CCS
In order to push the received command character into the UART transmitter
register, rst we have to make sure that the register UCA0TXBUF is ready or
not by checking the ag UCA0TXIFG. Then only need to assigned value from
receiver register UCA0RXBUF to transmitter register UCA0TXBUF as below:
For calculating distance:
When detect the rising edge of the Echo pulse, the microcontroller will copy
the value of timer register to pre cap, set the parameter rst pulse to 1. The
next time when microcontroller detect the changing pulse level of Echo pulse,
it will know that is falling edge because rst pulse is set.
If pre cap value is greater than current timer register value at the detection
time, that means the timer has counted up to 65535 (FFFFh) and started to
count from 0 again. We have to take
((0xFFFF pre cap) +TAC1CCR0)
in order to receive the number of counting value of timer from rising edge de-
tected time to falling edge detected time. Take the value divided by 4 to get
the value in uS and divided by 50 to get the value in centimeter.
18
4.1.3 Further Developments
List of tasks planning for further developments of the project:
Build up a real circuit board (in progress).
Figure 4.6: Schematic of completed board with preset time and LCD
19
Figure 4.7: Layout of completed board with preset time and LCD
Read the sensor values from the Controller and print values on a LCD.
Adding movement sensor to the Controller.
Adding touch pad to the Controller.
Design a Controller box.
20
Chapter 5
Reference
http://www.robo-electronics.co.uk/htm/srf05tech.htm
http://www.ti.com/product/msp430g2553
http://www.ti.com/tool/msp-exp430g2
http://jizhuo.e.tradeee.com/
http://www.tme.vn
21

Вам также может понравиться