LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending Values to an Array when a Record Button Is Pressed

Solved!
Go to solution

Hi,

 

I am displaying elapsed time on the display panel.  I also have a "record" button on the panel and I would like it to take the current elapsed time value and write it to a spreadsheet.  Currently my code runs the elapsed time and resets when I press record, but it records every single value and overwrites itself.

 

 

0 Kudos
Message 1 of 12
(4,564 Views)
Solution
Accepted by hturner

You need to set up a shift register instead of your tunnel you currently have.  What's happening is when you finally press stop, it takes the last value it saw for your elapsed time, record data, and time stamp and puts that in your spreadsheet.  You simply need to put a shift register and a build array that has one input as the current data and the next input as the new data.  You need to do that for each of your records that are going to change during a run.  

 

Also why are you building into an array before the spreadsheet?  I would think you might want to concatenate those strings instead.

Message 2 of 12
(4,551 Views)

Thank you.  I will try the shift register instead.  I honestly havent heard of concatenating before and I saw an example like this online that sent to a speadsheet so i tried to mimc it. 

0 Kudos
Message 3 of 12
(4,541 Views)

Just keep in mind you need to initialize the shift register outside of the while loop as a 1D array of strings.

 

You can find the concatenate under Programming>Strings>Concatenate.  You could build it into array though as you are doing and have the tab as the delimiter.  That would just change your 1D array into a 2D array.  Concatenating is useful if you want a specific format i.e. Time Stamp : Record Data/Time Elapsed. Though if you wanted this in Excel, you should indeed build an array because as just mentioned it will put each one into its own individual column.

0 Kudos
Message 4 of 12
(4,535 Views)

The Shift Register worked great!  Thanks

 

Currently my code records every single elapsed value during operation.  This make 100000+  entries, not good.  What loop structure would you suggest or funtion block to only record the elapsed time when I press record?

 

 

0 Kudos
Message 5 of 12
(4,528 Views)

An event structure.  Just house all of your code into an event structure that waits for record to be pressed.  Note you would also have to add an event for the stop button, so that it exits the while loop properly.

0 Kudos
Message 6 of 12
(4,525 Views)

I have tried putting the event structure around my code as you suggested and I added the record triggered action but what happend was when I ran the program nothing happend until I pressed record and then It ran my normal code.  I then tried putting the event around the output string to the array so that it would block the signal until callled upon but that didnt work either. I suggested labview to my company because I remember it being use friendly in college so now i just feel stupid.

0 Kudos
Message 7 of 12
(4,509 Views)

Can you go over the steps you want for your VI? There are a lot of stray indicators and a random run button.  You really first need to think of what you want your VI to do.  Then make an architecture from that.  You need to plan out what happens when one button is pressed.  I really feel you need to write all of these things down in a pseudo-code like format first.  LabVIEW is, indeed, more user-friendly than trying to do what you are currently doing in C++ or some other language mainly because of what it takes to make a GUI. You'll eventually get the hang of it.

0 Kudos
Message 8 of 12
(4,503 Views)

The stray indocators at the bottom are going to be used for parts/per hour indication.  simple items that I am ignoring for now.    The meat and potatos of the program is that it will show a machine operator the time it has taken for a part or cylce compared to the accepted time.  Got that.   Now the difficulty is getting the data to record properly.  I would like to press the record button and the current elapsed time be saved along with the timestamp and part number.  Then the elapsed time will restart and i will be able to press record agian.  I want one excel data entry everytime I press record.

0 Kudos
Message 9 of 12
(4,497 Views)

@hturner wrote:

I have tried putting the event structure around my code as you suggested and I added the record triggered action but what happend was when I ran the program nothing happend until I pressed record and then It ran my normal code.  I then tried putting the event around the output string to the array so that it would block the signal until callled upon but that didnt work either. I suggested labview to my company because I remember it being use friendly in college so now i just feel stupid.


You don't put the event structure around your code, you put it inside the outermost while loop. It has taken me a while to get used to event structures, too (I still don't always do them right the first time). Go to the help file first.

 

If your company bought LabVIEW with a SSP, then you're in luck! As long as the SSP is in force, you can go onto NI's website and go through the Core 1, 2, and 3 classes online for free (Event structures are Core 2, Lesson 3). There, you'll learn a LOT about LV. It is a relatively user friendly language, just like you thought, but there is a non-trivial learning curve involved.

 

Oh, and if you upload your code as LV12 VIs, there will be many more people (including myself) who can help you, since many haven't upgraded to LV13 yet.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 10 of 12
(4,489 Views)