Answer the question
In order to leave comments, you need to log in
How to calculate engine rpm without interruption?
Using interrupts slows down the code a lot. during the passage of the hall sensor by the magnet, the interruption loops, the same thing happens when the magnet stops in front of the sensor. Is it even possible to roughly calculate the revolutions without interruption?
Answer the question
In order to leave comments, you need to log in
Maybe then it is not necessary to calculate programmatically?
Zayuzat, for example, mikruhu from a real-time clock (for example, DS1372), where instead of quartz, use pulses from the Hall sensor.
Or take an analog Hall sensor and a circular magnet, then you can read the rotation speed with an analog input, and then translate it into the number of revolutions.
1) If the use of interrupts "slows down the code", then you stuffed too much into the interrupt handler, perhaps something that just doesn't belong there. In your case, there should be one single operator for increasing some variable by one.
2) What does "interrupt loops" mean? Unclear.
3) If an interrupt is constantly called when the magnet stops in front of the sensor, then you may have configured the interrupt to be level, not change.
4) Would you give some characteristics of the motor. To assess what kind of speed the controller cannot handle.
If you have interruptions when the engine is stopped, then you need to either review the code or use an oscilloscope to go to the sensor output and see what it outputs in such a situation. If pulses come from it when the engine is stopped, either the sensor is faulty or you catch pickups, which may be the case if the sensor is not turned on correctly, for example.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question