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.

DLP freezes after 10 frames

Other Parts Discussed in Thread: DLPC300

I am trying to continuously display images as they are captured by USB camera using Matlab. This is on a Win7 64-bit PC with 8 GB RAM and Pointgrey Firefly MV. I have everything working using Jan Winter's .m code but projector hangs after about 10 frames and continues to display the last image. Any suggestions?

Thanks,

Walter

  • Hi Walter,

    Which input trigger mode are you using? Can you check if the LightCrafter is providing triggers correctly by hooking a scope to J7 on Systems Board?

    Regards,

    Divya

  • Divya,

    thank you for the prompt reply. I am using static image mode (L.setBMPImage). I do not have a scope to use now.

    Walter

  • Is it possible that the memory buffer is filling and a busy signal is returned to Matlab, causing the failure? Is there a way to clear the memory before sending another image? I tried pausing after each send and manually advancing, but same problem.

    Thanks,

    Walter

  • Hi Walter,

    The StaticImage interface actually writes into to same allocated memory space inside the DDR DRAM memory used by DM365. I think it is not the issue related with LCr memory. Perhaphs you may want to debug on the matlab code side. One suggestion to validate, if you generating new static image in the matlab code you can disable it after generating two images then send them alternatively in a loop to check if it hangs. This will confirm if it is still a problem with LCr memory overfilling.

    Regards,

    Sanjeev

     

  • Sanjeev,

    thank you for your response. I tried your suggestion using the code below. It still froze after 7-8 frames. I have tested with just displaying the images collected from camera on monitor and it does not freeze. After it freezes, I have to restart the projector to try again.

    Walter

    clc
    clear all
    close all

    vid = videoinput('winvideo', 2, 'Y800_376x240');
    src = getselectedsource(vid);
    vid.FramesPerTrigger = 1;
    vid.ReturnedColorspace = 'grayscale';

    tcpObject = tcpip('192.168.1.100',21845);
    fopen(tcpObject);
    L=LightCrafter()

    count = 5;
        
        start(vid);
        data = getdata(vid);
        stop(vid);
        
        I = imresize(data,[472 316]);
        imnew = uint8(zeros(684,608,3));
        imnew(220:691,100:415,2) = I(1:472,1:316);
        imwrite( imnew, 'im1.bmp' );    
        
        pause
        
        start(vid);
        data = getdata(vid);
        stop(vid);
        
        I = imresize(data,[472 316]);
        imnew = uint8(zeros(684,608,3));
        imnew(220:691,100:415,2) = I(1:472,1:316);
        imwrite( imnew, 'im2.bmp' );
        
      while count < 1000  
        imFile1 = fopen( 'im1.bmp' );
        imData1 = fread( imFile1, inf, 'uchar' );
        fclose( imFile1 );
        
        L.setBMPImage( imData1, tcpObject );
        
            imFile1 = fopen( 'im2.bmp' );
        imData1 = fread( imFile1, inf, 'uchar' );
        fclose( imFile1 );
        
        L.setBMPImage( imData1, tcpObject );
        
    end

  • Hi Walter,

    You can double check by repeating your experiment by using LightCrafter GUI you will notice LightCrafter will not hang.

    Can you show your implementation for setBMPImage() function?

    Regards,

    Sanjeev

     

  • Sanjeev,

    I will check the LC GUI and suspect you are right.

    I am using the Matlab code from Jan Winter: https://github.com/fglichttechnik/TI-DLP-LightCrafter

    Walter

  • I checked with the LC GUI and it does not freeze with the repeated pattern. But is this not comparing apples to oranges? The Matlab code repeatedly sends the alternate images while the pattern display in GUI loads the 2 images and LC alternates display. It seems the send/receive is not working correctly. I read in previous posts that USB hub has been required. Is this still the recommendation? The RNDIS/Ethernet gadget always searches for connection before I can connect. Has this problem been solved?

    Thanks,

    Walter

  • Hello Walter,

    No we are not comparing apples to oranges. My point was to show the problem is not at the LightCrafter side.

    About the search issue, if you are running on Windows 7 the 'searching' occurs, this to find if there is a internet connection available with the newly found IP connection by the Operating System. You can actually avoid the searching step by hardcoding the IP adress in the new TCP connection properties on the PC/Desktop. For example, you can set it to like 192.168.1.99. Next time when you connect it will work.

    Back to the MATLAB code. I looked into the code found that important piece of implementation missing in the code. I am not a MATLAB programming expert but I can suggest the missing implementation part, someone with MATLAB knowldge can modify the code.

    The missing part, refer to the DLP® LightCrafter™ DM365 Command Interface Guide (http://www.ti.com/lit/ug/dlpu007c/dlpu007c.pdf) Section 2. it is clearly mentioned that "Each command packet is acknowledged by a response packet" but in the MATLAB code it is ALWAYS sending the packet data function sendData( obj, packet, connection ) but it is not reading the response packet. As per the protocol for everypacket written you must read back the response to validate if the sent packet was successful. In MATLAB context you must add fread() http://www.mathworks.com/help/matlab/ref/fread.html  code after every fwrite() operation.

    After this modification i believe it will work.

    Regards,

    Sanjeev

  • Sanjeev,

    I found this section in LichtCrafterTest.m:

    tcpObject = tcpip('192.168.1.100',21845)
    tcpObject.BytesAvailableFcn = @instrcallback
    tcpObject.BytesAvailableFcnCount = 7;
    tcpObject.BytesAvailableFcnMode = 'byte';
    fopen(tcpObject)

    and implemented it. I'm not certain why this worked as it is not in the write loop, but it stopped the freezing and now running for >15 min.
    I also set IP of Lightcrafter, which may have helped. It is running much faster now.
    Thank you,
    Walter
  • Sanjeev,

    Walter and I are working in this project, and implementing the code together. Here are few things that are still not working alright. 

    1- Suppose, I run this code:

    tcpObject = tcpip(192.168.1.100,Port Number)

    fopen(tcpObject);

    count  = 1

    while count < 20

         fwrite(tcpObject,uint8(hex2dec(['02';'01';'01';'00';'01';'00';'00';'05']))); %switch display mode to static

         fwrite(tcpObject,uint8(hex2dec(['02';'01';'03';'00';'01';'00';'00';'07']))); %switch to internal pattern: checkboard

    end

    I don't exactly remember what I exactly used in these two lines, but I am sure I tried to execute two different patterns one after another. If I try to execute this code, after a while, the lightcrafter keeps projecting these patterns sequentially, even though I exit MATLAB. 

    Now, this might mean that too many data get in the LightCrafter buffer, while the code above executes, and the lighcrafter keeps projecting the data even though MATLAB is closed. Following your comment, if I try to execute after each of the lines above as follows:

    ack = fread(tcpObject),

    I read some bytes. Please let me know which of these bytes will let me know there is no error and I can send the next set of data.

    2- It will be good if I learn how to clean the memory of lightCrafter. I think the problem is we are sending too many data; they are getting occupied in lightCrafter memory; and eventually lightCrafter gets frozen. I may be wrong, but I would expect that the new data should replace the old data, and due to this, old data should be removed from the lightCrafter memory. Question is how can I delete things from the lightCrafter memory.

    fwrite(tcpObject,uint8(hex2dec(['02';'06';'01';'00';'01';'00';'00';'10']))); %switch display mode to static

    This did not work. 

    3- We tried to power off the red and blue LED and keep only the green LED on. We used:

    fwrite(tcpObject,uint8(hex2dec(['02';'01';'04';'00';'06';'00';'00';'00';'01';'0C';'00';'00';'26']))); %switch display mode to static

    It did not work. For data bytes, we used '00';'00' to keep the red and green LED off, and '01';'0C' as 112 in hex to send 633 mA as specified for the green LED to let it remain on.

    It did not work.

    4- Finally, it could be just that the lightCrafter that we have has some hardware issues. It may be a faulty module that we have. Please let us know what would be our quick test to know that the projector is working as expected.... 

    We appreciate your quick response.

    Many thanks,

    Pinaki

  • Hello Pinaki,

    Welcome to DLP&MEMS forum.

    Good to know that you and Walter working together.

    I will answere your above question in another thread posted by you http://e2e.ti.com/support/dlp__mems_micro-electro-mechanical_systems/f/850/t/263813.aspx

    Now, let me answer Walter's earlier question.

    Sanjeev,
    I found this section in LichtCrafterTest.m:
    tcpObject = tcpip('192.168.1.100',21845)
    tcpObject.BytesAvailableFcn = @instrcallback
    tcpObject.BytesAvailableFcnCount = 7;
    tcpObject.BytesAvailableFcnMode = 'byte';
    fopen(tcpObject)
     and implemented it. I'm not certain why this worked as it is not in the write loop, but it stopped the freezing and now running for >15 min.
    I also set IP of Lightcrafter, which may have helped. It is running much faster now.
    Thank you,
    Walter

     Why it worked is because you are like installing a callback function in MATLAB http://www.mathworks.com/help/matlab/ref/instrcallback.html and http://www.mathworks.com/help/instrument/bytesavailablefcn.html also by default the readmode is set to 'auto' http://www.mathworks.com/help/matlab/matlab_external/readasyncmode.html which means as and when bytes available in the response it is read back. Note here you are reading 7 bytes in the response.

    Again refer to DLPC300 DM365 Command spec the packet structured is

    So for successful write response refer to Command Spec documentation

    there is no payload data, so the response packet will have just 7 bytes i.e., Byte6 will be basically a CHECKSUM value.

    Since you are sending a valid command there is no error happening. And you are reading 7bytes properly. So system will not hang :)

    Regards,

    Sanjeev