Functions which handle the wheel encoders. More...
Modules | |
Advanced informations | |
Enumerations | |
enum | eEncoderSelectMask |
clusters bit masks for the requests of the encoders More... | |
enum | eEncoderGet |
clusters select values for reading data from the encoders More... | |
Functions | |
void | encoders_clear (void) |
Clears the encoder values. More... | |
Request Funktions | |
void | encoders_request (eEncoderSelectMask bitmask, eRequestType request) |
Requests new data from the encoders. More... | |
eEncoderSelectMask | encoders_received (eEncoderSelectMask bitmask) |
Indicates if new data for the selected data blocks were received. More... | |
eEncoderSelectMask | encoders_changed (eEncoderSelectMask bitmask) |
Indicates if new data changed the selected data blocks. More... | |
Access Funktions | |
int32_t | encoders_get (eEncoderGet select) |
Returns the last stored version of the selected value. More... | |
Functions which handle the wheel encoders.
The encoders are part of the driving module. All actions, like reading their current value or reseting them, involve internal TWI communication. This may take some milliseconds (delay time).
After requesting kEncoderSelectAbs the encoder values can be regularly read with encoders_get().
In a similar way the speed of the wheels can be measured by requesting kEncoderSelectSpeed. The speed of the wheels is calculated within the drive module of the TUC-Bot. In order to allow the maximum possible precision, there are two ways of doing that:
The clearing of the encoder values is done by calling encoders_clear(). The last stored values can be read afterwards with encoders_get().
snippets
example
enum eEncoderGet |
clusters select values for reading data from the encoders
enum eEncoderSelectMask |
clusters bit masks for the requests of the encoders
Enumerator | |
---|---|
kEncoderSelectNone | bit mask (0x00): select no data block |
kEncoderSelectAbs | bit mask (0x01): select absolute encoder values (32-bit) |
kEncoderSelectSpeed | bit mask (0x02): select wheel speed in ticks per second |
kEncoderSelectAll | bit mask (0x03): select all data blocks (except for clear) |
eEncoderSelectMask encoders_changed | ( | eEncoderSelectMask | bitmask | ) |
Indicates if new data changed the selected data blocks.
bitmask | bit mask of the selected data blocks - see also eEncoderSelectMask The parameter is used to only return the value of the masked changed-bits. All other values(bits) are set to 0. |
void encoders_clear | ( | void | ) |
Clears the encoder values.
This function waits until the encoder values within the drive module were cleared.
The last values of the encoders, before clearing, are stored in data block sMD_EncoderClear and can be read afterwards with encoders_get():
Involved data blocks are:
sMD_EncoderClear
int32_t encoders_get | ( | eEncoderGet | select | ) |
Returns the last stored version of the selected value.
This function relies on the internal data blocks sMD_Encoder, sMD_SpeedRaw and sMD_EncoderClear - for new data use encoders_request() or encoders_clear().
select | value of the selected data - see also eEncoderGet |
select | decription | result |
kEncoderGetLeft kEncoderGetRight | current encoder value in ticks | 32-bit |
kEncoderGetSpeedLeft kEncoderGetSpeedRight | current encoder speed in ticks/s | 16-bit |
kEncoderGetClearedLeft kEncoderGetClearedRight | last encoder value before reset in ticks | 16-bit |
eEncoderSelectMask encoders_received | ( | eEncoderSelectMask | bitmask | ) |
Indicates if new data for the selected data blocks were received.
bitmask | bit mask of the selected data blocks - see also eEncoderSelectMask The parameter is used to only return the value of the masked received-bits. All other values(bits) are set to 0. |
void encoders_request | ( | eEncoderSelectMask | bitmask, |
eRequestType | request | ||
) |
Requests new data from the encoders.
For details on the request schema see The general request.
Involved data blocks are:
sMD_Encoder and sMD_SpeedRaw
bitmask | bit mask of the selected data blocks - see also eEncoderSelectMask |
request | See also eRequestType |