0% found this document useful (0 votes)
23 views30 pages

Baja Tach and Wheel Speed (2643)

The SAE Baja Group's final report details the design and implementation of a tachometer and speedometer for a Baja vehicle as part of an electrical engineering project. The project includes measuring the vehicle's speed and engine RPM, with a digital system to display these metrics, although housing and mounting were not completed due to time constraints. The report outlines the methodologies for measuring speed and RPM, including the use of reed switches and Hall Effect sensors, and discusses the challenges faced during the design process.

Uploaded by

Victor Marcos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views30 pages

Baja Tach and Wheel Speed (2643)

The SAE Baja Group's final report details the design and implementation of a tachometer and speedometer for a Baja vehicle as part of an electrical engineering project. The project includes measuring the vehicle's speed and engine RPM, with a digital system to display these metrics, although housing and mounting were not completed due to time constraints. The report outlines the methodologies for measuring speed and RPM, including the use of reed switches and Hall Effect sensors, and discusses the challenges faced during the design process.

Uploaded by

Victor Marcos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

1

SAE Baja Group: Final Report


EE A438

Muluneh Babiso

Bradley Ewers

Shawn Marshall

Tyler Tremont

Nick Tuchscherer

Friday, December 11, 2015

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 ................................................................................................................. 3


1.1 INTRODUCTORY STATEMENT ....................................................................................3
1.2 PROJECT DESCRIPTION ................................................................................................3
1.3 TASK BREAKDOWN .......................................................................................................3
2.0 TASK ONE – VEHICLE MPH ............................................................................................. 4
2.1 INTRODUCTION ..............................................................................................................4
2.2 DESIGN METHODOLOGY .............................................................................................4
2.3 ANALYSIS ........................................................................................................................4
3.0 TASK TWO – ENGINE RPM, METHOD ONE .................................................................. 7
3.1 INTRODUCTION ..............................................................................................................7
3.2 DESIGN METHODOLOGY AND ANALYSIS ...............................................................7
3.3 BILL OF MATERIALS ...................................................................................................13
4.0 TASK TWO – ENGINE RPM, METHOD TWO ............................................................... 14
4.1 INTRODUCTION ............................................................................................................14
4.2 DESIGN METHODOLOGY ...........................................................................................14
4.4 ANALYSIS ......................................................................................................................14
5.0 TASK THREE - MICROCONTROLLER .......................................................................... 17
5.1 INTRODUCTION ............................................................................................................17
5.2 DESIGN METHODOLOGY ...........................................................................................17
5.3 ANALYSIS ......................................................................................................................19
6.0 CONCLUSION .................................................................................................................... 21
7.0 REFERENCES .................................................................................................................... 22
8.0 APPENDIX A ...................................................................................................................... 23
8.1 ARDUINO SOURCE CODE ...........................................................................................23
9.0 APPENDIX B ...................................................................................................................... 23
9.1 FUTURE ARDUINO PSEUDOCODE ............................................................................29
3

1.0 INTRODUCTION

1.1 INTRODUCTORY STATEMENT


The purpose of this report is to present the Baja RPM and MPH meters’ final report for
EE A438 Design of Electrical Engineering Systems. This status report will cover the progress of
the design project from initial project description to expected final implementation, deliverables,
and future work.
1.2 PROJECT DESCRIPTION
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 Baja is an off-road
ten-horsepower vehicle designed and built by UAA ME students for the Society of Automotive
Engineers’ (SAE) yearly competition. Our system would measure the rotations per minute (RPM)
of the engine and mile per hour (MPH) of the vehicle and display these numbers to the driver. The
system would also act as a data acquisition (DAQ) system for the mph and rpm of the Baja. A gas
gauge would also be implemented if possible. The project’s design and final implementation must
adhere to SAE rules as well as non-specified goals added along the way. This project is expected
to deliver a fully implemented system as described onto the Baja and a final report and
presentation.

1.3 TASK BREAKDOWN


There are three main tasks to be distributed between the five project members; measuring
the mph of the vehicle, measuring the rpm of the motor, and a digital system whose inputs (and
outputs are logged in the DAQ) are the mph and rpm previously stated and whose outputs are the
tachometer and speedometer displays to the driver. The mph task has been given to Nick
Tuchscherer, the rpm task has been given to Brad Ewers and Muluneh Babiso, and the digital
system task has been given to Tyler Tremont and Sean Marshall.
4

2.0 TASK ONE - VEHICLE MPH


