In order to monitor engine speed changes in real time, sensor is detecting the motion of few magnets around a disk driven by the motor. 1st approach Hall effect sensor signal is regulated by LM393 comparative IC, resulting digital clean signal, connected as input to a selected pin then measuring the timing changes between of the signals to calculate the speed changes. 2nd approach is to connect hall sensor directly without modeling to a micro controller ADC, then process the digital noisy unclean signal which require much processing power than 1st approach. Better approach are welcome, but the question is how to choose proper controller specs for such task
1 Answers
The first option is way better than the second. Measuring a voltage with the ADC takes time and you don't really need the analog values in your code. (Though depending on the actual values you might not need a comparator befor it. The digital input pin acts as Schmitt Trigger. The only requirement for this is, that the signal range is greater than 0.3*Vcc to 0.7*Vcc.)
About the needed controller: That greatly depends on the speed, that the motor is running at (e.g. the frequency of pulses), and the way you are measuring it.
The easiest Arduino way is to attach an interrupt to the pin and increment a counter variable in it. Reading and resetting the variable in regular time ranges (using
millis()will give you the pulse frequency and thus the speed. For this you don't need much extra functionality in the microcontroller. One with external interrupts or pin change interrupts is sufficient (almost all microcontrollers have those).Another way is to utilize a hardware timer as counter. You can configure a timer of a microcontroller to get it's clock source from a pin. If you connect your sensor output to it, the counter will increment on every edge (falling and rising). The first timer of an Arduino is used by the Arduino core as time-keeper. You can use it to get the time component. Configure the second timer as counter, set it's value to zero, then start the timer and track the time passed using
millis(). When the measurement time has passed, you read the counter value, reset it to zero and start a new measurement. While the hardware timer counts the pulses, you can calculate the speed with the number of pulses and the time passed and do whatever you want with it. This approach of course needs at least 2 timers (which most microcontrollers have, I think).
Of course the general speed of the microcontroller, meaning it's clock frequency, is also a concern. But this only becomes relevant, as you reach high pulse frequencies.
This answer is a general overview on how to go on. For a more specific answer, you should edit your question to also be more specific. For example you could include the expected pulse frequency.
- 16,622
- 2
- 18
- 27