Baja Tach and Wheel Speed (2643)
Baja Tach and Wheel Speed (2643)
Muluneh Babiso
Bradley Ewers
Shawn Marshall
Tyler Tremont
Nick Tuchscherer
ABSTRACT
The purpose of this report is to present a Final report for EE A438 Design of Electrical
Engineering Systems. The project our group was tasked with was to design and implement a
tachometer and speedometer for the Mechanical Engineering (ME) department’s Baja. The
project is broken up into three tasks: measuring the mph of the vehicle, measuring the rpm of the
motor, and a digital system whose inputs (and outputs are logged) are the mph and rpm previously
stated and whose outputs are tachometer and speedometer displays to the driver. All three tasks
have been completed up to the point of being ready to be housed and mounted onto the Baja.
Unfortunately due to time constraints, housing and mounting will have to be done either by
another senior design group or the ME department.
2
TABLE OF CONTENTS
1.0 INTRODUCTION
Two different magnetic switches that can be used in this application are reed switches
and Hall Effect sensors. Reed switches are two ferrous metal reeds that are sealed in a glass
envelope. Reed switches can be configured so that in the absence of a magnetic field the metal
contacts are either touching or are separated and when the proper magnetic field is introduced the
contacts separate or touch, respectively. For this application, reed switches that close under a
magnetic field are preferred. Hall Effect sensors make use of the Hall Effect where by a
magnetic field passing perpendicular through a current carrying conductor will cause a potential
difference in the conductor that is transverse to both the current and the magnetic field [1]. The
Hall Effect sensor uses this principle to output a changing voltage depending on the strength of
the magnetic field perpendicular to the sensor. For this application, a Hall Effect sensor with a
digital output would be chosen.
Whether the reed switch or Hall effect sensor is chosen, the output of the system will be a
square wave; low in the absence of a magnetic field and high in the presence of a magnetic field,
or vice versa. The advantage of the reed switch is that they are cheap. The disadvantages are that
because this is a mechanical system, the rise and fall times and switching cycles per lifetime are
relatively slow/low depending on the frequency and load of the system. The advantages of Hall
Effect sensors are because it is a solid state component, rise and fall time are faster and more
lifetime switching cycles can be achieved. The disadvantage is that Hall Effect sensors are
relatively much more expensive and have to be configured to give a digital output.
2.3 ANALYSIS
For this project, we ordered two reed switches and four Hall Effect sensors to test for best
fit in this design. The parts were ordered from Digikey and the part numbers are 374-1166-ND,
374-1390-ND, 55110-3H-02-A-ND, and 55140-3H-02-A-ND for the two reed switches and two
Hall Effect sensors respectively. The other two Hall Effect sensors were parts 620-1414-ND and
620-1411-ND, but the data-sheets were illegible and proper setup was not tested.
The configuration of the reed switches is to have each of them pulled to ground through a
10k ohm pull-down resistor and have their other lead attached to 5V. The output would come
from the node connecting the reed switch to the pull-down resistor. When the switch comes into
5
contact with a magnetic south pole of around 60 Gauss at about 5 mm away, the output would
raise to the 5V supply voltage. Both reed switches behaved with the same results. When
connecting the circuit to 5.23V and ground, the outputs were 230mV and 5.23V in the absence
and presence of a magnet respectively. The rise and fall times of the output were at least as fast
as 600 microseconds which is a frequency of 1666.7 Hz which is faster than the wheel would
ever be going. The behavior of this system is precisely what we want to see; fast switching and
high and low logic voltage outputs.
Figure 2.1 – Switch voltage divider switch Figure 2.2 – Square output of reed switch
circuit
Figure 2.3 – 55110 square wave output Figure 2.4 – 55140 square wave output
The magnet that was used to trigger the reed switches and Hall effect sensors was from
Honeywell with part number 102MG11, but a larger, curved rare earth magnet will be used in
final implementation for its shape and increased magnetic field for improved distance between
magnet and sensor.
Though all the equipment and configurations are giving desirable outputs, the 55110
sensor will be used. The 55110 sensor already has its own housing which can easily be mounted.
It also has the simplest configuration and requires no external components. Due to time
constraints, mounting of the sensor and field testing was not achieved. Below are diagrams of
possible mounting places for the sensor and magnet. The mounting configure in the left picture
(figure 7) would be preferred, because the rear drive shaft the magnet would be mounted on, as
shown in figure 8, would be shifting around because it is adjoined to a CV joint.
The base circuit developed shown in Figure 3.1 uses mostly digital logic integrated
circuits. Specifically, it uses an SR latch coupled with JK flip-flops to output a square-wave.
Overall, the final circuit and the original circuit are not that different from each other. The two
key missing elements are the amplification and conditioning of the input signal coming from the
spark plug pick-up, and some form of a delay stage.
The signal coming from the spark plug pick-up is itself, not enough to simply input into
the circuit shown in Figure 1. Because we are using an SR latch, we will want the input signal
from the pick-up to be rectified, and inverted so positive voltage spikes are actually negative.
And because we are using digital circuitry, TTL voltage levels are ideal, meaning a range from
zero to five volts. In order to accomplish the condition of the signal, LM324 operational
amplifiers are used. The LM324 IC has four op-amps built into it – we will be requiring two.
The first op-amp will amplify and rectify the incoming signal with an output range of zero to five
volts. The second op-amp will further amplify and invert the signal around 2.5 volts so positive
voltage rises from the spark plug pick-up are seen as negative voltage drops (from five to zero
volts) by the SR latch. The conditioning circuit for this stage is shown in Figure 3.2.
Figure 3.3 depicts the input waveform from the spark plug pick-up and also shows the outputs of
each op-amp in Figure 3.2.
9
Figure 3.3 – Waveforms Generated by Spark Plug Pick-up and Amplification/Inversion Circuitry
There are three waveforms shown in Figure 3.3. The first, colored yellow, is the original signal
from the capacitive pick-up. The second, colored green, is the amplified and rectified signal
from the first op-amp. The third, colored purple, is the further amplified and inverted signal
from the second op-amp. The gain of each op-amp is arbitrary in that as long as it rails out the
signal at five volts, it is adequate. The gain is controlled by the input and feedback resistors of
each op-amp stage. Mathematically, the gain can be represented by Equations 3.1 and 3.2. [3]
Eq. 3.1
The first op-amp has a gain of 21 while the second op-amp has a gain of approximately 1.75.
With the input signal from the spark plug pick-up successfully pre-conditioned, the SR
latch can effectively use it as an input in order to turn the original signal into a square-wave. The
SR latch will latch when the output of the amplifier stage is five volts (a logical “1”) and when
the inverted reset signal is zero (a logical “0”). Not until these two conditions for “S” and “R” of
the SR latch are input again, will the output of the latch change. Figures 3.4 and 3.5 depict the
SR latch operation and the truth table is shown in Table 3.1. [4]
10
S R Q Action
1 0 1 Set
0 1 0 Reset
1 1 - Invalid Condition
The problem with using the SR Latch is that it will reset too frequently with the given
input signal. What we are desiring is one reset event per pulse from the spark plug pick-up. In
order to do this, we must devise a plan to add delay to the circuit that is at least as long as the
time-span of a spark plug pick-up signal event. Using the oscilloscope, we were able to measure
the time-span of the spark plug pulses and they ended up being approximately 6ms. This means
our delay circuit needs to add at least 6ms of delay to the circuit before the SR latch resets. We
were going to originally do this using a low-pass filter (LPF). This LPF would be placed
between the “Q” output of the first JK flip-flop and input “1” of the AND gate shown in Figure
3.1. Using Equations 3.3 and 3.4, we would be able to solve for the resistor and capacitor
needed to add 8ms of delay. [3] We chose 8ms of delay instead of 6ms to give more of a buffer
between events.
Eq. 3.3
Where
Eq. 3.4
Setting to 8ms, to 1V, to 5V, and solving for τ yielded τ equal to 35.9ms. This means the
product of the resistance and capacitance of our RC circuit must equal 0.0359. In the laboratory,
we have 0.1µF capacitors and chose a 36kΩ resistor to get τ. The only problem with using our
digital circuits is that when the inputs and outputs are “high” or a logical “1”, they have a
voltage. Through experimentation it was found that using an LPF to add delay to the circuit
would not work since the outputs which it would be connected to retain a voltage which means
the capacitor will not discharge at all. The solution to this problem is simple enough. Since we
have control over what our clock signal is (in this case we chose 1 kHz) we can use a 4-bit
Binary Adder to add delay. As the adder adds one bit every clock cycle, we get 8ms of delay
after 8 clock cycles. By using the most-significant bit of the adder as the output of our delay
12
circuit, we can add 8ms to the entire circuit thus achieving our desired output. After adding the
binary adder to the circuit, we achieve what is shown in figure 3.6 – the final circuit design.
The group members working on the source code for the Arduino microcontroller desired a
square-wave as the output of our circuit. We were successfully able to achieve a clean square
wave that is at half the frequency of signal events from the spark plug input signal, shown in
Figure 3.7.
For testing of this circuit, power supplies and signal generators were used. If we are to mount
this on the Baja vehicle, we will need to design a little more circuitry for power sources,
specifically 5V and 2.5V supplies. The team members working on the Arduino source code
should be able to implement a 1 kHz clock output from the Arduino board itself.
With this circuit, there was a significant result in cleaning up the noise and conditioning
the signal into a square wave. From the conditioned output the frequency found was around 60
HZ, which gave us an engine rpm of 3600. This engine rpm was maximum for Baja. There was
noise in the input signal after design. This made the output signal delay a little bit to match with
the input. This could be a problem with the wiring around the circuit board or from the design
itself. From this project, the theoretical and actual values are approximately same. In the future,
we would like to implement a design using Zener diodes and diode combination across the input
17
5.1 INTRODUCTION
Our group was tasked with creating a control interface to bridge analog data input, and
digital output (Fig 5.1). The first piece of input data would come from the Hall Effect sensor
attached to the rotating wheel. An inductive wire wrapped around the spark plug would produce
the second input. Both inputs would be processed by the Arduino to calculate engine RPM, MPH
of the Baja, and an optional gas gauge. An LED display was the chosen output means, which
would eventually be utilized by the driver of the Baja.
The Arduino Uno was chosen out of the possible candidates for hardware interfaces. Our
group’s reasoning behind the selection was that the Arduino provided the functionality we
required, and did not suffer unnecessary overhead that other similar hardware might experience.
Another positive aspect about the Arduino was its modular nature. “Shields” are essentially
building blocks for Arduinos, allowing multiple boards to be stacked on top one another. These
shields trivialize expansion of microcontroller functionality via hardware. Since our team was
tasked with making our overall project “plug-and-play” for the most general of users, the
Arduino for this reason was made more attractive. Additionally, our group had a fixed budget of
$200.00. The Arduino had a low price, which came into play when discussing controller options.
Our LED matrix was chosen because it was much brighter than similar hardware in its price
range. For a driver who needs to see the output at a glance, the LED matrix was a clear pick over
its competing hardware selections. Finally, the Arduino is a well-documented and maintained
microcontroller. Having an extensive library selection would ultimately reduce the time our team
18
spent troubleshooting and testing code. Our source code is heavily influenced by Arduino
libraries [5]. Online sketches for the Arduino already included mostly working code for the data
logging shield [6], and the LED matrix [7].
After the Arduino was chosen as a microcontroller, the team needed a way to interpret the
incoming data from the spark plug, and the Hall Effect sensor. Initially it was projected we
transform the delta-like spikes into square waves via Fast Fourier Transform. However, the noise
floor of the spark plug data (Fig. 5.2) was much too high to digitize the signal internally with the
Arduino. As such, the signal conditioning was chosen to be external to the Arduino. The input
signal from the Hall Effect sensor was close to being digital in form, so additional signal
conditioning was not required.
The actual Arduino coding was made simpler by taking advantage of the built in libraries
for SD interface and the HT1632 display. After planning which functions we would need to
create, we identified the flow of logic for the code as shown (Fig. 5.3).
19
For advanced troubleshooting, a “safety” was coded in where the program will end if the inputs
or the SD card is disconnected mid-trial.
5.3 ANALYSIS
To prepare the actual components, all the headers and jumpers were soldered on the
Arduino, data logger, and LED display. After assembling the components, three more wire leads
were soldered to the Arduino I/O pins for the two inputs and ground. To simulate the incoming
signals we would be processing, two waveform generators were connected to the inputs and
configured for similar square waves (Fig. 5.4). The display was connected to the Arduino via
colored jumpers that were later soldered in place.
Using the flowchart and existing libraries, our program was able to input both square waves
successfully and calculate the periods, and then use that data to output real-time values to the
LED display, while saving the tab-delimited data to a text file on the SD card for easy future
analysis. The actual code is shown in (Appendix A).
The system functions properly as intended but there are many future design
improvements that could be implemented into the system with relative ease (Appendix B). For
example, a simple percentage bar on the two rightmost LED pixel columns could be configured
into a gas gauge with a simple sensor or a timing calculation. The current numbers shown on the
display are the default font from the HT1632 library, but traditional racing-dash style numbers
may be easier to read for the driver. The system could be mounted in a number of places on the
BAJA, from the roll cage bar mount to a sunken dash past the steering wheel. A possible issue
became apparent in the display, where its half-second refresh rate may be distracting to the
driver. This could be fixed by additional nested loops in the code where the screen is updated
constantly (faster than the human eye can see, 60 Hz or more) whether there is a new value
instance or not. There are tons of additional applications: Bluetooth integration, network
monitoring and data upload via Wi-Fi or cellular, the list goes on.
21
6.0 CONCLUSION
The goal of our project was to design and build a system which is capable of displaying
the engine RPM and vehicle speed of the SAE Baja vehicle. Individual tasks were assigned to
each member, who developed an integral part of the project. Task one was to transduce the wheel
rotation into the MPH of the vehicle. This was successfully completed by using a Hall Effect
sensor. Task two was to transduce the firing of a spark plug which was representative of the
engine RPM. Two methods were attempted, although only the first method was successful. Task
three was to accept the outputs from the Hall Effect sensor and spark plug conditioning circuits
into a digital readout display, as well as design a method to log the data. Our project has
progressed fruitfully thus far albeit not as far as initially expected. The method of transducing the
rotation of the wheel into mph of the vehicle is ready to be mounted and tested. For connection
from the sensor to the Arduino module, BNC connectors would be used for easy attachment.
BNC connectors would also be used for the rest of the modules for easy attachment. The first
design for the circuit conditioning the spark plug pickup signal will be used for its reliability.
PCB fabrication and housing will have to be done before it is ready for mounting and testing.
Finally, the Arduino module is ready to be housed and mounted. The project is ready to be
handed to a second senior design group to conduct improvements and final installation.
22
7.0 REFERENCES
1. Cheng, D. (1983). Field and wave electromagnetics. Reading, Mass.: Addison Wesley.
2. Mixsell, J. (2015, September 18). Conversation [Personal interview].
3. Nilsson, J., & Riedel, S. (1996). Electric circuits (5th ed.). Reading, Mass.: Addison-
Wesley.
4. Mano, M., & Mano, M. (1984). Digital design. Englewood Cliffs, N.J.: Prentice-Hall.
5. Arduino. (2015, December 8). Arduino - Libraries. Retrieved from Arduino:
https://www.arduino.cc/en/Reference/Libraries
8.0 APPENDIX A
#include <SD.h>
#include <SPI.h>
#include "HT1632.h"
float t0, t1, period, p1, p2, noInput, RPM, MPH, tempRPM, tempMPH;
int count = 0;
File WaveAnalysis;
void setup() {
Serial.begin(115200);
pinMode(sparkInput, INPUT);
pinMode(hallInput, INPUT);
24
while (!Serial)
; // wait for serial port to connect. Needed for native USB port only
Serial.print("Initializing SD card...");
if (!SD.begin(pinCS))
return;
// open the file. note that only one file can be open at a time,
matrix.begin(HT1632_COMMON_16NMOS);
matrix.fillScreen();
delay(500);
void loop()
matrix.clearScreen();
WaveAnalysis.print("\n");
WaveAnalysis.println("NEW DATA:");
WaveAnalysis.print("\n");
Serial.print("\n");
Serial.print("NEW DATA:");
Serial.print("\n");
Serial.print("\n");
WaveAnalysis.print("PERIOD 1");
Serial.print("PERIOD 1");
WaveAnalysis.print("\t");
Serial.print("\t");
WaveAnalysis.print("PERIOD 2");
Serial.print("PERIOD 2");
WaveAnalysis.print("\t");
WaveAnalysis.print("\t");
Serial.print("\t");
Serial.print("\t");
WaveAnalysis.print("MPH");
Serial.print("MPH");
WaveAnalysis.print("\t");
WaveAnalysis.print("\t");
Serial.print("\t");
Serial.print("\t");
26
WaveAnalysis.print("RPM");
Serial.print("RPM");
WaveAnalysis.print("\t");
WaveAnalysis.print("\t");
Serial.print("\t");
Serial.print("\t");
Serial.print("\n");
WaveAnalysis.print("\n");
count++;
if (WaveAnalysis)
p1 = wavePeriod(sparkInput);
p2 = wavePeriod(hallInput);
Serial.print(p2);
WaveAnalysis.print(p2);
WaveAnalysis.print("\t");
WaveAnalysis.print("\t");
Serial.print("\t");
Serial.print("\t");
Serial.print(p1);
WaveAnalysis.print(p1);
WaveAnalysis.print("\t");
WaveAnalysis.print("\t");
Serial.print("\t");
27
Serial.print("\t");
matrix.print(tempMPH);
Serial.print(tempMPH);
WaveAnalysis.print(tempMPH);
WaveAnalysis.print("\t");
WaveAnalysis.print("\t");
Serial.print("\t");
Serial.print("\t");
tempRPM = getRPM(p1);
matrix.print(tempRPM);
WaveAnalysis.print(tempRPM);
Serial.print(tempRPM);
matrix.writeScreen();
Serial.print("\n");
WaveAnalysis.print("\n");
delay(700);
WaveAnalysis.close();
} else
exit(0);
t1 = pulseIn(input, HIGH);
period = t0 + t1;
return period;
return RPM;
//MPH = (1/(period2*10000))*(60000)*(2*3.14159*radius*60/5280);
return MPH;
}
29
9.0 APPENDIX B
percent =a/b;
gas_left = (1-percent)*100;
print.gas_left;
var arr[3];
arr[0] = old.period;
arr[1] = period;
arr[2] = new.period;
mu += arr[i];
//get new mu
{
30
mu = (b - a)/length(arr); //average
return mu;