25
Formula SAE Instrumentation Lee Knies, Electrical Engineering Project Advisor: Mark Randall March 27, 2017 Evansville, IN

Formula SAE Instrumentation - University of Evansville SAE Instrumentation Lee Knies, Electrical Engineering Project Advisor: Mark Randall March 27, 2017 Evansville, IN Acknowledgements

  • Upload
    lythien

  • View
    219

  • Download
    1

Embed Size (px)

Citation preview

Formula SAE Instrumentation

Lee Knies, Electrical Engineering

Project Advisor: Mark Randall

March 27, 2017

Evansville, IN

Acknowledgements

I would like to thank Dr. Phil Gerhart and the University of Evansville Engineering

department for financial support of this project. I would also like to thank Mr. Randall for his

support as my advisor and for the LCD code from his library. Lastly, I would like to thank the

UE formula car team for their support and cooperation on this project.

Table of Contents

I. Introduction

II. Background

III. Design

A. Hardware

B. Software

C. Pseudocode

D. Standards and Constraints

IV. Results

V. Conclusion and Recommendations

IV. References

Appendix A.

List of Figures

1. Block Diagram 2. 7 segment display 3. LCD screen 4. 8051 microcontroller 5. Logomatic data logger 6. Infrared thermocouple 7. Hall sensor 8. ECU 9. Keil logo

List of Tables

1. Cost breakdown

I. Introduction

The University of Evansville Formula Racing team has been competing in the Society of

Automotive Engineers (SAE) racing competition at Michigan International Speedway for several

years. The team is made of predominantly mechanical engineers. The team members have a full

schedule and do not have time to design and build extra electrical systems which fall outside

their expertise. The need presented this year was for an electronic dashboard and data acquisition

system. The end goal was to have a functioning dash board with readouts for speed, engine rpm,

and coolant temperature. The design is adaptable so inputs and readouts can be added and

removed later without too much work. The data displayed on the dash is also recorded in a way

that is easy to analyze.

II. Background

The University of Evansville formula car team has existed for years relying on the bare

minimum electronics. Things that had to be powered like fuel pumps, ignition, engine ECU and

kill switches were all used but with little extra. There was a need for driver instrumentation and

post run data. This data not only is useful to the driver during a run, but the data can also be used

to tune not only the engine, but other onboard systems like suspension and steering. In addition

to testing, the data can also be used to justify changes and design ideas to the judges at

competition.

The formula car team needs to have driver instrumentation on the status of the car and

engine. The readouts desired are speed, fuel/air ratio, coolant temperature and tire temperatures.

All data read should be stored in a way that is easy to access. The system must be able to be

powered by 12 volts and fit in a reasonable space in the car. The sensors used output a variety of

signal types including voltages from millivolts on thermocouples to full battery voltage of 12

volts on the hall effect sensor (used for vehicle speed). Other signals like from the ECU for

RPM are frequencies. The solution produced will have to be able to read and use data from

every input.

III. Design

A. Hardware

The solution provided accomplishes its goal of providing a readable dash to the driver

and giving data to the team after a run. The design uses the 8051 microcontroller as the main

control unit and interfaces to sensors and outputs. A basic overview is shown in Figure 1. The

8051 was chosen mainly because of its availability but also because of its ease of use and

available features. The analog to digital

converter (ADC) is very important for reading

sensors. The multiple timers are also needed to

run various parts of the code and hardware. The

data bus is also used to drive the LCD screen.

Figure 1 Block diagram

The dashboard consists of two seven segment displays shown in Figures 2 and 3, each

approximately 34x24 mm. Figure 2 shows front and side and Figure 3 shows

the installed displays. There is also a four line by twenty-character LCD

screen seen in Figure 4. The viewing area of this screen is approximately

25x76 mm. The four-line LCD was chosen because of

its known functionality. The original design specified

a single larger graphic LCD screen to incorporate all

data, however the one ordered did not work. It is still unsure if the device

was bad or if it was simply not set up correctly. The current LCD

is limited in its text size, but it is relatively easy to write any text to

it. Information like fuel air ratio and engine temperature will be

displayed on the LCD screen. The seven segment displays are

switchable between vehicle speed and engine RPM. These values

are more important and are therefore larger in size than any of the other values. These displays

are used because of their size and availability.

The specific microcontroller used is the Atmel 89C51CC03 8051 microcontroller. This

is an 8-bit system with many useful built in features. There are four full built in 8 bit ports

available for a total of up to 32 digital input/output connections. Built into this model of the

