0

I'm using an L298N motor driver to control a DC motor. I'm using only a single input pin since I need only a single direction control. I'm using a PWM pin on my Particle Photon (uses Arduino libraries) to control the speed of said DC motor. I have a 12V motor so I supply 14V to the L298N (due to 2V drop by it to get 12V actual on the motor).

analogWrite(PWM_PIN, 0 - 255)

This line will set the speed motor. However, it's not smooth speed control.

Values:
0 - 70: Noise, no movement.
70 - 130: Slow movement not really usable for my case.
130 - 255: Seems to be max speed.

The speed does not increase as I would expect. Additionally the changes in speed are sudden instead of smooth.

Is there a way to make the speed changes smoother and reflective of the value, instead of just having what appears to be Nothing, Slow, Max.? Could this also be an issue with my motors? I'm using a generic DC motor.

I was thinking of maybe upgrading to something of more quality like a A2212 2200KV Brushless DC motor.

  • L298N maybe? They are not very good BTW. – Andy aka Jan 11 '21 at 14:43
  • 1
    You need a speed control loop (typically a PI controller, with feedback from a speed sensor built into the motor or attached to its shaft. A BLDC motor will be useless on its own : it needs a dedicated motor controller (which will usually have a speed control loop built in). –  Jan 11 '21 at 14:47
  • Brian has suggested a Proportional-Integral **feedback** control (good idea). Another approach samples motor current and boosts PWM for higher current - a **feedforward** method. This idea actively compensates for internal motor resistance. When done properly, slow motor speeds are far more stable. BTW: a unidirection motor PWM might be better done with a simple MOSfet + freewheeling diode. – glen_geek Jan 11 '21 at 14:59
  • also, don't let the unused input float. pull it high or low. – Pete W Jan 11 '21 at 14:59
  • @BrianDrummond I'm still bit new to all of this. I'm trying to figure out your suggestion. But if I understand you guy is if I get a BLDC motor I need to get one that comes with a controller which would solve the issue for me. What about if I continue with this generic DC motor and L298N. – Sterling Duchess Jan 11 '21 at 15:32
  • @Andyaka Yes L298N do you have a better alternative ? – Sterling Duchess Jan 11 '21 at 15:32
  • [Maybe](https://electronics.stackexchange.com/questions/108686/l293-l298-and-sn754410-h-bridge-drivers-on-low-voltage-power-supply) but it's a bit out of date on the recommended alternatives. You have written L289N in your question (2 places). – Andy aka Jan 11 '21 at 15:35
  • Yes you can implement a PI controller using this motor and L298 ... and some other stuff. –  Jan 11 '21 at 16:15
  • @BrianDrummond from what I understand here is I need to have a way of feedback to get the actual speed back ? So I would need another part like a IR sensor to count RPM or. Guessing in this case it would be better to go for a BLDC motor one of those that come with a controller included. – Sterling Duchess Jan 11 '21 at 18:05
  • @BrianDrummond Basically this: [A2212 2200KV with ESC](https://ebay.us/Uo2kgV9) – Sterling Duchess Jan 11 '21 at 18:07
  • What do you intend to use the motor for? – Bruce Abbott Jan 11 '21 at 19:20
  • @BruceAbbott I'm building table tennis robots. The two DC motors are used for firing the ball out of a tube. The contact with the ball is incredibly short so I need high RPM motors. The RPM range should be above 8000 RPM. To produce usable spin on the ball and speed I need a smoother speed control. In my case currently it seems I get nothing, slow, max speed. – Sterling Duchess Jan 11 '21 at 21:02
  • Your motor does 15000 rpm on 12V with no load. To get 8000 rpm you need at least 6.4V (more if you want any torque, but a flywheel might sort that). The Arduino normally produces PWM at 490Hz, which is a bit low for linear speed control (should be at least 3kHz) but that doesn't explain the 'sudden' speed changes you described. Therefore I suspect there is something wrong with your setup (noise, power supply problems?). What happens if you run the motor on a variable DC power supply? How are you measuring rpm? – Bruce Abbott Jan 12 '21 at 03:25
  • @BruceAbbott I use a Particle Photon board which has a larger frequency range:1 Hz and 65535 Hz (default 500 Hz) so 3kHz should be possible. – Sterling Duchess Jan 12 '21 at 19:39

0 Answers0