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.

DMD Prototyping with Matlab

I have a discovery 4000 kit with the .55 XGA chip. I'm controlling the DMD through Matlab via the .OCX (ActiveX) file provided. Overall, it's an amazing piece of technology.

Fortunately, there are built-in Matlab functions that allow me to call the .OCX routines to control the DMD without rebuilding any significant portions of the code.

Now the  request... Unfortunately, the COM object  for the DMD in the .OCX driver doesn't conform to the OLE automation standard. MATLAB only supports COM objects that follow the OLE automation standard. In particular, the array being passed to the DMD is passed using a pointer to an array of SHORT's. While this is a perfectly good way of doing things (particularly for C or C++), this doesn't work well for quickly integrating the DMD control into other software.

When Matlab calls the COM object in the .OCX file, the type short* could have a lot of different meanings. MATLAB interprets it as a short type variable passed by reference in the COM interface. To pass arrays in or out of the COM object, SAFEARRAY rather than short* must to be used according to the OLE interface standards (the standard VB 6.0 conventions).

A VB wrapper should work to fix this. By creating a VB COM object following OLE standard using SAFEARRAYS which can handle transferring the info from the short* array. The COM object would refer to the other ocx and marshal-unmarshal the data by converting the data from SAFEARRAY to short* and vice versa. The simplest way is to do a deep data copying.

However, I was hoping that someone at TI (perhaps the person/team who wrote the .OCX code in the first place) might be able to provide a compiled .OCX file that uses the SAFEARRAY type, particularly as I have very little experience with making .OCX libraries or wrappers for them. This may also benefit other people, and speed up application development overall.

My current workaround is to save a .bmp to RAMDISK, then use the "ddc.LoadImageFileToBuffer('Temp.bmp');" command to read the bitmap from the disk. Unfortunately, even with a RAMDISK this provides a huge overhead, and makes for a ridiculously low refresh rate. I'd like to put patterns on the DMD on the order of 60 images per second, and right now I'm limited to one every second (rough estimate) due to all the type marshalling and ramdisk I/O. Please help!

Many thanks in advance, I love the device and the many new possibilities it opens up in our application,

