USB to I2C PR33-17 Protocol in c# (Serial Port) - Read Timeout

Hi,

I’m using PR33-17 to work with my device (Liquid Lens).

Understand that this device is not under NCD package.

So I have to create my own API in c# to send command to the device.

I do a simple testing by sending command to read device status. ( For more details, please refer to the attachment)

private SerialPort USB_PORT = new SerialPort();

        USB_PORT.Close(); // close any existing handle
        USB_PORT.BaudRate = 115200;
        USB_PORT.PortName = COM3;
        USB_PORT.StopBits = StopBits.One;
        USB_PORT.ReadTimeout = 2000;
        USB_PORT.WriteTimeout = 2000;
        USB_PORT.Open();

        byte[] sbufR = new byte[10];
        int j = 0;

        sbufR[j++] = 0xEE;  // Set Salve Address Write
        sbufR[j++] = 0x00;  // Register Address (Status)
        sbufR[j++] = 0xEF; // Set Salve Address Read
        sbufR[j++] = 0x80; // Read Data  (Status)

         USB_PORT.Read(readData, 3, 1);

However , I get exception error in “Read Timeout”

May I know the way I created reading command is correct?

Thanks.

Have you tried using the Any I2C software to build the command? If not I would recommend that. You can download it here:

You can build and validate the command bytes there. They will need to be wrapped in an API packet.

I have been told by NCD team that I’m not able to use AnyI2C software due to my device is not supported.

So I have no choice but to create own API.

You haven’t added any of the other header bytes requires or the checksum.

Take a look at this document:

Hi Travis,

I have few questions here after gone through the guideline

The command structure for an I2C Write Operation is as follows:
0xBE, , <Data Byte 1>, <Data Byte 2>, <Data Byte 3>, etc.

Format : 0xBE, → No issue for me.
So for my case would be B4,77

[Question]
for the following <Data Byte 1>, <Data Byte 2>, <Data Byte 3>, etc.
Do I have to register each address for multiple registers?

For example, I would like to send command to channel of LLV1, LLV2
LLV1 address= 0x04, value = 0x96
LLV2 address = 0x05, value = 0x32
so it should be written as
04, 96, 05,32
OR
04, 96,32?

Which one is correct?

Thanks.

First, you need to get communications working. Send these 5 bytes to the controller and see if you get a response. This does NOT talk to the I2C device, it talks to the converter CPU to make sure you are communication properly with the CPU. More information on this is in section 1.4 of the manual:

Byte 1 0xAA NCD API Header Byte
Byte 2 0x02 NCD API Byte Count
Byte 3 0xFE Payload Byte 1 Command Header
Byte 4 0x21 Payload Byte 2 Test 2-Way Communications
Byte 5 0xCB NCD API Checksum 0xAA + 0x02 + 0xFE + 0x21 = 0xCB