# Need help making sense of PWM circuit with an Arduino. I do not understand the voltages I measure

As you may have guessed from the title, I am a beginner in electronics so please forgive any absurdity that might follow.

I am playing around with powerful COB LEDs and how to drive them. To that end I have built a battery-powered power-limiting circuit using a 16V battery, a step-down converter, an Arduino to generate a PWM signal, and something that Amazon translates as a trigger switch drive to switch the load.

The Arduino is powered via the buck converter (set to output a bit above 5V) and generates a PWM signal at around 32kHz, the duty cycle of which is determined by a potentiometer's position.

That PWM signal is then fed to the switch drive, which switches the current coming directly from the battery. I know using an Arduino for this is overkill but I have other features in mind that I will add later.

I have made a schematic, not using the recommended stack-exchange tool sorry about that I didn't know about it.

This contraption of mine works quite well to control the intensity of the LED and prevent it from burning (the battery is a beefy LIPO so it's definitely needed.)

Adjusting the potentiometer to control the LED feels a bit random even though I have set a safe maximum value for the duty cycle of the PWM output, and I would like the duty cycle to automatically increase when the voltage of the battery drops.

In order to do that I want the Arduino to monitor the power consumption of the LED. For this, I have built a shunt resistor using sixteen 1 ohm resistors in parallel and I'm measuring the voltages with the Arduino across the shunt resistor.

I want the LED to operate between 0.2A and 2A so if I'm not mistaken I should measure voltages across the shunt between 0.2 / 16 = 0.0125 V = 12.5 mV and 2 / 16 = 0.125 V = 125 mV. Around 12.5 mV I'm not expecting the measurement to be very precise since the Arduino has a resolution of around 5mV but for higher intensities I figured it would be enough for my purposes, but the circuit is not behaving at all the way I expected it to.

The things I do not understand are:

• The voltage I measure across the shunt resistor (between points A and B in my schema) is systematically negative, but it looks more or less correct at high enough intensities when I compare it with the value I obtain from my voltmeter
• I measure a positive voltage difference between the negative side of the LED, i.e. the terminal labeled "V_OUT-" of the switch drive, and ground. This happens both with the Arduino and with my voltmeter. I was expecting this voltage to be zero. This voltage diminishes when the duty cycle increases.
• The voltage on the "V_OUT+" terminal on the other hand is constant at 16V.
• The potential difference between "V_OUT+" and "V_OUT-" is 6V at 0 duty-cycle and increases with the duty cycle. Why isn't it zero when the duty cycle is zero?

So, in summary, I think I do not understand what this switching component does exactly and I'd appreciate some pointers to help me figure it out. And about my negative voltage across the shunt resistor, do you think it is just a precision issue or is something obviously wrong in my circuit?

• Welcome! Please draw a schematic of what you are proposing. Click edit and click on the schematic symbol. Nov 19, 2021 at 21:58
• Thank you! I did draw a schematic and I have included the link in my post, unfortunately I did not know there was an integrated tool for that.
– djfm
Nov 19, 2021 at 22:03
• Your schematic does not show the 16 X 1ohm resistors used as a current shunt. Nov 19, 2021 at 22:05
• Please embed it as an image in your post if you already have a schematic. Nov 19, 2021 at 22:12
• This circuit either shouldn't work or burn the Arduino. Nov 19, 2021 at 22:14