How to send fully cycle pulse on lower volts with Arduino?

498 views Asked by At

I am currently using analog pin 3 on my Arduino Uno to send out voltage from 0 to 5V. I am using that voltage to control the motor and currently I am using the function:

analogWrite(pin, PWM_PULSE);

I am using 255 pwm for 5V and 127 for 2.5V. The problem is that PWM is sending full cycle at 255pwm(5V), but on 127V the cycle is at 50% which causes my motor to twitch a little bit.

How can I solve this? I am searching for a way to send full PWM cycle even at lower volts. Is it possible?

1

There are 1 answers

0
mpflaga On

First I believe you mean D3 not A3, since PWM does not exist on A3. Assuming you are driving a DC motor, and not something like a servo or stepper

You have two problems.

1st. you may need a smoothing capacitor. Where your formula would be F=L*C Noting that analogWrite uses a F=490Hz. The concept is simple, in short the cap average out the high and lows of the PWM, based on the duty cycle. And the capacitance needed is based on the frequency and impedance. This will provide the analog voltage.

2nd. And bigger problem is the output of the Arduino can not supply sufficient current to drive the motor correctly. It will max out at about 20ma, and the motor likely needs more. So at low speeds the pulses which were week, stall out during their low periods.

You should have your PWM output drive a transistor, which in turn will ON-OFF the motor directly from the power supply. Now your motor may have enough inertia as not to need the cap.

see adafruit-arduino-lesson-13-dc-motors/breadboard-layout

enter image description here

and here for a discussion about the smoothing cap