Go Down

Topic: L298 different output voltages (Read 4129 times) previous topic - next topic

raschemmel

That's really surprising. Most people use a variation of these (one of about 10 variations with different layouts):
   http://www.ebay.com/sch/i.html?_kw=L298+H-Bridge+Dual+Motor+Driver     
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

raschemmel

Oh and BTW,
This is what your code would look like if you had followed my instructions: (in Reply#3)

Code: [Select]
  #include<Wire.h>
const int GyroA=0x68;
const byte pin_motor1_dir = 2;
const byte pin_motor1_en = 3;
const byte pin_motor2_dir = 4;
const byte pin_motor2_en = 5;
const byte pin_buzzer = 6;
const byte pin_echo = 7;
const byte pin_trigger = 8;
const byte pin_led1 = 9;
const byte pin_led2 = 10;
const byte pin_btn = 12;
const byte pin_reflex_1 = A0;
const byte pin_reflex_2 = A1;
const byte pin_reflex_3 = A2;
const byte pin_reflex_4 = A3;
byte motor1_speed = 0;
int data_ultrasonido;
int data_reflex[4];

int buttonState;
int lastButtonState = LOW;
long debounceDelay = 50;
long lastDebounceTime = 0;

float data_imu[7];
byte z = 0;
void setup()
{
 pinMode(pin_motor1_dir,OUTPUT);
 pinMode(pin_motor1_en,OUTPUT);
 pinMode(pin_motor2_dir,OUTPUT);
 pinMode(pin_motor2_en,OUTPUT);
 pinMode(pin_buzzer,OUTPUT);
 pinMode(pin_trigger,OUTPUT);
 pinMode(pin_echo,INPUT);
 pinMode(pin_led1,OUTPUT);
 pinMode(pin_led2,OUTPUT);
 pinMode(pin_btn,INPUT);
 pinMode(pin_reflex_1,INPUT);
 pinMode(pin_reflex_2,INPUT);
 pinMode(pin_reflex_3,INPUT);
 pinMode(pin_reflex_4,INPUT);
 Wire.begin();
 Wire.beginTransmission(GyroA);
 Wire.write(0x6B);
 Wire.write(0); //Wake up
 Wire.endTransmission(true);
 //digitalWrite(pin_buzzer,HIGH);
 //digitalWrite(pin_led1,HIGH);
 //digitalWrite(pin_led2,HIGH);
 Serial.begin(9600);
}
void loop()
{
 //delay(350);
 //debug_imu();
 //debug_reflex();
 //debug_ultrasonido();
 debounce();
 
}
void debug_reflex()
{
 sensar_reflex();
 for(int i = 0;i<4;i++)
 {
   Serial.print("Reflex ");
   Serial.print(i);
   Serial.print(": ");
   Serial.println(data_reflex);
 }
 Serial.println();
}
void debug_ultrasonido()
{
 sensar_ultrasonido();
 Serial.print("Distancia: ");
 Serial.println(data_ultrasonido);
 Serial.println();
}
void debug_imu()
{
 sensar_imu();
 Serial.print("AcX: ");
 Serial.println(data_imu[2]);
 Serial.print("AcY: ");
 Serial.println(data_imu[1]);
 Serial.print("AcZ: ");
 Serial.println(data_imu[0]);
 Serial.print("GyX: ");
 Serial.println(data_imu[3]);
 Serial.print("GyY: ");
 Serial.println(data_imu[4]);
 Serial.print("GyZ: ");
 Serial.println(data_imu[5]);
 Serial.print("Temp: ");
 Serial.println(data_imu[6]);
 Serial.println();
}
void sensar_ultrasonido()
{
 long duration;
 digitalWrite(pin_trigger, LOW);
 delayMicroseconds(2);
 digitalWrite(pin_trigger, HIGH);
 delayMicroseconds(10);
 digitalWrite(pin_trigger, LOW);
 duration = pulseIn(pin_echo, HIGH,11765);
 if(duration!=0)
 {
   data_ultrasonido = duration/59;
 }
 else
 {
   data_ultrasonido = -1;
 }
}
void sensar_reflex()
{
 data_reflex[0] = analogRead(pin_reflex_1);
 data_reflex[1] = analogRead(pin_reflex_2);
 data_reflex[2] = analogRead(pin_reflex_3);
 data_reflex[3] = analogRead(pin_reflex_4);
}
void sensar_imu()
{
 Wire.beginTransmission(GyroA);
 Wire.write(0x3B);
 Wire.endTransmission(false);
 Wire.requestFrom(GyroA,14,true);
 data_imu[0] = Wire.read()*256+Wire.read();
 data_imu[1]=Wire.read()*256+Wire.read();
 data_imu[2]=Wire.read()*256+Wire.read();
 data_imu[6]=(Wire.read()*256+Wire.read())/340.00+36.53;
 data_imu[3]=Wire.read()*256+Wire.read();
 data_imu[4]=Wire.read()*256+Wire.read();  
 data_imu[5]=Wire.read()*256+Wire.read();  
 data_imu[3]/=131;
 data_imu[4]/=131;
 data_imu[5]/=131;
 data_imu[0]/=16384;
 data_imu[1]/=16384;
 data_imu[2]/=16384;
}
void debounce()
{
 int state = digitalRead(pin_btn);
 if(state!=lastButtonState)
 {
   lastDebounceTime = millis();
 }
 if ((millis() - lastDebounceTime) > debounceDelay)
 {
   if (state != buttonState)
   {
     buttonState = state;
     if (buttonState == HIGH)
     {
       //tone(pin_buzzer,1760,50);
       if(motor1_speed < 255)
       {
         motor1_speed+=51;
       }
       else
       {
         motor1_speed = 0;
       }
       analogWrite(pin_motor1_en,motor1_speed);
       analogWrite(pin_motor2_en,motor1_speed);
     }
   }
 }
 lastButtonState = state;
}
Report to moderator     Logged
       
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

mateoar


That's really surprising. Most people use a variation of these (one of about 10 variations with different layouts):
   http://www.ebay.com/sch/i.html?_kw=L298+H-Bridge+Dual+Motor+Driver     


Yea I also have one of those but for this project (micro sumo) i needed to save as much space as possible and so im going to etch my own pcb with all the circuit

raschemmel

Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

mateoar


raschemmel

#20
Sep 11, 2014, 03:14 pm Last Edit: Sep 11, 2014, 04:42 pm by raschemmel Reason: 1
Sometimes we do our best work when we have a gun to our head. :smiley-mr-green:

That's why there is always a Boss. Someone has to hold the gun....
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

narzan

hahaha @raschemmel
ok put the gun on my head  ;) and help me in this  :smiley-roll-sweat:
this is my post
http://forum.arduino.cc/index.php?topic=270583.15
Free schematics and BIOS files database https://www.scheme512.com/

Go Up