7:03 pm
March 19, 2015
I'm attempting to read data from a MCP9808 via I2C. I'm uncertain about the output that I get from Read All Bytes.vi and I'm trying to convert the output to binary so that I can handle the masking of the first 3 bits of my 16 bit register (and verify that my output makes sense).
If you take a look at the image below that I have taken from the 9808 spec sheet, it shows that the 4th bit is the sign bit and the rest is the actual data in 2's compliment. I'm currently at a loss as to how I can return the value of the register in binary, or at least mask the first 3 bits, use the 4th bit to reveal the sign to yield a temperature in deg C.
This is all a learning experience to me and I'm having a lot of fun with ACC4LV, I just reach a dead end every now and then. - Or maybe it's not so much a dead end as not knowing how to open the next door!
I would appreciate anyone's input on the matter.
Thanks,
Kbet
10:16 am
Hi,
in the datasheet of MCP9808 is a source code example. You can use this in your own header or "c" file. These files can be used in the Arduino compatible Compiler. Please read the manual. Chapter: "Porting an Arduino Library to LabVIEW".
There you can see all possibility's to use C-Code in the compiler. I think you can solve very easily your problem.
Adrian
7:34 pm
March 19, 2015
Adrian,
I thought this operation might come to porting the library to arduino, but I'm not familiar with the tool. So, I'm dragging my feet on that topic right now. I'll have to go through the add and subtract examples and work my way along.
Seffan,
Thanks for the tip on bitwise operators. Didn't know that And and Or could be used in Labview as it can be used in C. So, I'm now attempting to 'Split Number' then 'And' the upper byte to check for the sign in bit 12, followed by 'Or' to write the top 4 bits to '0'.
I'll let you know how it goes.
Kbet
13
1 Guest(s)