I’m looking for a clever code which does following task (with Arduino Hardware!).
-
Reading of 2 independent pulses (hall sensor, proximity senser, MPU etc. (each between approx. 0 and 4000 pulses per minute (or 0-67Hz). Let’s call the frequency values C1 and C2.
-
Calculation of the frequency difference between C1 and C2. Assumption: C1 is always greater than C2.
-
Reading of pulses coming from an oscillator with a fixed frequency (1Mhz) – it is preferred to use the internal system clock. Instead of reading pulses, also an accuracy stopwatch function might be also applicable…
-
If C2 has reached a defined frequency (eg. 58Hz) and if the difference between C1 and C2 is lower than a defined value (eg. 2Hz), then:
The next input pulse of C1 will start a new counter. This counter will be stopped by an input pulse of C2. The counter itself shall count the number of pluses from the 1Mhz oscillator (or measure the accurate time delay between C1 and C2 pulse).
If the time difference between C1 start pulse and C2 stop pulse is high, then the counter value is high (and vice versa). The counter value (and some values calculated out of the counter) shall be output continuously (C1 pulse always starts the counter, C2 pulse always stops it).
Reason: The function shall determine the differential speed and the differential phase angle between two fast rotating motors.
I don’t know if this is possible with simple Arduino hardware, because I guess several interrupt routines and maybe multithreading is required for this task.
Any idea? Or better ideas?