annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

MCP23017, I2C LabView HELP PLEASE.

Risolto!
Vai alla soluzione

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

0 Kudos
Messaggio 11 di 21
3.951Visualizzazioni

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
Messaggio 12 di 21
3.945Visualizzazioni

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.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Messaggio 13 di 21
3.941Visualizzazioni

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
Messaggio 14 di 21
3.937Visualizzazioni

@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.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Messaggio 15 di 21
3.934Visualizzazioni

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

Scarica tutti
0 Kudos
Messaggio 16 di 21
3.937Visualizzazioni
Soluzione
Accettato da 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
Messaggio 17 di 21
3.895Visualizzazioni

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

0 Kudos
Messaggio 18 di 21
3.877Visualizzazioni

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
Messaggio 19 di 21
3.869Visualizzazioni

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
Messaggio 20 di 21
3.853Visualizzazioni