Counting pulses from hand-cranked dynamo

I want to use Uno to count and decode a sequence of +/- 50v pulses from a hand-cranked dynamo (part of an old machine for transmitting messages). What kind of circuit do I need to convert these pulses to 5v and input them to Arduino? I think ac/dc converters need a steady-state input and won't do the job for a sequence of between 1 and 40 pulses. The image shows a sequence of 5 pulses if one sets a threshold of +/- 50v. The oscilloscope won't show more than 80v vertically, but by cranking the dynamo faster or slower I can adjust the peak volts.

Are you trying to keep the wave form of just the number of pulses. You can use voltage dividers to bring voltage down. You can also use your pulses to switch a different voltage using a transistor.

Thanks for quick reply. No I don't want to keep the waveform, just want to see some nice positive 5v pulses. Would I have to reduce voltage to switch a transistor, if so can I reduce it to a fixed maximum instead of dividing it? Ideally I would like some off-the-shelf module that would do it all!

You can use a high value series resistor like 1M and clamp the input to Vcc and Gnd with Schottky diodes.

Or an optocoupler appropriately rated

I'd suggest a bridge rectifier to turn your +/- pulses into + pulses, followed by an optocoupler with the input current-limited through a resistor. One concern is that if the input voltage is variable, then the resistance needs to account for both the upper and lower limits of the voltage -- you need enough to turn on the optocoupler (at the low voltage limit) but not so much that you exceed its current rating at the high voltage limit.

But it's a simple and safe circuit to implement.

1 Like

Thanks Cedar Lake, I'm a beginner & that's language I can understand. I never used either bridge rectifier or optocoupler before before & am mystified by the specs. Could you maybe suggest some part numbers?

I specifically excluded a bridge rectifier from my suggestion, because I thought unipolar pulses would be more well defined as they are closer to 50% duty cycle. The advantage of using a high impedance input such as the Arduino raw input, is that the input level clamping is much easier to perform. With an opto, the clamping (voltage regulation) circuit now has to carry whatever excess current is required to obtain signal headroom.

The OP hasn't addressed the issue of input magnitude range. If it is full wave rectified, brute force (fixed level) clamping will demand a minimum signal threshold, which if set low, will cause the duty cycle to increase with input level, something to be careful about if there is noise in the circuit. In fact, some analog low pass filtering might be a good plan.

The OP has implied (by the count of 5 compared with the diagram) full wave detection. But not the purpose of the circuit, so we don't know if it's necessary or incidental.

Lately, there have been a few threads where the OP was "let off the hook" about providing details, and they were badly derailed. So I would like to see some real information about this project... what dynamo, what it was used in, what the circuit output is for, and so forth...

All that should be forthcoming before any part numbers get handed out!

It was stated that the threshold was 50V but that was a scope setting. So we still don't know the actual dynamo output voltage range. Or, the output current. Or, whether other equipment will have to work in tandem with the circuit.

Apologies for not providing more details, I did not want to bore people with my hobby. Apologies also for trying to mooch part numbers. The dynamo is in the ABC Telegraph Communicator perfected by Prof Wheatstone (he of the bridge) in 1858 and in use by GPO at least until 1930s. Connects by telegraph circuit to receiver (which I don't have), where a pointer turns to the character encoded by the dynamo pulses. I have restored the transmitter and want to demonstrate it by displaying the message on the Arduino serial monitor. I chose threshold 50v because it is quite easy to turn the crank at that speed and produce a clean waveform. Each + or - pulse moves the pointer on the receiver to next character, so full wave needed. I have ordered opto (pc817, there is a YouTube tutorial) and bridge rectifier (which should be the easy bit) to play with. Fingers crossed I don't destroy too many Arduino chips.

We're more than happy to offer part numbers - we just want them to be the right ones.

Looking at your scope photo, it appears to me that the threshold setting is more critical than you have imagined. How many pulses are represented there? :slight_smile: How did you arrive at the number 5? I see 6.

Voltage divider (2 resistors), small capacitor, rectifier diode, and 5V zenner diode to protect from overvoltage.

I realize you are trying to be helpful, but you are wrong. Zener diodes make terrible input protectors. Also you really need to explain what the rectifier diode is for. A single diode would miss half the pulses. Better post a diagram...

Something like this AC-opto could work.

Very good current transfer ratio at low If, 4-pin through-hole available (in stock) at Digi-Key.

I like that: reduces part count. I always forget that those bidirectional optos exist!

@anon57585045 Draw the line at 50v and the first positive spike doesn't make the cut, so count would be 5. But you are right: how to implement a threshold of 50v is not clear. A preliminary single little spike always appears, + or - as the case may be. If the circuit lets it through the answer could be just to subtract 1 from the number of pulses when decoding.

@dlloyd Awesome, thanks. And thanks to Arduino forum for enabling this debate. I'll post a video link if I get this rare antique working.

I'm having problems measuring the digital signal with the Arduino and I hope someone can help.
The miracle chip 140814240110 does its job. I used the circuit drawn by @dlloyd with the pullup resistor in pin 3 of the Arduino instead of the 10k on pin 4 of the chip. I also replaced the 10k resistor on pin 1 by a 10k/91k voltage divider to bring the input down to about 8v peak. The original 80v pulses didn't bother the chip - it just refused to take any notice of them!
The output from the chip when the pointer on the machine moves on two letters is shown below. The first ragged pulse is something that appears in the dynamo output however many letters it moves. The other two pulses are as expected for a 2 letter rotation.
I have tried conditioning this signal in software because hardware is not my thing. I have tried all kinds of interrupts - change, low, rising, falling, but got no sensible results.
My idea was that this 150 y old machine doesn't need any great precision and I could ignore the first interrupt and others for 20ms after it and then count how many low interrupts and the time between first and last. From this the software could guess how much the pointer has moved.
One isolated interrupt seems to appear as the sketch starts. If I ignore this, the interrupts seem to continue even after I have stopped cranking.
Any ideas on how to deal with this signal in software, please?


Come on. If a 150 year old machine can decode it, 21st century technology can, also.

Your real problem, you skipped over the initial deep dive reverse engineering of how the system really works. I'm sorry, I don't wish to be judgmental or unfriendly, but that is what I see, and that is how I am calling it.

Thus you accepted an input method that is probably destroying badly needed information from the input signal. I warned you about this back in reply #10.

Now we're tossing around theories about how the interrupts are behaving. When you get to that stage, you've mostly passed the chance to apply holistic, deterministic, functional, mathematically defined processing to the signal.

Forget about the entire solution that you now have, and try to characterize the input signal better. I don't know if you have a receiver or plans for it, but it might give strong clues about how to decode, since as I pointed out, it wasn't a real challenge for them in the horse and buggy age.

Do you have the auxiliary readout that shows the character transmitted or is that missing also?

Unfortunately, I now realize the OP already stated that no receiver was available to study. One interesting aspect, if you look at the scope trace in the first post, there is a voltage step at the beginning. So it is likely that there are commutation contacts in the machine that connect and disconnect the dynamo output before and after a transmission sequence. That could be important.

The transmitter had a separate readout that showed the character that was actually encoded. I don’t know if it doubled as the receiver or not. Maybe it did.