INF2004-Project v0.1
 
Loading...
Searching...
No Matches
wheel_encoder.h File Reference

Header file for the wheel encoder drivers. More...

#include "pico/stdlib.h"
Include dependency graph for wheel_encoder.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  wheel_encoder
 Struct to store global encoder data. More...
 

Macros

#define WHEEL_ENC_CYCLE_PULSE   20
 Number of encoder pulses per 1 full rotation.
 
#define WHEEL_ENC_DIST_PER_PULSE   (204.203f / 20.0f)
 Distance travelled per encoder tick in mm.
 
#define WHEEL_ENC_SEC_TO_MSEC   1000.0f
 Conversion from seconds to milliseconds.
 

Typedefs

typedef struct wheel_encoder wheel_encoder_t
 Struct to store global encoder data. More...
 

Functions

float wheel_enc_get_speed (float time_elapsed, bool is_pulse)
 Get the speed in either pulses/second or mm/second. More...
 
float wheel_enc_get_time_diff (uint64_t current_time, uint64_t prev_time)
 Get the time difference in ms. More...
 

Detailed Description

Header file for the wheel encoder drivers.

Author
Bryan Seah
Version
0.1
Date
2023-11-26

Typedef Documentation

◆ wheel_encoder_t

Struct to store global encoder data.

Function Documentation

◆ wheel_enc_get_speed()

float wheel_enc_get_speed ( float  time_elapsed,
bool  is_pulse 
)

Get the speed in either pulses/second or mm/second.

Parameters
[in]time_elapsedTime elapsed in ms
[in]is_pulseTrue if speed is in pulses/second, false if speed is in mm/second
Returns
float Speed in either pulses/second or mm/second

References WHEEL_ENC_DIST_PER_PULSE, and WHEEL_ENC_SEC_TO_MSEC.

◆ wheel_enc_get_time_diff()

float wheel_enc_get_time_diff ( uint64_t  current_time,
uint64_t  prev_time 
)

Get the time difference in ms.

Parameters
[in]current_timeCurrent time in us
[in]prev_timePrevious time in us
Returns
float Time difference in ms

References WHEEL_ENC_SEC_TO_MSEC.