Post on 12-Apr-2017
Page 1 of 26
Autonomous Tank
Interim Report
Pablo Villa-Martinez
Project Lab 1
ECE – 3331 – 303
Texas Tech University
May 2015
Group 7 - Team Members:
Fawaz Iqbal
Kameron Johnson
Luis Puente
Page 2 of 26
ABSTRACT
This paper gives the details on how to design an autonomous tank to traverse a track as
fast as possible. The parameters will be given as problems that need solutions which will enable
the tank to traverse a track. The parameters include how the tank remains on and traverses’ the
track, how the tank will avoid obstructions, the motor protection the tank has, the ability to
count the numbers of times the tank traverses the track, and the ability to start given an audio
cue. The goal is to use the parameters that have been given to design, program, and build a tank
that will be able to traverse a track as quickly and effectively as possible without interference
of any potential obstructions on the track. The methods applied to approach these parameters
was one of both theory and experimentation. The design of the tank began by taking theory
and applying the physical measurements that are then changed as necessary based on
experimental observations and the result is a tank that operates based on the parameters given
and capable of traversing a track.
Page 3 of 26
TABLE OF CONTENTS
Abstract …………………………………………………………………………………..2
List of Figures .....................................................................................................................4
List of Tables ......................................................................................................................5
1. Introduction .....................................................................................................................6
2. Body……….....................................................................................................................7
2.1 Basys2 FPGA Board......................................................................................................7
2.1.1 Board Power………………………………………………………………………...8
2.2 H-Bridge Motor Driver…………………………..........................................................8
2.3 Audio Detection……………………………………………………………………….9
2.4 Boundary Detection…………………….......................................................................12
2.5 Start Line Sensor……………………………………………………………………....14
2.6 Proximity Detection ……...…………………………………………………………...14
2.7 Motor Stall Protection…..………………………………………………………….....16
3. Conclusion……...............................................................................................................17
References ...........................................................................................................................17
Appendix A .........................................................................................................................19
Appendix B .........................................................................................................................21
Appendix C………………………………………………………………………………..25
Page 4 of 26
LIST OF FIGURES
Figure1: Basys2 FPGA Board................................................................................................ 8
Figure 2: H-Bridge Motor Driver...………………………………………………………….8
Figure 3: ADMP 401 MEMs microphone….………………………………………………..10
Figure 4: Transducer…………………………..……..………………………………………10
Figure 5: Bandpass Filter design…………………………………………………………….11
Figure 6: Virtual Peak Rectifier……………………...………………………………………11
Figure 7: Inductive proximity Sensor……………………………..........................................12
Figure 8: Proximity sensor operation……………………………………………….……….13
Figure 9: Inductive proximity sensor diagram……………………………………………….14
Figure 10: RPR-220 – start line sensor………………………………………………………14
Figure 11: Ultra Sonic Sensor...………….….……………………………………………….16
Figure 12: LM311 Comparator ….…………………………………………………………..17
Figure 13: motor stall diagram………………..……………………...…………………….…17
Page 5 of 26
LIST OF TABLES
Table 1: H-Bridge Truth Table (L298N)..................................................................................9
Page 6 of 26
Introduction:
A tank is to be designed that must traverse a track given the following specifications.
The tank must traverse a track as quickly and effectively as possible. The tank must start with
an audio cue of a 500 Hz buzzer. The tank will then traverse the track while avoiding any
obstructions on the track. The only acceptable time the tank may stop are under two conditions:
either the tank encounters an obstruction on the track or the tank has completed three rotations
around the track. There must also be motor protection on the tank. Once these parameters have
been met the tank will be operating within its specifications.
This report presents a possible conceptual design for the tank. In evaluating the given
parameters the following criteria are considered: the cost of the tank, the methods of designing,
programming, construction of the circuits, mounting on the tank, the power consumption of the
tank, the knowledge of simulating electrical circuits and understanding electrical behaviour in
a circuit. The conceptual design of the tank is presented in the form of theory, measurements,
and experimentation.
Page 7 of 26
2. BODY
In order to approach the parameters and meet the goal of a working tank, the parameters
were analysed and looked at in great detail. The first step of analysing these parameters began
with the learning and understanding of the resources, tools, equipment, and circuits assembled
and already accessible. For this project, the equipment already accessible was: soldering iron,
Oscilloscope, and an external power source. The circuits already assembled and accessible
were the Digilent Basys2Board and the H-bridge dual full-bridge driver. The second step was
to analyse the parameters with the given circuits: the Digilent Basys2Board and the H-bridge
dual full-bridge driver, and continue use theory and develop the rest of the necessary circuits
such as the Sound sensor, Inductive proximity sensors, Start line sensors, Proximity sensor,
and Motor stall protection. All of which will be discussed further in the following sections. The
third step was to test all circuits individually and all together. And finally was mount all circuits
and batteries on the tank.
2.1 Basys2 FPGA Board
The Basys2 FPGA board can implement circuits ranging from introductory logic
designs to complex digital systems without the need for any other components. The FPGA
stands for Field Programmable Gate Array. A field-programmable gate array (FPGA) is an
integrated circuit designed to be configured by a customer or a designer after manufacturing –
hence "field-programmable". The Code that is loaded in this FPGA is written in Verilog
Programming language using Xilinx Software. Verilog Programming is a hardware description
language (HDL) used to model electronic systems. It is most commonly used in the design and
verification of digital circuits. It is also used in the verification of analog circuits and mixed-
signal circuits. The Basys2 FPGA board is shown in the figure below.
Page 8 of 26
2.1.1 Board Power
The Basys2 board is typically powered from a USB cable, but a battery connector is
also provided so that external supplies can be used to power the Basys2 using a battery or other
external source, such as attaching a 3.5V- 5.5V battery pack. Voltages higher than 5.5V on
either power connector may cause permanent damage. Total board current is dependent on
FPGA configuration, clock frequency, and external connections.
2.2 L298N H-Bridge Motor Driver
The main component of the motor driver circuit is L298N H-Bridge. This IC contains two
H-Bridges which allows the chip to operate two separate motors. The function of this chip is
to control the direction, speed, and movement of the two motors. Its max operating voltage is
46V with a DC current of 4A or 2A for each motor. Each motor has two outputs and uses
Enable A and Enable B to switch each motor on or off independently.
Figure 1: Basys2 FPGA Board
Figure 2: H-Bridge Motor Driver and Pin Layout
Page 9 of 26
The direction of the movement of the motors will be determined based on the truth table
shown in Table 1. Each input of the L298N H-Bridge will receive an output from the Basys2
board that will direct the motor drive in forward or backward direction as shown in the table.
Apart from that, the enable pins will also be driven by the Basys2 board.
2.3 Audio Detection
To approach the parameter of having the tank start on the 500Hz buzzer. A ADMP 401 MEMS
Microphone, which was assembled and available was the component used in the design to
receive the signal . Shown below in figure X. Applying theory to this problem and using the
already built and MEMs microphone receiver was done in 4 stages. The 4 stages are as follows:
The 500 Hz buzzer is received by the MEM’s microphone receiver, the Signal is then allowed
to pass through by using a Narrow Bandpass filter, then the signal is amplified using a
operational amplifier; rectified, then it is sent to the Basys2 FPGA Board. And finally, the
signal arrives to the H-Bridge motor drive and starts the motors. The program diagram can be
referenced in Appendix B - part 3 (a): Audio Sensor diagram. These stages will be discussed
shortly in the following sub-sections
Table 1: H-Bridge Truth Table
Page 10 of 26
Starting with the MEMs microphone, the receiver functions as a basic transducer that converts
sound waves into a electrical signal. The sound signal emitted from the outside environment is
sensed on the diaphragm on the microphone, which makes movements based on the frequencies
of the incoming signal. This movement is used to change the magnetic field in the internal
circuitry which gives an electric signal of an appropriate amplitude and frequency. Such as
shown in figure X below
The sound sensor is connected to a Bandpass filter that isolates the 500 Hz signal from other
frequencies. The circuit below was created using FilterLab®2.0 Filter Design Software from
Microchip Technology Inc. The design gave recommended values for capacitors and resistors
to filter the required frequency; a single supply LM 358 op amp was used, with Vcc being 5
volts.
Figure 3: ADMP 401 MEMS Microphone
Figure 4: Transducer
Page 11 of 26
A peak rectifier circuit is connected across the output of the amplifier, which consists
of a diode connected across a capacitor and resistor in parallel configuration. The diode acts as
a half wave rectifier for the waveform. For the positive cycle of the waveform, the diode would
conduct; for the negative cycle, the diode does not allow current to pass through.
The capacitor charges for the positive half of the cycle, after which the diode goes in
reverse bias. For the negative half of the cycle, the capacitor discharges across the resistor, and
the waveform below is seen across the resistor.
Figure 5: Bandpass Filter Design
Figure 6: Visual of Peak Rectifier – source credit to Fawaz Iqbal
Page 12 of 26
The values for the capacitor and resistor is calculated based on the condition CR >> T
A sufficiently large value for the CR time constant leads to smaller ripples across the waveform.
For a 500 Hz signal, Calculations are as follows:
Time Period = T = 1/500 = 2 ms
Choosing R = 100 kΩ, C = 470 μC,
Time constant = RC = 47 s
This satisfies the condition that RC >> T
The signal is then connected across an LM 339 comparator that gives a logic high signal
for voltage values equal to the peak, and a logic low for values below the peak. As of the time
of this report, the voltage levels have not been calculated to find the resistance values needed
for the comparator. The voltage measured into the Basys2 Board was at 2V
2.4 Boundary Detection:
The parameter of the tank staying on and traversing the track was to use two Inductive
proximity sensor circuits. Inductive proximity sensors are used for non-contact detection of
metallic objects. Their operating principle is based on a coil and oscillator that creates an
electromagnetic field in the close surroundings of the sensing surface, such as shown below in
the figure
Figure 7: Inductive Proximity Sensor
Page 13 of 26
The output of the sensors directs the Basys2 board to change the direction of the motors
with respect to the motors sensors. The track which has the Aluminium surface is regarded as
logic low (0) and non-aluminium is regarded as logic high (1) to the proximity sensors. The
proximity sensors are placed on the front of the tank; so that the sensors will always see the
track line before the tank does. This will avoid the tank driving out off of the track. The physical
operation of the inductive proximity sensors is shown in the figure below
The method which this logic was applied to the tank was expressed in the figure below
where when both Inductive proximity sensors are on the tack the tank traversed the track at full
speed represented by two arrows on both sides of the tank. However when one sensor runs off
the track the opposite sensor will decrease in speed while the sensor off the track will speed up
and correct the tanks direction and therefore keep the tank on the track. The Inductive proximity
Sensors are capable of operating at voltage from 6V to a max of 36V. This sensor has 3 colored
wires where Brown is Vcc, Black is output, and Blue is ground. The sensor is active high. The
program Flow chart can be referenced in Appendix B part II: Track Detection Diagram
Figure 8: Proximity sensor operation
Page 14 of 26
2.5 Start Line Sensor
The Tank stops after completing three laps around the aluminium tape track. The start of the
track is marked by white tape. Using a RPR-220, two LM311N Comparators, and an AND gate
a start line detector system is created. The RPR-220 is composed of 2 parts. The 2 parts are a
LED in parallel with a NPN transistor.
The RPR-220 (Rohm Photo Reflector) is an optical sensor. Its emitter is an infrared LED and
its detector is a phototransistor. Its max collector-emitter breakdown voltage is 30V. Its max
forward voltage is 1.6 V with a max forward current of 50 mA. Its sensing distance is 6mm
with a response time of 10 µs. The RPR-220 is active high and has analog output through a
phototransistor. Output voltage is variable and depends on the reflectiveness of the object it’s
detecting. Oscilloscope readings show that the RPR-220, operating at 5 V, outputs 3 V when
detecting white tape and 4.5+ V when detecting the aluminium track.
Figure 9: Inductive proximity sensor diagram
Figure 10: RPR220 – Start line sensor
Page 15 of 26
As will be discussed in Motor Stall Protection section where the LM311N comparator
op-amp is also in use. Two LM311N’s with outputs tied to an AND gate create a window in
which the output of the AND gate is high or 1 only when the RPR-220 is detecting the white
tape. Comparator1 has a fixed voltage into the inverting input of 1.5 V, while comparator has
a fixed voltage of 3.5 V into its non-inverting input. The full start line circuit can be referenced
in Appendix B part III – Start line Sensor
2.6 Proximity Detection
The HC-SR04 ultrasonic sensor is used for collision detection. It operates on a 5v supply. Its
detecting range is 2cm-400cm. It has four pins: Vcc, Trig, Echo, and Gnd. The sensor sends
out eight 40 kHz pulses when the Trig pin is set to at least 10µs high and receives it through
the Echo pin. The program code used to send the trigger pulse of the Ultrasonic sensor can be
referenced in Appendix A - Verilog code part IV: Collision Detection Code “a”. The modules
includes ultrasonic transmitters, receiver and control circuit. The basic principle of work:
Using IO trigger for at least 10us high level signal,
The Module automatically sends eight 40 kHz and detect whether there is a
pulse signal back.
IF the signal back, through high level , time of high output IO duration is
the time from sending ultrasonic to returning.
Test distance = (high level time×velocity of sound (340M/S) / 2,
Depending on the distance detected the tank will continue running or perform a soft stop,
running again when the distance detected is greater than 5 cm. the program code used to find
the distance can be referenced in Appendix A - Verilog code part IV: Distance Measurement
Code “b”. The Basys2 FPGA Board will display the distance measured using 3 LEDs on the
board. 3 LEDs ON signifies distance greater than 30 cm, 2 LEDs ON signifying less 20 cm but
greater than 5 cm, and 1 LED ON for less than 5 cm
Page 16 of 26
2.7 Motor Stall Protection
The purpose of the motor stall protection is to make sure that current does not spike
through the autonomous tank and the Digilent Basys2 board. The circuit for the motor stall
protection is composed of two different parts, a voltage comparator and a voltage divider.
Having wires from sensor A and sensor B connected in parallel into the inverting input of the
LM311H would not allow the motor stall to function properly. The solution of this problem is
to use two comparators and dividers for each of the motors on the autonomous tank.
The comparator that was chosen to build the circuit is the LM311HP which is a differential
voltage comparator with strobes. There were other comparators that could have been used like
the LM339 or LM211, but the LM311H was chosen because it has a higher quiescent current
per channel (7.5 mA), a higher offset voltage (7.5 mV), and it has less pins, which makes
connecting to the breadboard less confusing. The comparator is used to compare two voltages.
If true the output is high, if false the output is low. Something that should be noted is that the
LM311H max voltage is 30v and its minimum amount of voltage is 3.5v. Figure 5 shows a
LM311 and its pin options.
Figure 11: Ultra Sonic Sensor
Page 17 of 26
3.0 Conclusion
In conclusion this report presents a possible conceptual design for the tank in question.
This report also describes the power consumption which can be referenced in Appendix C –
part II – power consumption which will allow choose the proper battery size for this project.
Using the information in this report has resulted in the design, programmed, and constructed
tank that addresses the parameters of: The tank must traverse a track as quickly and effectively
as possible. The tank must start with an audio cue of a 500 Hz buzzer. The tank will then
traverse the track while avoiding any obstructions on the track. The only acceptable time the
tank may stop are under two conditions: either the tank encounters an obstruction on the track
or the tank has completed three rotations around the track. There must also be motor protection
on the tank. Applying knowledge of electrical behaviour, circuit simulation, theory, taking
measurements and experimenting has resulted into the successful integration of all individual
circuits and application of the tank on the track.
Figure 12: LM311H Differential Comparator with Strobes
Figure 13: Motor Stall Diagram
Page 18 of 26
References
Band-pass Filter
http://www.electronics-tutorials.ws/filter/filter_7.html
http://www.allaboutcircuits.com/vol_2/chpt_8/4.html
Components
Mouser.com
Digikey.com
Sound Sensor
http://abra-electronics.com/robotics-embedded-electronics/breakout-boards/bob-
09868-breakout-board-for-admp401-mems-microphone-bob-09868.html
LM311
https://www.fairchildsemi.com/datasheets/LM/LM311.pdf
Inductive proximity Sensor:
http://en.wikipedia.org/wiki/Inductive_sensor
https://www.pc-control.co.uk/Inductive.htm
Phototransistor - RPR220
http://blog.csdn.net/len_worm/article/details/7484938
http://swest.toppers.jp/SSEST/top/?SSEST4%2F%BB%F6%C1%B0%BC%C2%BD%AC%2F%A5%E9%A5%A4%A5%F3%B8%A1%BD%D0%B2%F3%CF%A9
Page 19 of 26
APPENDIX A: Verilog Code
I) Motor Code:
II) Inductive Proximity Sensor Code:
III) Code For turning:
IV) Collision Detection Code:
a) Trigger Pulse code:
Page 20 of 26
b) Distance Measurement Code:
V) Motor Stall Protection Code:
VI) Start Line Sensor Code:
Page 21 of 26
VII) Audio Sensor Code:
APPENDIX B
Flow Chart Diagrams
I) Motor Connection Diagram:
Page 22 of 26
II) Boundary Detection Diagram
III) (a) Start line Sensor Circuit
(b) Start line virtual circuit
Page 23 of 26
(c) Window comparator
IV) (a) Audio Sensor diagram
(b) Audio Sensor diagram - LM 339 Quad Operational Amplifier
LM 339
Page 24 of 26
(c) Audio Sensor Diagram– Narrow Bandpass filter
(d) Audio Sensor Diagram – amplification w/ gain of 2
(e) Audio Sensor diagram – Comparator – use of LM311P
Page 25 of 26
APPENDIX C:
I) Gantt Chart
II) Power Consumption
III) VTTL
IV) Projected Budget and Actual Bugdet
Page 26 of 26
V)