Little help for icp pin and prescaler

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use a capture module to measure both RPM and duty cycle.

Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

Imagecraft compiler user