8051 are additional features like an 8-bit data bus. There are also up to 8 of the digital ports

available for analog input connected to a built-in analog to digital converter. This model also has

a built in serial communication function. The 8051 microcontroller and its control board as

provided by UE is shown in figure 5. The 8051 microcontroller is programable in the standard C

Figure 2 Seven segment display front and side

Figure 3 Installed seven segment displays

Figure 4 LCD screen

language, which is taught in the first year at the

University of Evansville. Keil microvision 5 is a free

software that is used to write and compile code for

the 8051 [1].

To record data a Logomatic serial SD Datalogger made by SparkFun is used. This device

was used in previous projects at UE and is available. This device communicates using serial

communication with the 8051. The device uses a FAT32 disk format and is compatible with any

size micro SD [2]. The data is recorded as a text file to a micro SD card which can be easily put

in a computer. The file can be opened in excel as a spreadsheet to be analyzed. The Logomatic

board is pictured in Figure 6.

Vehicle speed is measured with a hall effect

sensor/magnet system. The hall effect sensor is mounted near the

jack shaft in the drive train. This is an intermediate spinning shaft from the transmission that

drives the chain to the wheels. The hall effect sensor that is

used is a digital sensor. It will put out a digital high every time

a magnet is detected. The output high voltage will be the same

as the input voltage anything between 3 and 24V [3]. The

resulting output is a frequency the same as the shaft RPM. The

hall effect sensor is shown in Figure 7.

Figure 2 Hall sensor

Figure 6 Logomatic data logger [2]

Figure 5 8051 and control board

Engine data is taken from the engine control unit (ECU) pictured in Figure 8. The ECU

used is the PE3 8400. This unit is made by Performance Electronics,

Ltd. The ECU is responsible for all ignition and fuel delivery of the

engine. This model has a designated tachometer output. This output is

a configurable pulse width modulation signal with 30% high time. The

ECU can be programmed to have one to four pulses per revolution [4].

As used by the team, there is one pulse per revolution meaning the frequency output is the same

as the frequency of the engine or revolutions per second. There are other analog and digital

outputs available on the ECU for other engine data like temperature and fuel/air ratio. The

fuel/air ratio is an analog voltage between 0 and 5V. A full diagram of all connected systems

and devices is shown in Figure 9.

B. Software

The microcontroller code for this project was developed in Keil microvision 5. The 8051

uses the standard C language. The main body of the code is simple running only a timer

initialization, LCD screen initialization, and multiplexing the seven segment displays.

Initialization is followed by while(1) command that is quickly and continuously turning on one

display at a time and updating it. The remaining operations are done by functions and triggered

by an interrupt. The timer 1 interrupt is set to interrupt every millisecond and count real time.

After 250 ms the data is collected and output, and the clock counter is restarted. The full code

can be found in appendix A.

Figure 8 ECU [4]

C. Pseudocode

Initialize LCD

Initialize timers

Loop forever

Start real time clock/start counting pulses

Figure 9 Circuit diagram

Wait .25 seconds

Display/record data

Multiply pulses by 4 to get frequency

Read AD converter

Write data to LCD screen / seven segment displays

Reset timer and counter

D. Standards and Constraints

The biggest constraint for this project is reliability with adverse conditions present in a

racecar. Being in a racecar the device will be exposed to vibration, G force, and the possibility

of impact. Having solid, well-made components and connections is key to making the system

hold up to the demands of racing. Power is not an issue with a steady 12 volts coming from the

battery and engine charging system. Overall size was also considered in design. Anything

produced will have to fit in the current electronics tray area. Also important is the weight.

Weight is watched and managed very closely on the vehicle. Most components used are very

light. The main consideration for weight was the mounting of components.

Safety is always a big issue in automotive applications especially in racing. Although

this device does not present any direct hazards like moving parts or electric shock, it could be a

distraction to the driver. The displays for the most important data, speed and engine RPM, are

larger so they can be easily read. The driver needs to keep his attention on the course as much as

possible. By making the most important readouts larger, the driver will only need a quick glance

to get the information he needs. If the other details listed on the LCD screen are needed it will

require the driver to take his eyes off the course a little longer. However, these numbers are not

needed as often and won’t be needed at all once testing is done.

Automotive applications are always electrically noisy especially in this one of a kind race

car situation. Much of the data from various sensors is jumpy and erratic. This is likely due to

noise from the engine and other components. IEEE standard 1143-2012 gives a guide to

shielding low voltage signal lines [5]. Following these guidelines in any situation is important to

