Hi Jakkrich, sorry for the slow response. One thing you need to make sure of is that you have the drivers properly installed for LabVIEW to access the serial port. You will need a special disk for this, LabVIEW does not automatically have the drivers for it. You can search for serial port drivers on the national instrument website. If I can find the link i will post it. Most likely that error means you don't have the necessary drivers for LabVIEW to access your serial ports on the computer. Have you loaded these drivers?
Thanks David for warmly reply. Yeah I think so, my pc is see no arduino on it' serial port USB. Now, I have to use the LINX instead, as suggestion in arduino play ground website. So, the labview can work with arduino. However, it was unable to connect arduino intermittently whenever I stop-run my program, I try to reset many time to make it recover. Therefore, I have to replace the new Uno board its working better, but a few same trouble so it about 1/10 faulty occurred. Thank you so much David for your Idea shared through UA-cam, you wake me up to starting, and also people around the world. Its a goodness.
Remember you can not have LabVIEW and the arduino software running at the same time. You can only do one at a time. Are using Arduino UNO or nano. I had trouble with the Nano on a Mac. Uno is good. Are you using USB 2 or 3 on your PC?
Configure VISA port can go outside the while loop, because you only need to do it once. Inside the while loop will cause it to re-establish a connection every with iteration, slowing the loop down.
Hi David, nice video. I have one doubt, why are you keeping the VISA initialization inside the loop. We can place it outside the loop as well. so that it won't initialize each time the loop iterates. I'm not much familiar with hardware interfacing in the LabVIEW. Could you please clear my doubt?
Can i make one question to you? If i have a Power Spectrum and i want it's coordinates to be sent to arduino for further processing how would I know in which format they arrive? I know it's in ASCII so first of all i have to translate them, but how would i know if the first number i translate is in Y axis( for me dB) or in X axis ( for me Hz). Do you have any ideas ? I sent them via COM/port to Arduino Uno. Thank you in advance.
Hi david,thank you for this amazing video,But I have a question, I need to have the data from one arduino to 3 different analog input(voltage) and one digital input (temperature) so I have 'text value text value text value text value' format in my serial port.how can I have all of this data in one excel file ?? thanks a lot
Hi David really great Video, I need some help over reading multiple data from the serial port in my arduino code I send some text and some bytes arrays how can I read the two data types differently thank you
Hi Kevin, can you be a little more specific about your problem? What devices are you trying to read? In general when you read data from a serial port with LabVIEW, it just reads what is coming in. It will help to know what your data looks like. You can see what it looks like from your Arduino program. In general, with this program you should just be able to read the serial port with LabVIEW. Once you have it in LabVIEW, you will have to save it as a string, and then take what you want. There are many options in the string menu for taking pieces of a string. Here is what you can do: From the back panel, right click and go to the programming window, then go to the string menu, then choose string subset. Then beginning at the offset, it will return a string of the length you specify. If you do this twice, you can get out multiple pieces of data. I used it once to get temperature and pressure. You will need to set the length of the strings in your Arduino code so you can retrieve them in LabVIEW.
Hi David, I am sending from the arduino 4 numbers (4 temperatures) and I want to read it in labview to plot it individually; Currently I can read the whole string of data... thus, How can I split the string coming from the arduino into individual temperature values? Thanks in advance...
Hi Mario, Look in the Functions menu under Programming>Strings. You can use the String Subset to pull out part of the string. You an do this four times for each of the numbers that are coming in as a string. Then you can convert them to numbers and put them in some type of an array depending on what you need. Under Programming>Strings you will find all the tools you need to do this. You should be able to find a lot of useful code online. You could post your Arduino code in the comments so I can take a look at it.
Hi David' First of all, many thanks for the helpful video. I am using HAMAMATSU c12880ma mini-spectrometer. I want to get data from my spectrometer by using arduino UNO and I am gonna use LabView for graphical interface. Do you think if I do the same block diagram with you, it works for me ? Thanks, in advance. My Code ; /* * Macro Definitions */ #define SPEC_TRG A0 #define SPEC_ST A1 #define SPEC_CLK A2 #define SPEC_VIDEO A3 #define WHITE_LED A4 #define LASER_404 A5 #define SPEC_CHANNELS 288 // New Spec Channel uint16_t data[SPEC_CHANNELS]; void setup(){ //Set desired pins to OUTPUT pinMode(SPEC_CLK, OUTPUT); pinMode(SPEC_ST, OUTPUT); pinMode(LASER_404, OUTPUT); pinMode(WHITE_LED, OUTPUT); digitalWrite(SPEC_CLK, HIGH); // Set SPEC_CLK High digitalWrite(SPEC_ST, LOW); // Set SPEC_ST Low Serial.begin(115200); // Baud Rate set to 115200
} /* * This functions reads spectrometer data from SPEC_VIDEO * Look at the Timing Chart in the Datasheet for more info */ void readSpectrometer(){ int delayTime = 1; // delay time // Start clock cycle and set start pulse to signal start digitalWrite(SPEC_CLK, LOW); delayMicroseconds(delayTime); digitalWrite(SPEC_CLK, HIGH); delayMicroseconds(delayTime); digitalWrite(SPEC_CLK, LOW); digitalWrite(SPEC_ST, HIGH); delayMicroseconds(delayTime); //Sample for a period of time for(int i = 0; i < 15; i++){ digitalWrite(SPEC_CLK, HIGH); delayMicroseconds(delayTime); digitalWrite(SPEC_CLK, LOW); delayMicroseconds(delayTime);
} //Set SPEC_ST to low digitalWrite(SPEC_ST, LOW); //Sample for a period of time for(int i = 0; i < 85; i++){ digitalWrite(SPEC_CLK, HIGH); delayMicroseconds(delayTime); digitalWrite(SPEC_CLK, LOW); delayMicroseconds(delayTime);
} //One more clock pulse before the actual read digitalWrite(SPEC_CLK, HIGH); delayMicroseconds(delayTime); digitalWrite(SPEC_CLK, LOW); delayMicroseconds(delayTime); //Read from SPEC_VIDEO for(int i = 0; i < SPEC_CHANNELS; i++){ data[i] = analogRead(SPEC_VIDEO);
Dear Sir Kindly post the code for arduino as i am trying to read temperature from the analogue pin of my Arduino mega in Lab view for my final year project . If you upload the sample code for arduino that would be pretty helpful . Thanks waiting for your response.
Hi David, I configure the same program, but when I´m trying to read the data with Labview it gives the wrong numbers. for example I send 5.23 and it read 5.js in Labview. I have the same baud rate (9600), but even if I change it in both programs It keeps sending the same problem. Do you know what could be the solution? Thanks
+David Saenz Hey David, it could be a number of issues. The first thing to check would be to see if your computer is able to read the correct data from the Arduino card. You can do this by clicking on the Serial Monitor button at the top in the native Arduino software. This can tell you if something weird is going on with your card. If that is working, then it is a problem in LabVIEW. It is most likely a setting with the way you are displaying your numbers. If you could post a screenshot that would be very helpful. Often with LabVIEW there is a setting that is incorrect that is causing the issues. The Arduino card should be giving you strings. Then you need to convert it to a number.
Here is some example code: int TMP36 = A0; int temperature = 0; int temp[10]; int tempf = 0; int time= 20; void setup() { //The middle pin (signal) is connected to analog pin A0. //Value for the temperature. //temp[10] creates ten values with the names temp[1], temp[2], temp[3] and so on... //The value „time“ is for the delay between two measurements. // 14 Serial.begin(9600); } void loop() { temp[1] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time); temp[2] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time); temp[3] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time); temp[4] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time); temp[5] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time);// temp[6] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time); temp[7] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time); temp[8] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time); temp[9] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time); temp[10] = map(analogRead(TMP36), 0, 410, -50, 150); temperature= (temp[1]+temp[2]+temp[3]+temp[4]+temp[5]+temp[6]+temp[7]+temp[8]+temp[9]+temp[10])/10; // everything in one line!!!! tempf= temperature*9/5+32; Serial.print(tempf); Serial.println(" degree"); } The critical part is at the end Serial.print(temps). Labview will capture anything coming over the serial port. You just need to send something to the serial port. It usually is a string, so you will have to process it in LabVIEW appropriately for what you are doing.
Correct, feedback is needed to save the actual value of the serial port before it is deleted
Hi Jakkrich, sorry for the slow response. One thing you need to make sure of is that you have the drivers properly installed for LabVIEW to access the serial port. You will need a special disk for this, LabVIEW does not automatically have the drivers for it. You can search for serial port drivers on the national instrument website. If I can find the link i will post it. Most likely that error means you don't have the necessary drivers for LabVIEW to access your serial ports on the computer. Have you loaded these drivers?
Thanks David for warmly reply. Yeah I think so, my pc is see no arduino on it' serial port USB.
Now, I have to use the LINX instead, as suggestion in arduino play ground website.
So, the labview can work with arduino. However, it was unable to connect arduino intermittently whenever I stop-run my program, I try to reset many time to make it recover. Therefore, I have to replace the new Uno board its working better, but a few same trouble so it about 1/10 faulty occurred.
Thank you so much David for your Idea shared through UA-cam, you wake me up to starting, and also people around the world. Its a goodness.
Remember you can not have LabVIEW and the arduino software running at the same time. You can only do one at a time. Are using Arduino UNO or nano. I had trouble with the Nano on a Mac. Uno is good. Are you using USB 2 or 3 on your PC?
Yap, I agree. So I using Uno board and USB2 of PC.
Configure VISA port can go outside the while loop, because you only need to do it once. Inside the while loop will cause it to re-establish a connection every with iteration, slowing the loop down.
Hi David, nice video. I have one doubt, why are you keeping the VISA initialization inside the loop. We can place it outside the loop as well. so that it won't initialize each time the loop iterates. I'm not much familiar with hardware interfacing in the LabVIEW. Could you please clear my doubt?
If you put the VISA configure serial port outside the loop that will fix problems with noise or unnecessary characters on your results.
Thank's bro, very helpful your video to start. Some details to change but very useful, it work for me perfectly. (y)
Can i make one question to you? If i have a Power Spectrum and i want it's coordinates to be sent to arduino for further processing how would I know in which format they arrive? I know it's in ASCII so first of all i have to translate them, but how would i know if the first number i translate is in Y axis( for me dB) or in X axis ( for me Hz). Do you have any ideas ? I sent them via COM/port to Arduino Uno.
Thank you in advance.
Hi david,thank you for this amazing video,But I have a question, I need to have the data from one arduino to 3 different analog input(voltage) and one digital input (temperature) so I have 'text value text value text value text value' format in my serial port.how can I have all of this data in one excel file ?? thanks a lot
Hi David really great Video, I need some help over reading multiple data from the serial port in my arduino code I send some text and some bytes arrays how can I read the two data types differently thank you
Hi Kevin, can you be a little more specific about your problem? What devices are you trying to read? In general when you read data from a serial port with LabVIEW, it just reads what is coming in. It will help to know what your data looks like. You can see what it looks like from your Arduino program. In general, with this program you should just be able to read the serial port with LabVIEW. Once you have it in LabVIEW, you will have to save it as a string, and then take what you want. There are many options in the string menu for taking pieces of a string. Here is what you can do:
From the back panel, right click and go to the programming window, then go to the string menu, then choose string subset. Then beginning at the offset, it will return a string of the length you specify. If you do this twice, you can get out multiple pieces of data. I used it once to get temperature and pressure. You will need to set the length of the strings in your Arduino code so you can retrieve them in LabVIEW.
Hello, how can i start a program with serial communication instead of push button for example
Hi David, I am sending from the arduino 4 numbers (4 temperatures) and I want to read it in labview to plot it individually; Currently I can read the whole string of data... thus, How can I split the string coming from the arduino into individual temperature values? Thanks in advance...
Hi Mario,
Look in the Functions menu under Programming>Strings. You can use the String Subset to pull out part of the string. You an do this four times for each of the numbers that are coming in as a string. Then you can convert them to numbers and put them in some type of an array depending on what you need. Under Programming>Strings you will find all the tools you need to do this. You should be able to find a lot of useful code online. You could post your Arduino code in the comments so I can take a look at it.
www.instructables.com/id/Arduino-Labview-With-2-DS18B20/
Hi sir, i'm having problem converting from read buffer of visa reader to number, it converts only one time .
Is the arduino code that you show in the video complete? Or is there more code at the top of the file?
Let me find the code and I will post it. It has been some time and I have to teach class right now. But I will get back to you!
Hi David'
First of all, many thanks for the helpful video. I am using HAMAMATSU c12880ma mini-spectrometer. I want to get data from my spectrometer by using arduino UNO and I am gonna use LabView for graphical interface. Do you think if I do the same block diagram with you, it works for me ? Thanks, in advance. My Code ;
/*
* Macro Definitions
*/
#define SPEC_TRG A0
#define SPEC_ST A1
#define SPEC_CLK A2
#define SPEC_VIDEO A3
#define WHITE_LED A4
#define LASER_404 A5
#define SPEC_CHANNELS 288 // New Spec Channel
uint16_t data[SPEC_CHANNELS];
void setup(){
//Set desired pins to OUTPUT
pinMode(SPEC_CLK, OUTPUT);
pinMode(SPEC_ST, OUTPUT);
pinMode(LASER_404, OUTPUT);
pinMode(WHITE_LED, OUTPUT);
digitalWrite(SPEC_CLK, HIGH); // Set SPEC_CLK High
digitalWrite(SPEC_ST, LOW); // Set SPEC_ST Low
Serial.begin(115200); // Baud Rate set to 115200
}
/*
* This functions reads spectrometer data from SPEC_VIDEO
* Look at the Timing Chart in the Datasheet for more info
*/
void readSpectrometer(){
int delayTime = 1; // delay time
// Start clock cycle and set start pulse to signal start
digitalWrite(SPEC_CLK, LOW);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, LOW);
digitalWrite(SPEC_ST, HIGH);
delayMicroseconds(delayTime);
//Sample for a period of time
for(int i = 0; i < 15; i++){
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, LOW);
delayMicroseconds(delayTime);
}
//Set SPEC_ST to low
digitalWrite(SPEC_ST, LOW);
//Sample for a period of time
for(int i = 0; i < 85; i++){
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, LOW);
delayMicroseconds(delayTime);
}
//One more clock pulse before the actual read
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, LOW);
delayMicroseconds(delayTime);
//Read from SPEC_VIDEO
for(int i = 0; i < SPEC_CHANNELS; i++){
data[i] = analogRead(SPEC_VIDEO);
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, LOW);
delayMicroseconds(delayTime);
}
//Set SPEC_ST to high
digitalWrite(SPEC_ST, HIGH);
//Sample for a small amount of time
for(int i = 0; i < 7; i++){
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
digitalWrite(SPEC_CLK, LOW);
delayMicroseconds(delayTime);
}
digitalWrite(SPEC_CLK, HIGH);
delayMicroseconds(delayTime);
}
/*
* The function below prints out data to the terminal or
* processing plot
*/
void printData(){
for (int i = 0; i < SPEC_CHANNELS; i++){
Serial.print(data[i]);
Serial.print(',');
}
Serial.print("
");
}
void loop(){
readSpectrometer();
printData();
delay(10);
}
I have made this program but the error pop up always appears
Dear Sir Kindly post the code for arduino as i am trying to read temperature from the analogue pin of my Arduino mega in Lab view for my final year project . If you upload the sample code for arduino that would be pretty helpful . Thanks waiting for your response.
Hi David,
I configure the same program, but when I´m trying to read the data with Labview it gives the wrong numbers. for example I send 5.23 and it read 5.js in Labview.
I have the same baud rate (9600), but even if I change it in both programs It keeps sending the same problem. Do you know what could be the solution? Thanks
+David Saenz Hey David, it could be a number of issues. The first thing to check would be to see if your computer is able to read the correct data from the Arduino card. You can do this by clicking on the Serial Monitor button at the top in the native Arduino software. This can tell you if something weird is going on with your card.
If that is working, then it is a problem in LabVIEW. It is most likely a setting with the way you are displaying your numbers. If you could post a screenshot that would be very helpful. Often with LabVIEW there is a setting that is incorrect that is causing the issues.
The Arduino card should be giving you strings. Then you need to convert it to a number.
+David Wisbey I was sending the data without delay. I put a delay of (100) and it started working, but sometimes it sends the wrong data.
Thanks!
+David Saenz Great! Glad it works!
Can you provide the arduino code, please?
Here is some example code:
int TMP36 = A0;
int temperature = 0;
int temp[10];
int tempf = 0;
int time= 20;
void setup() {
//The middle pin (signal) is connected to analog pin A0.
//Value for the temperature.
//temp[10] creates ten values with the names temp[1], temp[2], temp[3] and so on...
//The value „time“ is for the delay between two measurements.
// 14
Serial.begin(9600); }
void loop() {
temp[1] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time);
temp[2] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time);
temp[3] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time);
temp[4] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time);
temp[5] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time);//
temp[6] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time);
temp[7] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time);
temp[8] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time);
temp[9] = map(analogRead(TMP36), 0, 410, -50, 150); delay(time);
temp[10] = map(analogRead(TMP36), 0, 410, -50, 150);
temperature= (temp[1]+temp[2]+temp[3]+temp[4]+temp[5]+temp[6]+temp[7]+temp[8]+temp[9]+temp[10])/10; // everything in one line!!!!
tempf= temperature*9/5+32;
Serial.print(tempf); Serial.println(" degree"); }
The critical part is at the end Serial.print(temps).
Labview will capture anything coming over the serial port. You just need to send something to the serial port. It usually is a string, so you will have to process it in LabVIEW appropriately for what you are doing.