Functions which handle the line sensors. More...
Modules | |
Advanced informations | |
Enumerations | |
enum | eLineDigitalMask |
clusters bit masks for the digital state of the line sensors More... | |
enum | eLineEnableMask |
clusters bit masks for the enable-flags of the line sensors More... | |
enum | eLineSelectMask |
clusters bit masks for the requests of the line sensors More... | |
enum | eLineGet |
clusters select values for reading data from the line sensors More... | |
enum | eLineSet |
clusters select values for writing data to the line sensors More... | |
Request Funktions | |
void | line_request (eLineSelectMask bitmask, eRequestType request) |
Requests new data from the line sensors. More... | |
eLineSelectMask | line_received (eLineSelectMask bitmask) |
Indicates if new data for the selected data blocks were received. More... | |
eLineSelectMask | line_changed (eLineSelectMask bitmask) |
Indicates if new data changed the selected data blocks. More... | |
uint8_t | line_transmitted (void) |
Indicates if the data block sMD_SensLineEnable was transmitted. More... | |
Access Funktions | |
uint8_t | line_get (eLineGet select) |
Returns the last stored version of the selected value. More... | |
void | line_set (eLineSet select, uint8_t value) |
Sets the selected values of the line sensors. More... | |
Functions which handle the line sensors.
The line sensors are part of the driving module. All actions, like reading their current value or setting them up, involve internal TWI communication. This may take some milliseconds (delay time).
The TUC-Bot has five line sensors. Three in front and two in the middle. The three front sensors are indented for line following tasks, while the other two are designed for maze solving tasks.
The following figure shows a bottom view of the TUC-Bot. The red sensors labeled with number 4 are the line sensors.
The sensors themself are analog and converted using the internal adc. That's why each sensors measurement is an 8-bit number between 0 and 255.
In principle the line sensor are just measuring the brightness. To make them independend of lighting conditions they have their one light source. This additional light is activated using the enable flags.
Any measurement from these sensors need to be requested. To reduce the communication overhead the measurement values can be requested in parts:
As mentioned before the front sensors and the middle sensors are usually used for different applications and must be requested separately.
Typically the single sensor measurements are compared to threshold values. If the threshold for all sensors is the same, the comparing can be done by the driving module. This will reduce each sensor information to a binary number and speeds up communication. This relies to the third way of requesting data. The forth way is dedicated to the readout of the current enable flags and the threshold value.
See also eLineSelectMask.
example
enum eLineDigitalMask |
clusters bit masks for the digital state of the line sensors
enum eLineEnableMask |
clusters bit masks for the enable-flags of the line sensors
enum eLineGet |
clusters select values for reading data from the line sensors
enum eLineSelectMask |
clusters bit masks for the requests of the line sensors
Enumerator | |
---|---|
kLineSelectNone | bit mask (0x00): select no data block |
kLineSelectFront | bit mask (0x01): select the front line sensors |
kLineSelectMiddle | bit mask (0x02): select the middle line sensors |
kLineSelectDigital | bit mask (0x04): select the digital line sensors |
kLineSelectEnable | bit mask (0x08): select the enable flags and treshold value |
kLineSelectAll | bit mask (0x0F): select all data blocks |
enum eLineSet |
clusters select values for writing data to the line sensors
Enumerator | |
---|---|
kLineSetEnable | constant (kLineGetEnable): bitfield of enabled line sensor groups |
kLineSetThreshold | constant (kLineGetThreshold): theshold value for converting to digital bitfield |
eLineSelectMask line_changed | ( | eLineSelectMask | bitmask | ) |
Indicates if new data changed the selected data blocks.
bitmask | bit mask of the selected data blocks - see also eLineSelectMask The parameter is used to only return the value of the masked changed-bits. All other values(bits) are set to 0. |
uint8_t line_get | ( | eLineGet | select | ) |
Returns the last stored version of the selected value.
This function relies on the internal data blocks sMD_SensLineF, sMD_SensLineM, sMD_SensLineD and sMD_SensLineEnable - for new data use line_request().
select | value of the selected data - see also eLineGet |
select | description | result |
kLineGetFront... kLineGetMiddle... | analog measurement | 0..255 |
kLineGetThreshold | threshold for analog measurement | 0..255 |
kLineGetDigital | bitfield | eLineDigitalMask |
kLineGetEnable | bitfield | eLineEnableMask |
eLineSelectMask line_received | ( | eLineSelectMask | bitmask | ) |
Indicates if new data for the selected data blocks were received.
bitmask | bit mask of the selected data blocks - see also eLineSelectMask The parameter is used to only return the value of the masked received-bits. All other values(bits) are set to 0. |
void line_request | ( | eLineSelectMask | bitmask, |
eRequestType | request | ||
) |
Requests new data from the line sensors.
For details on the request schema see The general request.
Involved data blocks are:
sMD_SensLineF, sMD_SensLineM, sMD_SensLineD and sMD_SensLineEnable
bitmask | bit mask of the selected data blocks - see also eLineSelectMask |
request | See also eRequestType |
void line_set | ( | eLineSet | select, |
uint8_t | value | ||
) |
Sets the selected values of the line sensors.
This function changes the internal data block sMD_SensLineEnable.
select | value of the selected data - see also eLineSet | |||||||||
value | 8-bit unsigned integer value to be stored within the selected data
|
uint8_t line_transmitted | ( | void | ) |
Indicates if the data block sMD_SensLineEnable was transmitted.
The return value is boolean.