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);
}
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."
"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.
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.