• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » DLP & MEMS » DLP LightCrafter Development Platform » MATLAB code to control LightCrafter(TM)
Share
DLP & MEMS
  • Forums
Options
  • Subscribe via RSS

MATLAB code to control LightCrafter(TM)

MATLAB code to control LightCrafter(TM)

  • Jan Winter
    Posted by Jan Winter
    on Jul 09 2012 07:31 AM
    Prodigy240 points

    Hi everybody,

    for those who want to control the LightCrafter(TM) via MATLAB:

    I've prepared a framework in order to send BMP images (more to come) to the LightCrafter(TM). You can download (or have a look at it) on https://github.com/fglichttechnik/TI-DLP-LightCrafter

    Best regards

    Jan

    bmp image LightCrafter Matlab
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • 1973284
    Posted by 1973284
    on Jul 19 2012 22:54 PM
    Prodigy60 points

    Kudos.

    Lee

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jan Winter
    Posted by Jan Winter
    on Jul 20 2012 02:58 AM
    Prodigy240 points

    :)

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Adam Kunzman
    Posted by Adam Kunzman
    on Jul 26 2012 22:23 PM
    Intellectual265 points

    Jan,

    Thanks, I'll see if we can adapt this for our X3 system. It uses USB, but it should be fairly straightforward to adapt.

    - Adam

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Cem Girit
    Posted by Cem Girit
    on Oct 22 2012 18:07 PM
    Prodigy70 points

    Hello Jan,

        I am very glad that you posted a great example on how to control LC through MATLAB. Thank you. I was wondering, if I can start and stop pattern sequence loaded internally in LC through MATLAB as well? This I need because, I am triggering LC by a Point Gray USB camera to project series of patterns for 3D scanning and am afraid that  if this external triggering misses the order of patterns, the scan will not work. I am experiencing false triggers once a while. Therefore, if I stop and start loaded patterns before every scan I can start with the same sequence each time. Thank you for your help.

    Sincerely,

    LC control Matlab
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jan Winter
    Posted by Jan Winter
    on Oct 23 2012 03:02 AM
    Prodigy240 points

    Hi Cem,

    have a look into a file titled: "DLP® LightCrafterTM DM365 Command Interface Guide ".

    All commandeds are described there, I'm currently not aware of all commands. With the provided Code on gitHub it should be very easy to add new commands.

    Best regards

    Jan

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Cem Girit
    Posted by Cem Girit
    on Oct 23 2012 15:57 PM
    Prodigy70 points

    Hello Jan,

        Based on your code , I added more control functions to your LightCrafter m.file (see attached zip file for LightCrafter.m, and LightCrafterTest.m) . Since I am not as good programmer as you, the first function I wanted to test did not work. It i sintended to get the version information of various LC parts. I am sending '00' as in input argument to this getVersion function, but it does not return any value back. According to the the programming manual, there supposed to be 32 bit information for the various version information. could you please let me know what I am doing wrong? If you check my other functions in the m-file, maybe we can publish this to the DLP LC community. This is really good way of controlling LC. Thank you for your help and  nice insight.

        Sincerely,

    Cem

    7271.MATLAB Code.zip

    LightCrafter Matlab
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jan Winter
    Posted by Jan Winter
    on Oct 24 2012 08:50 AM
    Prodigy240 points

    Hi Cem,

    thanks for adding those new methods. I currently don't see what's wrong. I have no access to my LCr till next week, so you might want to recheck the manual if everything is as it should be (also compare my functions). Maybe one of your other function works? Are my functions working in your current set up?

    Please make method names start with lower case letters an between all ( ) a space, e.g. aMethod( arg1, arg2 )

    (I know I didn't do it everywhere, but it makes the code better to read ).

    Best regards

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Cem Girit
    Posted by Cem Girit
    on Oct 24 2012 15:47 PM
    Prodigy70 points

    Hello Jan,

            The Matlab returns the following output if the input argument to getVersion is '00'. See if you can make sense of it. I expected, for example, for DM65 an output like  3.31 as LC GUI report when it is connected. For the input argument '10' which is for FPGA we should get 2.4.39 etc. The reason I wanted to use this LC function becasue it does not write or change anything on LC, it should just return some info showing we have communication. On te hother hand your code does something to LC. But when I tried your code to change the color of the projected background, I got the following output and the background color did not change.

              My understanding with the structure of your code is that  a call like L.getVersion( '00', tcpObject) should return something or we should do something like this:

              Output = L.getVersion( '00', tcpObject);

              In which case, the "Output" variable should store what is returned from LC. But even this did not work.It gives "Too many output  arguments" error.

             I will correct any programming error/formatting per your recommendation.  As you can see. I am not a programmer.

    The L.gettVersion code:


            function getVersion( obj,Version, connection )

                if (~ischar(Version) && (length(Version)~=2))
                    disp('Version must be a 2 digit hex string 00, 10, or 20')
                    return;
                end

                header = obj.createHeader();
                header( 1 ) = uint8( hex2dec( '02' ) );    %packet type
                header( 2 ) = uint8( hex2dec( '01' ) ); %CMD1
                header( 3 ) = uint8( hex2dec( '00' ) ); %CMD2
                header( 4 ) = uint8( hex2dec( '00' ) ); %flags
                header( 5 ) = uint8( hex2dec( '01' ) ); %payloadLength LSB
                header( 6 ) = uint8( hex2dec( '00' ) ); %payloadLength MSB
                payload = uint8( hex2dec( Version ) ); %payload
                packet = obj.appendChecksum( [ header; payload ] );
                %packet
                obj.sendData( packet, connection );
            end

    Program running L.getVersion ('00', tcpObject) returns in Matlab:

    >> LightCrafterTest

    L =

      LightCrafter handle

      Properties:
        tcpConnection: []

      Methods, Events, Superclasses


       TCPIP Object : TCPIP-192.168.1.100

       Communication Settings
          RemotePort:         21845
          RemoteHost:         192.168.1.100
          Terminator:         'LF'
          NetworkRole:        client

       Communication State
          Status:             closed
          RecordStatus:       off

       Read/Write State  
          TransferStatus:     idle
          BytesAvailable:     0
          ValuesReceived:     0
          ValuesSent:         0
     

       TCPIP Object : TCPIP-192.168.1.100

       Communication Settings
          RemotePort:         21845
          RemoteHost:         192.168.1.100
          Terminator:         'LF'
          NetworkRole:        client

       Communication State
          Status:             closed
          RecordStatus:       off

       Read/Write State  
          TransferStatus:     idle
          BytesAvailable:     0
          ValuesReceived:     0
          ValuesSent:         0
     

    checksum =

         4

    wrote some data
    BytesAvailable event occurred at 10:27:59 for the object: TCPIP-192.168.1.100.

    -------------------------

    Program runningL.setStaticColor( 'FF', 'FF', 'FF', tcpObject) retturns in Matlab and nothing happens on LC.

    >> LightCrafterTest

    L =

      LightCrafter handle

      Properties:
        tcpConnection: []

      Methods, Events, Superclasses


       TCPIP Object : TCPIP-192.168.1.100

       Communication Settings
          RemotePort:         21845
          RemoteHost:         192.168.1.100
          Terminator:         'LF'
          NetworkRole:        client

       Communication State
          Status:             closed
          RecordStatus:       off

       Read/Write State  
          TransferStatus:     idle
          BytesAvailable:     0
          ValuesReceived:     0
          ValuesSent:         0
     

       TCPIP Object : TCPIP-192.168.1.100

       Communication Settings
          RemotePort:         21845
          RemoteHost:         192.168.1.100
          Terminator:         'LF'
          NetworkRole:        client

       Communication State
          Status:             closed
          RecordStatus:       off

       Read/Write State  
          TransferStatus:     idle
          BytesAvailable:     0
          ValuesReceived:     0
          ValuesSent:         0
     

    checksum =

         5

    wrote some data

    checksum =

        10

    wrote some data

    LightCrafter Matlab
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jan Winter
    Posted by Jan Winter
    on Oct 25 2012 03:17 AM
    Prodigy240 points

    Hi Cem,

    this is the problem:

      TCPIP Object : TCPIP-192.168.1.100

    ...

         Status:             closed


    the LightCrafterTest.m is outdated.


    Try this:

    L = LightCrafter();

    L.connect();


    -> now the status should be "open"

    If not you're having a communications problem with your lightcrafter, maybe due to the driver it needs or maybe because it has another standard internal IP.

    Unless the status is open no other command will work.

    Try until you get it open, then test one of my commands,

    then yours. They seem as they should work.

    Maybe reading commands are not supported, yet, but I'm not sure, I never listened to any of the answers he sent.


    Best regards

    J.


    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Cem Girit
    Posted by Cem Girit
    on Oct 25 2012 08:22 AM
    Prodigy70 points

    Hello Jan,

          I guess we are getting there. The code of line L.connect was commented out by mistake. But even after, it was un-commented, the status of communication is "Closed". But strange enough if I change input argument from '00' to say '10', the checksum changes fro 4 to 10.The IP address info is as reported by ipconfig. I do not know how to find out tcpip port number. It could be different than 21845 for my machine? So what is wrong?

    Ethernet adapter Local Area Connection 4:

       Connection-specific DNS Suffix  . :
       Description . . . . . . . . . . . : USB Ethernet/RNDIS Gadget #3
       Physical Address. . . . . . . . . : FA-AF-11-A3-84-67
       DHCP Enabled. . . . . . . . . . . : Yes
       Autoconfiguration Enabled . . . . : Yes
       Link-local IPv6 Address . . . . . : fe80::64e6:bc2c:2a81:8702%23(Preferred)
       IPv4 Address. . . . . . . . . . . : 192.168.1.99(Preferred)
       Subnet Mask . . . . . . . . . . . : 255.255.255.0
       Lease Obtained. . . . . . . . . . : Thursday, October 25, 2012 8:40:14 AM
       Lease Expires . . . . . . . . . . : Monday, November 05, 2012 10:26:53 PM
       Default Gateway . . . . . . . . . :
       DHCP Server . . . . . . . . . . . : 192.168.1.100
       DHCPv6 IAID . . . . . . . . . . . : 439549842
       DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-17-BF-30-4D-3C-97-0E-1A-20-16

       DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                           fec0:0:0:ffff::2%1
                                           fec0:0:0:ffff::3%1
       NetBIOS over Tcpip. . . . . . . . : Enabled

    >> LightCrafterTest

    L =

      LightCrafter handle

      Properties:
        tcpConnection: []

      Methods, Events, Superclasses


    obj =

      LightCrafter handle

      Properties:
        tcpConnection: [1x1 tcpip]

      Methods, Events, Superclasses


       TCPIP Object : TCPIP-192.168.1.100

       Communication Settings
          RemotePort:         21845
          RemoteHost:         192.168.1.100
          Terminator:         'LF'
          NetworkRole:        client

       Communication State
          Status:             closed
          RecordStatus:       off

       Read/Write State  
          TransferStatus:     idle
          BytesAvailable:     0
          ValuesReceived:     0
          ValuesSent:         0
     

       TCPIP Object : TCPIP-192.168.1.100

       Communication Settings
          RemotePort:         21845
          RemoteHost:         192.168.1.100
          Terminator:         'LF'
          NetworkRole:        client

       Communication State
          Status:             closed
          RecordStatus:       off

       Read/Write State  
          TransferStatus:     idle
          BytesAvailable:     0
          ValuesReceived:     0
          ValuesSent:         0
     

    checksum =

         4

    wrote some data
    >>

    LifghtCrafter Matlab
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jan Winter
    Posted by Jan Winter
    on Oct 25 2012 09:26 AM
    Prodigy240 points

    Hi Cem,

    did you manually try to fopen the tcpConnection object?

    The IP and port are standard by default, at least for the LCr I bought. I think you can use the TI LCr tool to set up that information or ask in other threads for help how to connect to the LCr.

    Best regards

    J.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use