Light Sensors

Light Sensors:

PIC_ReadAllAmbientSensors(); PIC_ReadAllAmbientSensors(); //retrieves reading for all 3 ambient light sensors. Accurate to within 20ms ago. Populates the following global variables: ambLeft, ambRight, ambRear

.

PIC_ReadAllSurfaceSensors(); PIC_ReadAllSurfaceSensors(); //retrieves reading for all 6 surface sensors. Accurate to within 20ms ago. Populates the following global variables: surfLeft0, surfLeft1, surfRight0, surfRight1, surfRear0, surfRear1

.

PIC_ReadAllAmbientSensorsInstant(); PIC_ReadAllAmbientSensorsInstant(); //retrieves instant reading for all 3 ambient light sensors. Populates the following global variables: ambLeft, ambRight, ambRear This function pauses PIC for a short moment to take a new instant reading of the sensors and reply with the values. Use this function if an instant reading is really necessary. In most cases, a reading that is between 1ms and 20ms old is okay. In that case, you should generally use the normal function PIC_ReadAllAmbientSensors instead.

.

PIC_ReadAllSurfaceSensorsInstant(); PIC_ReadAllSurfaceSensorsInstant(); //retrieves instant reading for all 6 surface sensors. Populates the following global variables: surfLeft0, surfLeft1, surfRight0, surfRight1, surfRear0, surfRear1 This function pauses PIC for a short moment to take a new instant reading of the sensors and reply with the values. Use this function if an instant reading is really necessary. In most cases, a reading that is between 1ms and 20ms old is okay. In that case, you should generally use the normal function PIC_ReadAllSurfaceSensors instead.

.

PIC_ReadAllAmbientAverages(); PIC_ReadAllAmbientAverages(); //retrieves running average for all 3 amb light sensors. Populates the following global variables: ambLeftAverage, ambRightAverage, ambRearAverage

.

PIC_ReadAllSurfaceAverages(); PIC_ReadAllSurfaceAverages(); //retrieves running average for all 6 surface sensors. Populates the following global variables: surfLeft0Average, surfLeft1Average, surfRight0Average, surfRight1Average, surfRear0Average, surfRear1Average

.

PIC_SetAverageIntervals(); PIC_AvgIntervalSurface = 6; //Average surface every 6th 20ms period. PIC_AvgIntervalAmbient = 6; //Average ambient every 6th 20ms period. PIC_SetAverageIntervals(); //Sets average intervals to PIC processor. The PIC processor automatically calculates a running average based a given count of 8 previous readings. Set the global variables PIC_AvgIntervalSurface and PIC_AvgIntervalAmbient first, then call PIC_SetAverageIntervals(); to latch the values to PIC processor. A reading will be taken every n'th 20ms period, and averaged in with the previous readings taken at n'th 20ms periods. Setting the interval to a lower level will make the average change more quickly. Values can range from 1 to 255 periods. Note: This function also latches the global variable PIC_AvgIntervalPower at the same time, which controls a similar average for battery voltage and current consumption averages.

Last updated