01-01-2017 06:54 PM
Hello, I am doing a program in labview that receives arduino data and saves them in excel along with the time and date.
The program is to save the events of the user inputs for an access control system. When the user enters the place, save the user ID along with the time and date in an excel sheet.
If a user does not enter the place does not save anything.
I have already done the program and it works well. The problem is that the program saves every millisecond of time (without the user having entered the site) (see Labview Excel image) . And consequently saves a lot of data (time and date) that is useless.
I need to make a condition that saves the time and date every time I receive a data from the serial port, if the program does not receive any data does not save anything.
I did 2 labview programs. In labview 1.0 (see labview 1.0 image) add a case in order to know if I received a serial port data. In case of receiving a data from the serial port "save" in excel the data together with the time and date. In case you do not receive any information "Do not keep anything." But I did not know how to make that condition so I put a boolean.
In labview 2.0 I did the same thing only that I put the structure case outside of the while and the condition put an error state. I get the same result as the previous one. I keep saving the time and date without having received a data by the serial port.
Someone can kindly help me, I'm new and I've been learning labview for 1 week.
Thank you very much
Merry Christmas and Happy New Year
(Translate by: translate google)
01-02-2017 03:01 AM
Hi Carlos,
saves them in excel
No, you create a (formatted) text file. Even naming it with a "xls" suffix seems wrong to me. Use ".csv" instead!
The problem is that the program saves every millisecond of time (without the user having entered the site) (see Labview Excel image) . And consequently saves a lot of data (time and date) that is useless.
Yes, you programmed it this way…
I need to make a condition that saves the time and date every time I receive a data from the serial port, if the program does not receive any data does not save anything.
That's your condition: "IF no data received THEN don't save to file"!
Another problem:
When you set your serial connection to wait for a TermChar you should not use BytesAtPort! (Infact you don't need BytesAtPort at ~99.9% of all serial communication routines!)
Use a "big" number for the bytes to read and check for TimeOut errors…
01-02-2017 08:10 PM
That's your condition: "IF no data received THEN don't save to file"!
Hi, thank you very much for your help. I just want to know how to make that condition in labview? In short, I do not know what function / instruments to use to make that condition.
In arduino to receive a data for example is easy:
// Read if you received a serial port data
If (Serial.available ()> 0) {
// read the incoming byte:
read = Serial.read ();
// Print the value "read"
Serial.println (read);
//
}
But in labview I do not know how to make the condition to know if it received a data or not.
I really hope your help, I'm very new to labview and I want to learn, really.
It's my only query at the moment, thank you very much. Happy New Year!
01-03-2017 01:27 AM - edited 01-03-2017 01:28 AM
Hi Carlos,
In arduino to receive a data for example is easy
"If (Serial.available ()> 0)"
In LabVIEW it's easy too!
You either check for an empty string (after VISARead) or you simply check the output of BytesAtPort - which basically is the same as "Serial.available"…
Btw. Using BytesAtPort is just WRONG here! You have initialized your serial communication to use a TermChar (see the help for InitSerialPort): delete the BytesAtPort node and use a constant (like 99) as input for VISARead!
01-03-2017 07:29 AM
From your latest image:
Refer to this image that I used here. This is a proper set up a serial read when the instrument sends data at non-determinate times. I first use the Bytes At Port to see if any data is available. If there is data, I read it. AND DO NOT USE THE BYTES AT PORT TO DETERMINE HOW MANY BYTES TO READ. With the termination character, the VISA Read will stop reading when that termination character is read. So tell the VISA Read to read more bytes than your message could possibly be. The reason is that you could be reading partial messages due to weird race conditions. This is true not matter what language you use. The Serial.println does the same thing. Also note that in the 0 case I have a wait (I think 50ms). No reason to wait if you have data.
01-03-2017 10:58 PM
I did it, it works the way I want it to. Thank you very much for helping me. Happy New Year!
I share it with the community. (Attached image)
01-04-2017 12:17 AM
If you want to share your code with the community, do not use a simple picture in jpg. Use a LabVIEW snippet, or attach your actual VI. Besides, if you have found a solution, mark that post as "solution". This helps future visitors with the same problem.
01-04-2017 06:43 AM
@Blokk wrote:
Besides, if you have found a solution, mark that post as "solution". This helps future visitors with the same problem.
You should also give Kudos for posts that you found helpful.
09-07-2021 07:41 AM - edited 09-07-2021 07:42 AM
good evening dear,
Could you please share the Arduino code file for this example.
or a pic