2linear motors with motordriver + hall sensor - movable backrest of a bench

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)

Perhaps the average voltage being low is due to the use of analogWrite.

What voltage do you get if you directly set the motor driver inputs to logic low/high as
necessary to drive the motor at full speed in one direction?

Since that driver chip has about 0.56 ohms of resistance, there will be a small voltage loss due to
it.

If any of you wiring is thin signal wires, then that alone could account for the loss - 3A takes
suitably rated wires and solid connections. Dupont header hook-up wires are not normally rated for
high currents, note.

The DRV8871 will be struggling at 3A continuous, its rated for 3.6A peak, so 2A or less continuous
is a realistic current to expect from it.

Also measure the current output of your power supply.
(And it's voltage)

The currents you state are rated currents.
Motors take a lot more current during start up.
So it's possible your supply goes into some protection mode (which will occur as a voltage drop), and the system might not be able to recover from that.

The supply can deliver 90 Watts of power.
If the current rises, the voltage will drop and so the maximum power remains.

Thank you for your answers and taking time!

Unfortunately, I don't have a multimeter at the moment, which is why I can't measure the output any more (by chance, an electrician was in the house once and measured the first data).

I have run the following test code:

// Basic sketch for trying out the Adafruit DRV8871 Breakout
#define MOTOR_IN1 9
#define MOTOR_IN2 10
#define MOTOR_IN3 5
#define MOTOR_IN4 6
void setup() {
Serial.begin(9600);
Serial.println("DRV8871 test");
pinMode(MOTOR_IN1, OUTPUT);
pinMode(MOTOR_IN2, OUTPUT);
pinMode(MOTOR_IN3, OUTPUT);
pinMode(MOTOR_IN4, OUTPUT);
}

void loop() {

//Positive Voltage Test

//Max Output with PWM
digitalWrite(MOTOR_IN1, LOW);
digitalWrite(MOTOR_IN3, LOW);
analogWrite(MOTOR_IN2, 255);
analogWrite(MOTOR_IN4, 255);
Serial.println("Output with PWM, 12V anticipated");
delay(5000);


//Negative Voltage Test

//Neg. Max. Output with PWM
digitalWrite(MOTOR_IN2, LOW);
digitalWrite(MOTOR_IN4, LOW);    
analogWrite(MOTOR_IN1, 255);
analogWrite(MOTOR_IN3, 255);
Serial.println("Output with PWM, -12V anticipated");
delay(5000);


}

With this code the motors ran without problems....

MarkT:
Perhaps the average voltage being low is due to the use of analogWrite.

what exactly do you mean by too much AnalogWrite? Please excuse me, this is my first Arduino project and I copied the code together somehow...

Do you think I should try another motorshield? for example this? or do you have another good product in mind?

Thanks in advance

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.