motor output not as expected using PWM

Hi all,

For a project I want to build a controlable motor, which I have achieved with a fairly basic setup. My setup is based on this guide: DC Motors with L298N Dual H-Bridge and Arduino | DroneBot Workshop.

the used components:

code:

int enA = 9;
int in1 = 8;
int in2 = 7;

int SpeedControl1 = A0;  
int MotorSpeed1 = 0;

void setup()
{
  pinMode(enA, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
}
void loop() { 
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW); 
  MotorSpeed1 = analogRead(SpeedControl1);  
  MotorSpeed1 = map(MotorSpeed1, 0, 1023, 0, 255);   
  if (MotorSpeed1 < 8)MotorSpeed1 = 0;    
  analogWrite(enA, MotorSpeed1); 
}

The problem is this:
Initially I tried to run my mechanics by applying the current directly from my adapter to the motor. This worked fine, and the machine was working properly. Even on with 3 volts it was running fine, and the RPM increased by increasing the voltage on the adapter. So i was confident the motor was up to the job.

Then I tried the same thing, but with the previously mentioned PWM setup. The motor now only kicks in when I fully ‘open-up’ the potentiometer. It only achieves an RPM equivalent to about the 6volts directly from the adapter, not higher-nor lower.

Any suggestions? I was looking into maybe using other motor shields, and upgrading the adapter.
Is this just an inherent limitation to the use of PWM, so maybe there is another more suitable aproach?

Frozenking:
Initially I tried to run my mechanics by applying the current directly from my adapter to the motor. This worked fine, and the machine was working properly. Even on with 3 volts it was running fine, and the RPM increased by increasing the voltage on the adapter. So i was confident the motor was up to the job

Please explain this more clearly - a diagram would be a good idea - so that I can understand how it differs from the other arrangement.

...R

Please explain this more clearly - a diagram would be a good idea - so that I can understand how it differs from the other arrangement.

What I meant is that I simply put the + and - of the powersource (adapter) directly on the motor, compared to the diagram described in the dronebotworkshop website (which entails putting those wires in the L298N)

I suspect it’s less to do with PWM and more that you’re falling over the fact that the ancient L298N cannot supply much current and tends to drop 2-2.5V of any available voltage.

But it might make sense to include a Serial.print() to show you exactly what values you are writing to enA.

Steve

the ancient L298N cannot supply much current and tends to drop 2-2.5V of any available voltage.

do you have a suggestion for a replacement?

But it might make sense to include a Serial.print() to show you exactly what values you are writing to enA.

i'll give it a shot

The Pololu website has a good selection of motor drivers. Similar products are available elsewhere.

...R

There is a MINIMUM PWM that will start the motor, but once started you can turn the PWM down gradually until the motor stalls, I won’t tell you to set the adapter to 12V until I see a wiring diagram.

until I see a wiring diagram.

2019-01-31_091652.jpg

slipstick:
the ancient L298N … tends to drop 2-2.5V of any available voltage.

Closer to 5V, in fact, at any appreciable current:

298 volt drop.GIF

Closer to 5V, in fact, at any appreciable current:

Ok, so it makes sense now. I'll try to find another motor driver.
I see that there are a lot of options, any suggestions?

Frozenking:
I see that there are a lot of options, any suggestions?

Try and match voltage and current from this list at Pololu, for instance.

Hi all, thank you for the advice.

I've updated the setup with a new driver, the Dual MAX14870 Motor Driver Shield (Pololu - Dual MAX14870 Motor Driver Shield for Arduino).

It should be able to put more power into the engine, but I do not notice a difference between this driver and the L298N. It is still not able to turn the engine, while a direct hook-up to the adapter works at ranges from 3 to 12v.

I assume it is not possible/reliable to measure the voltage that gets to the engine since it is power by PWM?

I will take a picture of the setup and wiring when I get home so you get a better picture of the issue.

Thanks!

If you have a Digital Multi Meter measure the voltage at the motor driver output pins or directly on the motor terminals. Hope you considered the motor’s stall current when selecting a driver and power supply.