Project 3: Pulse-Width Modulation and Proportional-Derivative Control

Project Goals

At the end of this project, you should be able to:


Project Components

All components are required to receive full credit for the project.

Part 1: Microcontroller Circuit

The current amplifier board is composed of two full H-Bridge circuits. We will be using one full H-Bridge to control the middle fan (allowing us to control rotation speed and direction). We will split the other H-Bridge into two "Half Bridges": one for each of the left and right fans. This will allow us to control speed of these two fans, but not direction.

The board and connections to your circuit are documented on the Lab Hardware page: see the Motor Control Board section.

Connect the current amplifier board to your three fans and to motor power:

Connect the current amplifier board to your Atmel chip (the 15 pin connector on one side of the board):

Part 2: Fan Control Interface

Note: this part will count for a total of one personal programming credit

Create the function interface that will generate the PWM signals for each of the three PWM inputs to the motor control board.

Define four macros at the top of your C file (or in a private header file):

#define BRAKE 0
#define HOVER 1
#define LEFT 1
#define RIGHT 0

These strings can be used in place of the integers and make your code much more readable.

Implement the following functions:

Note:

Testing

Implement the following functions:

Modify your main function such that it executes one of the two above functions, depending on the initial state of switch 0.

Part 3: Proportional Derivative Control

Note: this part will count for one personal programming credit

Create a function that will implement a proportional-derivative controller:

void pd_control(int16_t error, int16_t rotation_rate, uint16_t forward_thrust) where error is the heading error, rotation_rate is the rate of craft rotation, and forward_thrust is the total forward thrust that should be generated by the left/right fans combined (this latter value will be between 0 ... 1023)

This function will:

Note: you are strongly encouraged to use integer math instead of floating point math.

Notes on tuning the PD control parameters:

Part 4: Obstacle Avoidance Control

Note: this part will count for one half of a personal programming credit

Create a function that will implement an obstacle avoidance controller:

int8_t obstacle_control(uint16_t distance_left, unt16_t distance_right, int16_t rotation_rate, uint16_t forward_thrust) distance_left and distance_right are the distances (in mm) to the nearest obstacle for the left and right sensors, rotation_rate is the rate of craft rotation, and forward_thrust is the total forward thrust that should be generated by the left/right fans combined (this latter value will be between 0 ... 1023)

This function will do the following:

Part 5: High-Level Control

Note: this part will count for one personal programming credit

For this part, you will implement a high-level control loop that will cycle once every 50 ms. For each of these control steps, the hovercraft will first steer away from obstacles (while moving forward). If there are no obstacles, then the hovercraft will steer toward the goal heading (also, moving forward).

Part 6: Hovercraft Layout

Revisit the mounting of your components on the Frisbees: Let us know if you need any additional components for mounting.


References


What to Hand In

All components of the project are due by Wednesday, April 20th at 5:00pm.


Grading

Group grade distribution:

Grades for individuals will be based on the group grade, but weighted by the assessed contributions of the group members.


fagg [[at]] cs.ou.edu

Last modified: Sat Apr 23 22:32:54 2011