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.

control LED intensity with matlab

Other Parts Discussed in Thread: DLPC300

Dear all,

I am trying to control the lightcrafter with Matlab based on the code described in a previous post :

http://e2e.ti.com/support/dlp__mems_micro-electro-mechanical_systems/f/850/t/200078.aspx


It works fine, but I am not successful at creating a function controlling the LED intensities. From the command interface guide, I didn't understand the format of the adapted payload bytes. Also, what should be the payload lengths in this case?

Thanks a lot,

Fred

  • Hello Fred,

    Per interface LightCrafter DM365 command interface document specification, LED Current Setting (0x01 0x04), the payload is 6-bytes, 2-bytes each for Red, Green and Blue LEDs, 

    Let us know if you are looking for something else? 

    Regards,

    Sanjeev

  • Hi Sanjeev,

    thank you very much for the quick answer!

    I am still a bit confused about the format of the header.

    here is the matlab code that I use. Is the format of the header/payload correct? What is the format of the bytes to modulate the intensity? Sorry I am new at programming!

    tcpObject = tcpip('192.168.1.100',21845);

    fopen(tcpObject);

    obj = LightCrafter();

    header = obj.createHeader();

    header( 1 ) = uint8( hex2dec( '02' ) ); %packet type

    header( 2 ) = uint8( hex2dec( '01' ) ); %CMD1

    header( 3 ) = uint8( hex2dec( '04' ) ); %CMD2

    header( 4 ) = uint8( hex2dec( '00' ) ); %flags

    header( 5 ) = uint8( hex2dec( '00' ) ); %payloadLength LSB

    header( 6 ) = uint8( hex2dec( '00' ) ); %payloadLength MSB

    payload = uint8( [ hex2dec( '0' ) ; hex2dec( '0' ); hex2dec( '0' );hex2dec( '0' ) ; hex2dec( '0' ); hex2dec( '0' )] ); 

    packet = obj.appendChecksum( [ header; payload ] );

     obj.sendData( packet, tcpObject );

  • Hi,

    I quickly glanced at Jan's git https://github.com/fglichttechnik/TI-DLP-LightCrafter

    I appears to me you are not properly updating the payload length i.e.,

    header(5) & header(6), change your code to 

    header( 5 ) = uint8( hex2dec( '06' ) ); %payloadLength LSB

    header( 6 ) = uint8( hex2dec( '00' ) ); %payloadLength MSB

    It should work I think.

    Regards,

    Sanjeev

  • Thanks a lot, it works just fine!

    However I am still confused about the format of the header to specify individual LED intensities :

    why are there 2 bytes per LED? One should make it just fine in principle?

    Specifically, how do you set different intensity levels from 0 to the maximum one?

    Thanks a lot

  • Hello Fred,

    why are there 2 bytes per LED? One should make it just fine in principle?

    [Sanjeev]

    The DLPC300 register exposes it as a 10-bit register setting, so the digital LED current PWM values are set b/w 0 - 1023. Note, the register definition, 1023 - setting is for minimum and 0 - setting is for maximum.

    Where as in the DLP LightCrafter DM365 command interface guide, that you are using currently, is inverted to look normal, that is 0 - minimum and 1023 - maximum current. 

    Specifically, how do you set different intensity levels from 0 to the maximum one?

    [Sanjeev] Since you are communicating to DM365 on the Kit, you should follow the minimum - 0 and max - 1023 approach. Different intensity levels, you can write any values 0x000 to 0x400.

    Note sure i have answered your question completely, let us know if anything not clear here.

    Regards,

    Sanjeev

  • Thanks Sanjeev,

    I am still a bit confused.

    To be more precise, I use that kind of payload (this one turns all the LED off) :

    0

    0

    0

    0

    0

    0

    each pair of  two consecutive bytes corresponds to one LED (redfirst then green then blue).

    I still do not get how do you map the 1024 levels to values between 0x000 and 0x400 (by the way I do not undestand neither your conventions : what are the numbers before and after the x symbol?)

    Pratically, I think I would understand with an exemple :How would you write the payload associated to full power on the red, and an intermediate level on the red, like 500?


    Thanks again!

    Fred

  • Hello Fred,

    x stands for hex number representation. Each LED current takes two-byte of data, so the min and max will be 0x0000 to 0x0400 (Referring to LightCrafter DM365 Command Interface document)

    Example: Red LED max - 200, Green -  400, Blue - 1023 in hex representation it will be 0x00C8 , 0x0190, 0x0400 respectively. 

    The payload looks like

    0xC8

    0x00

    0x90

    0x01

    0x00

    0x04

    Let me know if it helps.

    Regards,
    Sanjeev

  • thanks a lot Sanjeev,
    it works perfectly!