In this lab, I added two motor drivers to the car, removed the existing control board, and integrated my Artemis and TOF sensors into the car.
I used pins 0,1,4,5 to control the motor drivers. I used stranded wires since they are more resistant to breaking than solid core wires. I used separate batteries for the Artemis and motor drivers to maximize the available current for the motor drivers. Additionally, the motor drivers require a lot of current, so separate batteries for the Artemis and motor drivers will maximize the robot’s lifetime.
Wiring Diagram
I soldered the input pins of both my motor drivers to the Artemis and connected the output pins to an oscilloscope and the power pins to an external power supply. For the power supply, I used 3.7 V as the input voltage, since the 850 mAh batteries are 3.7 V batteries. From the datasheet, I noted that the maximum steady current drawn when coupling both channels was 2.4 A. I set a limit of 1.6 A since I did not think the motor drivers would need the maximum current when running without a motor.
I used this code to generate the PWM signals for one of my motor drivers.
This is the oscilloscope output.
I soldered the motor driver outputs into the motors, following my wiring diagram. I powered the motor drivers using the same external power supply with the current limit set to 2.4 A.
I used one motor driver to control the motors on its side. The code and video are shown below.
I repeated this process for the 2nd motor driver (to confirm its functionality).
I used the battery power to drive each motor driver separately. I used the same codes in the previous section since the only change was the power source.
One side:
Other side:
I assembled everything into my car, using electrical tape and double-sided tape to secure my components. I decided to place TOF sensors on the front and back of the car. Additionally, I drilled an additional hole in the battery compartment so I could have both batteries in the same compartment. The image below shows the assembled car.
After assembling everything, I programmed the car to drive forward for a few seconds and then stop.
I placed the car on the lab table and slowly incremented the PWM values until the car barely started to move. For straight, I found that a minimum PWM of 70 was needed to move forward.
For turning, I drove one side forward and the other side backward to execute a turn. I found that a value of 100 on the left motor and 90 on the right motor was necessary to just start turning. This was higher than going forward because the car has to overcome more friction to turn then go straight.
My car initially did not move in a straight line, so I had to add a calibration factor (increased the right motor speed) to ensure it moved in a straight line. Here is the code and the video.
After getting the car to move in a straight line, I programmed an open-loop procedure for it to follow. I sent the command using ble in Python.
I measured the frequency of the analogWrite commands using an oscilloscope. I found that the frequency was 186Hz. This frequency was enough to run the motors (based on experimental observations). If the PWM signal was faster, you could achieve finer control over the car for high-speed maneuvers.
I tried to determine the lowest PWM value for which the robot would continue to drive forward. I set an initial PWM signal to start the robot, let it run for 1.5 seconds, and then supplied a lower PWM signal. I lowered the value until the robot stopped. The lowest value I got was 60, which is higher than expected, but could be because of extra wheel friction, weaker motors, or a depleted battery. Additionally, the car quickly settled on this lower speed.