LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

MCP23017, I2C LabView HELP PLEASE.

Solved!
Go to solution
Highlighted

Great catch! that definitely needed to change but it didn't fix everything, same error code.

0 Kudos
Message 11 of 20
(175 Views)
Highlighted

Capture.PNG

 

My biggest confusion is when I use the "Write.vi" I'm putting in an array and I'm assuming it's supposed to tell it the register A or B (x12) and the I/O direction (x18) but what I'm wondering is am I allowed to put two values? How does it know which value is the register and which is the data?

 

 

0 Kudos
Message 12 of 20
(169 Views)
Highlighted

In an I2C write, the first value is the register and the second is the value to write to that register.  If you want to read a register, you need to use the I2C Write Read and just write the register.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 13 of 20
(165 Views)
Highlighted

Interesting, I'll trust ya cause I cant find any documentation that says that. Do you think it matters if the array is a column or a row (vertical or horizontal).

 

 

0 Kudos
Message 14 of 20
(161 Views)
Highlighted

@GeneralDynamic wrote:

Interesting, I'll trust ya cause I cant find any documentation that says that.


Read the documentation on your device.  It clearly states to write the register and then the value using a "Rewrite".  All that means is you write the register and then the value in a single write message (as far as the LabVIEW API is concerned).

 


@GeneralDynamic wrote:

Do you think it matters if the array is a column or a row (vertical or horizontal).


In LabVIEW, it is just a 1D array.  There are no rows or columns.  When you get into 2D arrays, then you can worry about that stuff.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 15 of 20
(158 Views)
Highlighted

I'm completely lost with getting my code to work. I'm trying to write some data to a Port Expander (Part Number: MCP23S17) but nothing seems to work. I'm using a USB-8451 I2C module from NI to provide the controlling but i'm trying to code it in LabVIEW. 

 

If i understand the protocol right then it is as followed:

1. Write to the correct Device & Register Address and define the I/O direction first.

2. Then write to the Device and Register Address with the actual data control.

 

Device Address: 0100100 (7-bit) because the LSB is R/W and the code will take care of this bit.

 

 

 

LabView Test Code.PNGError.PNG

Download All
0 Kudos
Message 16 of 20
(161 Views)
Highlighted
Solution
Accepted by GeneralDynamic

@GeneralDynamic wrote:

What do you mean the I2C example that ships with LabVIEW? How can I get this?


Go to Help, Find Examples.  In the "Search" option, type I2C.  Click on what it finds.  I've attached the 2019 845x "General I2C Write" VI as a Snippet -- it has no "hidden states", so you should be able to manually reproduce it.  I've never used I2C (but have used the SPI examples, and "think I understand SPI"), so I can't offer much additional help (like why there are references to EEPROMs).  Some of the other examples might be more appropriate.  I'll note that writing code for the SPI version of your chip was pretty straight-forward.

General I2C Write.png

 

Bob Schor

0 Kudos
Message 17 of 20
(119 Views)
Highlighted

I figured it out! I was able to command my RF switches!! I definitely had some coding issues that you helped with.

0 Kudos
Message 18 of 20
(101 Views)
Highlighted

How about a brief explanation of how you fixed it?  Someone else might, as you did, start using this Chip and want to use I2C, and be as confused as you were about how to get started.  What step did you add, what change did you make?  Was it simply that you left out a step that was explained in the Example?

 

Bob Schor

0 Kudos
Message 19 of 20
(93 Views)
Highlighted

Okay I'll put something together and upload some material. Part of it was code related and how to initialize/configure the chip but the final missing piece was hardware related where I missed connecting a GND wire from the NI-8451 device's terminal block.

0 Kudos
Message 20 of 20
(77 Views)