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
Kudos.
Lee
:)
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
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,
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.
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.
Cem
7271.MATLAB Code.zip
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 ).
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:
>> LightCrafterTestL = 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 = 4wrote some dataBytesAvailable 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.
>> LightCrafterTestL = 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 = 5wrote some datachecksum = 10wrote some data
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.
J.
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
>> LightCrafterTestL = LightCrafter handle Properties: tcpConnection: [] Methods, Events, Superclassesobj = 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 = 4wrote some data>>
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.