I have an Arduino DUE. I would like to read temperature from MLX90614. But I got altid 0xFF.
I used: I2C Open.vi, I2C Request From.vi (6 Bytes),I2C Available.vi, I2C Read.vi (6 Bytes)
I need to use C-code from here and it works:
http://forum.arduino.cc/index......msg1556216
Do you have an explain why the compiler does not support the parameters, that is found in C-codes ?
How can I integrate the parameters to the LabVIEW compiler ?
5:12 pm
March 12, 2015
To provide further detail, it appears this sensor requires a repeated start condition. See here. This is possible with the compiler in the Write functions through the Send Stop input. This is fed directly to the Wire.endTransmission(stop) input of the Arduino TWI api, which should do a repeated start when set to False. See here. However, it appears the Due has some issues with the repeated start implementation and may not work. I haven't tried it though but there is some reference to it here.
One thing to try would be to run on an Uno. Does this work? If so it is likely an issue with the repeated start on the Due, assuming you have implemented that correctly in your VI.
To answer your original questions, the Compiler implements the native Wire library only as defined here. But you can certainly wrap the above C code in a LabVIEW APIs that the your VI can call, which will be accepted by the Compiler. Take a look at the user manual section titled "Porting an Arduino Library to LabVIEW".
Hope this helps.
6:28 am
March 12, 2015
A few issues I see. You are not explicitly writing a False to the Stop input of I2C Request From. The default appears to be True, which means a stop will be sent (not a repeated start). You should not be using that time delay function as it is not in the palette. Use the included palette delay functions or the delay may not be what you expect.
Fundamentally your code is missing something else. I believe you need to write the register you want to read from first, followed by a repeated start, then a request from and read. You are never sending the write register. Please take a look at the Adafruit library. This is what you should be doing in your LabVIEW code:
uint16_t Adafruit_MLX90614::read16(uint8_t a) {
uint16_t ret;
Wire.beginTransmission(_addr); // start transmission to device
Wire.write(a); // sends register address to read from
Wire.endTransmission(false); // end transmission
Wire.requestFrom(_addr, (uint8_t)3);// send data n-bytes read
ret = Wire.read(); // receive DATA
ret |= Wire.read() << 8; // receive DATA
uint8_t pec = Wire.read();
return ret;
}
I have inserted a function : I2C Write Byte from your C-code, bute I am not sure StopEnd input will be True or False when I read from I2C in the loop. (attched: Test_I2C_with_TempC.vi)
I tried to use "Porting an Arduino Library to the Arduino Compatible Compiler for LabVIEW" as the attachment: I2CTemperature.rar. I can not upload a rar file, please download it from here:
https://www.dropbox.com/s/svwr.....e.rar?dl=0
I can compile: Get_Temperature.vi without error but when I checked the Arduino code. It was not as I expected:
1. missing : #include <Wire.h>
2. The function did not appear as expected: Wire.beginTransmission(_addr); Wire.endTransmission(false); etc.. but appeared as : BeginTrans(boolean CON_Address, unsigned short Address);EndTrans(boolean CON_StopEnd, boolean StopEnd); etc. Why there is boolean CON_Address ?
3. The RequestFrom is wrong parameters "RequestFrom(true, Const1028, true, Const1058);" I tried to exchange the 2 parameters but the result is the same.
Are there some thing wrong in my Translator.vi ?
4:07 pm
March 12, 2015
You need to re-read Step 3 – Creating the LabVIEW API VIs. You are forgetting to password protect your APIs.
You have also changed the terminal pattern of your Translator.vi, which will break the translator. You need to maintain the same terminal pattern as the Template example. After I fixed these issues, this is the output I got:
#include "LVArray.h"
#include "A4Lhelper.h"
#include <Wire.h>
void setup()
{
boolean Const1005;
unsigned short Const1028;
unsigned short Const1058;
unsigned short Const938;
unsigned short Const908;
Const1005 = false;
Const1028 = 3;
Const1058 = 90;
Const938 = 7;
Const908 = 90;
Wire.beginTransmission(Node525Out);
Wire.write(Node766Out);
Wire.endTransmission(Node777Out);
unsigned char Node1107Out;
Node1107Out = Wire.read();
unsigned char Node1153Out;
Node1153Out = Wire.read();
unsigned char Node1199Out;
Node1199Out = Wire.read();
}
void loop()
{
}
8
1 Guest(s)