09-19-2012 12:14 PM
Greetings all,
I am trying to communicate with an I2C device (a magnetometer - https://www.sparkfun.com/products/10619?) and it's I2C. I have it hooked up to the USB-8451.
I am trying to implement it in LabView, but a couple issues I am having from the start. And please note that I have looked at example block diagrams and am still having some trouble as I've never worked with I2C before.
1.) Labview won't let me enter the address properly. According to sparkfun, it's supposed to be 0x0E, but I can only input 0xE.
2.) I can't enter a decimal value for the voltage.
3.) Does anyone know if the 8451 has an internal pull-up resistor? I looked at the manual but it didn't answer my question specifically.
4.) I assume the max clock rate the 8451 can handle is 250 kHz, correct?
5.) When I do try to run the program, I receive the error Error -301713 occurred at Property Node (arg 1) , and it says NI-845x: An input parameter, or combination of parameters, is invalid. An example of this error may be setting an invalid baud rate or enabling I2C ACK polling while using 10-bit addressing. Does anyone know how to fix this?
I'm just trying to read from this device and then go from there. Please let me know if you need me to attach my VI.
Thanks!
TheLT
09-19-2012 12:56 PM
@TheLT wrote:
1.) Labview won't let me enter the address properly. According to sparkfun, it's supposed to be 0x0E, but I can only input 0xE.
0x0E and 0xE are the same number. Just like 03 and 3 are the same number. Leading zeros are irrelevant, and are only useful for humans to see things in certain formats.
2.) I can't enter a decimal value for the voltage.
I have no idea what this means. Enter it where?
3.) Does anyone know if the 8451 has an internal pull-up resistor? I looked at the manual but it didn't answer my question specifically.
The 8451 does not have pull-up resistors.
4.) I assume the max clock rate the 8451 can handle is 250 kHz, correct?
Correct. This is indicated in the specifications.
5.) When I do try to run the program, I receive the error Error -301713 occurred at Property Node (arg 1) , and it says NI-845x: An input parameter, or combination of parameters, is invalid. An example of this error may be setting an invalid baud rate or enabling I2C ACK polling while using 10-bit addressing. Does anyone know how to fix this?
Not without seeing your code. Please upload your VI.
09-19-2012 03:43 PM
smercurio,
Thanks for getting back to me! I was pretty sure about the 0xE and 0x0E being the same, but someone at Sparkfun was saying that they are two different things.
Ok, attached is my code. I did give it an honest effort to try and read from this device. Oh, on the front panel, I tried to enter in 3.3V in the voltage level as they do in General I2C Read in the NI Example code, but it wouldn't let me do it, and eveything is the same on my end.
Please let me know what you can suggest.
Thanks!
TheLT
09-19-2012 08:57 PM
Update - I did fix the decimal issue in the voltage level - I just copied it from the General I2C Read Example since that has an option to Edit Values in the Properties section of that control on the front panel. I don't know how to do that (possibly create an Edit Values tab in Properties) so I just copied it over.
But, still, I cannot read from the device.
Thanks!
09-20-2012 07:30 AM
Unfortunately, I do not have LabVIEW 2012 yet, so I can't view your code. If you resave it as 2011 then I can take a look at it for you. Or, someone else with LabVIEW 2012 can as well.
09-20-2012 07:33 AM
smercurio,
Hold on - I do have 2011 - give me 10 minutes and I will post back.
Thanks!
TheLT
09-20-2012 07:47 AM
smecurio,
Ok - here's the same thing in 2011. Funny thing is, in 2011 the I/O voltage level control is automatic, where in 2012 I had to cut and paste it from the example code.
Still having the other problems though.
Thanks!
TheLT
09-20-2012 08:03 AM
You can't set a decimal value for I/O voltage level. That parameter is an integer in which the integer value corresponds to a specific voltage level. When you right-click on the parameter and select Create -> Control then a ring gets automatically created to provide the integer values. The ring string items correspond to the "meaning" of the integer values. When you are not sure about a parameter, right-click and select "Help for <parameter>".
As for your VI, you cannot read from the device unless you tell it which register address to start reading from. You are not doing that. You need the I2C Write Read VI, and you need to write the register address where you want to start reading, and how many bytes to read. The "Microchip 24LC512 Read" example is the one you should be looking at. The difference between that and your device is that in your case the register address is a U8, and in the 24LC512 it's a U16. This just means you would not need the Split Number function. You can just wire the U8 register address directly into a Build Array functions that's just one element high.
09-20-2012 11:35 AM
smecurio,
Ok, I "fixed" it but now I'm confused on the difference between the register address on the read-write and the address on the configuration. According to these magnetometers, they have a 7-bit I2C address of 0x0E, but I thought that information went into the configuration VI.
Sorry, it's kind of confusing.
Thanks!
TheLT
09-20-2012 01:08 PM
0xE is the address of the device. That's what's used in the first byte of the I2C command so that when a device sees an I2C command it will check the device address in the command against its own address so it knows whether it's the one being talked to, instead of another device on the bus.
The register address refers to the memory location in the device that you want to read/write from. This is second byte of the I2C command. This is so the device knows which memory location should be written to or read from. If the command is to write to a device, then the I2C command will have a third byte, which is the value to write.