Functions
motor.h File Reference

Motor Outputs. More...

Functions

void motor_init (void)
void motor_set_vel (uint8_t motor, int16_t vel)
int16_t motor_get_vel (uint8_t motor)
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 motor_set_vel() again will disable the brake state.

Parameters:
motorMotor port to brake.
uint16_t motor_get_current ( uint8_t  motor)

Read the current in a given motor.

Parameters:
motorMotor 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:
motorMotor to sense current of.
Returns:
the current of motor 'motor', in milliamps.
int16_t motor_get_vel ( uint8_t  motor)

gets the current motor vel since the last time motor_set_vel was called. Without set_vel called, this returns 0

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:
motorMotor port to set.
velVelocity to set motor 'motor'.