Modules | Enumerations

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...
 

Detailed Description

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

/*******************************************************************************
* examples/lineSimple.c *
* ===================== *
* *
* Version: 1.0.5 *
* Date : 07.11.17 *
* Author : Peter Weissig *
*******************************************************************************/
//*********************************<Included files>*****************************
#include <tucbot/tucbot.h>
//*********************************<Methods>************************************
void testLine(void);
int main(void);
//*********************************[testLine]***********************************
void testLine(void) {
lcdclr();
lcdstr_p(PSTR("Line" ));
lcdxy(0,1);
lcdstr_p(PSTR("### ### ###"));
while (1) {
lcdxy( 0,1);
lcdxy( 6,1);
lcdxy(13,1);
mdelay(250);
}
}
}
//*********************************[main]***************************************
int main (void) {
init_tucbot(0xFF);
testLine();
return (0);
}

Enumeration Type Documentation

◆ eLineDigitalMask

clusters bit masks for the digital state of the line sensors

See also
line_get()
Enumerator
kLineDigitalNone 

bit mask (0x00): no line sensor

kLineDigitalFrontLeft 

bit mask (0x01): front left line sensor

kLineDigitalFrontMiddle 

bit mask (0x02): front middle line sensor

kLineDigitalFrontRight 

bit mask (0x04): front right line sensor

kLineDigitalMiddleLeft 

bit mask (0x08): middle left line sensor

kLineDigitalMiddleRight 

bit mask (0x10): middle right line sensor

kLineDigitalAll 

bit mask (0x18): all line sensor

◆ eLineEnableMask

clusters bit masks for the enable-flags of the line sensors

See also
line_get() and line_set()
Enumerator
kLineEnableNone 

bit mask (0x00): enable no line sensors

kLineEnableFront 

bit mask (0x01): enable front line sensors

kLineEnableMiddle 

bit mask (0x02): enable middle line sensors

kLineEnableAll 

bit mask (0x03): enable all line sensors

◆ eLineGet

enum eLineGet

clusters select values for reading data from the line sensors

See also
line_get() and eLineSet
Enumerator
kLineGetFrontLeft 

constant (1): front left line sensor

kLineGetFrontMiddle 

constant (2): front middle line sensor

kLineGetFrontRight 

constant (3): front right line sensor

kLineGetMiddleLeft 

constant (4): middle left line sensor

kLineGetMiddleRight 

constant (5): middle right line sensor

kLineGetDigital 

constant (6): bitfield of all line sensor

kLineGetEnable 

constant (7): bitfield of enabled line sensor groups

kLineGetThreshold 

constant (8): theshold value for converting to digital bitfield

◆ eLineSelectMask

clusters bit masks for the requests of the line sensors

See also
line_request(), line_received() and line_changed()
Enumerator
kLineSelectNone 

bit mask (0x00): select no data block

kLineSelectFront 

bit mask (0x01): select the front line sensors
see also sMD_SensLineF

kLineSelectMiddle 

bit mask (0x02): select the middle line sensors
see also sMD_SensLineM

kLineSelectDigital 

bit mask (0x04): select the digital line sensors
see also sMD_SensLineD

kLineSelectEnable 

bit mask (0x08): select the enable flags and treshold value
see also sMD_SensLineEnable
only this data block can also be transmitted

kLineSelectAll 

bit mask (0x0F): select all data blocks

◆ eLineSet

enum eLineSet

clusters select values for writing data to the line sensors

See also
line_set() and eLineGet
Enumerator
kLineSetEnable 

constant (kLineGetEnable): bitfield of enabled line sensor groups

kLineSetThreshold 

constant (kLineGetThreshold): theshold value for converting to digital bitfield

Function Documentation

◆ line_changed()

eLineSelectMask line_changed ( eLineSelectMask  bitmask)

Indicates if new data changed the selected data blocks.

