Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Interface with I2C SDA and SCL with PCI 6224 digital ouputs in C/C++

I am trying to use the pci 6224 in order to send SDA and SCL to an I2C. I have been able to control the Digital Output, but I have been unsuccessful with generating a clock source to satify the I2C. I am writing this code in C/C++. Any ideas or examples would surely be appreciated. I need a good starting point, but I have not been able to find any useful examples that have worked. I am using the SCB-68 and I am trying to use my digital multi-meter to verify my code. 

 

I have looked at the examples provided, but is there a description of these functions that are being called using the NIDAQmx.h? 

0 Kudos
Message 1 of 4
(7,922 Views)
Hi,  are you trying to use a digital output as a clock signal?  The digital outs typically do not have the power or speed to drive a clock.  You can use the counters on the card to produce a pulse train that can be used as a clcok.  The generate pulse train example in the LabVIEW shipping examples should give you a template for doing this.
Chris Bakker
SET Americas
CEO

0 Kudos
Message 2 of 4
(7,850 Views)

What about the frequency out? Can the freqout be used instead of the counters?

 

Will the freqout regulate the transmission of the digital output bits?

0 Kudos
Message 3 of 4
(7,844 Views)

Hello VJohnson,

 

The counter will give you control of the clock frequency and duty cycle.  However, this card also has correlated DIO, which means that you can clock your digital lines.  Because of this, you can write a specific pattern (101010) to the buffer and just have it continuously output.  However, you will have to write this in a way that you know what values you're writing based on the part of the clock you're at.  

 

My I2C implemetation knowledge isn't the greatest, so I do not know how big each of your communication packets will be, but one implemetation would be to write your data in packets to regulate your SDA and SCL lines.  The WriteDigChan-ExtClk is the best option that shows how to write a digital channel with a clock.  You will just need to modify the DAQmxCfgSampClkTiming( function call.  The second input should be changed from "/Dev1/PFI0" to OnboardClock or NULL.  Hope this helps! 

ColeR
Field Engineer
0 Kudos
Message 4 of 4
(7,839 Views)