This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DLPLCR70EVM: Controlling DLP7000 in Python

Part Number: DLPLCR70EVM
Other Parts Discussed in Thread: DLP7000, DLPC410

Hi Team,
I hope you all are doing good. 

Actually, I want to control DLP7000 with python. I have already a c++ script and it's really working fine for me with the *.h, *.lib and *.dll files they have already provided. 

Now, I am trying to wrap c++ script into python, but it shows me some errors. When i am trying to create source.o file and source.dll file from source.cpp file it shows me errors of incompatibility and even sometimes it shows me that the functions (GetNumDev, GetDMDTYPE, SetBlkMd, SetNSFLIP, LoadControl) you have used in your source.cpp file are not defined. 

Any one you ever tried to wrap c++ code into python for DLP or controlling it directly in python?? 

Any leads?

Code:

// #define STB_IMAGE_IMPLEMENTATION
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include <stdint.h>
#include <cstdint>
#include <vector>
#include "D4100_usb.h"
#include "CyAPI.h"
#include "RegisterDefines.h"
#include "8055.D4100_usb.h"
#include "windows.h"
// #include "stb_image.h"


#pragma comment(lib, "D4100_usb.lib")
#pragma comment(lib, "6562.D4100_usb.lib")

using namespace USB;
using namespace std;
 
