Skocz do zawartości

Źle dopasowane baterie do mostka-h L293D i Arduino?


kxdfh

Pomocna odpowiedź

I am bulding an arduino based robot. The robot is supposed to drive away from the light. I'm using:

dc motors:

Motor supply voltage: max. 6 V

Torque: 0.8 kg*cm (0.78 Nm)

Engine speed without load: 90 +/- 10 rpm

Motor current consumption without load: 190 mA (max. 250 mA)

Motor current consumption when the shaft is stopped: 1 A

h-bridge - L293D
These are two-channel ICs, designed for use with voltages up to 36 V and current not exceeding 0.6 A per channel (temporary current can reach a maximum of 1.2 A per channel).
Connected like this:

2 Photoresistors 5-10kΩ GL5616

2 10k resistors (to photoresistors)

6V battery connected to h-bridge

// Definicje pinów czujników światła
const int leftSensorPin = A0;  // Pin dla lewego czujnika światła
const int rightSensorPin = A1; // Pin dla prawego czujnika światła

// Definicje pinów sterujących silnikami
const int leftMotorPin1 = 4;   // Pin 1 dla lewego silnika
const int leftMotorPin2 = 5;   // Pin 2 dla lewego silnika
const int leftMotorPinSteering = 6;
const int rightMotorPin1 = 8;  // Pin 1 dla prawego silnika
const int rightMotorPin2 = 7;  // Pin 2 dla prawego silnika
const int rightMotorPinSteering = 9;

// Stałe prędkości silników
const int baseSpeed = 100;     // Bazowa prędkość silników

void setup() {
  // Inicjalizacja pinów jako wyjścia
  pinMode(leftSensorPin, INPUT);
  pinMode(rightSensorPin, INPUT);
  pinMode(leftMotorPin1, OUTPUT);
  pinMode(leftMotorPin2, OUTPUT);
  pinMode(rightMotorPin1, OUTPUT);
  pinMode(rightMotorPin2, OUTPUT);
  pinMode(leftMotorPinSteering, OUTPUT);
  pinMode(rightMotorPinSteering, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  // Odczyt wartości z czujników światła
  int leftLight = analogRead(leftSensorPin);
  int rightLight = analogRead(rightSensorPin);

  // Obliczenie różnicy między wartościami czujników
  int lightDifference = leftLight - rightLight;

  // Obliczenie prędkości silników w zależności od różnicy wartości odczytów
  int leftSpeed = baseSpeed + lightDifference;
  int rightSpeed = baseSpeed - lightDifference;

  // Ograniczenie prędkości do zakresu 0-255
  leftSpeed = constrain(leftSpeed, 0, 200);
  rightSpeed = constrain(rightSpeed, 0, 200);

  Serial.print("Left Light: ");
  Serial.print(leftLight);
  Serial.print("  |  Right Light: ");
  Serial.println(rightLight);
  Serial.print("Left speed: ");
  Serial.print(leftSpeed);
  Serial.print("  |  RrightSpeed: ");
  Serial.println(rightSpeed);

  delay(10000);

  // Ustawienie kierunku obrotów silników
 
  digitalWrite(leftMotorPin1, HIGH);
  digitalWrite(leftMotorPin2, LOW);
  digitalWrite(rightMotorPin1, HIGH);
  digitalWrite(rightMotorPin2, LOW);
  analogWrite(leftMotorPinSteering, leftSpeed);
  analogWrite(rightMotorPinSteering, rightSpeed);

    
  
}

Arduino is powered by laptop but it will be powered by 9V battery in the final project
My code looks like this:

There is no problem with photoresistors or code connected to calculating motorspeed, it is printed on serial monitor correctly, but the wheels won't spin, the motors make the noise typical for PWM. Is there something wrong with the voltage or something? Should I use different batteries? Maybe use resistors with h-bridge? I tried powering the whole project with just 9V battery connected to arduino connected to breadboard with h-bridge, it didn't work too. Any ideas what I am doing wrong?

Link do komentarza
Share on other sites

@kxdfh welcome to our forum. A 9V battery is not suitable for powering such a project because it has too little current capacity. You wrote that the motors are powered by a 6V battery, what exactly do you mean? Remember that this controller has a large voltage drop, so when powered from 6V, a lower voltage will reach the motors (see the technical documentation for details).

Link do komentarza
Share on other sites

Link do komentarza
Share on other sites

@kxdfh the 9V battery has too little current capacity. It is better to use 6xAA. Can you show us your electronics and all the connections? For a test, disconnect the motors and measure the voltage at the output of the h-bridge.

Link do komentarza
Share on other sites

Zarejestruj się lub zaloguj, aby ukryć tę reklamę.
Zarejestruj się lub zaloguj, aby ukryć tę reklamę.

jlcpcb.jpg

jlcpcb.jpg

Produkcja i montaż PCB - wybierz sprawdzone PCBWay!
   • Darmowe płytki dla studentów i projektów non-profit
   • Tylko 5$ za 10 prototypów PCB w 24 godziny
   • Usługa projektowania PCB na zlecenie
   • Montaż PCB od 30$ + bezpłatna dostawa i szablony
   • Darmowe narzędzie do podglądu plików Gerber
Zobacz również » Film z fabryki PCBWay

8 godzin temu, kxdfh napisał:

what is the difference between 6xAA and the battery that I have?

These are ability to provide higher current (due to lower internal resistance) and higher capacity.

The reason is the same, why you can't use 8 pcs of AA battery (which are nominal 12V) as your car battery.

 

 

  • Lubię! 1
Link do komentarza
Share on other sites

Dołącz do dyskusji, napisz odpowiedź!

Jeśli masz już konto to zaloguj się teraz, aby opublikować wiadomość jako Ty. Możesz też napisać teraz i zarejestrować się później.
Uwaga: wgrywanie zdjęć i załączników dostępne jest po zalogowaniu!

Anonim
Dołącz do dyskusji! Kliknij i zacznij pisać...

×   Wklejony jako tekst z formatowaniem.   Przywróć formatowanie

  Dozwolonych jest tylko 75 emoji.

×   Twój link będzie automatycznie osadzony.   Wyświetlać jako link

×   Twoja poprzednia zawartość została przywrócona.   Wyczyść edytor

×   Nie możesz wkleić zdjęć bezpośrednio. Prześlij lub wstaw obrazy z adresu URL.

×
×
  • Utwórz nowe...

Ważne informacje

Ta strona używa ciasteczek (cookies), dzięki którym może działać lepiej. Więcej na ten temat znajdziesz w Polityce Prywatności.