minimize the error in the data.

IV. Results

The final design accomplished its goal and provided a useable dash to the formula car team. The

installed solution can be seen in Figure 10. Although each system works, they are not without

error. The seven segment displays for speed and engine rpm are dim and flicker. The displays

show the correct data, but are a bit hard to read in the bright sunlight. The LCD screen worked

as expected. The data processed by the microcontroller was useable, but not perfect.

Figure 10 Installed dash

Occasionally, an outlying data point would be shown, but would return to normal after the next

sample. The data recording also worked. The occasional outlier mentioned above would be

recorded, but the data was still useable. Sample data is shown in Figure 11 with outlying data at

.5 second. The serial communication to the Logomatic board is also susceptible to noise. The

main issue on this is at startup and shutdown. Occasionally

Figure 11 Testing data graph, engine speed x100 vs time

at one of these two times there will be a line of random text. Since this is mostly at the

beginning and end, it is easily removed and the data can still be used. The data displayed on the

dash was helpful to the driver for mid run adjustments and real time status. The recorded data

was helpful for adjustments between runs and for driver training.

V. Conclusions and Recommendations

There are data recording systems commercially available. The current ECU the team is

using even has the capability of recording data. What makes this design unique is its ability to

display a dash and record data. Using a SD card allows for almost unlimited space. Possibly the

0

50

100

150

200

0.25 0.5 0.75 1 1.25 1.5 1.75 2 2.25 2.5 2.75 3 3.25 3.5 3.75 4 4.25 4.5 4.75 5 5.25 5.5 5.75 6 6.25 6.5

biggest advantage to a custom system is cost. The cost of this design was just over $100. The

detailed cost breakdown is shown in Table 1. Most commercially available systems begin at four

times that amount and go up in price. The system described here accomplishes the needed

results and is cost effective.

Item Quantity Price per total

LCD 1 7.99 7.99 7 segment display 2 1.99 3.98 8051 microcontroller 1 17 17 Logomatic 1 54.95 54.95 Logic level converter 1 2.95 2.95 OP amps 2 1.01 2.02 Hall effect sensor 1 1.98 1.98 SD card 1 5.99 5.99 assorted wires/pins 1 10 10

Total 106.86

Table 1 Cost breakdown

This project was fun and rewarding. In completion, I was able to help the formula car

team in the testing of their race car and prepare it for competition. By working on an

interdisciplinary project, I learned things about cars and other mechanical theory that I otherwise

would not have had the chance to learn.

In continuation of this project wireless data transmission could be added. In order to fix

the flicker and brightness of the seven segment displays, a seven segment decoder/latch was

purchased. Although it is not installed at the time of the report, it should be delivered and

installed before leaving for competition on May 8. This device works as a driver supplying more

current than the microcontroller/op amp combo, and will fix the flicker by latching the output

until new data is written.

VI. References

[1] D. Blandford, "EE 354," [Online]. Available: http://csserver.evansville.edu/~blandfor/EE354/index.htm. [Accessed 25 1 2017].

[2] "Logomatic Hookup Guide," Sparkfun, [Online]. Available: https://learn.sparkfun.com/tutorials/logomatic-hookup-guide?_ga=1.206742739.1149332126.1477341173. [Accessed 6 December 2016].

[3] "Hall Effect Sensor - US1881," sparkfun, [Online]. Available: https://www.sparkfun.com/products/9312. [Accessed 6 December 2016].

[4] "The PE3 Series User Manual Version 1.1," [Online]. Available: http://pe-ltd.com/assets/pe3-series-manual.pdf. [Accessed 6 December 2016].

[5] IEEE, "1143-2012 - IEEE Guide on Shielding Practice for Low Voltage Cables," 4 March 2013. [Online]. Available: http://ieeexplore.ieee.org/document/6471984/. [Accessed 24 April 2017].

Appendix A: Code

//LCDTest.c #include<at89c51cc03.h> #include<stdio.h> #include <string.h> #define LCDCmdAddr 0xAF00 //LCD Command port address #define LCDDataAddr 0xBF00 //LCD Data port address //functions void LCDInit(void); void DisplayText(unsigned char lineNum, unsigned char startPos, unsigned char text_message[]); void LCDelay(unsigned int x); void timer_init(void); void a_to_d_init(void); void dataprint(void); //unsigned short pulses, unsigned short advalue); void sevensegment(unsigned char digit); void serial_init(void); void write_data(void); //global variables unsigned char tenthsCounter; unsigned char milliSeconds; unsigned short pulses; unsigned char tmp; unsigned char temperature; double volts; void main(void) { unsigned char ones; unsigned char tens; unsigned char x; LCDInit(); timer_init(); a_to_d_init(); serial_init(); while(1) { ones = pulses%10; tens = pulses/10; sevensegment(ones);