int main()
{
	short numDevices = GetNumDev();
    printf("NumDevices : \t\t%d\n", numDevices);
	// std::cout << "Number of Devices Connected: " << numDevices << std::endl;
	short DeviceNumber = numDevices - 1; // Only One device is connected.
	short dmdType = GetDMDTYPE(DeviceNumber); // should be 1(DLP7000)
    printf("DMD Type : \t\t%d\n", dmdType);
	// std::cout << "DMD Type 0.7XGA connected: (1 = Yes, 0 = No, -1 = No USB Connected) " << dmdType << std::endl;

	//// Just for Assertion ////
	unsigned long driverrev = GetDriverRev(DeviceNumber);
	unsigned long firmwarerev = GetFirmwareRev(DeviceNumber);
	short usbspeed = GetUsbSpeed(DeviceNumber);
	unsigned long dllRev = GetDLLRev();
	unsigned long fpgaRev = GetFPGARev(DeviceNumber);
	short ddcVersion = GetDDCVERSION(DeviceNumber);	

	printf("Driver Rev : \t\t0x%08X\n", driverrev);
	printf("Firmware Rev : \t\t0x%08X\n", firmwarerev);
	printf("USB Speed : \t\t%d\n", usbspeed);
	printf("DLL Revision : \t\t0x%08X\n", dllRev);
	printf("FPGA Revision: \t\t0x%08X\n", fpgaRev);
	printf("DDC Version : \t\t0x%04X\n", ddcVersion);
	///////////////////////////
	
		SetWDT(0, DeviceNumber); // Watch Dog Timer (1 - Enable, 0 - Disable)
	//x SetPWRFLOAT(0, DeviceNumber); // Disable Power Float - Keep this commented
	    SetTPGEnable(0, DeviceNumber); // Disable TestPatternGenerator with 0 
	    
	    char choice;
	do {	
	cout << "Enter the filename of the bin file: ";
    string filename;
    getline(cin, filename); // user input

    // Open the bin file
    ifstream file(filename, ios::binary);
    if (!file.is_open()) {
        cerr << "Error: Unable to open file " << filename << "!" << endl;
        return 1;
    }

    // Read the binary data into a buffer
    const int width = 1024;
    const int height = 768;
    uint8_t rowData[width * height / 8];
    file.read(reinterpret_cast<char*>(rowData), sizeof(rowData));
    file.close();
    
    SetBlkMd(0, DeviceNumber); // DMD Block Operations -- NOP
	LoadControl(DeviceNumber); // DMD Block Operations -- Execute!

	SetRowMd(3, DeviceNumber); // Set First row address (Default # 3) // 3 before
    SetNSFLIP(0, DeviceNumber); // north south flip flag (0 = no flip, 1 = flip)
    LoadControl(DeviceNumber); // Row Operations -- Execute!
    
	SetRowMd(1, DeviceNumber); // Increment internal row address by 1 // 1 before
    SetNSFLIP(0, DeviceNumber); 
    LoadControl(DeviceNumber); // Row Operations -- Execute!


    ClearFifos(DeviceNumber); // Reset hardware receiving FIFO buffers and initialize DMD to take input
    // LoadData(rowData, sizeof(rowData), dmdType, DeviceNumber);  // Load pattern into the DMD.
    LoadData(rowData, sizeof(rowData) / 2, dmdType, DeviceNumber);  // Load 1st half of pattern into the DMD.
    LoadData(rowData + sizeof(rowData) / 2, sizeof(rowData) / 2, dmdType, DeviceNumber); // Load last half of pattern into the DMD.

	
	SetBlkMd(3, DeviceNumber); // DMD Block Operations -- Global Reset Request // 3 before
    SetBlkAd(8, DeviceNumber); // BLK_AD=4'b10xx
    LoadControl(DeviceNumber); // DMD Block Operations -- Execute!
	
	cout<<"Do you want to add more files to load on DMD? (Y/N): ";
	cin>>choice;
	cin.ignore();

	} while (choice == 'y' || choice == 'Y');
	
	return 0;
}

  • Hi ,

    TI does not have any python wrappers for this because the GUI is not supposed to be production-ready software. The GUI is a means to test the basic functionality of the DLPC410.

    I can, however, leave a few words for you to think about. Bear with me as I rubber-ducky this and try to understand what it is you have done so far.

    • You have created a new source file called source.cpp?
    • Is this the same script you mention here?
      Actually, I want to control DLP7000 with python. I have already a c++ script and it's really working fine for me with the *.h, *.lib and *.dll files they have already provided. 
      • If it is, I do not understand how it is working if you are unable to create the object file?
      • I do not know the specifics of the makefile, but have you added proper flags for the compilation of this source.cpp target and where to find its dependencies? I believe this project uses makefile.
    • Perhaps this source.cpp is from TI? (I am not familiar with the code base here, but can try to understand it).
      • Does this then belong to the Discovery4100 software? I would assume it does, and if so, where is this file? I am unable to find it?
    • My coworker has answered another question in the past, and this thread may be of some use to you as well.

    If this helps "resolve" your answer, please consider marking this comment as, "This resolves my issue." I'm sorry we can't provide further assistance on this apart from these thoughts.

    Regards,
    Michael Ly

  • Hi Michael, 

    Previously, I was running this C++ script on VSCode. I do have *.o file for this source file (DMD_Automation.cpp) but i am unable to get a makefile for this. Now, i want to wrap that c++ code and import in into python. For that, I need *.dll file for my source code (DMD_Automation.dll) which i was trying to get using command in Mingw64 command prompt:
    "$ g++ -shared -o DMD_Automation.dll DMD_Automation.cpp -std=c++11" and got error of linking libraries. 

    Again, I run this command: 
    "$ g++ -shared -o DMD_Automation.dll DMD_Automation.cpp -std=c++11 -LD4100_usb -l6562.D4100_usb"
    and got an error for incompatibility with D4100_usb.dll file. 
     

    Also, when i downloaded and installed D4100Explorer for DMD7000, I didn'get any other file than D4100.exe file. I don't have any of these files, can you provide me these files, so i can see and try to run them at my end! maybe it resolve my issue? 

    One more thing, I get CyAPI.h, RegisterDefines.h and remaining header files from this link headers 

    May it helps in rectifying issue.

    Thanks
    Aisha 

  • Hi Aisha,

    Which version of the GUI do you have? Yours sounds like the older version. Is it v2.0?

    https://www.ti.com/tool/DLPLCRC410EVM#order-start-development

    You should download this version:

    This version has the header files you require. Please let me know if this works for you.

    You can check your version by doing the following:

    Once you have the correct version, you may want to check out any README files 

    Regards,
    Michael Ly

  • Hi Michael, 

    I have the same version as you shown, I am attaching about GUI here. 
    I think I went wrong somewhere, maybe I never used the header files I have with this software, instead, I download headers from a post. 

    Let me install my software again and try to run source file. let's see how it works!
    Will get back to you soon with update. 

    Thanks for guide.

  • Hi Aisha,

    Thanks for the picture. This looks correct to me.

    The file name should be something similar to this:

    You can see that going two levels deep into the downloaded zip file (extracted) shows these directories:

    Regards,
    Michael Ly

  • Hi Michael, 

    Yes these all folders are there in dlpc133a, 


    Do I need to install the application? 

    There is a file in GUI folder DDC4100.exe but it is simply starting the GUI not installing as an application. 
    and if I don't need to install application separately, then should I move this folder from downloads to my Disk??? or what!!!

    Regards,
    Aisha

  • Aisha,

    There is no need to install this onto your computer. The DDC4100.exe file should be able to run without installation.

    The reason I asked for you to install this version was so that you would have access to all the header files you might not have had before.

    May you send me a log file of your compilation? I assume you are using some terminal emulator to compile and add options/flags.

    Please redirect those to a log file for me so I can see all errors you are experiencing during the build process. This would help me the most in determining what may be going wrong.

    I am also unsure what directory 6562.D4100_usb is? Is this a directory you made yourself and are pointing to for build?

    May I ask if your flags are correct such as -L for lib path, -I for header path, etc?

    One other thing to look out for, if you are not doing it already, is to list your object or source files before your library files. Make sure that you are also linking the library you want.

    Example:

    gcc test.c --o test \
    >    -I ../inc \
    >    -L ../myLib \
    >    -lm -l myNewMathLib  -lopencv_core

    Regards,
    Michael Ly

  • Hi Aisha,

    Do you still require help or have updates?

    Regards,
    Michael Ly

  • Hi Michael,

    I am getting some programming errors with new header files, because I updated previous headers as discussed in my previous thread. let me sort this, then i can be able to compile and run the file. will come back to you in short span (hopefully). 

    Best regards,

    Aisha

  • Aisha,

    I thought your name sounded familiar! Hoping to hear some good news soon!

    Regards,
    Michael Ly

  • Hi Aisha,

    Sorry to ask again, but how is everything going? Do you still require help? If you end up or ended up figuring it out, may you let me know?

    Thank you,
    Michael Ly

  • Aisha,

    It has been about a month since our last talk. I am closing this thread, assuming you were able to find a solution within this time frame.

    If this is not the case, or if you wish to reopen the thread, simply reply to the thread.

    To summarize the actions, we installed the latest version of DLPC410 Discovery 4100 GUI, and you were able to find the header files. You had some compilation(?) errors because of the new headers, but it sounds like you have it sorted out by now or are able to do this, but it just takes time.

    Best regards,
    Michael Ly