$24
Objective
The primary focus of this experiment is to write a MATLAB script to automate the sweep of a DC voltage signal from the arbitrary waveform generator (AWG) which is supplied to an Arduino and used to generate a PWM signal of proportional duty cycle, which causes a wheel attached to a DC Motor to rotate. The goal of this experiment is to generate, using automation, the RPM vs. duty cycle characteristic plot of a DC motor using the Arduino as a PWM source.
Equipment List
HP Oscilloscope
HP Arbitrary Waveform Generator (AWG)
Power Supply
Arduino Mega 2560
DC Motor with wheel
H-bridge
(2) Banana jack-to-alligator clip cables
(3) BNC to Alligator clip cables
Optical counter
Procedure
First, the H-bridge is set up and tested to ensure it is functioning correctly by connecting it to the motor and performing a test run using input voltage from the AWG. The optical counter is also connected properly, and its output is connected to the oscilloscope. Next, the Arduino is connected to the system. The voltage from the AWG is connected to an input pin of the Arduino, and one of its output pins is connected to the H-bridge. The AWG output is automated to sweep from 0 VDC to 5 VDC in 0.1 V increments each with a duration of 5s, using MATLAB’s USB commands. The resulting signal is sent to the Arduino, which is programmed to adjust an output PWM signal with duty cycle based on the input voltage.
The resulting PWM signal sent to the DC motor causes the motor to accelerate over time until it reaches a 100% duty cycle at 5V. The corresponding RPM of the motor is recorded in MATLAB using two methods. The first is by measuring the pulse frequency of the optical counter via the oscilloscope every 5s. The second is by programming the Arduino to initiate an interrupt that manually counts the number of rising edges from the pulses for a second and then reset the counter. Using serial communication with MATLAB, the pulse count is sent to MATLAB every fifth second and is recorded within the MATLAB code. Once the voltage sweep is finished, the two frequencies are plotted against the corresponding DC voltage inputs in MATLAB for comparison and analysis.
Deliverables
MATLAB and Arduino code
Plot of RPM (optical sensor pulse frequency) vs. AWG voltage, with a linear fit to the data
Plot of RPM (using the counter approach) vs. AWG voltage, with a linear fit to the data
Plot of combined graphs for comparison
Results