P3_7 = 1; for (x=0;x < 20;x++) { } P3_7 = 0; sevensegment(tens); P1_7 = 1; for (x=0;x < 20;x++) { } P1_7 = 0; } } //LCDisplay // Sends LCDData to the port at LCDAddr void LCDisplay( unsigned int LCDAddr, unsigned char LCDData) {unsigned char xdata *Lcd; Lcd = (char xdata *)LCDAddr; *Lcd = LCDData; } //LCD Delay Routine void LCDelay(unsigned int DelayTime) {unsigned int TimeTic, Tock; for (TimeTic=0;TimeTic < DelayTime;TimeTic++) for(Tock=0;Tock<40;Tock++); } //LCD Initialization Module void LCDInit(void) {LCDelay(1000); LCDelay(1000); LCDelay(5); LCDisplay(LCDCmdAddr, 0x38); //function set 8-bits LCDelay(5); LCDisplay(LCDCmdAddr, 0x0C); //display on LCDelay(5); LCDisplay(LCDCmdAddr, 0x01); // display clear LCDelay(50); LCDisplay(LCDCmdAddr, 0x06); // auto-increment pointer no shift LCDelay(1); } //Display text to LCD

void DisplayText(unsigned char lineNum, unsigned char startPos, unsigned char msg[]) {unsigned char index, length; LCDelay(1); switch (lineNum) {case 1: LCDisplay(LCDCmdAddr, 0X80 + startPos); break; case 2: LCDisplay(LCDCmdAddr, 0XC0 + startPos); break; case 3: LCDisplay(LCDCmdAddr, 0X94 + startPos); break; case 4: LCDisplay(LCDCmdAddr, 0XD4 + startPos); break; default: LCDisplay(LCDCmdAddr, 0X80 + startPos); break; } length = strlen (msg); for(index = 0; (index < length) && (index < 20 - startPos); index++) {LCDelay(1); LCDisplay(LCDDataAddr, msg[index]); LCDelay(1); } } //real time initialization void timer_init(void) { CKCON = 0x01; //x2 mode (system/4 ?) TMOD = 0x51; //timer 1 counter 16 bit, timer 0 timer 16 bit T2CON = TH0 = 0xED; TL0 = 0xA2; // loading prescaler to timer TR0 = 1; // Start timer 0??? TR1 = 1; ET0 = 1; //Timer 0 interupt enable EA = 1; //global interrupt enable } //real time interrupt void T0Int() interrupt 1 using 1

