Inconsist Feedback Readings when using Dual VNH5019 Shield


I have been working with the Arduino and the Dual VNH5019 Shield (Part number 2502) and I have been getting inconsistent readings from the feedback on 1 of 2 linear actuators. The circuit components are as follows: 2 linear actuators, 1 3 position switch, Arduino, Arduino Protoshield, Dual VNH5019 Shield (Part number 2502), and a 12 Volt battery system.

I uploaded an attachment of the circuit.

The idea behind the project is to put the switch in the up position and then both actuators would extend at the same time and length out until they hit the limit. (The limit code is not in the code below.) When in the down position the it would go down synchronized as well. When in the other position they would turn off. Currently the issue I am having is that the feedback from the 2nd motor potentiometer is not giving me consistent results. The result I am get is when the 3 position switch tells the actuators to move it cause the feedback in linear actuator 2 to go up by about 25mV which in the Arduino world is like 20-25 out of 0-1023. I tried taking the motor driver board off and moving the Actuators and checking the feedback and the result become consistent, so I think it has something to do with motor driver board but I cannot track it down.

Here is the code that I am using with the Arduino:

#include <DualVNH5019MotorShield.h>
DualVNH5019MotorShield md;

// Variables

int keyUp = 3;  // Reads signal from keylock switch. If high it will be used to move the actuators UP
int keyDown = 5;  // Reads signal from keylock switch. If high it will be used to move the actuators Down
float act1 = 0;  // Motor 1 speed value
float act2 = 0;  // Motor 2 speed value
int actPot1MapVal;  // Variable to store the new map value of the potentiameter
int actPot2MapVal;  // Variable to store the new map value of the potentiameter
int limit1Up;  // Limit to be set to stop the actuators from extending to far
int limit1Down;  // Limit to be set to stop the actuators from retracting to far
int limit2Up;  // Limit to be set to stop the actuators from extending to far
int limit2Down;  // Limit to be set to stop the actuators from retracting to far

void setup() {
  analogReference(EXTERNAL);
  pinMode(keyUp, INPUT_PULLUP);
  pinMode(keyDown, INPUT_PULLUP);
  md.init();
  Serial.begin(115200);
  READACT1POT();
  READACT2POT();
}

void loop() {
  int actPot1 = A4;
  int actPot2 = A5;
  Serial.print("Actuator Pot REAL 2 = ");  // Prints to the Serial Monitor the value of the POT 2
  Serial.println(analogRead(actPot2));
  Serial.print("Actuator Pot REAL 1: ");
  Serial.println(analogRead(actPot1));
  if(digitalRead(keyUp) == HIGH && digitalRead(keyDown) == HIGH){
    act1 = 0;
    act2 = 0;
    md.setM1Speed(act1);
    md.setM2Speed(act2);
    md.setM1Brake(400);
    md.setM2Brake(400);    
  Serial.print("Act1 Speed: ");
  Serial.println(act1);  
  Serial.print("Act2 Speed: ");
  Serial.println(act2);  
    return;
  }
  else if (digitalRead(keyUp) == LOW){
    READACT1POT();
    READACT2POT();
    UP();
  }
  else if(digitalRead(keyDown) == LOW){
    READACT1POT();
    READACT2POT();
    DOWN(); 
  }
  Serial.print("Act1 Speed: ");
  Serial.println(act1);  
  Serial.print("Act2 Speed: ");
  Serial.println(act2);   
}

void UP(){  // If the Up keylock switch is activated then it will move the actuators Up
  if(actPot1MapVal == actPot2MapVal){
    act1 = 360.00;
    act2 = 360.00;
  }
  else if(actPot1MapVal > actPot2MapVal){
    act1 = (float(actPot2MapVal) / float(actPot1MapVal)) * 360.00;
    act2 = 360.00;
  }
  else if(actPot1MapVal < actPot2MapVal){
    act2 = (float(actPot1MapVal) / float(actPot2MapVal)) * 360.00;
    act1 = 360.00;
  }
  md.setBrakes(0, 0);
  md.setM1Speed(act1);
  md.setM2Speed(act2);
}

void DOWN(){  // If the Down keylock switch is activated then it will move the actuators Down
  if(actPot1MapVal == actPot2MapVal){
    act1 = -360.00;
    act2 = -360.00;
  }
  else if(actPot1MapVal < actPot2MapVal){
    act1 = (float(actPot1MapVal) / float(actPot2MapVal)) * -360.00;
    act2 = -360.00;
  }
  else if(actPot1MapVal > actPot2MapVal){
    act2 = (float(actPot2MapVal) / float(actPot1MapVal)) * -360.00;
    act1 = -360.00;
  }
  md.setBrakes(0, 0);
  md.setM1Speed(act1);
  md.setM2Speed(act2);
}

