locked
Read/write data through I2C-USB adapter on Windows 7 RRS feed

  • Question

  • in Microsoft .NET Micro Framework, there are lots of classes to support I2C communication (e.g. I2CDevice, Configuration, etc). But recently I started to work on a project that would run on Windows 7, and the application would read/write data through a I2C-USB adapter (for those who are interested, the I2C-USB device can be found here). The USB adapter has a Cypress USB 2.0 controller built in. My question is: is it possible to run .NET Micro Framework on Windows 7? If it is not possible, what is the right way to access an I2C device through a USB adapter?

    On the internet, there are lots of information about I2C on embedded systems, but not on Windows OS itself. Any code example would be sincerely appreciated!

    Thanks!

    lakeeast


    lakeeast


    • Edited by lakeeast Friday, May 25, 2012 3:58 AM
    Friday, May 25, 2012 3:56 AM

Answers

  • Lakeeast,

    You don't need .NET Micro Framework to talk I2C in this case -- you need to find the API and documentation for your USB to I2C adapter -- the VCNL USB Plug.  Chances are on the CD that came with the USB adapter there is documentation, a driver for the USB device, a DLL you link to, and some sample code.  Unfortunately I can't help you more than this because they don't seem to publish the documentation or software to the web.

    I haven't used this adapter.  When I talk to I2C devices from Windows, I use an Arduino.  A good choice here would be the Teensy which has great USB support.  A bit simpler approach would be to use an Arduino Uno which is a bit more 'mainstream' but is a bit more expensive and is slower over USB.  Both devices talk to I2C devices using the Wire library.  The Arduino IDE comes with a number of samples showing how to talk to a I2C devices.

    When you start using I2C you're going to find it's difficult to get started.  I2C has a number of settings and it's easy to get something wrong.  When you do, you just don't see data come back like you expect.  It can be tough to work through this stage because like most microcontrollers it's difficult to debug and when you're using I2C you're talking between *two* microcontrollers over a bus.  The best way to deal with this is to have a I2C protocol debugger you attach to your bus wires.  There are a number of choices available to you, the two I've used are the Saleae Logic and the USBee DX.  The software for analyzing I2C is a little better with the USBee because it gives you a 'trace log' of all messages down the side of the window.  I personally own the Saleae Logic because it's less expensive and feels better made.  Either will help you succeed with I2C.

    Good luck, I hope you enjoy success with your I2C sensors.

     - jcb

    Thursday, May 31, 2012 4:45 AM
    Moderator

All replies

  • As I understand it, the .NET Micro Framework is a subset of the .Net Framework which is on Windows 7.  So presumably you should be able to use the same Visual Studio tools.  I'll let others correct me if I'm wrong.

    Dan.

     

    Dan Sionov

    Saturday, May 26, 2012 2:28 AM
    Moderator
  • Maybe I didn't make my question clear: I understand that I can COMPILE the .NET micro framework on Windows 7, but how can I execute the compiled assemblies INSIDE Windows 7 (not downloading the assemblies to a target machine) ? In other words, the Windows 7 PC will be acting like a microcontroller, and the compiled code will be running side by side with other windows assemblies (e.g. WPF 4, WCF, SQL Server...). 

    Thanks for your thoughts in advance!


    lakeeast

    Saturday, May 26, 2012 1:06 PM
  • I believe you may be able to use the SerialPort class in .Net to communicate through your I2C-USB adapter.  Of-course the problem is what protocol is being used.  You might have to ask the manufacturer of your I2C-USB adapter to see if they will share the protocol with you.

    Dan Sionov

    • Marked as answer by lakeeast Thursday, May 31, 2012 4:58 AM
    • Unmarked as answer by lakeeast Thursday, May 31, 2012 4:58 AM
    Monday, May 28, 2012 4:02 PM
    Moderator
  • Lakeeast,

    You don't need .NET Micro Framework to talk I2C in this case -- you need to find the API and documentation for your USB to I2C adapter -- the VCNL USB Plug.  Chances are on the CD that came with the USB adapter there is documentation, a driver for the USB device, a DLL you link to, and some sample code.  Unfortunately I can't help you more than this because they don't seem to publish the documentation or software to the web.

    I haven't used this adapter.  When I talk to I2C devices from Windows, I use an Arduino.  A good choice here would be the Teensy which has great USB support.  A bit simpler approach would be to use an Arduino Uno which is a bit more 'mainstream' but is a bit more expensive and is slower over USB.  Both devices talk to I2C devices using the Wire library.  The Arduino IDE comes with a number of samples showing how to talk to a I2C devices.

    When you start using I2C you're going to find it's difficult to get started.  I2C has a number of settings and it's easy to get something wrong.  When you do, you just don't see data come back like you expect.  It can be tough to work through this stage because like most microcontrollers it's difficult to debug and when you're using I2C you're talking between *two* microcontrollers over a bus.  The best way to deal with this is to have a I2C protocol debugger you attach to your bus wires.  There are a number of choices available to you, the two I've used are the Saleae Logic and the USBee DX.  The software for analyzing I2C is a little better with the USBee because it gives you a 'trace log' of all messages down the side of the window.  I personally own the Saleae Logic because it's less expensive and feels better made.  Either will help you succeed with I2C.

    Good luck, I hope you enjoy success with your I2C sensors.

     - jcb

    Thursday, May 31, 2012 4:45 AM
    Moderator
  • Jay,

    Thanks for your help! I contacted the vendor, and interestingly they don't have driver, dll nor sample code for windows! I eventually figured it out by using something called "Usb2dll" from a third party, and now everything works.

    Your information is very helpful, and I will look into them and get a better understanding of I2c programming.

    Best regards,

    lakeleast


    lakeeast

    Thursday, May 31, 2012 4:58 AM