Other Parts Discussed in Thread: DLP7000
Tool/software:
I am experiencing an analogous problem as i cannot load not even the simplest test pattern on the DMD using the function LoadData. Am i misinterpreting anything?
#include <iostream>
#include "D4100_usb.h" // Include your header file for USB functions
#include <cstring> // Per memset
#include <chrono>
#include <thread>
using namespace std;
using namespace USB;
// Costanti DLP7000
#define DMD_WIDTH 1024 // pixel
#define DMD_HEIGHT 768 // righe totali
#define BYTES_PER_ROW (DMD_WIDTH / 8) // 128
#define MAX_ROWS_CHUNK 400 // massimo numero di righe da caricare per chiamata
#define DMDTYPE_DLP7000 1 // da GetDMDType(), tipicamente 1 per DLP7000
int main() {
// Step 1: Get the number of devices connected
short numDevices = GetNumDev();
cout << "Number of connected devices: " << numDevices << endl;
if (numDevices <= 0) {
cout << "No devices found. Exiting..." << endl;
return -1;
}
// Step 2: Get basic information about the first device
short deviceNumber = 0; // Index of the first device
unsigned int firmwareRev = GetFirmwareRev(deviceNumber);
unsigned int driverRev = GetDriverRev(deviceNumber);
long dllRev = GetDLLRev();
short usbSpeed = GetUsbSpeed(deviceNumber);
short dmdType = GetDMDTYPE(deviceNumber);
short disabilito = 0;
cout << "Device Information:" << endl;
cout << "Firmware Revision: " << firmwareRev << endl;
cout << "Driver Revision: " << driverRev << endl;
cout << "DLL Revision: " << dllRev << endl;
cout << "USB Speed: " << (usbSpeed == 0 ? "Low" : "High") << endl;
cout << "DMD Type: " << dmdType << endl;
// Step 3: Clear FIFOs and set basic parameters
cout << "Clearing FIFOs..." << endl;
short result = ClearFifos(deviceNumber);
short blockmode = GetBlkMd(deviceNumber);
cout << "BlockMode: ..."<< blockmode << endl;
/*
SetTPGEnable(1, deviceNumber);
SetPatternForce(1, deviceNumber);
SetPatternSelect(0x1, deviceNumber);
std::this_thread::sleep_for(std::chrono::seconds(5));
SetPatternSelect(0x2, deviceNumber);
std::this_thread::sleep_for(std::chrono::seconds(5));
SetPatternSelect(0x7, deviceNumber);
cout << "aaa" << endl;
if (result == 1) {
cout << "FIFOs cleared successfully." << endl;
}
else {
cout << "Failed to clear FIFOs." << endl;
}
cout << "Setting block mode to 11..." << endl;
if (result == 1) {
cout << "Block mode set successfully." << endl;
}
else {
cout << "Failed to set block mode." << endl;
}
cout << "Setting block address to 1000..." << endl;
result = SetBlkAd(1000, deviceNumber);
if (result == 1) {
cout << "Block address set successfully." << endl;
}
else {
cout << "Failed to set block address." << endl;
}
*/
// step 3.b vero
/*
short rowAddress = 27; // Riga da impostare
// Imposta il Row Address a 27
if (SetRowAddr(rowAddress, deviceNumber) == 1) {
cout << "Row Address impostato a: " << rowAddress << endl;
}
else {
cout << "Errore durante l'impostazione del Row Address!" << endl;
return -1;
}
// Leggi il Row Address attuale
int currentRowAddress = GetRowAddr(deviceNumber);
if (currentRowAddress = rowAddress) { // Supponiamo che -1 indichi un errore
cout << "Row Address attuale: " << currentRowAddress << endl;
}
else {
cout << "Errore durante la lettura del Row Address!" << endl;
}
*/
// Step 4: Test data loading
// Configurazione iniziale
ClearFifos(deviceNumber);
LoadControl(deviceNumber);
SetBlkMd(10, deviceNumber); // Modalità per reset multiplo di blocchi
SetBlkAd(0000, deviceNumber); // Iniziamo con il blocco 0
// Dati per una riga tutta a 1 e una tutta a 0
unsigned char rowAllOn[128]; // 1024 pixel / 8 = 128 byte
unsigned char rowAllOff[128];
// Inizializziamo i dati
memset(rowAllOn, 0xFF, sizeof(rowAllOn)); // Tutti i pixel ON
memset(rowAllOff, 0x00, sizeof(rowAllOff)); // Tutti i pixel OFF
// Carichiamo alternativamente righe ON e OFF
for (int j = 0; j < 16; j++) { // Per tutte le righe del DMD7000
SetWDT(1, deviceNumber); // Abilita Watchdog Timer
LoadControl(deviceNumber); // Carica il controllo
SetRowMd(10, deviceNumber); // Modalità riga standard
SetNSFLIP(1, deviceNumber); // Nessun flip nord-sud
SetRowAddr(j, deviceNumber); // Imposta la riga corrente
cout << "Caricamento riga: " << j << endl;
if (j % 2 == 0) {
// Riga pari: carica tutti 1
LoadData(rowAllOn, sizeof(rowAllOn), dmdType, deviceNumber);
}
else {
// Riga dispari: carica tutti 0
LoadData(rowAllOff, sizeof(rowAllOff), dmdType, deviceNumber);
}
}
cout << "dimensioni rowAllON: " << sizeof(rowAllOn) << endl;
SetRST2BLKZ(0, deviceNumber);
SetRowAddr(0, deviceNumber);
// Step 5: Retrieve the current row address
short currentRowAddr = GetRowAddr(deviceNumber);
short currentROwmode = GetRowMd(deviceNumber);
cout << "Current Row Address: " << currentRowAddr << endl;
cout << "Testing completed." << endl;
cout << "Current Row Md: " << currentROwmode << endl;
cout << "Testing completed." << endl;
return 0;
}