LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you write register values to a sensor chip attached to arduino using LabView

Hello,

I am a High School Chemistry teacher working with the sparkfun breakout board for the MPR121 Capacitive Sensing chip-

http://www.sparkfun.com/products/9695

MPR121 Data Sheet.

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=MPR121

There are about 28 registers that you can write to and about 121 registers total. Because I am investigating the use of this chip for a variety of different applications I need to be able to write to these 28 registers, in addition I need to read more than just the touched or not touched state of each pad.  I have been able to access them all at various stages using the Arduino IDE and have been able to use it as both a touch and a proximity sensor.  But I would like to program a  VI so that I can graph different varaibales and write the data to files.

I have looked at a number of sketches by Nathan B and they have been extremely helpful but I do not understand how the values to the sensor chips are written to the chip. Any insight into to how to assign values to specific registers would be great- I would like to understand the basic theory behind the process as well as the process itself so when I move on to other sensors I code it on my own.

Thank you.

Also, I have a portion of my arduino code that allows me to examine the ADC values returned by one of the 12 touch sensors.

Download All
0 Kudos
Message 1 of 8
(6,945 Views)

To get you started, this should be the equivalent of the set_register() function.  Use the context help to see how to hook it up.  If it doesn't work or have questions let me know.

0 Kudos
Message 2 of 8
(4,879 Views)

Thank you very, very much.

0 Kudos
Message 3 of 8
(4,879 Views)

Thank you. I guess I was thinking that I could input an array with the address as one element and the values as a second element, but looking at my Arduino code and the code of others, the registers are set individually one at a time.

So with your Set Register VI, I could create a sub VI called MPR121 setup where I include the Set Register VI for each register I want to set. Is this a correct statement? Thank you again.

Sean

0 Kudos
Message 4 of 8
(4,879 Views)

Yep, that's what I would do.  You will then need to make a VI like I did to read the data values and such.  Like I said, you are essentially just porting the Arduino code to LabVIEW.  But you have to remember that it can't be done for everything that you see done on the Arduino.  I would say you could do everything this time with the exception of the interrupt.

0 Kudos
Message 5 of 8
(4,879 Views)

Thank you again. I have one more question about sub VIs in general. In the Set Registers VI, if I just put that into my VI I still need to wire the I2C address, the register address, and the value. But when I look at the front panel of the Set Registers VI, now a sub VI in my VI, I can set both addresses and the register value. Why then does it still need to be wired into my VI - why can I just set the values in the front panel of each instance of the Set Registers I use in my VI- I am sure this question illustrates my total ignorance of all things computer programming. I am teaching myself from scratch.

Also, if I were to program the array to set the values would I take an array of my addresses and the array of my setting for those addreses and combine them into a single array such that

Array of Hypothertical Register Addresses

C, 1, 4

Values I wan them set to

0, 1, 8C

Input array into set registers

Address, value, address, value

0C, 0, 1, 1, 8C

Is that how an I2C chip basically looks at the write values- the first is an address, 2nd it value, 3rd address, 4th its value?

Thank you very much for all of your help.

0 Kudos
Message 6 of 8
(4,879 Views)

There is only ONE instance of the Set Register VI.  It's a function.  You can use it many times with different parameters (the wires).  It's exactly the same as the set_register() function in your code.  You have to give it the three values everytime you use it.  The wire inputs are exactly the same as the input arguments in a text based function.

When communicating via I2C, you have to initiate the communication with the device address.  Then, you send the register value for which you are going to do something with.  Then, if you are writing to the register, you send the value and end the communication.

As for your hypothertical situation, using arrays is one way to do it.  You could then use a loop to pull values from the array and use those values wired to my VI.  This way you wouldn't have to use my VI 20 times for 20 values.

I'm thinking I woudl probably use an array of clusters (consisting of a register and it's value) and then loop through that array but if you are not familiar with LabVIEW data structures then maybe that would be too complicated.

0 Kudos
Message 7 of 8
(4,879 Views)

Okay. Now I am begining to understand. I just was not linking the way LabView does things to the code in IDE. I will wait to play with arrays until I have more programming experience. Thank you very much.

0 Kudos
Message 8 of 8
(4,879 Views)