Topic outline
- General
- Dynamics/Mechatronics/Controls
Dynamics/Mechatronics/Controls
---------Day 1--------
Day 1 Resources
Video recording of first lecture
In Class:
- 2 V P-P sine wave, 1 KHz frequency, 1.5 V DC Bias
- Before leaving: Display above sine wave on oscilloscope and have checked by TA or Professor
- Recording of lab experiment is posted below
HW: (due Day 2)
Plot (in MATLAB) the following on the same figure (2 full cycles):
- 2V P-P Sine wave, 1.5V DC Bias, 1KHz (same signal as used in class)- Plot "continuous" signal (is this even possible? can you approximate?)
- Same wave as above using a discrete sample time of 20KHz
Title, with name, label axes, include a legend
Also print your code (and make sure you can access it during lab)
Staple and bring to class
---------Day 2--------
In Class (do the following one at a time moving on after each works):
*Do not build the circuit until you are doing the challenge
- Run Blink demo on Teensy (be sure to select Teensy 3.1/3.2 as board type under tools before uploading)
- Look at standard AnalogWrite on pin 9 (File->Examples->Basics->Fade)
- View on scope and measure with multi-meter
- Try adding to void Setup():
analogWriteFrequency(9, 50000);
Next add analogWriteResolution(12); to void Setup() of the fade demo
What happens to the signal on the scope and multi-meter? Are we still getting voltages from 0-3.3V? What do you need to change to fix it?
Create 2 kHz low pass filter shown in circuit diagram below, look at fade before and after the resistor using the scope. Compare with the multimeter
Using this circuit do the following challenge (if you want, should help clarify things)
Challenge: Can you modify the code to create the 1KHz, 2V P-P, 1.5V DC Bias wave on the scope?
- Note: For the challenge you will need to write your own code (from scratch). Try to convert the equation for a sine wave in continuous time (used in MATLAB for the HW) into Arduino. Lookup the command to find the current time in uS in Arduino. Calculate what the voltage should be for any given time. Convert this into a desired PWM value then output using analogWrite. Use the low pass filter to view the output on the oscilloscope.
- Run Blink demo on Teensy (be sure to select Teensy 3.1/3.2 as board type under tools before uploading)
---------Day 3--------
Lecture 3
In Class:
- KEEN Linear Motor Model Exercise
- Look at motor signal on the scope
- Keep plugged into power supply and very voltage using knobs
- Build circuit below and verify that it stays below ~5V on scope BEFORE attaching Teensy
- Use Frequency Measure to collect data needed to model motor using excel worksheet below
- File->Examples->Frequency Measure->Serial_Output
- More info about how it works can be viewed at the link below
- Note that you will need to select Serial port and set Baud rate on serial monitor (it will be the largest COM port number)
- Collect data at ~1KHz via serial using Teensy and Motor for a 10V step input
- Modify the Frequency Measure example such that it outputs to the serial window every piece of data (remove the averaging) and the current time (so it should be Time (tab) Speed)
- Step input means start unplugged from power supply, plug in until full speed is reached, then unplug again
- Plot and label the response curve in MATLAB (rads/sec vs time)
- Hint: you can copy and paste from serial window to a MATLAB array
- Add plot of voltage input vs time to MATLAB plot
- Add plot of estimated speed for 10V using your w = KV from the worksheet (should be a straight line)
- How/where does the response curve differ from the model we created earlier (w=KV)?
- Think about this difference when you are going through the Michigan tutorials
Experiment 3
HW:
- Go through University of Michigan Tutorials:
- Motor Modeling
- Motor Analysis (Open-loop response and LTI Characteristics)
---------Day 4--------
No Class:
Watch video lecture of equation derivation below
- Prepare for interview on Tuesday
Homework:
- Review UMich and Parameter Estimation videos
- Prepare for Interviews on Tuesday
- Start working on Planning Report
Interview Topics:
- Microcontroller information discussed
- DC Motor linear and differential models
- Experimental procedure (we've done the majority of it already)
- Parameter identification using Simulink and procedure (watch the video)
- Other topics identified on the planning report guidelines
---------Days 5 & 6--------
Perform the experiment using the Simulink model below.
- Collect the step response for 5 different voltages
- Check your units for K and R
- In the constrain section (see the video) you can set the range for K and R based on your initial measurements/experiments
- You should have 5 separate experiments imported into the Parameter Estimation tool
- Use Voltages for step inputs > 5 Volts
- Follow the same procedure used to generate the plot (to create time and data arrays for each test)
- Be sure your data is padded with 0 volts before step
- Remove data from after the step (i.e. motor slowing)
- Time units should be seconds, speed in radians per second
- Have at least 1 second of padding (i.e. no speed) and 2-3 seconds at steady state for each experiment
- Record your constants
- Evaluate the error between model and experimental results
- There are numerous resources on the internet to help you...Google it!
Simulink Tutorial Video
---------Lab 2 Resources--------
Watch Build it Bigger clip from minute 30:55 to 37:09
How to enter your motor parameters to Simulink Model:
- View->Model Explorer->Model Explorer
- Expand Lab_2_... in the Model Hierarchy on left
- Select Model Workspace
- Update values in MATLAB code box on right to the values for your motor (1st experiment)
- Select Reinitialize from source
---------Lab 2 Things to Consider--------
- DO NOT WIRE 12 VOLTS TO THE BREADBOARD OR TEENSY! ONLY PUT 12 VOLTS INTO THE H-BRIDGE 12 VOLT IN
- Both the Teensy code and Simulink model calculate speed as radians/second. Your target spec is given in linear speed. You can update both systems to output speeds in inches/second so you don't need to manually convert
- Play with the no controller Simulink model before attempting to tune controller
- Be sure to update the model parameters (see above)
- Tune your controller before implementing on your crane (so you can figure out how many gears and pulley etc.)
- Play with varying loading situations
- Remember that the motor cannot draw more than 12 volts (so there is a limit to the load it can lift)
- Test your wiring of the h-bridge and motor in open loop first (use simple code like fade or fading that should cause the motor to speed up/slow down) (you will need to set the LED pin to match the pin you wired the H-Bridge to)
- Test your control algorithms on just the motor before integrating into the crane
- You may end up only needing a PI controller so tune accordingly in Simulink and only update the Kp and Ki values in the Teensy code