2.1 INTRODUCTION
One way of obtaining the mph of the Baja is by measuring the rpm of its wheel. The rpm
of the wheel will be converted into mph by multiplying the rpm by whatever fraction of a mile
the circumference of the wheel is and converting minutes to hours. There are at least a couple of
ways to measure the rpm of the wheel, such as using optics or magnetic switches. One such
optical method is using a photo-gate; an infrared beam between a transmitter and receiver which
measures the time between the beam being blocked or unblocked. On the other hand, magnetic
switches are great because they’ll work in the muddy and dusty conditions that the Baja will be
operating in as opposed to tools that use optics which could be obstructed by such conditions.

2.2 DESIGN METHODOLOGY

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

The configuration and outputs for 55110-3H-02-A-ND and 55140-3H-02-A-ND Hall


effect sensors are slightly different but similar enough with similar results to cover them in the
same paragraph to reduce redundancy. The 55110 sensor is the simplest of all the configurations
as it has three leads that connect to Vcc, ground, and output without needing external
components. The 55140 sensor also has these three leads but a pull-up resistor, 10k ohms was
used, connecting the output to Vcc is required for proper functioning. Both circuits were
connected to 5.23V and ground. The 55110 gave outputs of 3.91V and 290mV in the absence
and presence of a magnet respectively. The triggering distance was the same for the Hall Effect
sensors as for the Reed switches. The 55140 gave outputs of 5.23V and 230mv likewise. For
both of these circuits, the output was inverted relative to the reed switch circuit. If one of these
circuits is to be used in the final product, this inversion of outputs will have to be taken into
account either in the Arduino coding or an inverter, but if the Arduino were only looking for
positive or negative transitions the inversion of the signal would not matter. Both of the circuits
had rise and fall times of under 600 microseconds. Even though the outputs are inverted, these
circuits are giving us fast switching and good high and low logic voltages that we want to see.
6

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.

Figure 2.5 – Lug-Mount Location Figure 2.6 – Driveshaft Mount Location


7

3.0 TASK TWO - ENGINE RPM, METHOD ONE


3.1 INTRODUCTION
This section outlines the methodology of the design and construction of a circuit which
will turn a spark plug signal from a capacitive pickup into a square-wave which will be readable
by an Arduino microcontroller. SAE rules do not allow us access to the engine compartment so
the only way to get a signal indicating engine RPM is from the spark plug wire. The original
thought was a simple integrating circuit which would turn ideal pulses from the spark plug into a
square-wave. As it turns out, the signal coming from the capacitive pickup is noisy and does not
yield ideal delta functions. Thus, integrating the signal is out. The final goal is to be able to
design an entire system which will be small enough to mount on to an SAE Baja vehicle. This
means it must be small, removable, and simple enough for the students on the Baja team to be
able to install and operate without the supervision of the students working on the design project.
Through meetings with Dr. Mixsell, a base circuit design was developed which would give us a
start in designing a circuit that would meet the criteria we desire. [2]

3.2 DESIGN METHODOLOGY AND ANALYSIS

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.

Figure 3.1 – Original Circuit Design


8

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.2 – Circuit for Amplification and Inversion of Input Signal

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

Non- Eq. 3.2

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

Figure 3.4 – SR Latch Circuitry

Figure 3.5 – Input and Output Waveforms of SR Latch


11

S R Q Action

0 0 Last Value - Latched No Change

1 0 1 Set

0 1 0 Reset

1 1 - Invalid Condition

Table 3.1 – SR Latch Truth Table

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.

Figure 3.6 – Final Circuit Design for Signal Conditioning

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.

Figure 3.7 – Final Input and Output Waveforms


13

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.

3.3 BILL OF MATERIALS

1. LM324N Op-Amp I.C.


2. SN74LS00N 2-Input NAND I.C.
3. DM74LS04N INV I.C.
4. SN74LS08N 2-Input AND I.C.
5. HD74LS76AP J-K Flip-Flop I.C.
6. HD74LS93P 4-Bit Binary Counter I.C.
7. 3 x 1kΩ Resistor, 5% Tolerance
8. 1 x 20kΩ Resistor, 5% Tolerance
9. 1 x 91kΩ Resistor, 5% Tolerance
10. 1 x 100kΩ Resistor, 5% Tolerance
14

4.0 TASK TWO - ENGINE RPM, METHOD TWO


4.1 INTRODUCTION
This was the second method for measuring the Baja engine rpm using the spark plug
current coupling method. This design was cost effective and back up for the first design.
4.1 DESIGN METHODOLOGY
We chose to measure current flowing through the spark plug. This is due to the fact that
the rate of the spark plug’s current spikes has a direct proportionality with the engine rpm. There
were two ways of detecting the current signal; capacitive coupling with a pick up wire and
current transformer. Both methods gave very similar results; a noisy voltage signal with periodic
spikes. The wave form picked up from the sensors was too noisy for the Arduino group to
measure the timing of the events. We needed some analog and digital circuitry to up clean the
noise.
4.2 ANALYSIS
We used Monostable -555 timer to clean up the noise. The oscillator-timer was cheap and
simple to use for this design. We tested the design on Spice first before we tested it on a circuit
board. The Spice results were satisfactory to proceed for building and testing the circuit.

