Timer Calculations(Measuring the period of one revolution of the crank)

Phase 1

Count values proportion to RPM

At 1000 revolutions per minute. 1000 revolution in 60 seconds. One revolution in 60ms.

G1 and G2 are 360 degrees out of phase. G1 and g2 is 360 degrees.

 

A 16 bit counter can count up to 65536. To stop it from reaching zero before a g2 trigger is received we

ensure the maximum count is 50,000.

 

We are using a ne555 as a counter. The equation is t(period) = 0.693 (r1 +2r2)c

 

 

0.693 * 1 * 1000 *.01 /1000000 = 6.93 us.

with 60 ms or 60000us the counter will count to 8658.

at 8000rpm it will count to 1082

 

Remember frequency is the reciprocal of the period. Therefore revolutions per minute is the frequency * 60.

 

 

 

 

 

 

 

 

Ne signal comes from the 24 tooth wtihin the distributor. When the crankshaft turns 30 degrees the cam turns 180 gegrees.i.e 12 tooth or twevle pulses would have occured in that time frame. At 1000rpm the time between pulse will be 5ms . 60ms divided by 5. 5 ms or 5000us which is really a lot of time for a microcontroller. However as the engine speed increases the microcontroller becomes challenged. However in the first phase we will focus on the time between g1 and g2. At 8000rpm we have 7500 microseconds which is easy for the micro . On the board above 3 0.33uf capacitors are required plus a serial to paralles chip which extendeds the number of I/O ports the controller has.

At 1000rpm the time between g1 and g1 is 60ms or 60000us. This is enough time I believe for the microcontroller running basic. This will be tested by spining the distributor anti-clockwise with a drill Phase on will therefore attempt to measure RPm as this does not required a lot of speed. The most taxing job is the ne interrupts which occur ever 30 degrees. Should we run out of speed there is a pro controller which operates at 4 times the current processor. Failing that we would have to resort to assembly language

This is the starlet distributor showing g1 and g2 opposite each other. The Ne sensor is the one by itself in the middle.

 

 

 

The distributor hooked up to the monitor. A noisy pwoer supply was cuasing spurios interrupts. The on board serial to parralle register is function properly. It send all the correct instructions to the Counter and to the output ports t1,t2 ,t3 and t4. The current issue is that the current port states are not being saved when an intterupt occurs. This is mportant as this information allow us to determing which of the sensors cuased the interrupt. In addition the starlet wiring diagram for the distributor is wrong. The wire indicaed for g1, g2, and ne are all wrong. With careful analysis I was able to determine correct wires for respective sensors.

The only issue to resolve is the capturing of the pin state that cuase the interrupt. This is closely linked to the the lm1815 variable reluctance i.c A scope is required to look at the output of the lm1815 when the lug in the distributor passes the sensors..

 

 

 

The scope proved that the microcontroller is getting 5 volt pulses when the distributor is rotated. We would like the interrupt pules to finish before the interrupt service routine is completed . This is essential becuase the change of pin state on port b would cuase the controller to spuriously interrupt. I am of the opinion that by time the interrupt service routine is executed the 5volt pulse would have gone back to zero. Perhap because the program was executed in debug mode and is really slow. Will proceed to run the program out of debug mode and allow it to flash an led if an interrupt occurs and pin7 on the rbint port is high.

The scope also verified that the counters are getting a clock signal. One clock tick is 8us. So this figure will be used to claculate the period of one rotation...

The lenght of the pulse generated by the lm1815 is determne by the capaicitor and resistor connected to pin 14. The pulse = 0673RC .This works out to be 673us.

The scope has also allowed us to determine the the g1 and g2 sensor physical location on the distributor. When The connector is pointing to you the g1 sensor is on the lef and the g2 is onthe right. G1 is orange/blue, g2 is white and blue and Ne is green and Blue

The critical path of this project is now reading port b to get pin states.The current pin states need to be known so that there can be compared to the previous state. the bit which changed relative to the previous bit is the bit that caused the interrupt. An exclusive OR with the saved nibble twill reveal the bit . ...

 

Timing Calculations