Well I begin a new project about car ,here is the link for the idea https://www.avrfreaks.net/index.p....
So the first step is to read something simple like rpm.
I have read here some examples , in c code. and if I understand well if we have 4cyl engine for 6000rpm is about 200hz from cranksaft sensor.
because the cpu have many things to do it is impossible to wait for measure how many pulses i read /second.
My first thought is to use a second avr to measure the rpm and send the data to the main cpu with uart when is need it for the display.
My second thought is to use the icp pin but i dont know how and with what prescaler in order to read very quick the rpm about 1ms or lower.
Also I have in my mind to use icp pin to measure the injector duty.And this make it more complicated to me.
So what do you beleive that is the best way to go?
I will use mega168 at 16mhz maybe and 20mhz.
Also I use assembly so the code who I found in my search didnt help me a lot.
Little help for icp pin and prescaler
Author
Message
Use a capture module to measure both RPM and duty cycle.
I can never be sure that the fastest or slowest time between pulses will fall within the selected prescaler. So what I do is use a pinchange interrupt and read a 16 bit timer with an overflow accumulator into a long. Do this on two consecutive edges and calc the diff. This gives a nice long period (can handle real slow rpm) and excellent resolution.