Parameters
bitmaskbit 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.
Returns
bitfield of the selected data blocks - see also eLineSelectMask
If a data block is changed its related bit will be 1, otherwise 0.
If only one data block is selected the return value can be interpreted as a boolean expression.
See also
line_received(), line_request(), line_get()
Examples
lineComplex.c, and lineSimple.c.

◆ line_get()

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().

Parameters
selectvalue of the selected data - see also eLineGet
Returns
8-bit unsigned integer
select description result
kLineGetFront...
kLineGetMiddle...
analog measurement 0..255
kLineGetThreshold threshold for analog measurement 0..255
kLineGetDigital bitfield eLineDigitalMask
kLineGetEnable bitfield eLineEnableMask
See also
line_request() and line_set()
Examples
lineComplex.c, and lineSimple.c.

◆ line_received()

eLineSelectMask line_received ( eLineSelectMask  bitmask)

Indicates if new data for the selected data blocks were received.

Parameters
bitmaskbit 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.
Returns
bitfield of the selected data blocks - see also eLineSelectMask
If a data block is received its related bit will be 1, otherwise 0.
If only one data block is selected the return value can be interpreted as a boolean expression.
See also
line_changed(), line_request(), line_get()
Examples
lineComplex.c.

◆ line_request()

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

Parameters
bitmaskbit mask of the selected data blocks - see also eLineSelectMask
requestSee also eRequestType
See also
line_get()
Examples
lineComplex.c, and lineSimple.c.

◆ line_set()

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.

Parameters
selectvalue of the selected data - see also eLineSet
value8-bit unsigned integer
value to be stored within the selected data
select decription value
kLineSetThreshold threshold for analog measurement 0..255
kLineSetEnable bitfield eLineEnableMask
See also
line_transmitted() and line_get()
Examples
lineComplex.c, and lineSimple.c.

◆ line_transmitted()

uint8_t line_transmitted ( void  )

Indicates if the data block sMD_SensLineEnable was transmitted.

The return value is boolean.

Returns
8-bit unsigned integer which is a boolean value
See also
line_set()
kLineEnableFront
@ kLineEnableFront
bit mask (0x01): enable front line sensors
Definition: line.h:53
line_request
void line_request(eLineSelectMask bitmask, eRequestType request)
Requests new data from the line sensors.
kLineGetFrontMiddle
@ kLineGetFrontMiddle
constant (2): front middle line sensor
Definition: line.h:147
kLineGetFrontLeft
@ kLineGetFrontLeft
constant (1): front left line sensor
Definition: line.h:145
line_get
uint8_t line_get(eLineGet select)
Returns the last stored version of the selected value.
kRequestContinuous
@ kRequestContinuous
constant (3): request continuous updates
Definition: update.h:37
kLineSetEnable
@ kLineSetEnable
constant (kLineGetEnable): bitfield of enabled line sensor groups
Definition: line.h:169
uint16tostr
void uint16tostr(void *out, uint16_t number, uint8_t digits)
Converts an unsigned integer to a string and passes it to an output function.
lcdclr
void lcdclr(void)
Clears the display.
line_changed
eLineSelectMask line_changed(eLineSelectMask bitmask)
Indicates if new data changed the selected data blocks.
lcdxy
void lcdxy(uint8_t x, uint8_t y)
Moves the cursor to a postion on the display.
kLineGetFrontRight
@ kLineGetFrontRight
constant (3): front right line sensor
Definition: line.h:149
lcdstr_p
void lcdstr_p(const char *send_data)
Writes a string located in the flash to the display.
lcdout
void lcdout(uint8_t data)
Writes one byte to the display.
init_tucbot
void init_tucbot(uint8_t enable_interrupts)
Initiates the TUC-Bot.
mdelay
void mdelay(uint16_t mseconds)
Waits for the given time in milliseconds.
line_set
void line_set(eLineSet select, uint8_t value)
Sets the selected values of the line sensors.
kLineSelectFront
@ kLineSelectFront
Definition: line.h:122