PWM goes from 0V to only 4V

Hi,

I have an application that reads PWM output and does something with it. When I measure the voltage with multi-meter on PWM, I see that voltage goes from 0V to only 4V. Why is this happening?

Here is the code:

int val = Serial.read(); // read from serial

if (val < 10) // if forward
{
val = map(val, 10, 0, defaultHaltValue, 255); // the output voltage is 4V !?!?!?!?
analogWrite(leftPin, val);
}
else if (val > 10) // if reverse
{
val = map(val, 10, 20, defaultHaltValue, 0); // the output voltage is 0
analogWrite(leftPin, val);
}
else // if halt
{
analogWrite(leftPin, defaultHaltValue);
}

please help.

I see that voltage goes from 0V to only 4V. Why is this happening?

It depends on what current you are drawing from the pin, do you know what it is?

The data sheet says that at 20mA a 5V powered processor may give out 4.2V, any more current and it will be lower.

My Arduino is powered by Sabertooth 2x25 motor driver. This motor driver is then powered by a 18V battery. The motor driver datasheet says: "The 5v terminal on Sabertooth is capable of supplying 100 milliamps if the source battery is 12.6v or less. If the source battery is greater than 12.6 volts, the 5v terminal is capable of supplying 10 milliamps."

Is this causing my problem?

"The 5v terminal on Sabertooth is capable of supplying 100 milliamps if the source battery is 12.6v or less. If the source battery is greater than 12.6 volts, the 5v terminal is capable of supplying 10 milliamps."

Are you sure that is the right way round? It supplies more current with a lower voltage!

The simple thing is to measure what voltage is on the +5V pin of the arduino. If it is less that +5V then you can expect the logic output of a pin to be even lower. For example according to the data sheet powering the arduino with 3V and the output pin taking 10mA you can expect the output voltage to drop to 2.3V.

Typically an arduino needs about 30mA to function plus what ever current you are drawing from (or sinking to) the output pins.

You were right, the +5V pin on Arduino really shows 4V!!!!

But I don't understand why is this happening if the input to Arduino is 5V???

But you are not giving it 5V you are only giving it 4V. This is probably because it is drawing too much current from your power supply pin.

I'm sorry, I wasn't clear in previous post. I'm giving to Arduino 5V, I measured. The output from Arduino (+5V pin) is then 4V. Where is that 1V lost?

I'm giving to Arduino 5V,

Where are you giving it this? Not on the Vin or the power jack because it is too low you need a minimum of about 7.5V.

If you want to give it +5v then connect your supply to the +5V pin.

5V terminal on the Sabertooth is connected to Vin pin on Arduino. So you suggest that I connect the 5V terminal to 5V pin on Arduino?

Yes Vin is the wrong place to connect a 5V supply.

I would assume, based on the Sabertooth's statements on input voltage vs output voltage, that it uses a linear voltage regulator to get the 5v out. Just as with the Arduino's Vin, high input voltages negatively affect output current, as the higher voltage drop across the regulator increases the heat generated for a giving output current.

The sharp cutoff of output spec at above 12.6v seems a bit incongruous, but that just may indicate additional components are involved in the circuit. Regardless, the Arduino is going to draw more than 10mA of current, which with an 18v source battery, will be above the specs of the motordriver per DEs own documentation.

I connected the 5V terminal to 5V pin on Arduino and now works perfectly!

Thank you :slight_smile:

Ok but check the regulator on your supply for excessive heat like jraskell suggested.

Another possibility would be to connect the power in jack on the arduino to the 18V battery directly.