• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Baterie do projektu arduino
#1
Sad 
I am bulding an arduino based robot. The robot is supposed to drive away from the light. I'm using:
  1. 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
  1. 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:
    [Obrazek: 5ca65eda4436e1c3feaee2d72975c9777d2675ed.png]

  2. 2 Photoresistors 5-10kΩ GL5616

  3. 2 10k resistors (to photoresistors)

  4. 6V battery connected to h-bridge

  5. Arduino is powered by laptop but it will be powered by 9V battery in the final project
    My code looks like this:
Kod:
// 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);
}

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?
 
Odpowiedź
#2
You are loosing about 2V on L293D, so there rest only 4V for motor, this is maby too low for it. 9V batter have small capasity, soo this set won't work too long, also have small current output, not enaught to power motor, better idea is to use set of AA acu.
Czemu w ogóle piszesz po angielsku, skoro komentarze w kodzie masz po polsku?
Miło być decenianym https://buycoffee.to/kaczakat
 
Odpowiedź
#3
(14-03-2024, 04:16)kaczakat napisał(a): You are loosing  about 2V on L293D, so there rest only 4V for motor, this is maby too low for it.  9V batter have small capasity, soo this set won't work too long, also have small current output, not enaught to power motor, better idea is to use set  of AA acu.
Czemu w ogóle piszesz po angielsku, skoro komentarze w kodzie masz po polsku?
Zamieniłam baterie na 6xAA i nadal nie dziala.
 
Odpowiedź
#4
Sprawdź w takim wypadku, czy silnik rusza przy napięciu z baterii 6V. Potem dołącz drugi z nich i zobacz, czy oba wystartują "na twardo" przy zasilaniu z 4 baterii AA.

Silniki mają w swojej naturze pobór znacznie większego prądu niż znamionowy w momencie startu.

Tak jak pisał kolega @kaczakat L293D powoduje duże spadki napięcia i może uniemożliwić start silnika.

Drugą z akcji, którą możesz dla testów zrobić to płynne narastanie napięcia zasilania dla silników przez stopniowe zwiększanie wypełnienia PWM i sprawdzenie, czy taki softstart uruchomi silniki.

Mostek masz o wydajności 600mA na silnik więc może być mało dla zestawu, który masz.
 
Odpowiedź
  


Skocz do:


Przeglądający: 1 gości