I'm trying to figure out a way to extrapolate wheel speed from the Dynamo hub I just purchased. I outputs 6V 3W AC, and I would like to potentially measure it using an arduino if possible, I' assuming I would have to measure the sinewave somehow. Any ideas?
3 Answers
The dynamo usually outputs a simple full sine-wave, this means you can just measure the frequency by looking only at the positive peaks, by rectifying the power and then feeding the raw AC voltage with a sufficiently large resistor and a single diode to an I/O pin.
You may want to add an extra zener diode from the I/O pin to ground at 4.7V or 5.1V, to protect from transients. An extra capacitor on the I/O pin could help to catch some transient noise.
If Arduino still uses Atmels and they support the Analog Comparator, you could use an I/O pin that uses that to create even more noise immunity. Compare the signal with 1.1V reference and you'll get very little noise. As such:
EDIT1: Added a pull-down resistor to the schematics to make sure it fully turns off
simulate this circuit – Schematic created using CircuitLab
EDIT3: Added the capacitor I mentioned, but forgot to draw.
If they use an Atmel capable of Input Capture in their board design you can do the same with an external transistor on the input capture module to decode the signal frequency with maximum hardware support.
EDIT2:
Then, of course, finish the exercise with some exercises, to determine the number of pulses per wheel rotation.
While the accepted answer works just fine, if you're using an arduino it can actually be slightly simpler. Atmega chips have clamping diodes on the input pins, meaning that with the right current restrictions the voltage can be well out of range of what would otherwise be tolerated on the input pins. Essentially you would just run the input signal through a large resistance, as in the following diagram from AVR182:
Using this method, D1, R3, Z1, and C3 from Asmyldof's answer are no longer necessary, but a very small value for C3 may still be helpful for some noise filtering.
What you want is a zero-crossing detector. You will need to rectify the AC into DC, and the you basically set up a circuit where a transistor will turn on whenever it crosses zero.
There's more information in this article.