Regulating PWM Voltage

I have done research on this topic for a few hours now and can only find info on using a PWM to regulate voltage (which makes sense of course).

I believe my issue is a bit off the beaten path. I have a device (not designed by me) which has a PWM output which varies between 34V and 8V peak voltage. The frequency can also vary between 10Hz and 50Hz, although this isn't really an issue.

Now for my problem, I am trying to input this PWM into my arduino, but of course the pins can't accept a voltage this high. My first thought was to use a voltage regulator, but I believe this won't work because most regulators seem to use PWMS, so a PWM input into a PWM would be a mess.

For testing purposes I just used a voltage divider, terrible I know but it worked for proof on concept. I don't think this will work for long term because of course the voltage on the PWM can vary. I tested it under constant voltage conditions with my divider. I was hoping someone with more brains than myself can held shed some light onto this for me.

Thanks

It sounds odd that a device would output a PWM signal with a varying duty cycle and at the same time have a variable peak voltage.
Such a signal would be modulated in two ways with two independent signals. It is possible but odd.

So to measure the peak voltage you need a potential divider arranged such that the maximum voltage gives you 5V or less on the arduino. This will affect the resolution, if this is too much then you will need a higher resolution external A/D converter.

To get at the duty cycle information you could feed the signal into the base of a transistor ( through a resistor ) and have the emitter to ground and the collector to the arduino input pin, then enable the internal pull up resistor. Use the Pulse in function to measure the high and low periods of the signal.

Mike,
Thank you for the helpful response, I believe the transistor circuit should work. I agree, it is a very odd situation, but just for clarification I will explain a bit more.

The PWM peak actually doesn't vary through its signal, it varies depending on the input voltage to my device. Basically the output peak voltage of the PWM is supply voltage - 2V. Therefore it is possible I could see an 8-34V peak voltage since the device can take 10-36V supply.

Once again, thank you for the help.

Why not just regulate the supply voltage to the device, for example 10V? Then you can use two resistors (e.g. 10 K) to divide the output down to Arduino range.

jremington:
Why not just regulate the supply voltage to the device, for example 10V? Then you can use two resistors (e.g. 10 K) to divide the output down to Arduino range.

Because it turns out he doesn't want t measure that bit of the signal at all.

My approach allows pulse width measurements, too.

jremington:
My approach allows pulse width measurements, too.

So does mine:- :stuck_out_tongue: