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.

Simple example codes for dlpc900

Other Parts Discussed in Thread: DLPC900

Hi,

i just started working with a lightcrafter 6500 evaluation module. Through the GUI the device works fine, but i need to be able to develop my own software controlling basic functions of the device. I understand i should refer to the dlpc900 programmer's guide (www.ti.com/.../dlpu018a.pdf). I quite understood the logic of the write/read commands, but i never worked with HIDs, and any possible help would be appreciated.

Could someone please upload a simple code with a read and a write example (like the two reported in sections 2.2 and 2.3 in the guide) for the usb interface?

At the moment i am trying to do it with python and the pywinusb module, but an example code in any kind of language would be a great help.

Thanks for your help

Paolo

  • Hi Paolo,

    We do not currently have any example code available other than those shown in the Programmer's Guide.

    Perhaps someone from the E2E Community would be willing to post an example.

    If you have any specific questions regarding HIDs or programming the DLPC900, I would be happy to answer them.

    Best regards,
    Trevor
  • Dear Trevor,

    ok, i hope he community will help :)

    In the meantime, my main problem with the guide i linked is how to send to the device an "API level readfile", which is needed to perform read operations. The guide only uses those three words, and i struggle to find a way to do it in practice. Any further description of what an API level readfile is would be immensely useful.

    Moreover, can you confirm that all the "commands" should be 65 bytes long? In the guide it seems that they can be shorter, but if i try sending a shorter package, an error message is raised. In case i need to send a shorter command, should i fill the remaining bits with 0x00s?

    Thanks for your help

    Paolo
  • Hello Paolo,

    Sending a command is seen by the controller as sending an "API level readfile" or "writefile," but to put it simply, you are just sending a command - read or write.

    A good test would be to send a command (that you mentioned) covered in 2.2 or 2.3 of the Programmer's Guide. See if, for example, reading the curtain color causes an error. Also, make sure the LIghtCrafter6500 GUI is closed when you run your code.

    Commands do have a maximum length of 64 bytes, but do not have to be 65 bytes long. What is the error you receive if you send a shorter command?

    Best regards,
    Trevor
  • Hi Paolo,
    You can take a look ant my post e2e.ti.com/.../411779 for an example code using the USB commands.
    I am using the HIDAPI library.
    I hope it will help you.
    Nathan Klein.
  • Hi Nathan,

    Thank you, your post is exactly what i was looking for! When you are satisfied with the code you should consider making it public on something like github, as far as i know it is the only example free code for the control of dlpc900 based devices.

    By the way, in the meantime i managed to create a basic input-output interface in python with the pyusb library.

    You can find it at the end of this message (for some reason the ti forum doesn't allow atachment of py files), in case any future developer ends up here by googleing "python dlpc900". It is just a basic interface, allowing the user to send usb commands specifying:

    -write or read command

    -a sequential byte for readout check

    -the usb control bytes

    -the payload data

    and to read out the responses of the dlp as a series of bytes. It includes the example read and write commands in the guide, plus two functions for "power mode" switching.

    It should be enough to get a user with no clues about usb interface started. Remember the pyusb library requires the libusb0.dll file in your windows/system32 folder.

    python code:

    import usb.core
    import usb.util
    
    
    class dmd():
        def __init__(self):
            self.dev=usb.core.find(idVendor=0x0451 ,idProduct=0xc900 )
    
            self.dev.set_configuration()
    
        def command(self,mode,reply,sequencebyte,com1,com2,data=None):
            buffer = [0x00]*64
    
            flagstring=''
            if mode=='r':
                flagstring+='1'
            else:
                flagstring+='0'
            if reply:
                flagstring+='1'
            else:
                flagstring+='0'
            flagstring+='000000'
            buffer[0]=int(flagstring,2)
            buffer[1]=sequencebyte
            len1=2+len(data)
            if len1>254:
                len2=(2+len(data))/255
                len1=len1-len2
            else:
                len2=0
            buffer[2]=len1
            buffer[3]=len2
            buffer[4]=com2
            buffer[5]=com1
            for i in range(len(data)):
                buffer[6+i]=data[i]
    
    
            self.dev.write(1, buffer)
    
        def readreply(self):
            a=self.dev.read(0x81,64)
            for i in a:
                print hex(i)
    
        def idle_on(self):
            self.command('w',False,0x00,0x02,0x01,[int('00000001',2)])
    
        def idle_off(self):
            self.command('w',False,0x00,0x02,0x01,[int('00000000',2)])
    
        def standby(self):
            self.command('w',False,0x00,0x02,0x00,[int('00000001',2)])
    
        def wakeup(self):
            self.command('w',False,0x00,0x02,0x00,[int('00000000',2)])
    
        def testread(self):
            self.command('r',True,0xff,0x11,0x00,[])
            self.readreply()
    
        def testwrite(self):
            self.command('w',True,0x22,0x11,0x00,[0xff,0x01,0xff,0x01,0xff,0x01])
    
    
    
    
    dlp6500=dmd()
    
    
    dlp6500.wakeup()
    
    dlp6500.testwrite()
    
    dlp6500.testread()
    
    dlp6500.standby()
    

  • Thank you for sharing Nathan and Paolo! I am sure that these examples will be helpful for future dlpc900 developers!

    Best regards,
    Trevor