|
Files | |
file | MSLL-driver.h |
Mindsensors Line Tracking Sensor. | |
Defines | |
#define | LL_I2C_ADDR 0x02 |
#define | LL_CMD_REG 0x41 |
#define | LL_SETPOINT 0x45 |
#define | LL_KP_VALUE 0x46 |
#define | LL_KI_VALUE 0X47 |
#define | LL_KD_VALUE 0X48 |
#define | LL_KP_FACTOR 0x61 |
#define | LL_KI_FACTOR 0X62 |
#define | LL_KD_FACTOR 0X63 |
#define | LL_READ_STEERING 0x42 |
#define | LL_READ_AVERAGE 0X43 |
#define | LL_READ_RESULT 0X44 |
#define | LL_SENSOR_RAW 0X49 |
#define | LL_WHITE_LIMIT 0X51 |
#define | LL_BLACK_LIMIT 0X59 |
#define | LL_SENSOR_UNCAL 0x74 |
Functions | |
bool | LLinit (tSensors link) |
bool | LLwakeUp (tSensors link) |
bool | LLsleep (tSensors link) |
bool | LLinvertLineColor (tSensors link) |
bool | LLresetLineColor (tSensors link) |
bool | LLtakeSnapshot (tSensors link) |
bool | LLcalWhite (tSensors link) |
bool | LLcalBlack (tSensors link) |
bool | LLsetPoint (tSensors link, ubyte data) |
int | LLsetPoint (tSensors link) |
bool | LLsetKp (tSensors link, ubyte data, ubyte factor) |
int | LLreadKp (tSensors link) |
int | LLreadKpFactor (tSensors link) |
bool | LLsetKi (tSensors link, ubyte data, ubyte factor) |
int | LLreadKi (tSensors link) |
int | LLreadKiFactor (tSensors link) |
bool | LLsetKd (tSensors link, ubyte data, ubyte factor) |
int | LLreadKd (tSensors link) |
int | LLreadKdFactor (tSensors link) |
int | LLreadSteering (tSensors link) |
int | LLreadAverage (tSensors link) |
int | LLreadResult (tSensors link) |
bool | LLreadSensorRaw (tSensors link, tByteArray &pMsg) |
bool | LLreadSensorUncalibrated (tSensors link, tIntArray &sensorValues) |
bool | LLreadWhiteThresh (tSensors link, tByteArray &pMsg) |
bool | LLreadBlackThresh (tSensors link, tByteArray &pMsg) |
bool | _lineLeader_cmd (tSensors link, ubyte cmd) |
bool | _lineLeader_write (tSensors link, ubyte regToWrite, ubyte data) |
bool | _lineLeader_read (tSensors link, ubyte regToRead, ubyte &retval) |
bool | _lineLeader_read (tSensors link, ubyte regToRead, int numBytes, tByteArray &pDataMsg) |
Variables | |
tByteArray | LL_I2CRequest |
tByteArray | LL_I2CReply |
ubyte | oneByte |
LineLeader Sensor
#define LL_BLACK_LIMIT 0X59 |
ubyte array (8) with raw value of black calibration for each sensor
Definition at line 68 of file MSLL-driver.h.
#define LL_CMD_REG 0x41 |
Register used for issuing commands
Definition at line 53 of file MSLL-driver.h.
#define LL_I2C_ADDR 0x02 |
I2C address used by the LL
Definition at line 52 of file MSLL-driver.h.
#define LL_KD_FACTOR 0X63 |
D factor for D value of PID control
Definition at line 61 of file MSLL-driver.h.
#define LL_KD_VALUE 0X48 |
D value of PID control
Definition at line 58 of file MSLL-driver.h.
#define LL_KI_FACTOR 0X62 |
I factor for I value of PID control
Definition at line 60 of file MSLL-driver.h.
#define LL_KI_VALUE 0X47 |
I value of PID control
Definition at line 57 of file MSLL-driver.h.
#define LL_KP_FACTOR 0x61 |
P factor for P value of PID control
Definition at line 59 of file MSLL-driver.h.
#define LL_KP_VALUE 0x46 |
P value of PID control
Definition at line 56 of file MSLL-driver.h.
#define LL_READ_AVERAGE 0X43 |
weighted average value for all sensors in array
Definition at line 64 of file MSLL-driver.h.
#define LL_READ_RESULT 0X44 |
1 or 0 for line or no line for all 8 sensors
Definition at line 65 of file MSLL-driver.h.
#define LL_READ_STEERING 0x42 |
steering value for simple mode line following
Definition at line 63 of file MSLL-driver.h.
#define LL_SENSOR_RAW 0X49 |
ubyte array (8) with raw value for each sensor
Definition at line 66 of file MSLL-driver.h.
#define LL_SENSOR_UNCAL 0x74 |
ubyte array (16) with uncalibrated sensor data
Definition at line 69 of file MSLL-driver.h.
#define LL_SETPOINT 0x45 |
average value considered center of line (def=45)
Definition at line 55 of file MSLL-driver.h.
#define LL_WHITE_LIMIT 0X51 |
ubyte array (8) with raw value of white calibration for each sensor
Definition at line 67 of file MSLL-driver.h.
bool _lineLeader_cmd | ( | tSensors | link, |
ubyte | cmd | ||
) |
Send a command to the Line Leader
This function sends a command to the lineleader over I2C.
Note: this is an internal function and should not be called directly.
link | the sensor port number |
cmd | the command to be sent |
PRELIMINARY COMMANDS FROM NXC LIB CODE
Definition at line 144 of file MSLL-driver.h.
bool _lineLeader_read | ( | tSensors | link, |
ubyte | regToRead, | ||
ubyte & | retval | ||
) |
Read one ubyte from a Line Leader Register
This function reads one ubyte from a register in the LL sensor over I2C.
Note: this is an internal function and should not be called directly.
link | the sensor port number |
regToRead | the register to read from |
retval | the ubyte in which to store the reply |
Definition at line 187 of file MSLL-driver.h.
bool _lineLeader_read | ( | tSensors | link, |
ubyte | regToRead, | ||
int | numBytes, | ||
tByteArray & | pDataMsg | ||
) |
Read data from a Line Leader Register
This function reads multiple bytes from a register in the LL sensor over I2C.
Note: this is an internal function and should not be called directly.
link | the sensor port number |
regToRead | the register to read from |
numBytes | the number of bytes to read |
pDataMsg | tByteArray to store reply |
Definition at line 214 of file MSLL-driver.h.
bool _lineLeader_write | ( | tSensors | link, |
ubyte | regToWrite, | ||
ubyte | data | ||
) |
Write to a Line Leader Register
This function writes data to a register in the LL sensor over I2C.
Note: this is an internal function and should not be called directly.
link | the sensor port number |
regToWrite | the register to write to |
data | the value to write to the register |
Definition at line 164 of file MSLL-driver.h.
bool LLcalBlack | ( | tSensors | link ) |
Set black threshold for dark area
This function calibrates the black threshold for each sensor in the array. Place the array over the white surface with all sensors on the black area. Execute this command to set black values internally.
link | the sensor port number |
Definition at line 337 of file MSLL-driver.h.
bool LLcalWhite | ( | tSensors | link ) |
Set white threshold for light area
This function calibrates the white threshold for each sensor in the array. Place the array over the white surface with all sensors on the white area. Execute this command to set white values internally.
link | the sensor port number |
Definition at line 323 of file MSLL-driver.h.
bool LLinit | ( | tSensors | link ) |
Set up Line Leader sensor type
This function initializes the line leader to prepare for use. Issuing a command also wakes the line leader as needed.
link | the sensor port number |
Definition at line 241 of file MSLL-driver.h.
bool LLinvertLineColor | ( | tSensors | link ) |
Inverts detected line color
the function toggles from dark line on light to light line on dark and back.
link | the sensor port number |
Definition at line 282 of file MSLL-driver.h.
int LLreadAverage | ( | tSensors | link ) |
Read weighted sensor array average value
Read the Weighted "Average" value from the sensor. This value is calculated internally by the sensor where each of the eight sensors is either triggered or not and multiplied by a a factor to help determine if the line is left, right or on center of the line (according to the set point).
EXPECTED VALUES: 0-80 (-1=ERROR)
SENSOR: 0 1 2 3 4 5 6 7 MULTIPLIER: 10 20 30 40 50 60 70 80
FORMULA: Sum(Weighted Values)/Number sensors on line
Ex. if sensor 0 and 1 are over a line, the average is:
(10 + 20 + 0 + 0 + 0 + 0 + 0 + 0)/2 = 15
in this case 30 < 45 (set point) so the bot is left of center
link | the sensor port number |
Definition at line 552 of file MSLL-driver.h.
bool LLreadBlackThresh | ( | tSensors | link, |
tByteArray & | pMsg | ||
) |
Return array of black thresholds (8 bytes)
Read the "Black Threshold" values from the Line Leader for each sensor.
Each of the eight sensors has a value. Raw values less then this threshold equal black (line).
The values are set when calibrating the black points for the sensor.
link | the sensor port number |
&pMsg | is 8 bytes returned. One for each sensor with Threshold. |
Definition at line 635 of file MSLL-driver.h.
int LLreadKd | ( | tSensors | link ) |
READ Kd value
Read the "Kd" value from the sensor.
link | the sensor port number |
Definition at line 503 of file MSLL-driver.h.
int LLreadKdFactor | ( | tSensors | link ) |
READ d factor value
Read the "Kd factor" value from the sensor.
link | the sensor port number |
Definition at line 514 of file MSLL-driver.h.
int LLreadKi | ( | tSensors | link ) |
READ Ki value
Read the "Ki" value from the sensor.
link | the sensor port number |
Definition at line 459 of file MSLL-driver.h.
int LLreadKiFactor | ( | tSensors | link ) |
READ i factor value
Read the "Ki factor" value from the sensor.
link | the sensor port number |
Definition at line 470 of file MSLL-driver.h.
int LLreadKp | ( | tSensors | link ) |
READ Kp value
Read the "Kp" value from the sensor.
link | the sensor port number |
Definition at line 415 of file MSLL-driver.h.
int LLreadKpFactor | ( | tSensors | link ) |
READ p factor value
Read the "Kp factor" value from the sensor.
link | the sensor port number |
Definition at line 426 of file MSLL-driver.h.
int LLreadResult | ( | tSensors | link ) |
Read boolean sensor array values for all sensors
Read a ubyte with each bit equal to a sensor.
1 = Line
0 = No Line
SENSOR: 0 1 2 3 4 5 6 7 MULTIPLIER: 1 2 4 8 16 32 64 128
To determine if a given sensor is over a line or not, use binary math to test each bit.
A returned value of 3 means sensor 0 and 1 are over a line.
link | the sensor port number |
Definition at line 572 of file MSLL-driver.h.
bool LLreadSensorRaw | ( | tSensors | link, |
tByteArray & | pMsg | ||
) |
Return array of raw light values (8 bytes)
Read the "Raw Sensor" values from the Line Leader. Amount of light or dark each sensor sees. Typically between 0-20. 0=black, 100=white
link | the sensor port number |
&pMsg | is 8 bytes returned. One for each sensor with raw value. |
Definition at line 585 of file MSLL-driver.h.
bool LLreadSensorUncalibrated | ( | tSensors | link, |
tIntArray & | sensorValues | ||
) |
Return array of raw uncalibrated light values (8 ints)
Read the uncalibrated sensor values from the Line Leader. Each sensor returns a 16 bit value.
link | the sensor port number |
sensorValues | is 8 bytes returned. One for each sensor with raw value. |
Definition at line 597 of file MSLL-driver.h.
int LLreadSteering | ( | tSensors | link ) |
Read internally calculated steering value
Read the "Steering" value from the sensor. This value is calculated internally and can directly be used to set turning values for the robot's motors.
EXPECTED VALUES: -100 to 100 (-101=ERROR)
link | the sensor port number (range: -100 to 100) |
Definition at line 529 of file MSLL-driver.h.
bool LLreadWhiteThresh | ( | tSensors | link, |
tByteArray & | pMsg | ||
) |
Return array of white thresholds (8 bytes)
Read the "White Threshold" values from the Line Leader for each sensor.
Each of the eight sensors has a value. Raw values greater then this threshold equal white (area).
The values are set when calibrating the white points for the sensor.
link | the sensor port number |
&pMsg | is 8 bytes returned. One for each sensor with Threshold. |
Definition at line 621 of file MSLL-driver.h.
bool LLresetLineColor | ( | tSensors | link ) |
Resets line color to dark on light bkgrnd
the function resets to default of sensing a dark line on light background
link | the sensor port number |
Definition at line 294 of file MSLL-driver.h.
bool LLsetKd | ( | tSensors | link, |
ubyte | data, | ||
ubyte | factor | ||
) |
WRITE Kd value
Set the "Kd" value for the sensor's internal PID calculations.
This value is usually set lower to stabilize default 8/32
EXPECTED VALUES: 0 to 255
DEFAULT VALUE: 8
EXPECTED VALUES: 1 to 255
DEFAULT FACTOR: 32
link | the sensor port number |
data | - the value to set Kd |
factor | - the Kd factor where d = Kd/Kdfactor |
Definition at line 490 of file MSLL-driver.h.
bool LLsetKi | ( | tSensors | link, |
ubyte | data, | ||
ubyte | factor | ||
) |
WRITE Ki value
Set the "Ki" value for the sensor's internal PID calculations.
This value is usually set close to 0 default 0/1
EXPECTED VALUES: 0 to 255
DEFAULT VALUE: 0
EXPECTED FACTORS: 1 to 255
DEFAULT FACTOR: 1
link | the sensor port number |
data | - the value to set Ki |
factor | - the Ki factor where i = Ki/Kifactor |
Definition at line 446 of file MSLL-driver.h.
bool LLsetKp | ( | tSensors | link, |
ubyte | data, | ||
ubyte | factor | ||
) |
WRITE Kp value
Set the "Kp" value for the sensor's internal PID calculations.
This value is usually set close to 1.0 default 25/32
EXPECTED VALUES: 0 to 255
DEFAULT VALUE: 25
EXPECTED FACTORS: 1 to 255
DEFAULT FACTOR: 32
link | the sensor port number |
data | - the value to set Kp |
factor | - the Kp factor where p = Kp/Kpfactor |
Definition at line 402 of file MSLL-driver.h.
int LLsetPoint | ( | tSensors | link ) |
READ SetPoint value
This function reads the setpoint value from the sensor
link | the sensor port number |
Definition at line 362 of file MSLL-driver.h.
bool LLsetPoint | ( | tSensors | link, |
ubyte | data | ||
) |
WRITE mid-point or center of line value
The set point is used by internally (or externally) by the sensor to determine the middle of the sensor over a line. This value is compared to the average value to help the robot know if it is left or right of center.
link | the sensor port number |
data | - the value to set the set point to |
Definition at line 352 of file MSLL-driver.h.
bool LLsleep | ( | tSensors | link ) |
Sleep to conserve power when not in use
This function puts the line leader to sleep conserve power.
link | the sensor port number |
Definition at line 270 of file MSLL-driver.h.
bool LLtakeSnapshot | ( | tSensors | link ) |
takes a snapshot to determine line color
This function takes a snapshot of the line under the sensor and tracks that position in subsequent tracking operations. Also this function will set inversion if it sees white line on dark background
link | the sensor port number |
Definition at line 309 of file MSLL-driver.h.
bool LLwakeUp | ( | tSensors | link ) |
Wake sensor from sleep mode
This function wakes the line leader to prepare for use. Issuing a command also wakes the line leader as needed.
link | the sensor port number |
Definition at line 258 of file MSLL-driver.h.
Array to hold I2C reply data
Definition at line 72 of file MSLL-driver.h.
Array to hold I2C command data
Definition at line 71 of file MSLL-driver.h.
ubyte oneByte |
Definition at line 73 of file MSLL-driver.h.