Hello together
I have the following problem:
I would like to control two linear motors (12VDC, 3.2A) via a power supply (output 12VDC 7.5A) using two motor drivers (DRV8871, Adafruit). The motors run on and off, after random factor - once between 1-8min, via a Hall sensor (magnet is at the tip of the motor).
Unfortunately, I only measure 5-7V at the output of the motor driver.
Does anyone know the cause of this? im not sure if its in the Code or something with the Driver...
Unfortunately I have lost the overview.
thanks in advance
Here is the code, a youtube video of the bench [ and in the attachment a Fritzing-Sketch:
#define HallPin1 2
#define HallPin2 3
#define MOTOR_IN11 9
#define MOTOR_IN12 10
#define MOTOR_IN21 5
#define MOTOR_IN22 6
int state = 0;
int i = 0;
unsigned long randtime;
int minTime = 1;
int maxTime = 8;
void setup()
{
Serial.begin(9600);
Serial.println("Bänkil_Motion");
pinMode(MOTOR_IN11, OUTPUT);
pinMode(MOTOR_IN12, OUTPUT);
pinMode(MOTOR_IN21, OUTPUT);
pinMode(MOTOR_IN22, OUTPUT);
pinMode(8,INPUT_PULLUP);
pinMode(HallPin1, INPUT_PULLUP);
pinMode(HallPin2, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(HallPin1), stopUno, FALLING);
attachInterrupt(digitalPinToInterrupt(HallPin2), stopDue, FALLING);
randomSeed(analogRead(0));
//Initialize Statemachine with current state
if (digitalRead(HallPin1)==LOW)
{
state = 0;
Serial.println("Hall1 active");
}
else if (digitalRead(HallPin2)==LOW)
{
state = 1;
Serial.println("Hall2 active");
}
else
{
state = 2;
Serial.println("None active");
}
}
void loop()
{
if (digitalRead(8)==LOW)
{
/*Serial.println(state);*/
switch (state)
{
case 0:
digitalWrite(MOTOR_IN11, LOW);
digitalWrite(MOTOR_IN12, LOW);
digitalWrite(MOTOR_IN21, LOW);
digitalWrite(MOTOR_IN22, LOW);
Serial.println("Hall1 active");
i = 0;
randtime = random(minTime,(maxTime+1))*60000;
Serial.println((randtime/60000));
delay(randtime);
state = 2;
break;
case 1:
digitalWrite(MOTOR_IN11, LOW);
digitalWrite(MOTOR_IN12, LOW);
digitalWrite(MOTOR_IN21, LOW);
digitalWrite(MOTOR_IN22, LOW);
Serial.println("Hall2 active");
i = 0;
randtime = random(minTime,(maxTime+1))*60000;
Serial.println((randtime/60000));
delay(randtime);
state = 3;
break;
case 2:
digitalWrite(MOTOR_IN11, LOW);
digitalWrite(MOTOR_IN21, LOW);
if (i == 0)
{
for (i=0; i<128; i++)
{
analogWrite(MOTOR_IN12, (2*i));
analogWrite(MOTOR_IN22, (2*i));
delay(5);
}
Serial.println("Push");
}
analogWrite(MOTOR_IN12, 255);
analogWrite(MOTOR_IN22, 255);
break;
case 3://Einfahren
digitalWrite(MOTOR_IN12, LOW);
digitalWrite(MOTOR_IN22, LOW);
if (i == 0)
{
for (i=0; i<128; i++)
{
analogWrite(MOTOR_IN11, (2*i));
analogWrite(MOTOR_IN21, (2*i));
delay(5);
}
Serial.println("Pull");
}
analogWrite(MOTOR_IN11, 255);
analogWrite(MOTOR_IN21, 255);
}
}
else
{
digitalWrite(MOTOR_IN11, LOW);
digitalWrite(MOTOR_IN12, LOW);
digitalWrite(MOTOR_IN21, LOW);
digitalWrite(MOTOR_IN22, LOW);
}
}
void stopUno()
{
state = 0;
}
void stopDue()
{
state = 1;
}
](Projektskizze 2020 - YouTube)/iurl)
