![]() |
MSPM0_ValvanoWare
1.0
ECE445L starter code
|
RSLK sensors and Actuators. More...
Files | |
| file | BNO085.h |
| Interfacing the BNO085 IMU. | |
| file | Bump.h |
| RSLK Bumper switches. | |
| file | Motor.h |
| RSLK dual H-bridge driver. | |
| file | MotorControl.h |
| RSLK PI motor controller. | |
| file | Tachometer.h |
| RSLK tachometer. | |
| file | TFLuna1.h |
| Initialize TFLuna1, interrupt synchronization. | |
| file | TFLuna2.h |
| Initialize TFLuna2, interrupt synchronization. | |
| file | TFLuna3.h |
| Initialize TFLuna3, interrupt synchronization. | |
Macros | |
| #define | MOTOR_PERIOD 10000 |
| #define | MOTORMIN 2 |
| #define | MOTORMAX (MOTOR_PERIOD-2) |
| #define | DUMPSIZE 200 |
| DUMPSIZE is the size of the dump buffer. | |
Functions | |
| void | BNO085_Reset (uint32_t time) |
| Reset the BNO085. More... | |
| void | BNO085_Init (void(*function)(int16_t data[6])) |
| Initialize 9-DOF BNO085 IMU. More... | |
| void | Bump_Init (void) |
| Initialize bump switches. More... | |
| uint32_t | Bump_In (void) |
| Read bump switches. More... | |
| void | Motor_Init (void) |
| Initialize motors. More... | |
| void | Motor_Forward (uint32_t dutyLeft, uint32_t dutyRight) |
| Go forward. More... | |
| void | Motor_Backward (uint32_t dutyLeft, uint32_t dutyRight) |
| Go backward. More... | |
| void | Motor_Right (uint32_t dutyLeft, uint32_t dutyRight) |
| Turn right. More... | |
| void | Motor_Left (uint32_t dutyLeft, uint32_t dutyRight) |
| Turn left. More... | |
| void | MC_Init (void) |
| Initialize tach input and motor outputs. More... | |
| void | MC_PIControlLoop (void) |
| PI controller. More... | |
| void | MC_SetDesiredSpeed (uint32_t newSpeed) |
| Set desired speed. More... | |
| uint32_t | MC_GetDesiredSpeed (void) |
| Get desired speed. More... | |
| void | MC_SetKp1 (int32_t kp1) |
| Set numerator for proportial control. More... | |
| void | MC_SetKp2 (int32_t kp2) |
| Set denominator for proportial control. More... | |
| void | MC_SetKi1 (int32_t ki1) |
| Set numerator for integral control. More... | |
| void | MC_SetKi2 (int32_t ki2) |
| Set denominator for integral control. More... | |
| int32_t | MC_GetKp1 (void) |
| Get numerator for proportial control. More... | |
| int32_t | MC_GetKp2 (void) |
| Get denominator for proportial control. More... | |
| int32_t | MC_GetKi1 (void) |
| Get numerator for integral control. More... | |
| int32_t | MC_GetKi2 (void) |
| Get denominator for integral control. More... | |
| int32_t | MC_GetLeftE (void) |
| Get controller error on left. More... | |
| int32_t | MC_GetRightE (void) |
| Get controller error on right. More... | |
| int32_t | MC_GetLeftU (void) |
| Get controller actuator output on left. More... | |
| int32_t | MC_GetRightU (void) |
| Get controller actuator output on right. More... | |
| uint32_t | MC_Time (void) |
| Get controller time. More... | |
| uint32_t * | MC_DumpRight (void) |
| Get right speed log. More... | |
| uint32_t * | MC_DumpLeft (void) |
| Get left speed log. More... | |
| void | Tachometer_CheckForStopped (void) |
| Check for stopped motors. More... | |
| void | Tachometer_Init (void) |
| Initialize motors. More... | |
| uint32_t | Tachometer_GetRightrpm (void) |
| Right motor speed. More... | |
| uint32_t | Tachometer_GetLeftrpm (void) |
| Left motor speed. More... | |
| void | TFLuna1_Init (void(*function)(uint32_t)) |
| Initialize TFLuna1. More... | |
| void | TFLuna1_Format_Standard_mm (void) |
| mm units More... | |
| void | TFLuna1_Format_Standard_cm (void) |
| cm units More... | |
| void | TFLuna1_Format_Pixhawk (void) |
| Pixhawk. More... | |
| void | TFLuna1_Frame_Rate (void) |
| sampling rate More... | |
| void | TFLuna1_SaveSettings (void) |
| save format and rate More... | |
| void | TFLuna1_System_Reset (void) |
| start measurements More... | |
| void | TFLuna1_Output_Enable (void) |
| enable More... | |
| void | TFLuna1_Output_Disable (void) |
| disable More... | |
| void | TFLuna1_SendMessage (const uint8_t msg[]) |
| output message to TFLuna More... | |
| uint8_t | TFLuna1_InChar (void) |
| uint32_t | TFLuna1_InStatus (void) |
| uint32_t | TFLuna1_OutStatus (void) |
| void | TFLuna1_OutString (uint8_t *pt) |
| output string to TFLuna More... | |
| void | TFLuna1_OutChar (uint8_t data) |
| output character to TFLuna More... | |
| void | TFLuna2_Init (void(*function)(uint32_t)) |
| Initialize TFLuna2. More... | |
| void | TFLuna2_Format_Standard_mm (void) |
| mm units More... | |
| void | TFLuna2_Format_Standard_cm (void) |
| cm units More... | |
| void | TFLuna2_Format_Pixhawk (void) |
| Pixhawk. More... | |
| void | TFLuna2_Frame_Rate (void) |
| sampling rate More... | |
| void | TFLuna2_SaveSettings (void) |
| save format and rate More... | |
| void | TFLuna2_System_Reset (void) |
| start measurements More... | |
| void | TFLuna2_Output_Enable (void) |
| enable More... | |
| void | TFLuna2_Output_Disable (void) |
| disable More... | |
| void | TFLuna2_SendMessage (const uint8_t msg[]) |
| output message to TFLuna2 More... | |
| uint8_t | TFLuna2_InChar (void) |
| uint32_t | TFLuna2_InStatus (void) |
| uint32_t | TFLuna2_OutStatus (void) |
| void | TFLuna2_OutString (uint8_t *pt) |
| output string to TFLuna2 More... | |
| void | TFLuna2_OutChar (uint8_t data) |
| output character to TFLuna2 More... | |
| void | TFLuna3_Init (void(*function)(uint32_t)) |
| Initialize TFLuna3. More... | |
| void | TFLuna3_Format_Standard_mm (void) |
| mm units More... | |
| void | TFLuna3_Format_Standard_cm (void) |
| cm units More... | |
| void | TFLuna3_Format_Pixhawk (void) |
| Pixhawk. More... | |
| void | TFLuna3_Frame_Rate (void) |
| sampling rate More... | |
| void | TFLuna3_SaveSettings (void) |
| save format and rate More... | |
| void | TFLuna3_System_Reset (void) |
| start measurements More... | |
| void | TFLuna3_Output_Enable (void) |
| enable More... | |
| void | TFLuna3_Output_Disable (void) |
| disable More... | |
| void | TFLuna3_SendMessage (const uint8_t msg[]) |
| output message to TFLuna3 More... | |
| uint8_t | TFLuna3_InChar (void) |
| uint32_t | TFLuna3_InStatus (void) |
| uint32_t | TFLuna3_OutStatus (void) |
| void | TFLuna3_OutString (uint8_t *pt) |
| output string to TFLuna3 More... | |
| void | TFLuna3_OutChar (uint8_t data) |
| output character to TFLuna3 More... | |
RSLK sensors and Actuators.
| BNO085 | MSPM0 |
|---|---|
| Vcc | 3.3V Power |
| GND | GND |
| SCL | left not connected |
| SDA | PB13 RxD: is UART3 Rx (BNO085 to MSPM0) baud=115200 bps |
| AD0 | left not connected |
| CS | left not connected |
| INT | left not connected |
| RST | PB12 GPIO output (drive low to reset) |
| PS1 | left not connected (pulled low) |
| PS0 | 3.3V to select UART-RVC mode (there is a solder jumper on back) |
| TM4C | MSPM0 | Description |
|---|---|---|
| PA5 | PA27 | Left, Bump 0, |
| PF0 | PB15 | Center Left, Bump 1, |
| PB3 | PA28 | Center Right, Bump 2 |
| PC4 | PA31 | Right, Bump 3 |
| TM4C | MSPM0 | Description |
|---|---|---|
| PF2 | PB4 | Motor_PWML, ML+, IN3, PB.4/TIMA1_C0; |
| PF3 | PB1 | Motor_PWMR, MR+, IN1, PB.1/TIMA1_C1; |
| PA3 | PB0 | Motor_DIR_L,ML-, IN4, 1 means forward, 0 means backward |
| PA2 | PB16 | Motor_DIR_R,MR-, IN2 |
| TM4C | MSPM0 | Description |
|---|---|---|
| PB7 | PB8 | ELA TA0_C0 |
| PB2 | PB12 | ERA TA0_C1 |
| ERB GPIO input (not connected) | ||
| ELB GPIO input (not connected) |
| TM4C | MSPM0 | Description |
|---|---|---|
| PF2 | PB4 | Motor_PWML, ML+, IN3, PB.4/TIMA1_C0; |
| PF3 | PB1 | Motor_PWMR, MR+, IN1, PB.1/TIMA1_C1; |
| PA3 | PB0 | Motor_DIR_L,ML-, IN4, 1 means forward, 0 means backward |
| PA2 | PB16 | Motor_DIR_R,MR-, IN2 |
| TM4C | MSPM0 | Description |
|---|---|---|
| PB7 | PB8 | ELA TA0_C0 |
| PB2 | PB12 | ERA TA0_C1 |
| ERB GPIO input (not connected) | ||
| ELB GPIO input (not connected) |
| TFLuna Pin | Description |
|---|---|
| 1 | Red 5V |
| 2 | Serial TxD: PA8/PA17/PB4/PB6 is UART1 Tx (MSPM0 to TFLuna1) |
| 3 | Serial RxD: PA9/PA18/PB5/PB7 is UART1 Rx (TFLuna1 to MSPM0) |
| 4 | black ground |
| TFLuna Pin | Description |
|---|---|
| 1 | Red 5V |
| 2 | Serial TxD: PA21/PA23/PB15/PB17 is UART2 Tx (MSPM0 to TFLuna2) |
| 3 | Serial RxD: PA22/PA24/PB16/PB18 is UART2 Rx (TFLuna2 to MSPM0) |
| 4 | black ground |
| TFLuna Pin | Description |
|---|---|
| 1 | Red 5V |
| 2 | Serial TxD: PA14/PA26/PB2/PB12 is UART3 Tx (MSPM0 to TFLuna3) |
| 3 | Serial RxD: PA13/PA25/PB3/PB13 is UART3 Rx (TFLuna3 to MSPM0) |
| 4 | black ground |
| void BNO085_Init | ( | void(*)(int16_t data[6]) | function | ) |
Initialize 9-DOF BNO085 IMU.
Initialize the UART3 for 115,200 baud rate
8 bit word length, no parity bits, one stop bit, FIFO enabled
Callback function will be called at 100 Hz
data[0] Yaw 0.01 deg
data[1] Pitch 0.01 deg
data[2] Roll 0.01 deg
data[3] X-acceleration 0.001g
data[4] Y-acceleration 0.001g
data[5] Z-acceleration 0.001g
| function | pointer to callback function to which is passed an 6-element array |
| void BNO085_Reset | ( | uint32_t | time | ) |
Reset the BNO085.
Reset the 9-DOF BNO085 IMU
RST =0
wait time bus cycles
RST =1
| time | number of bus cycles to hold RST low |
| uint32_t Bump_In | ( | void | ) |
Read bump switches.
Input RSLK bump switches
bit 0 is left
bit 1 is left center
bit 2 is right center
bit 3 is right
| none |
| void Bump_Init | ( | void | ) |
Initialize bump switches.
Initialize RSLK bump switches
| none |
| uint32_t* MC_DumpLeft | ( | void | ) |
Get left speed log.
Get buffer to dumped left speed
| none |
| uint32_t* MC_DumpRight | ( | void | ) |
Get right speed log.
Get buffer to dumped Right speed
| none |
| uint32_t MC_GetDesiredSpeed | ( | void | ) |
Get desired speed.
Get desired speed in 0.1 rpm.
| newSpeed |
| int32_t MC_GetKi1 | ( | void | ) |
Get numerator for integral control.
Get Ki1
| none |
| int32_t MC_GetKi2 | ( | void | ) |
Get denominator for integral control.
Get Ki2
| none |
| int32_t MC_GetKp1 | ( | void | ) |
Get numerator for proportial control.
Get Kp1
| none |
| int32_t MC_GetKp2 | ( | void | ) |
Get denominator for proportial control.
Get Kp2
| none |
| int32_t MC_GetLeftE | ( | void | ) |
Get controller error on left.
Get LeftE
| none |
| int32_t MC_GetLeftU | ( | void | ) |
Get controller actuator output on left.
Get LeftU
| none |
| int32_t MC_GetRightE | ( | void | ) |
Get controller error on right.
Get RightE
| none |
| int32_t MC_GetRightU | ( | void | ) |
Get controller actuator output on right.
Get RightU
| none |
| void MC_Init | ( | void | ) |
Initialize tach input and motor outputs.
Initialize RSLK Controller
| none |
| void MC_PIControlLoop | ( | void | ) |
PI controller.
Run RSLK PI Controller
| none |
| void MC_SetDesiredSpeed | ( | uint32_t | newSpeed | ) |
Set desired speed.
Set desired speed in 0.1 rpm. Robot should move in a straight line
| newSpeed |
| void MC_SetKi1 | ( | int32_t | ki1 | ) |
Set numerator for integral control.
Set Ki1
| ki1 |
| void MC_SetKi2 | ( | int32_t | ki2 | ) |
Set denominator for integral control.
Set Ki2
| ki2 |
| void MC_SetKp1 | ( | int32_t | kp1 | ) |
Set numerator for proportial control.
Set Kp1
| kp1 |
| void MC_SetKp2 | ( | int32_t | kp2 | ) |
Set denominator for proportial control.
Set Kp2
| kp2 |
| uint32_t MC_Time | ( | void | ) |
Get controller time.
Get Time since last change in desired speed, 10 ms
| none |
| void Motor_Backward | ( | uint32_t | dutyLeft, |
| uint32_t | dutyRight | ||
| ) |
Go backward.
Set RSLK motor power backward
| dutyLeft | 2 to 99998 us |
| dutyRight | 2 to 99998 us |
| void Motor_Forward | ( | uint32_t | dutyLeft, |
| uint32_t | dutyRight | ||
| ) |
Go forward.
Set RSLK motor power forward
| dutyLeft | 2 to 99998 us |
| dutyRight | 2 to 99998 us |
| void Motor_Init | ( | void | ) |
Initialize motors.
Initialize RSLK motors
| none |
| void Motor_Left | ( | uint32_t | dutyLeft, |
| uint32_t | dutyRight | ||
| ) |
Turn left.
Set RSLK motor power left turn
Activate right motor forward and left motor backward (pivot)
| dutyLeft | 2 to 99998 us |
| dutyRight | 2 to 99998 us |
| void Motor_Right | ( | uint32_t | dutyLeft, |
| uint32_t | dutyRight | ||
| ) |
Turn right.
Set RSLK motor power right turn
Activate left motor forward and right motor backward (pivot)
| dutyLeft | 2 to 99998 us |
| dutyRight | 2 to 99998 us |
| void Tachometer_CheckForStopped | ( | void | ) |
Check for stopped motors.
Check for stopped motors Higher level software must run this every 10ms
| none |
| uint32_t Tachometer_GetLeftrpm | ( | void | ) |
Left motor speed.
Left motor speed in 0.1 RPM. Does not wait for next measurement, returns with last measurement
| none |
| uint32_t Tachometer_GetRightrpm | ( | void | ) |
Right motor speed.
Right motor speed in 0.1 RPM. Does not wait for next measurement, returns with last measurement
| none |
| void Tachometer_Init | ( | void | ) |
Initialize motors.
Initialize RSLK tachometers, 16-bit, 1us resolution
| none |
| void TFLuna1_Format_Pixhawk | ( | void | ) |
Pixhawk.
Configure TFLuna for Pixhawk
| none |
| void TFLuna1_Format_Standard_cm | ( | void | ) |
cm units
Configure TFLuna for measuring distance in cm
| none |
| void TFLuna1_Format_Standard_mm | ( | void | ) |
mm units
Configure TFLuna for measuring distance in mm
| none |
| void TFLuna1_Frame_Rate | ( | void | ) |
sampling rate
Configure TFLuna sampling rate
rate defined in #define TFLunaRate
| none |
| uint8_t TFLuna1_InChar | ( | void | ) |
Wait for new serial port input
Uses interrupt synchronization
This function waits if the receive software FIFO is empty
| Input | none |
| void TFLuna1_Init | ( | void(*)(uint32_t) | function | ) |
Initialize TFLuna1.
initialize UART1 for 115200 bps baud rate.
to use PA9/PA18/PB5/PB7, for PA9 set jumper J14
interrupt synchronization, priority=1
| function | pointer to a callback function |
| uint32_t TFLuna1_InStatus | ( | void | ) |
Returns how much data available for reading
| none |
| void TFLuna1_OutChar | ( | uint8_t | data | ) |
output character to TFLuna
Output 8-bit to serial port TFLuna
Uses interrupt synchronization
This function waits if the transmit software FIFO is full
| data | is an 8-bit ASCII character to be transferred |
| void TFLuna1_Output_Disable | ( | void | ) |
disable
Disable TFLuna output
| none |
| void TFLuna1_Output_Enable | ( | void | ) |
enable
Enable TFLuna output
| none |
| uint32_t TFLuna1_OutStatus | ( | void | ) |
Returns how many bytes are in the transmission software FIFO
| none |
| void TFLuna1_OutString | ( | uint8_t * | pt | ) |
output string to TFLuna
Output string to serial port TFLuna
Uses interrupt synchronization
This function waits if the transmit software FIFO is full
| pt | pointer to a NULL-terminated string to be transferred |
| void TFLuna1_SaveSettings | ( | void | ) |
save format and rate
execute TFLuna_SaveSettings to activate changes to Format and Frame_Rate
| none |
| void TFLuna1_SendMessage | ( | const uint8_t | msg[] | ) |
output message to TFLuna
Output message to serial port TFLuna
Uses interrupt synchronization
msg[0] is 0x5A for command type
msg[1] is length=n
msg[2] is command
msg[3]-msg[n-2] is optional payload
msg[n-1] is 8-bit checksum
E.g., 0x5A,0x05,0x05,0x06,0x6A sets format to mm
This function waits if the transmit software FIFO is full
| msg | pointer to a message to be transferred |
| void TFLuna1_System_Reset | ( | void | ) |
start measurements
execute TFLuna_System_Reset to start measurements
| none |
| void TFLuna2_Format_Pixhawk | ( | void | ) |
Pixhawk.
Configure TFLuna2 for Pixhawk
| none |
| void TFLuna2_Format_Standard_cm | ( | void | ) |
cm units
Configure TFLuna2 for measuring distance in cm
| none |
| void TFLuna2_Format_Standard_mm | ( | void | ) |
mm units
Configure TFLuna2 for measuring distance in mm
| none |
| void TFLuna2_Frame_Rate | ( | void | ) |
sampling rate
Configure TFLuna2 sampling rate
rate defined in #define TFLunaRate
| none |
| uint8_t TFLuna2_InChar | ( | void | ) |
Wait for new serial port input
Uses interrupt synchronization
This function waits if the receive software FIFO is empty
| Input | none |
| void TFLuna2_Init | ( | void(*)(uint32_t) | function | ) |
Initialize TFLuna2.
initialize UART2 for 115200 bps baud rate.
interrupt synchronization, priority=1
| function | pointer to a callback function |
| uint32_t TFLuna2_InStatus | ( | void | ) |
Returns how much data available for reading
| none |
| void TFLuna2_OutChar | ( | uint8_t | data | ) |
output character to TFLuna2
Output 8-bit to serial port TFLuna2
Uses interrupt synchronization
This function waits if the transmit software FIFO is full
| data | is an 8-bit ASCII character to be transferred |
| void TFLuna2_Output_Disable | ( | void | ) |
disable
Disable TFLuna output
| none |
| void TFLuna2_Output_Enable | ( | void | ) |
enable
Enable TFLuna output
| none |
| uint32_t TFLuna2_OutStatus | ( | void | ) |
Returns how many bytes are in the transmission software FIFO
| none |
| void TFLuna2_OutString | ( | uint8_t * | pt | ) |
output string to TFLuna2
Output string to serial port TFLuna2
Uses interrupt synchronization
This function waits if the transmit software FIFO is full
| pt | pointer to a NULL-terminated string to be transferred |
| void TFLuna2_SaveSettings | ( | void | ) |
save format and rate
execute TFLuna2_SaveSettings to activate changes to Format and Frame_Rate
| none |
| void TFLuna2_SendMessage | ( | const uint8_t | msg[] | ) |
output message to TFLuna2
Output message to serial port TFLuna2
Uses interrupt synchronization
msg[0] is 0x5A for command type
msg[1] is length=n
msg[2] is command
msg[3]-msg[n-2] is optional payload
msg[n-1] is 8-bit checksum
E.g., 0x5A,0x05,0x05,0x06,0x6A sets format to mm
This function waits if the transmit software FIFO is full
| msg | pointer to a message to be transferred |
| void TFLuna2_System_Reset | ( | void | ) |
start measurements
execute TFLuna2_System_Reset to start measurements
| none |
| void TFLuna3_Format_Pixhawk | ( | void | ) |
Pixhawk.
Configure TFLuna3 for Pixhawk
| none |
| void TFLuna3_Format_Standard_cm | ( | void | ) |
cm units
Configure TFLuna3 for measuring distance in cm
| none |
| void TFLuna3_Format_Standard_mm | ( | void | ) |
mm units
Configure TFLuna3 for measuring distance in mm
| none |
| void TFLuna3_Frame_Rate | ( | void | ) |
sampling rate
Configure TFLuna3 sampling rate
rate defined in #define TFLunaRate
| none |
| uint8_t TFLuna3_InChar | ( | void | ) |
Wait for new serial port input
Uses interrupt synchronization
This function waits if the receive software FIFO is empty
| Input | none |
| void TFLuna3_Init | ( | void(*)(uint32_t) | function | ) |
Initialize TFLuna3.
initialize UART3 for 115200 bps baud rate.
interrupt synchronization, priority=1
| function | pointer to a callback function |
| uint32_t TFLuna3_InStatus | ( | void | ) |
Returns how much data available for reading
| none |
| void TFLuna3_OutChar | ( | uint8_t | data | ) |
output character to TFLuna3
Output 8-bit to serial port TFLuna3
Uses interrupt synchronization
This function waits if the transmit software FIFO is full
| data | is an 8-bit ASCII character to be transferred |
| void TFLuna3_Output_Disable | ( | void | ) |
disable
Disable TFLuna3 output
| none |
| void TFLuna3_Output_Enable | ( | void | ) |
enable
Enable TFLuna3 output
| none |
| uint32_t TFLuna3_OutStatus | ( | void | ) |
Returns how many bytes are in the transmission software FIFO
| none |
| void TFLuna3_OutString | ( | uint8_t * | pt | ) |
output string to TFLuna3
Output string to serial port TFLuna3
Uses interrupt synchronization
This function waits if the transmit software FIFO is full
| pt | pointer to a NULL-terminated string to be transferred |
| void TFLuna3_SaveSettings | ( | void | ) |
save format and rate
execute TFLuna3_SaveSettings to activate changes to Format and Frame_Rate
| none |
| void TFLuna3_SendMessage | ( | const uint8_t | msg[] | ) |
output message to TFLuna3
Output message to serial port TFLuna
Uses interrupt synchronization
msg[0] is 0x5A for command type
msg[1] is length=n
msg[2] is command
msg[3]-msg[n-2] is optional payload
msg[n-1] is 8-bit checksum
E.g., 0x5A,0x05,0x05,0x06,0x6A sets format to mm
This function waits if the transmit software FIFO is full
| msg | pointer to a message to be transferred |
| void TFLuna3_System_Reset | ( | void | ) |
start measurements
execute TFLuna3_System_Reset to start measurements
| none |