|
Files | |
file | mindsensors-lightsensorarray.h |
Mindsensors LigthSensorArray. | |
file | mindsensors-lineleader.h |
Mindsensors Line Tracking Sensor. | |
Defines | |
#define | MSLSA_I2C_ADDR 0x14 |
#define | MSLSA_CMD_REG 0x41 |
#define | MSLSA_CALIBRATED 0x42 |
#define | MSLSA_WHITE_LIMIT 0x4A |
#define | MSLSA_BLACK LIMIT 0x52 |
#define | MSLSA_WHITE_CALIB_DATA 0x5A |
#define | MSLSA_BLACK_CALIB_DATA 0x62 |
#define | MSLSA_UNCALIBRATED 0x6A |
#define | MSLSA_CMD_FREQ_US 'A' |
#define | MSLSA_CMD_CALIB_BLACK 'B' |
#define | MSLSA_CMD_POWERDOWN 'D' |
#define | MSLSA_CMD_FREQ_EU 'E' |
#define | MSLSA_CMD_POWERUP 'P' |
#define | MSLSA_CMD_FREQ_UNI 'U' |
#define | MSLDA_CMD_CALIB_WHITE 'W' |
#define | MSLSAwakeUp(X) _MSLSAsendCommand(X, MSLSA_CMD_POWERUP) |
#define | MSLSASleep(X) _MSLSAsendCommand(X, MSLSA_CMD_POWERDOWN) |
#define | MSLSAcalWhite(X) _MSLSAsendCommand(X, MSLDA_CMD_CALIB_WHITE) |
#define | MSLSAcalBlack(X) _MSLSAsendCommand(X, MSLSA_CMD_CALIB_BLACK) |
#define | MSLSAsetEU(X) _MSLSAsendCommand(X, MSLSA_CMD_FREQ_EU) |
#define | MSLSAsetUS(X) _MSLSAsendCommand(X, MSLSA_CMD_FREQ_US) |
#define | MSLSAsetUni(X) _MSLSAsendCommand(X, MSLSA_CMD_FREQ_UNI) |
#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 | MSLSAreadSensors (tSensors link, ubyte *values) |
bool | MSLSAreadRawSensors (tSensors link, int *values) |
bool | _MSLSAsendCommand (tSensors link, ubyte cmd) |
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 | MSLSA_I2CRequest |
tByteArray | MSLSA_I2CReply |
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 69 of file mindsensors-lineleader.h.
#define LL_CMD_REG 0x41 |
Register used for issuing commands
Definition at line 54 of file mindsensors-lineleader.h.
#define LL_I2C_ADDR 0x02 |
I2C address used by the LL
Definition at line 53 of file mindsensors-lineleader.h.
#define LL_KD_FACTOR 0X63 |
D factor for D value of PID control
Definition at line 62 of file mindsensors-lineleader.h.
#define LL_KD_VALUE 0X48 |
D value of PID control
Definition at line 59 of file mindsensors-lineleader.h.
#define LL_KI_FACTOR 0X62 |
I factor for I value of PID control
Definition at line 61 of file mindsensors-lineleader.h.
#define LL_KI_VALUE 0X47 |
I value of PID control
Definition at line 58 of file mindsensors-lineleader.h.
#define LL_KP_FACTOR 0x61 |
P factor for P value of PID control
Definition at line 60 of file mindsensors-lineleader.h.
#define LL_KP_VALUE 0x46 |
P value of PID control
Definition at line 57 of file mindsensors-lineleader.h.
#define LL_READ_AVERAGE 0X43 |
weighted average value for all sensors in array
Definition at line 65 of file mindsensors-lineleader.h.
#define LL_READ_RESULT 0X44 |
1 or 0 for line or no line for all 8 sensors
Definition at line 66 of file mindsensors-lineleader.h.
#define LL_READ_STEERING 0x42 |
steering value for simple mode line following
Definition at line 64 of file mindsensors-lineleader.h.
#define LL_SENSOR_RAW 0X49 |
ubyte array (8) with raw value for each sensor
Definition at line 67 of file mindsensors-lineleader.h.
#define LL_SENSOR_UNCAL 0x74 |
ubyte array (16) with uncalibrated sensor data
Definition at line 70 of file mindsensors-lineleader.h.
#define LL_SETPOINT 0x45 |
average value considered center of line (def=45)
Definition at line 56 of file mindsensors-lineleader.h.
#define LL_WHITE_LIMIT 0X51 |
ubyte array (8) with raw value of white calibration for each sensor
Definition at line 68 of file mindsensors-lineleader.h.
#define MSLDA_CMD_CALIB_WHITE 'W' |
Calibrate white values
Definition at line 56 of file mindsensors-lightsensorarray.h.
#define MSLSA_BLACK LIMIT 0x52 |
Black Reading Limit
Definition at line 45 of file mindsensors-lightsensorarray.h.
#define MSLSA_BLACK_CALIB_DATA 0x62 |
Black Calibration data
Definition at line 47 of file mindsensors-lightsensorarray.h.
#define MSLSA_CALIBRATED 0x42 |
Calibrated Sensor reading
Definition at line 43 of file mindsensors-lightsensorarray.h.
#define MSLSA_CMD_CALIB_BLACK 'B' |
Calibrate black values
Definition at line 51 of file mindsensors-lightsensorarray.h.
#define MSLSA_CMD_FREQ_EU 'E' |
European frequency compensation
Definition at line 53 of file mindsensors-lightsensorarray.h.
#define MSLSA_CMD_FREQ_UNI 'U' |
Universal frequency compensation (default)
Definition at line 55 of file mindsensors-lightsensorarray.h.
#define MSLSA_CMD_FREQ_US 'A' |
American frequency compensation
Definition at line 50 of file mindsensors-lightsensorarray.h.
#define MSLSA_CMD_POWERDOWN 'D' |
Power down the sensor array
Definition at line 52 of file mindsensors-lightsensorarray.h.
#define MSLSA_CMD_POWERUP 'P' |
Power up the sensor array
Definition at line 54 of file mindsensors-lightsensorarray.h.
#define MSLSA_CMD_REG 0x41 |
Register used for issuing commands
Definition at line 41 of file mindsensors-lightsensorarray.h.
#define MSLSA_I2C_ADDR 0x14 |
I2C address used by the MSLSA
Definition at line 40 of file mindsensors-lightsensorarray.h.
#define MSLSA_UNCALIBRATED 0x6A |
Uncalibrated sensor voltage
Definition at line 48 of file mindsensors-lightsensorarray.h.
#define MSLSA_WHITE_CALIB_DATA 0x5A |
White Calibration data
Definition at line 46 of file mindsensors-lightsensorarray.h.
#define MSLSA_WHITE_LIMIT 0x4A |
White Reading Limit
Definition at line 44 of file mindsensors-lightsensorarray.h.
#define MSLSAcalBlack | ( | X ) | _MSLSAsendCommand(X, MSLSA_CMD_CALIB_BLACK) |
Calibrate the black value
Definition at line 64 of file mindsensors-lightsensorarray.h.
#define MSLSAcalWhite | ( | X ) | _MSLSAsendCommand(X, MSLDA_CMD_CALIB_WHITE) |
Calibrate the white value
Definition at line 63 of file mindsensors-lightsensorarray.h.
#define MSLSAsetEU | ( | X ) | _MSLSAsendCommand(X, MSLSA_CMD_FREQ_EU) |
Calibrate the black value
Definition at line 65 of file mindsensors-lightsensorarray.h.
#define MSLSAsetUni | ( | X ) | _MSLSAsendCommand(X, MSLSA_CMD_FREQ_UNI) |
Calibrate the black value
Definition at line 67 of file mindsensors-lightsensorarray.h.
#define MSLSAsetUS | ( | X ) | _MSLSAsendCommand(X, MSLSA_CMD_FREQ_US) |
Calibrate the black value
Definition at line 66 of file mindsensors-lightsensorarray.h.
#define MSLSASleep | ( | X ) | _MSLSAsendCommand(X, MSLSA_CMD_POWERDOWN) |
Put sensor into sleep mode
Definition at line 62 of file mindsensors-lightsensorarray.h.
#define MSLSAwakeUp | ( | X ) | _MSLSAsendCommand(X, MSLSA_CMD_POWERUP) |
Wake sensor from sleep mode
Definition at line 61 of file mindsensors-lightsensorarray.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 145 of file mindsensors-lineleader.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 186 of file mindsensors-lineleader.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 211 of file mindsensors-lineleader.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 165 of file mindsensors-lineleader.h.
bool _MSLSAsendCommand | ( | tSensors | link, |
ubyte | cmd | ||
) |
Send a command to the LightSensorArray
This function sends a command to the lightsensorarray.
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 91 of file mindsensors-lightsensorarray.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 331 of file mindsensors-lineleader.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 317 of file mindsensors-lineleader.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 235 of file mindsensors-lineleader.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 276 of file mindsensors-lineleader.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 546 of file mindsensors-lineleader.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 629 of file mindsensors-lineleader.h.
int LLreadKd | ( | tSensors | link ) |
READ Kd value
Read the "Kd" value from the sensor.
link | the sensor port number |
Definition at line 497 of file mindsensors-lineleader.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 508 of file mindsensors-lineleader.h.
int LLreadKi | ( | tSensors | link ) |
READ Ki value
Read the "Ki" value from the sensor.
link | the sensor port number |
Definition at line 453 of file mindsensors-lineleader.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 464 of file mindsensors-lineleader.h.
int LLreadKp | ( | tSensors | link ) |
READ Kp value
Read the "Kp" value from the sensor.
link | the sensor port number |
Definition at line 409 of file mindsensors-lineleader.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 420 of file mindsensors-lineleader.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 566 of file mindsensors-lineleader.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 579 of file mindsensors-lineleader.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 591 of file mindsensors-lineleader.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 523 of file mindsensors-lineleader.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 615 of file mindsensors-lineleader.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 288 of file mindsensors-lineleader.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 484 of file mindsensors-lineleader.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 440 of file mindsensors-lineleader.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 396 of file mindsensors-lineleader.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 346 of file mindsensors-lineleader.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 356 of file mindsensors-lineleader.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 264 of file mindsensors-lineleader.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 303 of file mindsensors-lineleader.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 252 of file mindsensors-lineleader.h.
bool MSLSAreadRawSensors | ( | tSensors | link, |
int * | values | ||
) |
Return the uncalibrated values from the sensors
link | the Mindsensors LightSensorArray port number |
values | pointer to integer array to hold the uncalibrated sensor values |
Definition at line 132 of file mindsensors-lightsensorarray.h.
bool MSLSAreadSensors | ( | tSensors | link, |
ubyte * | values | ||
) |
Return the calibrated values from the sensors
link | the Mindsensors LightSensorArray port number |
values | pointer to unsigned byte array to hold the sensor values |
Definition at line 107 of file mindsensors-lightsensorarray.h.
Array to hold I2C reply data
Definition at line 73 of file mindsensors-lineleader.h.
Array to hold I2C command data
Definition at line 72 of file mindsensors-lineleader.h.
Array to hold I2C reply data
Definition at line 59 of file mindsensors-lightsensorarray.h.
Array to hold I2C command data
Definition at line 58 of file mindsensors-lightsensorarray.h.
ubyte oneByte |
Definition at line 74 of file mindsensors-lineleader.h.