void READACT1POT(){
  int actPot1 = A4; // Reads signal from potentiometer in actuator 1 (left side when looking at back of trailer).
  int actPot1Val = 0;  // Variable to save the value of the potentiaometer from ActPot1
  for (int i = 0; i < 4; i = i +1){
   actPot1Val = actPot1Val + analogRead(actPot1); 
   }
   actPot1Val = actPot1Val / 4;
   actPot1Val = constrain(actPot1Val, 31, 945);
   actPot1MapVal = map(actPot1Val, 31, 945, 1, 1216);
   Serial.print("Actuator Pot 1 = ");  // Prints to the Serial Monitor the value of the POT 1
   Serial.println(actPot1Val);
   Serial.print("Actuator1 MV: ");
   Serial.println(actPot1MapVal);  // Prints to the Serial Monitor the mapped value of the POT 1
}

void READACT2POT(){
  int actPot2 = A5;  // Reads signal from potentiometer in actuator 2 (right side when looking at back of trailer).
  int actPot2Val = 0;  // Variable to save the value of the potentiaometer from ActPot2
  for (int z = 0; z < 4; z = z + 1){
   actPot2Val = actPot2Val + analogRead(actPot2);
   }
   actPot2Val = actPot2Val / 4;
   actPot2Val = constrain(actPot2Val, 32, 935);
   actPot2MapVal = map(actPot2Val, 32, 935, 1, 1216);
   Serial.print("Actuator Pot 2 = ");  // Prints to the Serial Monitor the value of the POT 2
   Serial.println(actPot2Val);
   Serial.print("Actuator2 MV: ");
   Serial.println(actPot2MapVal);  // Prints to the Serial Monitor the mapped value of the POT 2
}

Thank you to everyone who can help!!
Mike

Here is a better image of the circuit


25mV is not a significant difference. If you meant 25 counts out of 1023, that would correspond to ~125mV, which makes it slightly more significant. Could you try disconnecting the feedback wire from the Arduino and measure it with a multimeter while driving the actuator with and without the shield to see if there is a difference?

- Jeremy

I meant 25 counts out of 1023. I have driven the actuators from the power supply and took the motor driver shield off the Arduino and read the feedback from the Arduino. With the motor driver shield on the Arduino and the switch at the off position the feedback is accurate. If I change the switch to the up or down position the feedback goes up by 25 counts. With the shield off the change of the switch in any direction does not change the feedback read. Originally I thought it may have been the switch but I am leaning more towards the motor driver shield due to the above test.

–Mike

Jeremy,

I just ran the test you suggested I should run. I hooked up the multimeter the ground and the wiper of the feedback and was still getting the same results. As another test I hooked up the multimeter to the positive and the wiper and again got the same result as mentioned. When hooked up on positive and wiper I noticed that the voltage would be going down at an expected rate but it would go up by about 100mV about every 2 or 3 second and continue down.

Thanks again

Mike

It is unclear to me what the exact procedure and result was for each of your tests. For each test that you did, could you explicitly say what you changed in the system, what you measured, and how you measured it? Could you also measure just the high side of the potentiometer with a multimeter and see if there is any change when toggling your switch with and without the motor driver shield connected to the Arduino? Pictures of your setup would also be helpful.

- Jeremy

Due to a non-disclosure I have no pictures.

Test 1: Hooked up the multimeter the ground and the wiper of the feedback. With driver shield on Arduino.
Result 1: Toggling switch cause the voltage to rise by 125mV.

Test 2: Hooked up the multimeter to the positive and the wiper. With driver shield on Arduino.
Result 2: Toggling switch cause the voltage to rise by 125mV.

Test 3: Hooked up the multimeter the ground and the wiper of the feedback. With driver shield off Arduino. Powered motors by touching the power leads to the battery power.
Result 3: Toggling switch did not cause a rise in voltage. Moving the motor power leads near the battery terminals did cause a change in voltage.

Test 4: Hooked up the multimeter the positive and the wiper of the feedback. With driver shield off Arduino. Powered motors by touching the power leads to the battery power.
Result 4: Toggling switch did not cause a rise in voltage. Moving the motor power leads near the battery terminals did cause a change in voltage.

Test 5: Hooked up the multimeter the positive and the wiper of the feedback. With driver shield on Arduino. Powered motors by touching the power leads to the battery power.
Result 5: Just getting near the battery terminals causes the voltage to go down by 125mV.

From those tests, I suspect Vcc on your Arduino is not stable. Could you measure the +5V line off the Arduino (preferably with an oscilloscope) and see what it does during those 5 cases?

You might also try connecting a separate 5V supply for the linear actuator’s feedback circuitry.

