We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi Folks! I'm working in a digital panel for rally cars, with some pressure, temperature, engine and car speed and other things. My problem is: I need to measure car speed with a sensor plugged into the gearbox (it gives me 4000 pulses on each kilometer). If I do a measure every 1 second I can get the car speed with some calculus. But how I can do a 1 second interrupt using timer 0 or 2 (I'm using C517 from infineon and timer 1 is measuring engine speed). My program is written in C. Any suggestion will be extremelly apreciated. Thanks !! Luis
If your microcontroller has timer 2,it's easy to solve this,for the timer 2 has extern timer pulse input.If don't,you have to use a counter and link it to your microcontroller.
Maybe you can measure time between pulses. At 200km/h you get about 222 pulses/second which should not be a heavy load for CPU.Use FF to divide pulse train from gearbox and connect output as a gate for timer 0 or 1 and use falling edge of that signal as interrupt for CPU (measurement done).Also use timer overflow int. for extending counter range at lower speeds.You can even combine this method with the previously suggested one - for high speeds use period measurement method and for lower speeds use frequency measurement method. regards Dejan
You are right. I can measure period instead of frequency. In a 16 bit counter is ok to measure down to 15 pulses/second that gives me about 15 km/h. Some of our cars originally can measure only from 20km/h. And for sure my car cannot run at 921600km/h that corresponds to a 1 machine cycle. I think it's more clear now to me and I can figure out a routine to do that. Thank you a lot for now!!!! Luis