Figure 4.1 - Pspice schematic diagram for monostable-555 timer


15

Figure 4.2. Monostable -555 timer

Fig 4.3 - Square wave signal


When negative pulse trigger is applied to the timer (figure2), the timer oscillator changes
the output from low to high state. This actions helps the timing capacitor charge up through the
resistor and reach the threshold supply voltage which is 2/3 V. After the capacitor is fully
charged, it discharges back to its low state by using pin 7. The output pulse width is
approximated by: T=1.1*R1*C1. From the result part in figure 3, the output pulse width was
16.7ms. Theoretically, the time width was 22ms; using 2uF capacitor and 10k Ohm resistor.
16

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.0 TASK THREE – MICROCONTROLLER

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.

Figure 5.1 – Microcontroller Overview

5.2 DESIGN METHODOLOGY

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.

Figure 5.2 – Spark-Plug Signal Representation

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

Figure 5.3 – Code Layout

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.

Figure 5.4 – Input Signal Waveform


20

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

6. Earl, B. (2015, December 8). Adafruit Industries. Retrieved from Adafruit:


https://learn.adafruit.com/adafruit-data-logger-shield

7. Fried, L. (2015, December 8). Adafruit Industries. Retrieved from Adafruit:


https://learn.adafruit.com/16x24-led-matrix
23

8.0 APPENDIX A

8.1 ARDUINO SOURCE CODE

#include <SD.h>

#include <SPI.h>

#include "HT1632.h"

const int pinDATA = 2;

const int pinWR = 3;

const int pinCSDISP = 4; //LED Matrix Chip Select

const int pinCS2DISP = 5;

const int pinCS = 10; //SD Chip Select

const int pinCLK = 11;

const int sparkInput = 7;

const int hallInput = 8;

float t0, t1, period, p1, p2, noInput, RPM, MPH, tempRPM, tempMPH;

float radius = 0.25; //meters

int count = 0;

// use this line for single matrix

HT1632LEDMatrix matrix = HT1632LEDMatrix(pinDATA, pinWR, pinCSDISP);

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))

Serial.println(" initialization failed!");

return;

Serial.println(" initialization done.");

// open the file. note that only one file can be open at a time,

// so you have to close this one before opening another.

matrix.begin(HT1632_COMMON_16NMOS);

matrix.fillScreen();

delay(500);

void loop()

matrix.clearScreen();

// draw some text!

matrix.setTextSize(1); // size 1 == 8 pixels high

matrix.setTextColor(1); // 'lit' LEDs


25

WaveAnalysis = SD.open("wave.txt", FILE_WRITE);

if(count == 0) //sets up tabs and data columns

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");

tempMPH = getMPH(p2); //change period

matrix.setCursor(0, 0); // start at top left, with one pixel of spacing

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.setCursor(0, 8); // next line, 8 pixels down

matrix.print(tempRPM);

WaveAnalysis.print(tempRPM);

Serial.print(tempRPM);

matrix.writeScreen();

Serial.print("\n");

WaveAnalysis.print("\n");

delay(700);

WaveAnalysis.close();

} else

// if no data is being input, then exit program

Serial.println("error opening test.txt");


28

exit(0);

float wavePeriod(const int input)

t0 = pulseIn(input, LOW); //in microseconds

t1 = pulseIn(input, HIGH);

period = t0 + t1;

return period;

float getRPM(float period1)

RPM = (1/period1)*60*10000; //1000 or 10000?

return RPM;

float getMPH(float period2)

MPH = .621371*(36*3.14159*radius)/(5*period2)*100000; //change period

//MPH = (1/(period2*10000))*(60000)*(2*3.14159*radius*60/5280);

return MPH;

}
29

9.0 APPENDIX B

9.1 FUTURE ARDUINO PSEUDOCODE

//For a gas gauge:

var a = get (time from RTC); //at beginning of data acquisition


var b = get (time from RTC); //at end of data acquisition

//Next run time:

percent =a/b;
gas_left = (1-percent)*100;

print.gas_left;

//To smooth out data collected:

var arr[3];

var mu, oldmu;

//get old, current, and new period

arr[0] = old.period;

arr[1] = period;

arr[2] = new.period;

//calculate period via moving average

for {int i = 0, i <= 2, i++}

mu += arr[i];

//get new mu

var get.mu (var a, var b)

{
30

mu = (b - a)/length(arr); //average

return mu;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy