12
ALGORITHM DESIGN, EXECUTION TIME CALCULATIONS & CODE DEVELOPMENT FOR 2013 ASU RACING-FORMULA STUDENT ECU CODE AHMED EL-ERAKY AHMED ABD ELHADY

Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

Embed Size (px)

Citation preview

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 1/17

ALGORITHM DESIGN, EXECUTION TIME CALCULATIONS & CODE

FOR 2013 “ASU RACING-FORMULA STUDENT” ECU CODE

AHMED

AHMED

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 2/17

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.

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 3/17

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

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 4/17

LOOKUP TABLES

• X-axis is Throttle position percentage.

•Y-axis is RPM.

• We can get “ve” and “ignition angle” from these tables (ve: volumetr

efficiency).

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 5/17

LOOKUP TABLES

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 6/17

ENGINE MAPS

• Engine maps is the graphical figure of the lookup tables.

•Those are 3D graphs, that’s why we will need to use 3D interpolation

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 7/17

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

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 8/17

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

have one register so we should take one reading from one sensor, co

then saving it in memory and overwrite the next reading in the regist

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 9/17

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 periodictimes & 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 inmemory at the next “Top Land”.

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 10/17

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 11/17

14) Calculating time on injector.

15) Converting the time to “ticks”

according to the microcontroller’s

crystal.

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 12/17

16) Time of ignition.

17) Determining the angle of ignition

coils.

18) Stopping ignition

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 13/17

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.

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 14/17

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 (a

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 15/17

4 - from datasheet there is instructions takes 1 cycle to execute ,others take 2 cy

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 sh

optimize it

to make it efficient when extend it to execute within the engine cycle.

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 16/17

DEVELOPMENT NEEDED FOR THIS CODE

• This code was designed based on the crank shaft gear 12 tooth with

… 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 w

to restructure them again with different methodology for more efficie

performance.

• We noticed that they work on only two sensors … we will need to ad

inputs of the rest sensors.

• We noticed that they designed the array of the lookup tables and ta

fake numbers … we will edit the array & add the whole real lookup

7/22/2019 Algorithm Design, Execution Time Calculations & Code Development for 2013 _asu Racing-Formula Student_ Ecu Code

http://slidepdf.com/reader/full/algorithm-design-execution-time-calculations-code-development-for-2013-asu 17/17

• This code is working for only one cylinder, as our engine “HONDA CB

RR” is 4 cylinders engine …. We will need to shift the code 4 times to

all engine.

• We will develop GUI (Graphical User Interface) for controlling our E

human friendly interface for easy tuning.

• We advice using the same algorithm design with better code structur