Pathfinder – Chassis
Pathfinder Chassis – Motor Driver Test
October 3, 2018 / Pathfinder #6 / by Larry Vinh
Table of Contents
Introduction
The motor driver test is to check if the VNH5019 Motor Driver Shields are able to control the motors. If we are able to control the motors, then we will be able to control the speed and the direction of rotation for the wheels. As a result of the previous PCB shorting, this test has a second purpose of checking if the motor drivers are functional.
Parts Required:
- VNH 5019 Motor Driver Shield
- Arduino
- 12V Battery
- Motor
- Breadboard
This diagram shows which pins of the motor driver shield needs to be connected to which pins of the Arduino to run this test.
Instructions:
For this test, the motor driver was placed onto a breadboard. Then, pins were used to make connections from the breadboard to the arduino based on Figure 1. The 12V battery would be connected to VIN and GND on the motor driver’s terminal. For this test, a stepper motor was used as our test motor. It was connected to the terminal M1A and M1B. The code below was used to make the stepper motor rotate clockwise and counterclockwise. The serial monitor can be used to check how much current, in milliAmps, the motor is drawing. After verifying that the motor driver is causing the stepper motor to work, the stepper motor is connected to M2A and M2B to verify that those terminals work as well.
To have the code fully functional, the library from the following link would need to be included: https://github.com/pololu/dual-vnh5019-motor-shield
Code:
#include "DualVNH5019MotorShield.h" DualVNH5019MotorShield md; void stopIfFault() { if (md.getM1Fault()){ Serial.println("M1 fault"); while(1); } if (md.getM2Fault(){ Serial.println("M2 fault"); while(1); } } void setup(){ Serial.begin(115200); Serial.println("Dual VNH5019 Motor Shield"); md.init(); } void loop() { for (int i = 0; i <= 400; i++) { md.setM1Speed(i); stopIfFault(); if (i%200 == 100) { Serial.print("M1 current: "); Serial.println(md.getM1CurrentMilliamps()); } delay(2); } for (int i = 400; i >= -400; i--){ md.setM1Speed(i); stopIfFault(); if (i%200 == 100) { Serial.print("M1 current: "); Serial.println(md.getM1CurrentMilliamps()); } delay(2); } for (int i = -400; i <= 0; i++) { md.setM1Speed(i); stopIfFault(); if (i%200 == 100) { Serial.print("M1 current: "); Serial.println(md.getM1CurrentMilliamps()); } delay(2); } for (int i = 0; i <= 400; i++) { md.setM2Speed(i); stopIfFault(); if (i%200 == 100) { Serial.print("M2 current: "); Serial.println(md.getM2CurrentMilliamps()); } delay(2); } for (int i = 400; i >= -400; i--) { md.setM2Speed(i); stopIfFault(); if (i%200 == 100) { Serial.print("M2 current: "); Serial.println(md.getM2CurrentMilliamps()); } delay(2); } for (int i = -400; i <= 0; i++) { md.setM2Speed(i); stopIfFault(); if (i%200 == 100) { Serial.print("M2 current: "); Serial.println(md.getM2CurrentMilliamps()); } delay(2); } }
Output of the Serial Monitor. This determines if the Motor Driver shield is functioning because any motor connected to the shield terminal should current supplied to it.
This is the physical implementation of figure 1. This was used to conduct the test.
Results:
From this test, we learned that the motor driver shield can be used to control the speed of the Chassis and that the Chassis can have its wheels rotate clockwise or counterclockwise. This would allow us to decide when the Chassis should slow down or speed up depending on the terrain. If the Chassis manages to be blocked by an obstacle, then we can have it reverse and move around that obstacle. From testing, two of the three motor drivers’ stepper motors were able to rotate. We ordered a replacement and a spare motor driver.