Finally I have power and a robot chassis so time to start work on putting everything together and testing it!
The robot is powered by a 7.2V NiMh 4300mAH battery, this is connected to a Dagu High Power switch. This switch allows a manual on/off or one to be fed from some other electrical source, either a switch mounted elsewhere or from a microprocessor controller. The switch is then wired into the VNH5019 motor shield. This in turn powers the Arduino and gives power to the motors.
The VNH5019 comes with a pre written Arduino library so its pretty easy to get started. I loaded up the example program, downloaded to the Arduino and I had 4 motors powering up and down. One thing quickly became apparent, at full power this robot is too fast, so I edited the code to slow it down. Now I did this after about 10 seconds of first powering up, and it lead me on a 4 hour wild goose chase.
The VNH5019 code allows the motors to be peered from -400 (full power reverse) to +400 (full powered forward). At +/- 400 it was simply too fast so I changed the code to +/- 100. On doing so I began to notice that intermittently 1 or 2 of the motors would fail to power up. It would consistently be the same 2, 1 more than the other. Had I been sent some faulty motors? I stripped out all the powering wiring and re did everything. Still the same fault. I then disconnected each motor and tested it independently. Each seemed fine, it was only when they were all connected. I began testing voltages and the penny dropped. At +/- 100 The VNH5019 was only giving out 1.62V. The motors are rated 2v-7v. There simply wasn't enough power to drive each channel of 2 motors. On modifying the program to +/- 200 the problem disappeared. Voltage readings at this setting are approx. 3.2V.
Below is the code used to test the motors. It starts both sets of motors driving forward at half speed (200) for 2 seconds, then stops them, waits 5 seconds and does the same in the backwards direction. To turn the chassis, motors on the A channel should run one way and the motors on the B channel should run opposite ( e.g.md.setSpeeds (200,-200); ).
#include "DualVNH5019MotorShield.h"DualVNH5019MotorShield md;void setup(){Serial.begin(115200);Serial.println("Dual VNH5019 Motor Shield");md.init();}void loop(){md.setSpeeds (200,200);delay(2000);md.setBrakes (0, 0);delay(5000);md.setSpeeds (-200,-200);delay(2000);md.setBrakes (0, 0);delay(5000);}


No comments:
Post a Comment