MBot Software Library  v1.0
An API documentation to mbot_firmware repository
Macros | Typedefs | Enumerations | Enumerator | Functions
Motor

functions to control motor operations More...

Collaboration diagram for Motor:

Macros

#define PWM_SLICES   8
 

Typedefs

typedef enum mbot_motor_state mbot_motor_state
 
typedef enum mbot_motor_pins mbot_motor_pins
 

Enumerations

enum  mbot_motor_state { OFF , ON }
 
enum  mbot_motor_pins {
  M0_EN = M0_PWM_PIN , M0_PH = M0_DIR_PIN , M1_EN = M1_PWM_PIN , M1_PH = M1_DIR_PIN ,
  M2_EN = M2_PWM_PIN , M2_PH = M2_DIR_PIN , M3_EN = M3_PWM_PIN , M3_PH = M3_DIR_PIN
}
 

Functions

int mbot_motor_init_freq (uint8_t ch, uint16_t freq)
 Initialize motor with specific frequency. More...
 
void mbot_motor_adc_init ()
 Initialize ADC3 to read motor driver voltage. Must be called before mbot_motor_read_voltage.
 
int mbot_motor_init (uint8_t ch)
 Initialize motor with default frequency. More...
 
int mbot_motor_cleanup (uint8_t ch)
 Cleanup motor settings. More...
 
int mbot_motor_set_duty (uint8_t ch, float duty)
 Set duty cycle for the motor using an int16_t value. More...
 
float mbot_motor_read_voltage ()
 Returns voltage for motor driver read from ADC3 on Pico+ boards. More...
 

Detailed Description

functions to control motor operations

<mbot/motor/motor.h>

Function Documentation

◆ mbot_motor_cleanup()

int mbot_motor_cleanup ( uint8_t  ch)

Cleanup motor settings.

Parameters
chChannel number of the motor
Returns
int Returns MBOT_OK on success, MBOT_ERROR on failure

◆ mbot_motor_init()

int mbot_motor_init ( uint8_t  ch)

Initialize motor with default frequency.

Parameters
chChannel number of the motor
Returns
int Returns MBOT_OK on success, MBOT_ERROR on failure

◆ mbot_motor_init_freq()

int mbot_motor_init_freq ( uint8_t  ch,
uint16_t  freq 
)

Initialize motor with specific frequency.

Parameters
chChannel number of the motor
freqFrequency to set for the PWM slice
Returns
int Returns MBOT_OK on success, MBOT_ERROR on failure

◆ mbot_motor_read_voltage()

float mbot_motor_read_voltage ( )

Returns voltage for motor driver read from ADC3 on Pico+ boards.

Returns
float motor driver voltage in volts

◆ mbot_motor_set_duty()

int mbot_motor_set_duty ( uint8_t  ch,
float  duty 
)

Set duty cycle for the motor using an int16_t value.

Parameters
chChannel number of the motor
dutyDuty cycle value to set
Returns
int Returns MBOT_OK on success, MBOT_ERROR on failure

Set duty cycle for the motor using a float value

Parameters
chChannel number of the motor
dutyDuty cycle value to set
Returns
int Returns MBOT_OK on success, MBOT_ERROR on failure