MOTORS

The Motors Module is programmed to handle all events that involve motor actuation. Functions included in this module include helping to initialize the motors, changing the motor speed, setting the SWAG motor, and stopping the motors when needed.

Click here to see the hardware setup of the Motors

Click here to see and download the complete Motors.h module

Click here to see and download the complete Motors.c module

Public Level Functions:

Function: InitMotors(void)
Description: Performs any initialization necessary for all motors to run.
Input: None
Output: None
Psuedocode: Initialize PWM subsystem

Function: ChangeMotorSpeed(unsigned char speed_port)
Description: Based on an analog input (i.e. potentiometer), changes speed of a motor specified by the port that will govern that speed
Input: unsigned char speed_port, the port to read input from
Output: None
Psuedocode: Read and store AD pin of the speed port
Calculate duty cycle based on linearized range between max and min duty cycle

Function: DispenseSWAG(unsigned int timer_number)
Description: Pulses the SWAG motor for a set amount of time. Assumes timer12 module has already been initialized
Input: unsigned int timer_number to be used to time
Output: None
Psuedocode: Initialize timer for desired lenght of SWAG motor pulse
While timer is not expired
Set SWAG motor duty cycle to desired "on" level
End Loop
Set SWAG motor duty cycle to 0

Function: EndMotors(void)
Description: Stop the target motors at the end of the game
Input: None
Output: None
Psuedocode: Set target motor duty cycles to 0