Author Topic: CyUSB .Net libraries, I2C, and CyConsole  (Read 25207 times)

Jeff

  • Member
  • ***
  • Posts: 4
CyUSB .Net libraries, I2C, and CyConsole
« on: August 25, 2010, 04:03:51 am »
I am trying to write some application software that will access an Analog Devices AD7152 device that uses the cy68013a. I want to use the CyUsb.sys driver and the CyUSB managed .NET library to communicate with the device through the device driver.

The AD7152 ships with the ezusb.sys driver, but I already got the CyUsb.sys driver working. I can see the device in CyConsole and see all the End Points it exposes. I have written the .NET code to establish connection with the device and I can see the EndPoint data there too.

Now I need to start transferring data from this device. It is a capacitance Analog to Digital Converter. This is where there is a large gap in my knowledge. Looking at the AD7152 documentation, I was expecting to see information related to EndPoints, but it does not mention End Points at all. Instead, there are statements like "The master initiates a data transfer by establishing a start condition, defined by a high-to-low transition on SDA while SCL remains high," which seem way too low level for my situation. I'm not writing firmware for the device, after all.

There are several useful tables in the AD7152 documentation, however, but no sample code. I do know that I need to write 0x19 to register subaddress 0x0F to enable channel 1 and channel 2 for continuous operation. However, I have no idea how the concept of register translates to the concept of End Point. I have a feeling I need to send 0x90 to initiate the Write to the setup register. Therefore, I probably need to send 0x900F19. But, I don't know if I need to send these bytes all in one write operation, or separately.

I tried to use the CyConsole to write to the device on different End Points, but I always get  "Control Transfer Failed." I was thinking I could use CyConsole to figure out what bytes I need to write and read and what End Points to use, and then translate this into code. Maybe I have an endian problem? I don't even know where to begin.

I've hit a big wall, and any help would be greatly appreciated.
« Last Edit: August 25, 2010, 11:40:40 am by Jeff »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: CyUSB .Net libraries, I2C, and CyConsole
« Reply #1 on: August 25, 2010, 12:09:27 pm »
I haven't used this chip, but a look at the data sheet shows that the AD7152 only has an I2C port. Are you using the evaluation board, which does have USB?

Do you want to write an application that communicates via USB with the evaluation board? If so, you'll need documentation or example code for how the evaluation board's driver accomplishes I2C communications over the USB interface. If that's not available, you can attempt to reverse-engineer the evaluation board's application by monitoring the USB traffic with a protocol analyzer.

To access an AD7152 chip from a PC without using the evaluation board, you'll need a USB/I2C adapter. How to access the device will vary with the driver the adapter uses.

Jan
« Last Edit: August 25, 2010, 12:32:13 pm by Jan Axelson »

Guido Koerber

  • Frequent Contributor
  • ****
  • Posts: 72
Re: CyUSB .Net libraries, I2C, and CyConsole
« Reply #2 on: August 25, 2010, 05:42:36 pm »
You are mixing two things. The AD7152 is an I2C device, to talk to it you have to understand at least basically how I2C works. The next step is to select a USB to I2C converter. And I would not recommend to use the Cypress samples, while they are a great starting point to learn how to program the Cypress chips they are far from production quality code.

I hope it is OK with Jan if I drop a product plug here, since we happen to make a device that is well suited to handle this interfacing issue and it has I2C specific sample code and tools available:
http://www.codemercs.com/index.php?id=256&L=1

Jeff

  • Member
  • ***
  • Posts: 4
Re: CyUSB .Net libraries, I2C, and CyConsole
« Reply #3 on: August 25, 2010, 08:23:10 pm »
Thanks for the replies. I see where I went wrong now. Yes, I have the evaluation boards. Each has 2 channels. Since I need 3 channels, I plan on using 2 of the boards. I'm just trying to interface to one of the evaluation boards right now. The model is actually EVAL-AD7152EBZ. Now I understand the huge discrepancy in pricing too. Eval board is $70. You can buy 100 of the chips for $2.33 each, but this isn't the entire eval board, just the ADC chip that follows the I2C protocol.

This also explains why the product support is lacking from Analog Devices. They probably don't want/allow taking this too far.

This is a prototype, or proof-of-concept, if you will. I could convince my boss that a different solution is better if it saves us time/money. Since I only need 3 of these, it is not a big order right now.

The protocol analyzer might not be a bad idea for now. I don't mind doing this. I can easily setup the board using the ezusb.sys driver, use the evaluation program, and watch bits fly by. Given the documentation I do have that explains what it looks like to read from or write to a register, I may just be able to figure it out.

So, I shouldn't have to worry about the clock rate and other specific I2C issues, right? The other chips on the eval board handle those details, I assume.

Talking to the USB board, I should be speaking in terms of establishing a connection to an endpoint, correct?


Thanks,
Jeff

Jeff

  • Member
  • ***
  • Posts: 4
Re: CyUSB .Net libraries, I2C, and CyConsole
« Reply #4 on: August 25, 2010, 08:26:58 pm »
Does anyone have a recommendation for a protocol analyzer? I've used wireshark before for network traffic. I'll have to check if i can monitor USB traffic with it.

Thanks,
Jeff

Ron Hemphill

  • Member
  • ***
  • Posts: 19
Re: CyUSB .Net libraries, I2C, and CyConsole
« Reply #5 on: August 26, 2010, 10:45:07 am »
Does anyone have a recommendation for a protocol analyzer?
Jan has a pretty comprehensive list of USB Analyzers on her site:
http://www.lvr.com/development_tools.htm#analyzers

I've used the Ellisys Explorer 200 for years, it's been a great, easy-to-use, and inexpensive tool!
« Last Edit: August 26, 2010, 10:50:07 am by Ron Hemphill »

Jeff

  • Member
  • ***
  • Posts: 4
Re: CyUSB .Net libraries, I2C, and CyConsole
« Reply #6 on: August 26, 2010, 01:31:33 pm »
I started out using a trial version of USBTrace. So far it is good. It is $195 for a single license, according to their site.

Using what I learned, I was able to figure out how to ping the device from the CyConsole and I got back a positive response for the first time. I'm trying to figure out how to configure the device to turn on channels 1 and 2. I need to set the Transfer flags to 0x02, it looks like. There doesn't seem to be a way to do that in CyConsole, so I'm going to try doing it in code.