- Jeremy

With each of those test I was using a 12V battery power supply. The battery power supply is (5) 96Ah batteries in parallel to create a 12V @ 480Ah system. So I am confident there is enough power.

Thanks again for your help

Mike

Hello, Mike.

I do not think you should be using five batteries in parallel while troubleshooting this. The goal should be to simplify, so can you strip this situation down to the most basic components needed to demonstrate the issue? I am envisioning a completely standard, basic setup: just a single battery powering your Arduino, shield, and a single actuator with no load (no protoshield, and at least to start, no switch). It should be something where you can post pictures without violating your NDA (separately, I do not understand how pictures will violate your NDA while your wiring diagram does not). Also, can you tell me more information about the actuators you are using? Do you have a datasheet you could link me to?

What is the simplest setup that produces this behavior? It would be ideal if you could also post an accompanying oscilloscope capture of the pot feedback. Short of this, can you post a plot of the voltage the Arduino is measuring so I can better understand what you mean by “125 mV jump”?

Please try all the possible permutations, too: actuator 1 with channel 1, actuator 1 with channel 2, actuator 2 with channel 1, and actuator 2 with channel 2.

- Ben

Here is a link to the actuators all of the data for them on the page. They 12in stroke actuators.
servocity.com/html/180_lbs__ … tuato.html

I have simplified the system to: 1 battery, arduino, motor driver, and switch.
I did not attach the protoshield.
The pictures attached are of the system stated above. Sorry about the long wires.

I ran the simplified system with the code below. It worked as intended meaning that the feedback I was getting seemed to be more “accurate”. This was run as Motor 1 in channel 1 and Motor 2 in channel 2. (This is pretty much the way I have been trying to run it before.) I know you said no switch but I was curious. When I next get a chance I will try the simplified system with the protoshield. Also we do not have a oscilloscope. I will have a plot graph of the simplified system soon.

Please tell me what you think.

Thank you
Mike

#include <DualVNH5019MotorShield.h>
DualVNH5019MotorShield md;

// Variables

int keyUp = 3;  // Reads signal from keylock switch. If high it will be used to move the actuators UP
int keyDown = 5;  // Reads signal from keylock switch. If high it will be used to move the actuators Down
float act1 = 0;  // Motor 1 speed value
float act2 = 0;  // Motor 2 speed value
int actPot1MapVal;  // Variable to store the new map value of the potentiameter
int actPot2MapVal;  // Variable to store the new map value of the potentiameter
int limit1Up;  // Limit to be set to stop the actuators from extending to far
int limit1Down;  // Limit to be set to stop the actuators from retracting to far
int limit2Up;  // Limit to be set to stop the actuators from extending to far
int limit2Down;  // Limit to be set to stop the actuators from retracting to far

void setup() {
  analogReference(EXTERNAL);
  pinMode(keyUp, INPUT_PULLUP);
  pinMode(keyDown, INPUT_PULLUP);
  md.init();
  Serial.begin(115200);
  READACT1POT();
  READACT2POT();
}

void loop() {
  int actPot1 = A4;
  int actPot2 = A5;
  READACT1POT();
  READACT2POT();
  Serial.print("Actuator Pot REAL 2 = ");  // Prints to the Serial Monitor the value of the POT 2
  Serial.println(analogRead(actPot2));
  delay(25);
  Serial.print("Actuator Pot REAL 1: ");
  Serial.println(analogRead(actPot1));
  delay(25);
    if(digitalRead(keyUp) == HIGH && digitalRead(keyDown) == HIGH){
    act1 = 0;
    act2 = 0;
    md.setM1Speed(act1);
    md.setM2Speed(act2);
    md.setM1Brake(400);
    md.setM2Brake(400);    
  Serial.print("Act1 Speed: ");
  Serial.println(act1);  
  Serial.print("Act2 Speed: ");
  Serial.println(act2);  
    return;
  }
  else if (digitalRead(keyUp) == LOW){
    READACT1POT();
    READACT2POT();
    UP();
  }
  else if(digitalRead(keyDown) == LOW){
    READACT1POT();
    READACT2POT();
    DOWN(); 
  }
  Serial.print("Act1 Speed: ");
  Serial.println(act1);  
  Serial.print("Act2 Speed: ");
  Serial.println(act2);   
}

void UP(){  // If the Up keylock switch is activated then it will move the actuators Up
  if(actPot1MapVal == actPot2MapVal){
    act1 = 360.00;
    act2 = 360.00;
  }
  else if(actPot1MapVal > actPot2MapVal){
    act1 = (float(actPot2MapVal) / float(actPot1MapVal)) * 360.00;
    act2 = 360.00;
  }
  else if(actPot1MapVal < actPot2MapVal){
    act2 = (float(actPot1MapVal) / float(actPot2MapVal)) * 360.00;
    act1 = 360.00;
  }
  md.setBrakes(0, 0);
  md.setM1Speed(act1);
  md.setM2Speed(act2);
}