Francis

  • Franics,

    Let me look into this.   Thank you for bringing this to our attention. 

  • I'm curious if there has been any internal discussion about this?

    Thanks,

    Francis

  • Hello,

    I am also very interrested by the potential issue for this limitation. I have also a frame rate close 1 frame/s in loading .bmp file from the hard disk with ocx-matlab approach.

    Florent.

     

  • Hi Fizix,

    It has been nearly a month now. I'm wondering if there has been any progress on this topic, could you provide us with an update?

    Thanks again,

    Francis

     

  • Greetings Flo. 

    Welcome to the DLP section of the TI E2E Community.

    I would look at the time that it is taking Matlab to process your bmp file.  You may want to preconvert your images and save them as byte arrays, then you should be able to achieve a much faster throughput using the USB interface.

  • Hello Franics,

    I have had some discussions about the ActiveX code.  The changes would be fairly pervasive.  

    I am sorry I will not be able to address this immediately.  Keep pinging me occasionally about this issue.

    Sincerely,

    Fizix.

  • Hi Francis,

    Although I am not controlling the DMD using Matlab, I felt I should mention one fact I noticed while working with the DMD and ActiveX controls. (BTW, I am using a modified version of sample C code, and use Matlab only to create the bmp files I need to display)

    I think this is very similar to what FIzix was suggesting, perhaps this is more detailed.  I do this in two stages:

    1) convert *.bmp files into *.bin files before hand (Here you will feel the overhead!)

    using the command:  ddc.ConvertImage(OriginName,DestName,0);

    2) Display *bin files using: ddc.FileToFrameBuffer(DestName,0);

    This is essentially reading from the harddrive of the computer and downloading the image (bin) file into DMD board using USB connection. In my case, the DMD refresh rate is around 40 images / second.

    I also noticed the speed was slower in my laptop then my desktop. I was originally getting speeds around 1 image per second like you did with bmp images, and this made everything a lot better.

    Obviously, this is a way to move the overhead into a different stage. If you have a practically finite set of bmps you can then wait for converting them into *bin  files, but refreshing DMD will be much faster. In my case, for 50-60K bmp files take an overnight of processing. If that is not the case, your problem remains unsolved.

    I hope this helps,

    Ozgur

     

     

  • Hi I need your help or suggestions, I need to know how you control the DMD through Matlab via the .OCX (ActiveX) file provided. I had installed the Discovery 4000 and loading the images but I need to load the image row by row.  I dont have any experience with DMD or controllers and I dont have idea how to start.  I had read all the documents, the software user guide, the API guide, but still in the same situation. Please suggest me a book, reference or give a hint. I have looked in mathworkstoo but still confused.  I would really appreciate your help.
    Cheers
    Martha

  • Hi Martha,

    I don't know how to control DMD thorough Matlab via the .OCX file. But, I can suggest an easy but very inefficient way to get your task done. (in my opinion this is the quickest way to get this done if you don't know Matlab with .OCX )

    1) Use Matlab to create a different bmp files (imwrite command in Matlab). These bmp files would differ by only one row to imitate loading the image row by row

    2) Modify TI provided sample C code (which uses Active X through C++) to load these bmps to DMD one after another.

    If you have issues with the frame rate try converting bmp files to bin files as I suggested in my previous reply to Francis above.

    Good luck,

    Ozgur

  • Hi Ozgur, thanks for your advice, I will look in the code, but actually I want to sweep a pixel through the whole image, so I dont know who efficient would be to load more than 786,000 images. So for that I was thinking on loading 21 images and read it by rows per block and then repeat through all the blocks of the images to get in total more than 786000 cycles but just using 21 images. I wil check thanks!

    Martha

  • Hi Martha,

    Like you, we have too many images to pre-generate all the bin files. However, I don't think that your method of sweeping through pixels one-at-a-time is the way to go. You are probably doing some kind of compressive sensing, and there are much better algorithms than reading one pixel at a time. Matlab actually has a contest at the moment where a constrained case of compressed sensing is the contest goal. Look at http://www.mathworks.com/matlabcentral/contest/contests/2/rules.

    We're using a ramdisk (virtual hard drive partition, which is actually a chunk of memory mapped as if it's a hard drive) to save the images onto before loading them into the DMD. Unfortunately, I don't think that there is a row-wise pixel loading method. Nor is there a simple 'pixel on/off' command. I think that you will probably find a better algorithm for sequential mirror patterns, as regardless of what you're doing, there is no way that you want to sequentially measure values from ~1 million different mirror patterns. In almost any case, I doubt that the custom-built system will be focused well enough that single-pixel resolution is even achieved (perhaps it's possible with the newer kits, but not likely with the older kits).

    The fastest you will get is uploading the segments, but from reading the manual you probably already know that.

    If you're loading entire images that aren't compressed, then it would take about 1 second per image, meaning to scan the 786k images would require about 9 days. Probably you can speed that up by about a factor of 16 by only updating the subregion of interest, but that's still not a huge improvement.

    We haven't been able to load the image array directly onto the DMD via the OCX library using Matlab, because it would require passing a pointer to the memory array, and everything involved uses protected memory. Instead, we're forced to write a file, close the file handle, then load that through the .OCX file-reading command. It's ridiculously slow, and I think that the TI software engineers should address this issue. We have the same issue from C-sharp using visual studio with the .OCX library.

    Francis

     

  • Hello Francis,

    I know the interest on this topic has died but I need to control LCr using VB6 and I found that there is an OCX that might allow this. Your post is about using Matlab to access LCr control via this OCX. I could not find this file in LCr installation. Where is it? Why don't you use VB6 directly to control LCr but instead Matlab?  I want to change display mode "Static", then back to "Pattern Sequence" mode. Any help would e greatly appreciated. 

    Cem

  • Hi Francis, I know it's been a long time but I really have no idea how to use Matlab to control the DMD. I'm not sure how to set up the ActiveX Control: would you happen to have Matlab code for that?

    Alice

  • Alice,

    Please see the answer to DMD ActiveX Control in MATLAB <-- click.  It answers this question.  Thanks.

    Fizix