Reference firmware for PixArt's PAA5101 sensor and evaluation board. "Hello World" and "Library" contain the exact same files. Please import just one of the two into your mBed compiler as a new program and not as a library.
Welcome to the code repository for PixArt's PAA5101 sensor and evaluation board.
For general information about this product, please visit this product's components page here:
https://os.mbed.com/components/PAA5101-Floor-Tracking-Sensor-with-Wide-/
For guides and tips on how to setup and evaluate the PAA5101 sensor with the Nordic nRF52-DK microcontroller using this reference code, please visit this guide:
https://os.mbed.com/teams/PixArt/code/5101_referenceCode/wiki/Guide-for-nRF52-DK-Platform
For guides and tips on how to setup and evaluate the PAA5101 sensor with any microcontroller using this reference code, please visit this guide:
https://os.mbed.com/teams/PixArt/code/5101_referenceCode/wiki/Guide-for-Any-Platform
Revision 1:469063631a05, committed 2018-05-01
- Comitter:
- PixArtVY
- Date:
- Tue May 01 22:45:34 2018 +0000
- Parent:
- 0:2c144b6813d1
- Child:
- 2:045cc9f995ae
- Commit message:
- Changed image quality algorithm.
Changed in this revision
| commHeaders/SPIcommFunctions.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/commHeaders/SPIcommFunctions.h Mon Mar 19 21:18:40 2018 +0000
+++ b/commHeaders/SPIcommFunctions.h Tue May 01 22:45:34 2018 +0000
@@ -12,7 +12,7 @@
//=========================================================================
int16_t deltaX = 0; //Stores X-axis output data.
int16_t deltaY = 0; //Stores Y-axis output data.
-
+int16_t totalX, totalY = 0; //Stores the total deltaX and deltaY moved during runtime.
uint8_t frameCounter = 0; //Looping variable to track when we have grabbed 8 frames of data.
uint16_t imageQuality[8]; //Stores 8 frames of image data to determine when quality changes to a point where we need to switch modes (LED/laser).
uint16_t imageQuality_total = 0; //Stores the sum of all raw values from the 8 frames from imageQuality[8].
@@ -117,48 +117,30 @@
imageQuality_total = imageQuality_total + imageQuality[i];
}
- if(imageQualityOK == 0 && imageQuality_total > LED2laser_threshold) //If imageQuality is over 0x500, we can continue to select the proper mode.
+ if(mode == 1 && imageQuality_total < LED2laser_threshold) //Check the condition for when we need to change to laser.
{
- imageQualityOK = 1;
+ load(modeLaser, modeLaser_size); //Loads the register array that has the settings for laser mode.
+ mode = 0; //Sets the mode-tracker to be 0 to reflect laser mode.
+ LDP = 0; //Sets the laser diode GPIO pin to be LOW (active because of PMOS pull-up).
+ wait_ms(40); //Delay for timing.
+ writeRegister(0x03, 0x00); //Unlisted...
- }
-
- if(mode == 0 && imageQuality_total < LED2laser_threshold) //If image quality is too low even with brighter laser setting, LED/laser states will keep oscillating and sensor can't function.
- {
- imageQualityOK = 0;
- pc.printf("Image quality too low! Value: %4X\n\r", imageQuality_total);
+ //pc.printf("Image Quality: %4X\n\r", imageQuality_total);
+ //pc.printf("Now in laser mode. Value of 'mode': %1X\n\r", mode);
+ //Uncomment these lines and the other print lines below for debugging. Prints image quality and tracks mode-switches.
}
-
- if(imageQualityOK)
+ if(mode == 0 && imageQuality_total < laser2LED_threshold) //Check the condition for when we need to change to LED.
{
- pc.printf("Image quality OK! Value: %4X\n\r", imageQuality_total);
+ load(modeLED, modeLED_size); //Loads the register array that has the settings for LED mode.
+ mode = 1; //Sets the mode-tracker to be 1 to reflect LED mode.
+ LDP = 1; //Sets the laser diode GPIO pin to be HIGH (inactive because of PMOS pull-up).
+ wait_ms(40); //Delay for timing.
+ writeRegister(0x03, 0x00); //Unlisted...
- if(mode == 1 && imageQuality_total < LED2laser_threshold) //Check the condition for when we need to change to laser.
- {
- load(modeLaser, modeLaser_size); //Loads the register array that has the settings for laser mode.
- mode = 0; //Sets the mode-tracker to be 0 to reflect laser mode.
- LDP = 0; //Sets the laser diode GPIO pin to be LOW (active because of PMOS pull-up).
- wait_ms(40); //Delay for timing.
- writeRegister(0x03, 0x00); //Delta_XL?????? TRY TO FIND OUT WHAT THIS REGISTER IS FOR**********************************************************
-
- //pc.printf("Image Quality: %4X\n\r", imageQuality_total);
- //pc.printf("Now in laser mode. Value of 'mode': %1X\n\r", mode);
- //Uncomment these lines and the other print lines below for debugging. Prints image quality and tracks mode-switches.
- }
-
- if(mode == 0 && imageQuality_total < laser2LED_threshold) //Check the condition for when we need to change to LED.
- {
- load(modeLED, modeLED_size); //Loads the register array that has the settings for LED mode.
- mode = 1; //Sets the mode-tracker to be 1 to reflect LED mode.
- LDP = 1; //Sets the laser diode GPIO pin to be HIGH (inactive because of PMOS pull-up).
- wait_ms(40); //Delay for timing.
- writeRegister(0x03, 0x00); //Delta_XL?????? TRY TO FIND OUT WHAT THIS REGISTER IS FOR**********************************************************
-
- //pc.printf("Image Quality: %4X\n\r", imageQuality_total);
- //pc.printf("Now in LED mode. Value of 'mode': %1X\n\r", mode);
- //Uncomment these lines and the other print lines above for debugging. Prints image quality and tracks mode-switches.
- }
+ //pc.printf("Image Quality: %4X\n\r", imageQuality_total);
+ //pc.printf("Now in LED mode. Value of 'mode': %1X\n\r", mode);
+ //Uncomment these lines and the other print lines above for debugging. Prints image quality and tracks mode-switches.
}
}
@@ -187,7 +169,11 @@
{
if((deltaX != 0) || (deltaY != 0)) //If there is deltaX or deltaY movement, print the data.
{
- pc.printf("deltaX: %d\t\t\tdeltaY: %d\n\r", deltaX, deltaY);
+ totalX += deltaX;
+ totalY += deltaY;
+
+ pc.printf("deltaX: %d\t\t\tdeltaY: %d\n\r", deltaX, deltaY); //Prints each individual count of deltaX and deltaY.
+ pc.printf("X-axis Counts: %d\t\tY-axis Counts: %d\n\r", totalX, totalY); //Prints the total movement made during runtime.
}
deltaX = 0; //Resets deltaX and Y values to zero, otherwise previous data is stored until overwritten.
PAA5101 | Floor Tracking Sensor with Wide Surface Variety Coverage