AME 3623: Project 4
- All components of the project are due by Friday, March 15th
at 11:59 pm.
- Groups are the same as for project 1.
- Discussion within groups is fine.
- Discussion across groups may not be about the specifics of the
solution (general programming/circuit issues are fine to
discuss).
At the end of this project, you should be able to:
- through low-level functions, control the speed and direction of DC motors through an H-bridge circuit, and
- use a high-level program to test the functionality of the DC motor control interface.
Component 1: Microcontroller Circuit
You will receive two current amplifier boards for this project. Each
current amplifier board is composed of two full H-Bridge circuits.
We will be using one full H-Bridge to control each of the three lateral fans on
board your hovercraft.
The detailed documentation for the motor control board can be found on the
Pololu Web site.
Below is a picture of the H-Bridge board:
Motor/Power Connections
Add wires to connect the motor control board to the fans and to the
batteries:
- Connect GND and VIN (right side of the board) directly to the thick power cables
(not to your 5V power supply provided by the Teensy board!!!). There is one
pair of black/red cables for each board. Make sure
you do this without the batteries plugged in, and have
someone else check your connections before you apply power.
Note: you may need to use a wire stripper to remove the
insulation from these power wires. Remove 1/4 inch of
insulation and twist the strands of the wire together. Insert
the cables into the screw terminal on the side and tighten the
corresponding screw. Once you are done, you must have no
exposed wire; if it is necessary, trim down the length of
your exposed wire and re-connect.
- Each ducted fan has a pair of wires routed to the upper deck.
Connect each of the fans to their corresponding OUT A/B screw
terminals. Because these are brushed motors, the choice of
which wire connects to which of A or B is arbitrary.
H-Bridge Control Connections
Connect the H-Bridge boards to your Teensy chip (the 15 pin
connector on the left side of the board):
- Connect GND and GND to your Teensy's ground
- Connect +5V to the hovercraft +5V supply
- Connect PWM to a Teensy pin that generates PWM output
- INa and INb: connect each H-Bridge to a pair of Teensy
pins on the same digital I/O port (different H-Bridges
can use different ports)
Component 2
Add the following declarations at the top of your program:
// Promise that we will implement this function later
void fsm_step();
// Create a task that will be executed once per 50 ms
PeriodicAction fsm_task(50, fsm_step);
// Gains to be used for reverse thrust
const float FAN_GAIN[] = {1.0, 1.0, 1.0}
Implement your loop() function in this way:
void loop()
{
// Check to see if it is time to execute the fsm_task
fsm_task.step();
}
With this implementation, you will ensure that the function
fsm_task() is called once every 50ms
Component 3
Create the function interface that will generate the direction and
PWM signals for each of the inputs to the motor control board.
Implement the following functions:
- float clip(float value, float min_value, float max_value) that returns
- min_value if value is smaller than min_value
- max_value if value is larger than max_value
- value otherwise
- void set_lateral_fan_magnitudes(float magnitudes[3]) that sets the thrust magnitude for the
lateral fans (the order in the array is LEFT, RIGHT and BACK).
- This function must
ensure that each of the input magnitudes fall
within the range of -127... 127. If any do not, then
the offending value
should be clipped to this range. These values correspond to a
duty cycle of 50%.
- Positive values must correspond to pushing air through
the duct in the "correct" direction; negative values
correspond to pulling air through the duct in the
atypical direction.
- If a negative value is specified for fan i, then the
magnitude should be multiplied by FAN_GAIN[i]. Adjust
the values of FAN_GAIN to achieve approximately the same
thrust in the positive and negative directions (this
will be hard to assess for this project, so take your
best guess and we will readjust later).
PWM Interface
Use the following Arduino function to set the duty cycle of a PWM pin:
analogWrite(pin, duty);
where pin is an Arduino pin index and duty is an
integer value in the range 0 ... 255 (though we are limiting the allowable
range for our fans).
Component 4
Implement a Finite State Machine in fsm_step() that does the following:
- If your switch is pressed, initiate the following sequence:
- Slowly ramp the left fan up to a duty cycle of 25%
- Slowly ramp the left fan down to a duty cycle of -25%
- Slowly ramp the left fan back to zero
- Repeat for the back, then right fan
- Once complete, then your FSM should return to waiting for the switched to be pressed.
Finite State Machine notes:
What to Hand In
- Code: Check your documented code into your
group subversion tree for project 4.
This is due by Friday, March 15th at 11:59pm.
- Demonstration/Code Review: All group
members must be present. This must be completed by Tuesday, March 26th.
- Personal report: there is no personal report for this project.
Grading
-
Personal programming credit: this project offers one programming credit.
-
Group grade distribution:
- 35%: Project implementation
- 30%: Demonstration of working project (to either
of the TA or the instructor)
- 35%: Code documentation
-
Group Grading Rubric
-
Grades for individuals will be based on the group grade, but weighted
by the assessed contributions of the group members to the non-personal programming items.
andrewhfagg -- gmail.com
Last modified: Wed Mar 27 10:55:58 2019