LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement an I2C Bus with Lanbview embedded?

Hello and thank you macaba for replaying me. Unfortunately the I2C VI's for embedded are a little different than this instrument driver you Post.

 

to follow up this thread please go to http://forums.ni.com/ni/board/message?board.id=420&message.id=1362&jump=true#M1362

 

 

 

0 Kudos
Message 11 of 27
(2,727 Views)

Hi Amd1480,

 

I don't have an I2C chip connected to an MCB2300 in order to currently develop running I2C code.  However I was able to get my hands on an I2C example that was used with an MCB2400 and an I2C chip.  (Both the MCB2300 and the MCB2400 are Tier 1 supported devices, and I believe that I2C functionality is essentially identical between the two.)  I have attached a screen shot of the block diagram below - the code necessary to communicate with the I2C chip.  (I2C Port 0 was used - currently the use of Port 0 is hard coded into the I2C VIs in LabVIEW.)

 

I am in the process of discovering exactly which I2C chip was used.  If/when I find out, I can post that information as well.

 

I hope this helps,

Kevin S.

Applications Engineer

National Instruments

Message Edited by Kevin_S on 07-31-2009 02:17 PM
Message Edited by Kevin_S on 07-31-2009 02:19 PM
0 Kudos
Message 12 of 27
(2,706 Views)

Hello Kevin,

 

thank you for your answer. I post also my code (see here: http://forums.ni.com/ni/board/message?board.id=420&thread.id=1362) which I use to communicate with a slave I2C-Temperature sensor (DS1631). using this Code I got only a clock with 4kHz on I2C-SCL Line with a Start signal, then stays the I2C-SDA line law untill clock stops then goes high again, then nothing happens!!. Unfortunately I can not post the Oscilloscope screen shot now, but I will try to do that on monday.  Please take at this code, and I will wait your comments.

 

Thanks in advance

 

Regards

0 Kudos
Message 13 of 27
(2,685 Views)

Please take at this code, and I will wait your comments.

sorry I mea, take a look at this code 🙂

 

 

0 Kudos
Message 14 of 27
(2,681 Views)

hello AMD

 

Your description of the I2C lines makes me think you are sending a 7 bit address of 0x00 and a R/W bit of 0 (for a write command), thus SDA stays low.  Once this byte is sent, the master awaits an acknowledge from the temperature sensor.  However, it is never received as you are attempting to communicate to a device with address 0x00, yet your device has an address of 1 0 0 1 A2 A1 A0.

 

Depending on how the driver is written (I don't have the code in front of me), it will either deadlock while waiting for an ACK or return an error of some sort from the VI call.

 

I think you need to do a little more research on I2C and your device, as I know these drivers are capable of handling a single slave.  It's just a matter of sending the correct messages at the correct clock rate and verifying the expected signal is actually being sent.

0 Kudos
Message 15 of 27
(2,666 Views)

Hello Gmg,

 

That is right, the address I am sending to the slave device is wrong, it should be 72 (1001000). 

Actually I tried to send on this address (1001000) too before. But at that time I had no clock on the I2C-SCL line, so it did not work. Now and after I modified the LPC2300.s file as you described in another thread to make GPIO Port 0 and 1 working, I got a I2C clock signal.


Gmg wrote:

 

Your description of the I2C lines makes me think you are sending a 7 bit address of 0x00 and a R/W bit of 0 (for a write command), thus SDA stays low.  Once this byte is sent, the master awaits an acknowledge from the temperature sensor.  However, it is never received as you are attempting to communicate to a device with address 0x00, yet your device has an address of 1 0 0 1 A2 A1 A0



You are right.

just yesterday evening as I came home I thought about that and the performance of the clock and the data sent from Master to slave, as it appears on the oscillescope, should be correct . Since the master is sending a starting signal followed by the slave address, which I set as 0x0, so the I2C-data line keept low by the Master. then Master waits on an ACK-Signal from slave, which never come, becuase of the wrong slave address.

I will try again by setting the correct address and I will post back. (I can not do this before monday).

 

Gmg, Thank you very much for your support.

0 Kudos
Message 16 of 27
(2,655 Views)

Now it works.

the problem was the value of write address input of the I2C create configuration reference VI.  In my previous trials,I connect the write address input to a binary (0000 000) for zero address, which is wrong. then I tried with binary (1001 000) for zero address which should be correct. but it dose not work too! using the oscilloscope I found that, after sending the first 7-bits for the address, a read/write bit has been sent, but it was High ( High is for read operation). This bit should be law and that is why the communication to the device could not be established using the 7 bits connected to the write address input. 

Now I connected the Write address input of this VI to an 8-bits binary number (1001 0000). then "BINGO!" ..... it works!

 


Kevin_S wrote:

 

(I2C Port 0 was used - currently the use of Port 0 is hard coded into the I2C VIs in LabVIEW.)


so is it not possible to use other than I2C-Port0 using these VIs?

 

Many thanks to all of you, who tried to help and support me to fix this problem.

 

0 Kudos
Message 17 of 27
(2,603 Views)

Hi Amd1480.

 

What is your email?

Regards,
Claire Reid
National Instruments
0 Kudos
Message 18 of 27
(2,556 Views)

Hello Claire,

 

I would like to send you my email in a private message, but I don't know how I do this!

 

Greetings

 

0 Kudos
Message 19 of 27
(2,543 Views)

Hi Amro,

 

Are you running into  this issue as well?

 

 

Regards,
Claire Reid
National Instruments
0 Kudos
Message 20 of 27
(2,531 Views)