Pages: [1]   Go Down
Author Topic: L298N controller  (Read 707 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have bought a controller and two motors and connected them up to my Arduino.  However I cannnot make the motors move.  Can someone help.  The code is below:

Code:
case 'f':   
      Serial.write("forwards");
      //To move the motor forward: IN1=H, IN2=L, ENA=H
       digitalWrite(iEnableMotorA, HIGH);
   digitalWrite(iInOneMotorA, HIGH);
   digitalWrite(iInTwoMotorA, LOW);

    analogWrite(iEnableMotorA, 75);   //PWM Speed Control
     
     
      delay(1000);                  // waits for a second
      digitalWrite(iEnableMotorA, LOW);
      digitalWrite(iInOneMotorA, LOW);
 
     
      break;


All Pins have been set to out put.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34207
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So how have you wired it up? How is it being powered? Are the grounds common?

What results are you getting, for example do you see the printed message from that bit of code.
Does it twitch or just do nothing?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is being powered by 5v from the Arduino and the ground runs back to the Arduino. 

The pins are connected as such

Code:

 int iEnableMotorA = 3;  //Enable Motor A
 int iInOneMotorA = 11;  //IN1 for motor A
 int iInTwoMotorA = 6;   //IN2 for motor A
 
 int iEnableMotorB = 5;    //Enable Motor B
 int iInThreeMotorB = 10;  //IN1 for motor B
 int iInFourMotorB = 9;   //IN2 for motor B

 

I got it to move once but for it to move more I would need to re-flash the Arduino.  With the current code it just makes a beeping noise.  Any idea what that means?  Yes I see that printed message OK.

Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34207
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
With the current code it just makes a beeping noise.  Any idea what that means?
Well that code is only turning the motor on for a second so it might beep.

What current does the motor take, powering a motor off the USB is not the best idea because the interference from the motor often causes the arduino to reset.

Quote
I got it to move once but for it to move more I would need to re-flash the Arduino.
That is an odd thing to say, it is not how an arduino normally works.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It beeps also for 10 seconds, the sound comes from the controller. 

According to the spec:

Quote
The logical part of the operating current range: 0 ~ 36mA

By re-flash, I mean I need to put the sketch back onto the Arduino.  I think the HW part is right as I have got it to move, I just don't remember exactly what I did.  Is it right that I am setting the enable pin with the PWM value?  So, i only need to set the IN1 and IN2 to high or low?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is the HW:

http://dx.com/p/l298n-stepper-motor-driver-controller-board-for-arduino-120542
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34207
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the sound comes from the controller
From the arduino? That should not make a sound.

Quote
According to the spec:

Quote
The logical part of the operating current range: 0 ~ 36mA
No how much current does your motor take? That is the important value in determing if you can run it from the USB or if you need and external supply.

Quote
By re-flash, I mean I need to put the sketch back onto the Arduino.
No nothing should take the sketch out of the arduino once you have put it in. It keeps the same sketch until you put in another one.

Quote
I think the HW part is right as I have got it to move
Well it moved once, but maybe you fried it by doing something wrong.
I repeat how have you got this wired up, it sounds like you are not supplying any motor power.

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not sure it's fried yet, it just did some small movement plus the LEDs are coming on and off OK.

Looking at the pic here:

http://www.google.com/imgres?q=L298N+Stepper+Motor+Driver+Controller+Board+for+Arduino&um=1&hl=en&client=safari&sa=N&tbo=d&rls=en&biw=973&bih=680&tbm=isch&tbnid=VZD3tXby8PUlIM:&imgrefurl=http://dx.com/p/l298n-stepper-motor-driver-controller-board-for-arduino-120542&docid=baNjhY4l-J55nM&imgurl=http://img.dxcdn.com/productimages/sku_120542_1.jpg&w=600&h=600&ei=6EOxUJq4HaiN4gTO6YD4CQ&zoom=1&iact=hc&vpx=4&vpy=134&dur=713&hovh=225&hovw=225&tx=102&ty=128&sig=117348941556890433591&page=1&tbnh=135&tbnw=127&start=0&ndsp=20&ved=1t:429,r:0,s:0,i:87

Those yellow pins have been described except the 5v, which goes to the Arduino + the GND which also goes to the Arduino, no other power source.  Motor A/B of the blue pins are connected to the motors.  The red wire is the one nearest the letter "M" in each case.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34207
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So what is connected to the VMS connector?
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nothing, I am connecting 5v to that yellow 5v pin.  Or what is that for?  I was thinking that I can't connect to both?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34207
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Or what is that for?
The VMS is the Volts Motor Supply.

So with nothing connected to it you are driving your motors with zero volts therefore it is not a surprise if nothing moves. Connect it to the +5V from the arduino as well, if the motor is of sufficient low current it should move if you have not fried anything.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 56
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, I can try.  So shall I keep those yellow 5v + GND connected?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 626
Posts: 34207
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

yes
Logged

Pages: [1]   Go Up
Jump to: