motor.h File Reference

Motor Outputs. More...


Functions

void motor_init (void)
void motor_set_vel (uint8_t motor, int16_t vel)
void motor_brake (uint8_t motor)
uint16_t motor_get_current (uint8_t motor)
uint16_t motor_get_current_MA (uint8_t motor)

Detailed Description

The happyboard as 6 1.5A Motor drivers with current sensing capabilities. Motors can be set to 3 possible states: drive, coast, or brake.

Each motor port has a current sensor associated with it, allowing the robot to sense the current usage of each motor. Motor current increases proportional to torque and thus can be used to sense when a motor has stalled (driving into a wall, other robots, etc).


Function Documentation

void motor_brake ( uint8_t  motor  ) 

Set a motor to brake (stops the motor as quickly as possible). Calling motorSetVel() again will disable the brake state.

Parameters:
motor Motor port to brake.

uint16_t motor_get_current ( uint8_t  motor  ) 

Read the current in a given motor.

Parameters:
motor Motor to sense current of.
Returns:
the current of motor 'motor'.

uint16_t motor_get_current_MA ( uint8_t  motor  ) 

Read the current in a given motor in milliamps.

Parameters:
motor Motor to sense current of.
Returns:
the current of motor 'motor', in milliamps.

void motor_init ( void   ) 

Initialize motors. Should not be called by user.

void motor_set_vel ( uint8_t  motor,
int16_t  vel 
)

Set the motor velocity of a specific motor. The sign of 'vel' determines direction. A value of 0 sets the motor to coast.

Parameters:
motor Motor port to set.
vel Velocity to set motor 'motor'.