Go Down

Topic: Arduino UNO + Tamiya twin gearbox + 298 H bridge. Please help. (Read 3 times) previous topic - next topic

DuaneB

The only other suggestion is to make sure you have a common ground between arduino and 298.

The motors do turn if you power them directly with one or two AAs dont they ?

Duane B

oric_dan

#6
Nov 13, 2012, 08:41 pm Last Edit: Nov 13, 2012, 08:42 pm by oric_dan(333) Reason: 1
Did you build your own h-bridge ckt, or is it a commercial board?

Did you read the datasheet on the L298 'before' starting to play with it?

Those devices have certain requirements for minimum logic and motor-input voltages. Also, because
they are linear analog devices [BJTs, and not MOSFETs], there is a 1-1.5V loss of voltage between the
battery input and the motor output.

Also, for reference, the Tamiya twin gearbox motors don't draw a lot of current, and can be run off
of 754410 and L293 chips = 16pin DIP.

biotech

My H bridge is a commercial board. And yes, I did read the L298 datasheet.

A understand that there is a 1-1.5V loss of voltage. The 3.3 volts Tamiya motors however should work well even in that case as there is a 5 vots input from the batteries. That´s why I am so puzzled about these motors not moving at all.

So far even with all the valuable help I couldn´t get this sorted.


biotech

Just in case, this is the code I am using to run the two motors and read an ultrasonic sensor:

/*
HC-SR04 Ping distance sensor]
VCC to arduino 5v GND to arduino GND
Echo to Arduino pin 13 Trig to Arduino pin 12
More info at: http://goo.gl/kJ8Gl
*/

#define trigPin 12
#define echoPin 13
int ENA=5;//connected to Arduino's port 5(output pwm)
int IN1=2;//connected to Arduino's port 2
int IN2=3;//connected to Arduino's port 3
int ENB=6;//connected to Arduino's port 6(output pwm)
int IN3=4;//connected to Arduino's port 4
int IN4=7;//connected to Arduino's port 7

void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(ENA,OUTPUT);//output
pinMode(ENB,OUTPUT);
pinMode(IN1,OUTPUT);
pinMode(IN2,OUTPUT);
pinMode(IN3,OUTPUT);
pinMode(IN4,OUTPUT);
digitalWrite(ENA,LOW);
digitalWrite(ENB,LOW);//stop driving
}

void loop() {
  int duration, distance;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  if (distance >= 20 || distance <= 0){
    Serial.println("Out of range");
    analogWrite(ENA,255);//start driving motorA
    analogWrite(ENB,255);//start driving motorB
    digitalWrite(IN1,LOW);
    digitalWrite(IN2,HIGH);//setting motorA's directon
    digitalWrite(IN3,HIGH);
    digitalWrite(IN4,LOW);//setting motorB's directon
  }
  else {
    Serial.print(distance);
    Serial.println(" cm");
    analogWrite(ENA,255);//start driving motorA
    analogWrite(ENB,255);//start driving motorB
    digitalWrite(IN1,HIGH);
    digitalWrite(IN2,LOW);//setting motorA's directon
    digitalWrite(IN3,LOW);
    digitalWrite(IN4,HIGH);//setting motorB's directon
  }
  delay(500);
}

It all work as expected when I use other motors but it doesn´t with the tamiya gearbox.

oric_dan

Quote
It all work as expected when I use other motors but it doesn´t with the tamiya gearbox.


Strange it works with other motors. The Tamiya's are toy motors, and such as those usually take higher
PWM duty values before they start turning, but you seem to have that covered with

analogWrite(ENA,255);//start driving motorA

[BTW, you should use the '#' button to wrap your code].

Care to give a link for the h-bridge board.

Go Up