DC motor controling with L298

Audioguru

Joined Dec 20, 2007
11,248
Look at the total voltage drop of an L298 at 1A: 3.2V max. Then if the supply is 5.0V (it might be 4.8V) the motor gets only 1.8V (or only 1.6V).
 

Thread Starter

aGpLT

Joined Jan 21, 2010
128
Look at the total voltage drop of an L298 at 1A: 3.2V max. Then if the supply is 5.0V (it might be 4.8V) the motor gets only 1.8V (or only 1.6V).
So i need to supply 6-7V to L298 or to get external power supply for motors 12V and use PWM. or i could use voltage regulator to get 6-7V. :)
 

zola1

Joined May 21, 2012
4
Hi,

Just read your post,i too have issues with the power supply voltage (and associated voltdrop) on the L298N. !
Did you ever overcome it ?...can you help ? i tried your link to your project but it did not work ?..i am try to power a dvd drive motor via Arduino Uno and i have built this driver http://www.rkonlinestore.co.uk/rkl298-l298-h-bridge-motor-drive-project-pcb-self-build-kit-589-p.asp

The code is this



//VKWAREHOUSE - Speed control using L298n Dual H-Bridge IC and arduino

int motor1Front = 5;// defines motor1Front as connected to pin 5
int motor1Back = 6;// defines motor1Back as connected to pin 6
int motor2Front = 7;// defines motor2Front as connected to pin 7
int motor2Back = 8;// defines motor2Back as connected to pin 8

void setup ()
{
pinMode (motor1Front, OUTPUT);// initialises motor1Front as output
pinMode (motor1Back, OUTPUT);// initialises motor1Front as output
pinMode (motor2Front, OUTPUT);// initialises motor1Front as output
pinMode (motor2Back, OUTPUT);// initialises motor1Front as output
}

void loop ()
{
for (int i=0; i<=255; i++) //accelerate motor from 0 to 255
{
analogWrite (motor1Front, i);
delay (10);
}
delay (1000); //Pause at top speed

for (int i=255; i<=0; i++) // Decrease speed from 255 to 0
{
analogWrite (motor1Front, i);
delay (10);
}
delay (1000); //Pause at Zero
}

Any thoughts as the dvd does not reverse .. i have scope trace i could send you ?

regards

Derrick
 

Audioguru

Joined Dec 20, 2007
11,248
i too have issues with the power supply voltage (and associated voltdrop) on the L298N. !
Did you ever overcome it?
You forgot to say the max current of your motor so a simple voltage loss calculation cannot be made. If it is 2A then the datasheet for the L298 says that its max saturation voltage loss can be 5V. Some will have a little less voltage loss.
 

zola1

Joined May 21, 2012
4
Hi ,

Thank you for responding, regarding the current draw of the motor .

The motor is only small on it is used in the dvd drive assy, when i put a ammeter in the motor supply wire .Press the carriage open/close button i get the :-

1). Close dvd carriage result = 5v @ 1.1A
2). Open dvd carriage result = 5v @ 1.2A

Whilst the output of the H- Bridge Motor ouput circuit is a pwm signal, how does this affect the current draw ? e.g do i have to increase the voltage input to more than +5v to allow for the circuit loss ..to then drive the motor through the increase of current at the in-rush point at each end of the reverse of direction.

thanks

Derrick
 

Audioguru

Joined Dec 20, 2007
11,248
The motor is only small one, it is used in the dvd drive assy when i put a ammeter in the motor supply wire. When I press the carriage open/close button I get:

1). Close dvd carriage result = 5v @ 1.1A
2). Open dvd carriage result = 5v @ 1.2A
Maybe your ammeter cannot accurately measure the current at the high frequency of your PWM pulses? When a motor starts running then its current is very high because it is simply a piece of wire.

Whilst the output of the H- Bridge Motor ouput circuit is a pwm signal, how does this affect the current draw?
The pulse width determines the average current.

do i have to increase the voltage input to more than +5v to allow for the circuit loss?
What is "voltage input"? The logic input voltage levels must be TTL compatible. The supply voltage for the L298 should be as much as 5V higher than the required motor voltage if you want the motor to have a max total voltage of 5V (because of the 5V max saturation voltage losses I described).

.....to then drive the motor through the increase of current at the in-rush point at each end of the reverse of direction.
When the direction of the motor is changed then it draws a very high current.
Then the motor gets reduced voltage duev tothe saturation voltage losses of the old L298.
 

zola1

Joined May 21, 2012
4
Hi, many thanks for your advice ,


ref

Maybe your ammeter cannot accurately measure the current at the high frequency of your PWM pulses? When a motor starts running then its current is very high because it is simply a piece of wire.

please see DMM pic of current draw


Quote:
do i have to increase the voltage input to more than +5v to allow for the circuit loss?
What is "voltage input"? The logic input voltage levels must be TTL compatible. The supply voltage for the L298 should be as much as 5V higher than the required motor voltage if you want the motor to have a max total voltage of 5V (because of the 5V max saturation voltage losses I described).
Voltage input is from a desktop pc power supply Compaq 5v 11A I am not sure what you mean by;- The logic input voltage levels must be TTL compatible.....please advise ?



here is where i am at code wise in pwm,
i have a problem with the pwm only working from in one motor direction, any idea where you think i have got the code wrong ...i have tried m any combinations but no go ?

int motor1Front = 5;// defines motor1Front as connected to pin 5
int motor1Back = 6;// defines motor1Back as connected to pin 6
int motor2Front = 7;// defines motor2Front as connected to pin 7
int motor2Back = 8;// defines motor2Back as connected to pin 8

void setup ()
{
pinMode (motor1Front, OUTPUT);// initialises motor1Front as output

pinMode (motor2Front, OUTPUT);// initialises motor1Front as output

}

void loop ()
{
digitalWrite (motor1Front, LOW);
delay (2000);

digitalWrite (motor1Front, HIGH);//Turns one motor on for 2 seconds
delay (2000);

digitalWrite (motor2Front, LOW);
delay (2000);

digitalWrite (motor2Front, HIGH);// Reverses the first motors direction
delay (2000);


for (int i=1; i<=255; i++) //accelerate motor from 0 to 255
{
analogWrite (motor1Front, i);
delay (11);
}


for (int i=255; i<=0; i++) // Decrease speed from 255 to 0
{
analogWrite (motor1Front, i);
delay (15);
}

}


If i can get the PWM to codes correctly i will run the power in at +12v... and retest the rig and see if its a smooth mtr "stall and reverse" ..at the moment it is only a soft stall in one direction due to incorrect code..

cheers

Derrick
 

Attachments

Audioguru

Joined Dec 20, 2007
11,248
TTL logic ICs (Transistor Trasistor Logic) were used 35 years ago. A logic low was about 0.4V or less and a logic high was +2.4V to +3.5V. The logic input voltage levels to the old L298 must be like that.

I don't see the maximum peak current drawn by your motor.
 

zola1

Joined May 21, 2012
4
TTL logic ICs (Transistor Trasistor Logic) were used 35 years ago. A logic low was about 0.4V or less and a logic high was +2.4V to +3.5V. The logic input voltage levels to the old L298 must be like that.

I don't see the maximum peak current drawn by your motor.
Hi,

Thanks now i understand TTL ,the L298 logic circuit works exactly as you thought..high and low on the IP1 & IP2 with ENA at +5v (thro 10k pull up resistors).

Please see attch, i clicked the hold button on my DMM at the point of max current draw e.g when the mtr stalls and reverses direction at the end of the traverse.

any thoughts with my q's on the code issue ?

cheers

Derrick
 

Attachments

Top