{ unsigned short advalue; TH0 = 0xED; TL0 = 0xA2; // loading prescaler to timer milliSeconds++; if(milliSeconds > 99) //.1 sec = 100 msec {milliSeconds = 0; tenthsCounter++; if(tenthsCounter > 9) //For each 10 update seconds {tenthsCounter = 0; } } if ((tenthsCounter == 2) && (milliSeconds == 50)) { pulses = TL1; //take counter(Timer 1) pulses = pulses*4; if (P1_6==1) { pulses = pulses*60/100; } else { pulses = pulses*6.9;//changes for gear ratio } ADCON &= 0xF8; // Reset ADC Channel Select ADCON |= 0x00; // Select ADC = Ch0 ADCON |= 0x20; // Use Standard mode ADCON |= 0x08; // Start ADC Convert tmp = (ADCON & 0x10); // Get done bit while(tmp != 0x10) // Loop until complete tmp = (ADCON & 0x10); advalue = (ADDH << 2) + ADDL; ADCON &= 0xEF; // Clear ADEOC = 0 volts = (double) advalue/362; //needs configured for A to D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ if (P1_2==1) { temperature = 1; } else if(P1_3 == 1) { temperature = 2; }

else if(P1_4 == 1) { temperature = 3; } else { temperature = 4; } dataprint(); write_data(); milliSeconds = 0;//start timer 0 over tenthsCounter = 0; TL1 = 0; } } //AD initialization void a_to_d_init(void) { ADCF = 0x01; // P1.0 = ADC[0] ADCON = 0x20; // Enable ADC Function ADCLK = 0x00; // Prescaler to 0 } //print data to screen void dataprint(void) //unsigned short pulses, unsigned short advalue) { char words[20]; char wordstwo[20]; char wordsthree[20]; if (P1_6==1) { sprintf(words, "%02u x100 rpm ", pulses); DisplayText(1, 0, words);//write to screen } else { sprintf(words, "%02u MPH ", pulses); DisplayText(1, 0, words);//write to screen }

sprintf(wordstwo, "Fuel/Air ratio: %.3f", volts); DisplayText(2, 0, wordstwo);//write to screen switch(temperature) {case 1: sprintf(wordsthree, "Temp is low"); break; case 2: sprintf(wordsthree, "Temp is normal"); break; case 3: sprintf(wordsthree, "Engine is HOT!!"); break; default: sprintf(wordsthree, "Temp is not connected"); break; } DisplayText(3, 0, wordsthree);//write to screen } //Prints 7 segment display void sevensegment(unsigned char digit) { switch(digit) {case 0: P3_0 = 0; //a P1_5 = 0; //b P3_2 = 0; //c P3_3 = 0; //d P3_4 = 0; //e P4_0 = 0; //f P4_1 = 1; //g break; case 1: P3_0 = 1; //a P1_5 = 0; //b P3_2 = 0; //c P3_3 = 1; //d P3_4 = 1; //e P4_0 = 1; //f P4_1 = 1; //g break; case 2: P3_0 = 0; //a P1_5 = 0; //b P3_2 = 1; //c

P3_3 = 0; //d P3_4 = 0; //e P4_0 = 1; //f P4_1 = 0; //g break; case 3: P3_0 = 0; //a P1_5 = 0; //b P3_2 = 0; //c P3_3 = 0; //d P3_4 = 1; //e P4_0 = 1; //f P4_1 = 0; //g break; case 4: P3_0 = 1; //a P1_5 = 0; //b P3_2 = 0; //c P3_3 = 1; //d P3_4 = 1; //e P4_0 = 0; //f P4_1 = 0; //g break; case 5: P3_0 = 0; //a P1_5 = 1; //b P3_2 = 0; //c P3_3 = 0; //d P3_4 = 1; //e P4_0 = 0; //f P4_1 = 0; //g break; case 6: P3_0 = 0; //a P1_5 = 1; //b P3_2 = 0; //c P3_3 = 0; //d P3_4 = 0; //e P4_0 = 0; //f P4_1 = 0; //g break; case 7: P3_0 = 0; //a P1_5 = 0; //b P3_2 = 0; //c P3_3 = 1; //d

P3_4 = 1; //e P4_0 = 1; //f P4_1 = 1; //g break; case 8: P3_0 = 0; //a P1_5 = 0; //b P3_2 = 0; //c P3_3 = 0; //d P3_4 = 0; //e P4_0 = 0; //f P4_1 = 0; //g break; case 9: P3_0 = 0; //a P1_5 = 0; //b P3_2 = 0; //c P3_3 = 1; //d P3_4 = 1; //e P4_0 = 0; //f P4_1 = 0; //g break; } } //initalize serial communication with timer 2 void serial_init(void) { CKCON = 0x01; // x2 mode, T2 clock is same as crystal SCON = 0X40; // Mode 2, 8 bit uart transmit only, uses T2 RCLK=1; // Turn on receive clock in T2CON TCLK=1; // Turn on transmit clock in T2CON //Baud rate = fCrystal/(32*(65536 - (RCAP2H, RCAP2L)) for x1 mode //Baud rate = fCrystal/(16*(65536 - (RCAP2H, RCAP2L)) for x2 mode //1200 = 28.2076 x 10^6/(16(65,536 = (RCAP2H, RCAP2L)) // RCAP2H, RCAP2L = 64067 = FA43h //4800 = 28.2076 x 10^6/(16(65,536 = (RCAP2H, RCAP2L)) // RCAP2H, RCAP2L = 65169 = FE91h RCAP2H=0XFE; //4800 baud @ 28.2076 Mhz RCAP2L=0x91; // TR2=1; // TCON bit to start Timer 2 REN=0; // Transmit only RI = 0; // Clear the receive interrupt flag } //Write data to SD card

void write_data(void) { char msgg[30]; unsigned char i; unsigned char speed; unsigned char rpm; if (P1_6 == 1) { rpm = pulses; speed = 99; } else { rpm = 99; speed = pulses; } sprintf(msgg, "HI %06u %06u %.3f %06u $ \n", rpm, speed, volts, temperature); i=0; while(msgg[i] != 0) //Char string ends in 0 {TI = 0; SBUF = msgg[i]; i++; while (TI == 0); // Wait for write to be done } }