You are on page 1of 17

ALGORITHM DESIGN, EXECUTION TIME CALCULATIONS & CODE DEVELOPMENT FOR 2013 ASU RACING-FORMULA STUDENT ECU CODE

AHMED EL-ERAKY

AHMED ABD ELHADY

1) Start. 2) Enable global interrupt [sei ()].

3) Registers settings.
4) LCD Standard Code (Disabled because it caused problems during code running).

5) Analog to Digital Converter initialization.

6) Start timer0 (timer0: tooth timer).

7) Start timer1 (timer1: injection timer).


8) Start timer2 (timer2: ignition timer). 9) Input Time_ign_end, ve (ve: volumetric efficiency), angle_ign.

Those values should be taken from the look up tables

LOOKUP TABLES
X-axis is Throttle position percentage. Y-axis is RPM. We can get ve and ignition angle from these tables (ve: volumetric
efficiency).

LOOKUP TABLES

ENGINE MAPS
Engine maps is the graphical figure of the lookup tables. Those are 3D graphs, thats why we will need to use 3D interpolation.

10) While (1)


11) if the interrupt get the edge put 1 in "bit_is_state" if not put 0.

12) Analog to Digital Converting reading

Note: in Atmega 32 we have 8 pins for analog to digital converting but we


have one register so we should take one reading from one sensor, convert it then saving it in memory and overwrite the next reading in the register.

13) For the first 3 teeth on the crank gear we take reading 0, because if the cut_teeth is one of the first 3 teeth we will not be able to calculate two periodic times & compare between them.
We take the reading from the sensor at the Top Land of the tooth and convert the signal in the Bottom Land of the tooth then save the converted signal in memory at the next Top Land.

14) Calculating time on injector. 15) Converting the time to ticks according to the microcontrollers crystal.

16) Time of ignition.


17) Determining the angle of ignition coils.

18) Stopping ignition

19) timer0 overflow that means that we finished a full round on the gear 20) For finding the cut-tooth we calculate the time between every two teeth, then calculate the difference 21) Compare between the new difference & the old difference if larger, then the last tooth is the cut-tooth. 22) We take the cut-tooth as a reference. 23) Clear all the values. 23) Repeat.

EXECUTION TIME CALCULATION


First we work on engine cycle with 14000 rpm
then we need our code to execute in maximum 4.28 millisecond. calculating the time of the old code to execute: 1 - the processor operate on 16 MHZ clock; so single cycle will take 0.0625 micro second; 2 - the code consists of main () ,adc_select(),adc_init(),adc_start(); 3 - adc_init = 4instructions; adc_start = 2instructions; adc_select = 50 instructions; main = 450 instructions ,,2 intructions to call (adc_start),2 intructions to call (adc_select)

4 - from datasheet there is instructions takes 1 cycle to execute ,others take 2 cycles and others takes 3. 5 - we take average cycles = 2

6 - approximate time of execution = (2*((2*(50+4+2))+450))*0.0625 = 70.25 microsecond.

conclusion : this code works only for one cylinder and two sensors only then we should optimize it
to make it efficient when extend it to execute within the engine cycle.

DEVELOPMENT NEEDED FOR THIS CODE


This code was designed based on the crank shaft gear 12 tooth with cut teeth
we will work on the cam shaft gear 3 teeth with 2 cut teeth.

As we analyze this code we realized that there is some blocks that will need
to restructure them again with different methodology for more efficient performance.

We noticed that they work on only two sensors we will need to add the
inputs of the rest sensors.

We noticed that they designed the array of the lookup tables and taste it with
fake numbers we will edit the array & add the whole real lookup tables.

This code is working for only one cylinder, as our engine HONDA CBR 600
RR is 4 cylinders engine . We will need to shift the code 4 times to suit the all engine.

We will develop GUI (Graphical User Interface) for controlling our ECU with
human friendly interface for easy tuning.

We advice using the same algorithm design with better code structure.

You might also like