void DOWN(){  // If the Down keylock switch is activated then it will move the actuators Down
  if(actPot1MapVal == actPot2MapVal){
    act1 = -360.00;
    act2 = -360.00;
  }
  else if(actPot1MapVal < actPot2MapVal){
    act1 = (float(actPot1MapVal) / float(actPot2MapVal)) * -360.00;
    act2 = -360.00;
  }
  else if(actPot1MapVal > actPot2MapVal){
    act2 = (float(actPot2MapVal) / float(actPot1MapVal)) * -360.00;
    act1 = -360.00;
  }
  md.setBrakes(0, 0);
  md.setM1Speed(act1);
  md.setM2Speed(act2);
}

void READACT1POT(){
  int actPot1 = A4; // Reads signal from potentiometer in actuator 1 (left side when looking at back of trailer).
  int actPot1Val = 0;  // Variable to save the value of the potentiaometer from ActPot1
  for (int i = 0; i < 4; i = i +1){
   actPot1Val = actPot1Val + analogRead(actPot1); 
   }
   actPot1Val = actPot1Val / 4;
   actPot1Val = constrain(actPot1Val, 31, 945);
   actPot1MapVal = map(actPot1Val, 31, 945, 1, 1216);
   Serial.print("Actuator Pot 1 = ");  // Prints to the Serial Monitor the value of the POT 1
   Serial.println(actPot1Val);
   Serial.print("Actuator1 MV: ");
   Serial.println(actPot1MapVal);  // Prints to the Serial Monitor the mapped value of the POT 1
}

void READACT2POT(){
  int actPot2 = A5;  // Reads signal from potentiometer in actuator 2 (right side when looking at back of trailer).
  int actPot2Val = 0;  // Variable to save the value of the potentiaometer from ActPot2
  for (int z = 0; z < 4; z = z + 1){
   actPot2Val = actPot2Val + analogRead(actPot2);
   }
   actPot2Val = actPot2Val / 4;
   actPot2Val = constrain(actPot2Val, 32, 935);
   actPot2MapVal = map(actPot2Val, 32, 935, 1, 1216);
   Serial.print("Actuator Pot 2 = ");  // Prints to the Serial Monitor the value of the POT 2
   Serial.println(actPot2Val);
   Serial.print("Actuator2 MV: ");
   Serial.println(actPot2MapVal);  // Prints to the Serial Monitor the mapped value of the POT 2
}






Unfortunately, I don’t have any useful feedback for you. Your program is much too complicated for me to be able to evaluate, and it’s not possible for me to tell what’s going on in those pictures with all those wires.

You haven’t really given me a good description of what happens in this current setup other than “it worked as intended”, which I’m taking as a good sign (I don’t know how to quantify your “more accurate” statement). If this setup really does work as intended, that would imply that the problem was the result of something in your previous setup and likely not an issue with the motor driver or actuator. At this point, my guess is that it was some kind of interference from the prototyping shield.

- Ben

I hope that I am better at explaining what I meant. Sorry I am so vague.

When I put the switch in the up position I get readings starting at 31(actuator 1) and 29(actuator 2) and as the actuator extends the value grows to 944(actuator 1) and 945(actuator 2).When the actuators are moving they supposed to extended to the same position at the same time. (I am trying to get them to move in synchronicity). This is what I meant by intended result.

Since my last post I tried the system with the protoshield and also get the above results. So it seems it has something to do with the 5 batteries in parallel.

Seeing as it is not the setup but possibly what is powering the system, I am wondering if it has something to do with the other electronics being power by the system as well. Here is more info that I did not tell you before (Sorry that I didn’t. I don’t want to break the NDA but I think it is necessary now). The 5 batteries and connected to a solar charge controller and the arduino and the motor driver are being power of the load side of the charge controller.

Here is a link to the charge controller: (Its the PR-3030)
steca.com/index.php?Steca_PR_10_30_en
Data sheets are on the right

Thank you for the time
Mike

Here is what the issue is with everything and it has nothing to do with the Motor Driver shield. The motor that had the weird reading had a bad solder joint to one of the power leads to the potentiometer. This has been resoldered and is now working correctly.

I would like to thank Ben and Jeremy for all of the time they spent trying to help. I would also like to apologize seeing as the motor driver shield has been working perfectly the whole time.

Thank you
Mike

I’m very glad you were able to resolve the issue; thank you for letting us know what the problem ended up being. Connection issues like that can be very difficult to track down.

- Ben