Hi TI,
while trying to change the code for sending pattern sequences to also support variable exposure times we encountered a validation problem that we do not know the reason for.
The validation status returns 2 which we interpreted as BIT1 as in the documentation of DLPC350_CheckPatLutValidate. There it says: "Selected pattern numbers in LUT are invalid".
What does this mean? Our pattern numbers are correct since we can use the code below, which, however, does not yet send the variable exposure pattern LUT. When using the DLPC350_SendVarExpPatLut() command instead of DLPC350_SendPatLut() we receive the validation status described above.
So this problem seems to be related only to the function DLPC350_SendVarExpPatLut(). But since it doesn't take any arguments we assume, that we are configuring something wrong in the other commands used to setup the pattern LUT.
#include "hidapi-master\hidapi\hidapi.h" #include "dlpc350_common.h" #include "dlpc350_usb.h" #include "dlpc350_api.h" #include "dlpc350_error.h" #include <chrono> #include <thread> #include <iostream> #include <sstream> using namespace std; const unsigned int PAT_PAUSE = 1; const unsigned int PAT_STOP = 0; const unsigned int PAT_START = 2; const unsigned int PWR_ON = false; const unsigned int PWR_STANDBY = true; const unsigned int MODE_VID = false; const unsigned int MODE_PAT = true; const unsigned int DISP_MODE_RGB = true; const unsigned int DISP_MODE_FLASH = false; int SendPatternSequence(unsigned int *status, const char imageIndex, const int patternNumbers [], const int numberOfPatterns, const int bitDepth, const int triggerMode, const int exposureTime, const bool repeat, const bool refreshPattern) { if(DLPC350_SetMode(MODE_PAT) < 0) return -3; if(DLPC350_PatternDisplay(PAT_STOP) < 0) return -4; if(DLPC350_SetPatternDisplayMode(DISP_MODE_FLASH) < 0) return -5; if(DLPC350_SetPatternTriggerMode(1) < 0) return -6; DLPC350_ClearPatLut(); const int exposure = exposureTime; // µs const int refreshExposure = 100000000; const int numberOfImages = 1; unsigned char imageIndices[1]; imageIndices[0] = imageIndex; //if(DLPC350_SetExposure_FramePeriod(exposure, exposure) < 0) return -7; //if(DLPC350_SetPatternConfig(numberOfPatterns, repeat, numberOfPatterns, numberOfImages) < 0) return -8; if (DLPC350_SetVarExpPatternConfig(numberOfPatterns, numberOfPatterns, numberOfImages, repeat) < 0) return -8; for (int i = 0; i < numberOfPatterns; i++) { //if(DLPC350_AddToPatLut(triggerMode, patternNumbers[i], bitDepth, 0, false, false, (i == 0?true:false), false) < 0) return -9*(i + 1); if(DLPC350_AddToExpLut(triggerMode, patternNumbers[i], bitDepth, 0, false, false, (i == 0 ? true : false), false, exposure, exposure)) return -9 * (i + 1); } if(refreshPattern) if (DLPC350_AddToExpLut(triggerMode, patternNumbers[0], bitDepth, 0, false, true, false, false, refreshExposure, refreshExposure)) return -20; //if(DLPC350_SendImageLut(imageIndices, numberOfImages) < 0) return -10; if (DLPC350_SendVarExpImageLut(imageIndices, numberOfImages) < 0) return -10; if (DLPC350_SendPatLut() < 0) return -11; //if (DLPC350_SendVarExpPatLut() < 0) return -11; <-- if we use this command, we get the error if(DLPC350_ValidatePatLutData(status) < 0) return -11; if(DLPC350_PatternDisplay(PAT_START) < 0) return -12; std::cout << "press enter" << std::endl; std::string str; std::getline(std::cin, str); DLPC350_PatternDisplay(PAT_STOP); return 0; } int main(int argc, char *argv[]) { const int triggerMode = 1; // external positive trigger = 1 const int exposureTime = 235; // exposure time of all normal patterns const bool repeat = false; const bool refreshPattern = true; //Adds pattern with long exposure time at the end const int imageIndex = 0x04; const int patternNumbers[] = { 0, 1, 2 }; const int numberOfPatterns = 3; const int bitDepth = 1; DLPC350_USB_Init(); DLPC350_USB_Open(); bool ret_connect = DLPC350_USB_IsConnected(); if (!ret_connect) { return -1; } unsigned int status; // stores status of pattern sequence validation int ret = SendPatternSequence((unsigned int *)&status, imageIndex, patternNumbers, numberOfPatterns, bitDepth, triggerMode, exposureTime, repeat, refreshPattern); std::cout << "Function return = " << ret << "; Pattern validation status = " << status << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(3000)); DLPC350_USB_Close(); }
Regards,
Robert