From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding a time Delay and Reading from a file

Solved!
Go to solution

Hi there, new labview user here. Working on a project and having some issues getting it off the ground. 

 

First question, in the VI below, I'm trying to have a time delay between each input but when I take a look at the Delay control, I don't see how it's supposed to set up. Does the singal flow through the timer.

 

Question 2, I would like to write to these ports via a xcel file but not certain how to do so.. 

 

Thanks for your help in advance..

0 Kudos
Message 1 of 12
(3,533 Views)

I would use a FOR loop to sequence through the values to write.  You just need an array of values to write.

 

Is your file a xlsx file?  Could you make it a text file that is written by Excel?  If so, then you can just use Read Spreadsheet File.  I would recommend having a column for the value and a second colum for your delay.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 12
(3,518 Views)

That looks great. The file is a xlsx, I supposed I could change it to a text. If I were to add another column for a differnt port, I would just have another line extending from the spreedsheet?

0 Kudos
Message 3 of 12
(3,506 Views)

@tonyc_fla wrote:

That looks great. The file is a xlsx, I supposed I could change it to a text. If I were to add another column for a differnt port, I would just have another line extending from the spreedsheet?


Sounds about right

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 12
(3,503 Views)

Ok, I built what you had and included a the text file I'm using. Seems to be a error though as the timer doesn't seem to be working.

Download All
0 Kudos
Message 5 of 12
(3,466 Views)

I'm assuming that there is a issue with the the txt file using Hex and the block digram using integer. 

0 Kudos
Message 6 of 12
(3,457 Views)

Yeah, those values writtne in hex will not translate well with the Read From Spreadsheet File when you also have decimal numbers for the delay.  That's fine.  We just need to change a few things.  Start with using the Read Text File function.  Right-click on it and select to read lines (very useful trick there).  Set the number of lines to read to -1.  That will make it read all of the lines.  Now we just use a Scan From String to parse our data.  %x will decode the hex values and %d will parse the decimal.  So we want "%x\t%d" for our format string (the "\t" is for the tab between the colums).

 

Now for your text file...You do realize the Wait VI here is defined in seconds.  So your first data point will sit there for ~2.8 HOURS.  Was that supposed to be 10 seconds?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 12
(3,441 Views)

Ok, I built it and modified my text file ( Had random stuff in there for testing) and now getting a error: LabVIEW:  Scan failed. The input string does not contain data in the expected format.

 

I noticed you set the first input to unassined long, I'm not sure how to do this without creating a constant and then changing the representation like I did for the time variable. 

 

Thanks again for the help.

Download All
0 Kudos
Message 8 of 12
(3,423 Views)

So when testing it seems to read correctly but the 'read from string' isn't parsing the data correctly.

 

It's not even sending the right data to the delay.

0 Kudos
Message 9 of 12
(3,404 Views)
Solution
Accepted by topic author tonyc_fla

It looks like Excel is adding extra bytes in there for who knows what reason.  Save your spreadsheet as a CSV and they seem to go away.  Of course, you will need to change the format string to "%x,%d" when you do that.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 12
(3,384 Views)