Reading PWM pulses from a 12v source that can invert polarity?

Hey everyone.

So I'm trying to read a 12v PWM pulse from a L298N or similar PWM DC motor driver with an arduino nano. Currently I'm using a simple voltage divider to bring the voltage down to something the nano can read without frying and then using a pulseIn(2,HIGH) command and mapping it out however I need. This works fine.

The problem arises when the L298N reverses direction for the motor. I think this is because the entire voltage divider doesn't reverse with the L298N.

Any suggestions?

Use a bridge rectifier.

Perfect! I think that’s exactly what I need. I’ll try it out.

That should get me the PWM values regardless of polarity. What's a good way to detect which way the voltage is?

Don't think a rectifier will help. The issue seems that you are expecting one terminal of the motor
to always PWM? I also presume you have common ground and a single supply, so no negative
voltages are expected anyway.

Typically for each direction a different terminal is PWM'd, and the other is held at constant voltage.
So you'll need two dividers and two input pins to be able to read that.

Why are you not sensing the inputs to the H-bridge?

MarkT:
Don't think a rectifier will help. The issue seems that you are expecting one terminal of the motor
to always PWM? I also presume you have common ground and a single supply, so no negative
voltages are expected anyway.

Typically for each direction a different terminal is PWM'd, and the other is held at constant voltage.
So you'll need two dividers and two input pins to be able to read that.

Why are you not sensing the inputs to the H-bridge?

Thanks for the comment.
Sensing the inputs of the H-bridge is not going to be possible for this project as much I'd LOVE to be able to. I need the output of the L298N to power both a DC motor at times and other times be read by an arduino by only the output of the L298N. Last ditch effort I can go wireless with the L298N input but it would not be optimal at all.
10-4 on the no negative voltages. I understand.
For 2 dividers to individual pins, what's a good method to ground them as I think I've fried a board trying it my way which is just adding another reversed divider from the initial one and connecting the ground and pin wires.