Thanks for your quick answer.
However, it seems that the device I'd like to interface doesn't use tri-stating (http://www.robot-electronics.co.uk/htm/cmps3tech.htm). So if I use two digital I/O of my 6212 connected to SCL and SDA lines, with a proper VI, it wouldn't do the job ? I'm not familiar with I2C bus usage...
Thanks again !
in addition to tristating (which might not be necessary for your usecase), I2C communication requires hardware timed digital I/Os. As the digital I/Os on the USB-6212 are static / software timed, this board can't be used for this type of communication.
Sorry, but this is really not the appropriate hardware for your usecase. More information can be found here.
I have used the NI USB-8541 for several applications. It is very easy to use and supports clock rates up to 250kHz.
You would loose much time trying to implement an I2C communication with a DAQ card.
A search will list many third party interfaces but their implementation in your LabVIEW code may be more difficult.
Just a recommendation... from another JB
After some time working on this, I come back to you with some news.
First, I have to specify that the application I want to write is primarly aimed at students. I want them to really understand what an I2C bus is and how it works, and that's why I don't want to use a dedicated interface.
After some time, I came up with a solution that works quite well. See the VI attached, developped on Labview 2010.
+ I had to switch to a USB 6251 board since 6212 does not support digital inputs with external clock. As the clock is provided on the bus, I need this feature.
+ The clock on the bus is generated by writing three bits (0 - 1 - 0) one after the other on the SCL line for each bit written on the SDA line. This gives me a 300 Hz clock with the 6251, which is high enough for me.
+ I still have a problem of synchronization of the channels used to generate the messages and to read the answer from the sensor (see the comments in the VI). The two channels I used (1 for generating the I2C messages, and 1 for reading the sensor output) are not right on time.
Now some more questions:
+ How can I synchronize my two tasks, e.g. well enough to be able to catch the state of the bus right after I send an ACK ?
+ Is there a way not to have to start and end the decoding task (the one at the bottom) at each loop iteration while reading the bus when the 0xFF is on it ?
Thanks a lot !
I have actually the same problem that you have had, but I'm not so familiar with Labview.
I'd like to read data from an I2C sensor (http://www.ist-ag.ch/eh/ist-ag/resource.nsf/imgref/Download_DHDigiPicco_E1.0.pdf/$FILE/DHDigiPicco_E...
I'm not using the dedicated interface, but the USB 6343 board. After long seeking on the examples I've tried to use the standard MyDAQ VIs and different structures, but it doesn't work.
- Is there maybe a way to modify your application for this purpose?
- Could you make a more extended description of the functionality and VIs you used.
I'll be very grateful for any help.
I managed to create a communication between a DAQ-6009 and a IC2 circuit using the following code:
I used 2 DO and 1 DI channels. The code is software timed. There is a delay between the execution of each DO channel which is necessary for the IC2 communication.
Using this system, I could reach about 1kbit/s.
I believe that the same code could be used for DAQ-6259