View on GitHub

ECE4160 - Fast Robots

Spring 2024

Back

Lab 4: Motors and Open Loop Control

This lab involved connecting the two car motors to the Artemis via motor drivers. There are two motor drivers, one for each motor. The diagram below shows how I connected the motor drivers to the Artemis and power supply. I chose to use pins 7,9,11, and 12 on the Artemis to connect to the inputs to each motor driver. This is because all of these pins are capable of PWM which I need for the input signals. As seen in the diagram, the drivers have their inputs and outputs parallel coupled so I can drive twice the amount of current to each motor.

I am using separate batteries to power the Artemis and the motors. The motors draw a large amount of current compared to the Artemis. If the motors and Artemis were powered with the same battery and the motors drained a large amount of the battery this could cause the Artemis to shut off while driving. Using two separate batteries prevents this.

Regulating the Power on the Driver Output

After soldering the first motor driver to my Artemis, I powered the motor driver using a lab bench power supply. I used an oscilloscope to measure the driver output and input. I wrote Arduino code to use analogWrite commands to send PWM signals to make sure I could regulate the motor output. I set the power supply to 3.7 V since this is the same voltage as the battery that I will connect later.

I set a duty cycle of 100 to the driver’s positive output and 0 to the negative input. The result is below. The top wave is the motor driver’s output, and the bottom wave is the input from the Artemis. The output is a square wave, showing that the PWM signal is successfully regulating the output of the driver.

Here is a picture of the setup for the oscilloscope readings. Note how the red and black wires from the driver chip are connected to the power supply clips. Also, the two green wires from the chip are the output, and the two yellow wires are the input. The channel 1 clips of the oscilloscope are clamped to driver output and the channel 2 clips are clamped to the inputs.

Running the Car Motor With One Driver

For this task I first unscrewed the top of the RC. I then cut the wires to the LEDs inside and unscrewed the control board from the car. The control board also had wires connecting to both motors and to the battery. I cut both these wires as close to the board as possible to leave as much wire left to solder connections too. Each motor had two wires controlling it, and each motor controlled one set of wheels on either side. This allowed me to solder both outputs from my motor driver to the the wires to control one motor. I powered the driver using the lab power supply, and then wrote Artemis code to send PWM signals to the driver inputs to spin the wheels forward for 5 seconds, then backwards for 5 seconds. Going forwards or backwards is accomplished by changing which driver input has a non-zero PWM signal sent to it using analogWrite(). Below is the code snippet followed by the results.

Attaching Both Drivers

I then connected the second motor driver to the second motor and to pins 7 and 9 on the Artemis as shown in the wiring diagram at the top. I connected the Vin and Gnd pins from each motor driver together, and then connected these two wires to the battery supply on the RC car. After connecting the 850 mAh battery into the top chassis of the car, the motor drivers were exclusively powered by the battery. I then altered my code to spin both wheels forwards then backwards using both drivers now.

Fully Assembled Car

After connecting the motor drivers I attached all components to my car, including the ToF sensors, IMU, Artemis, and battery for the Artemis. Below is an image of the full car with labels for where the respective components are located.

Lower PWM Value Limit

I wanted to find the lowest PWM value that delivered enough power to move my car forward on the ground. I noticed during experimenting that when holding the car up in the air the wheels rotated at very low PWM values (~15-25) but on the ground they did not. The friction of the wheels actually being on the ground caused a signicant force to overcome that raised the lower PWM limit significantly. Since the car will drive on the ground I found that the lowest PWM value that allowed the car’s wheels to rotate on the ground was around 30. Granted, at this PWM value the car was moving really slowly still.

Calibration

I checked to make sure that both my wheels of the motor spun at the same rate when driven with the same PWM value. It turns out that for the same PWM value both motors had a similar enough spin rate to keep the car driving in a relatively straight line so no calibration was needed. Below is a video of my car following a line that is 2m long, with both motors driven at a PWM value of 75.

Open Loop Control

I then programmed my car to go forwards, rotate, and then go forwards again to demonstrate open loop control of the car. Below is the code and video.