LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read data from table step by step

Highlighted

Hello,

 

I created table inside of .VI, where I will later set:

1. column: time in seconds

2. column: voltage in V

3. column: current limit in A

 

These data will be sent to programmable power supply (WISA WRITE or DLL...) where I want to make "step by step operation". I also created graphical representation of just few data so when someone will programming procedure will know how sequence look.

 

1. Can anyone help me how I can create for example value in first row will mean time (wait ) then second value in first row voltage (so for example wait for 5 seconds at voltage 13 V ). After time expired I want that it automatically go to second row.

 

2. how can I change code that I can insert "relative" seconds, like:

 

time(s)     voltage (V)

0                   5

5                   13

10                14

3                   13

 

that means->  at 0 s voltage is 5V then for 5 seconds at voltage 13V than for 10 seconds at voltage 14 and then for 3 seconds at voltage 13V.

 

thanks

_________________________
Rookie; LV 2011 on WIN 7
Download All
0 Kudos
Message 1 of 10
(1,723 Views)
Highlighted

Anyone ???

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 2 of 10
(1,671 Views)
Highlighted
You should be using a for loop. The table should be passed in from outside the loop. One of the fundamental features in LabVIEW is the auto-indexing of an array by the for loop. Inside the loop, you will get each row.

Have you taken any of the free tutorials? Class material is also free with the purchase of LabVIEW. After completion, your fairly simple task should be easily written.
Message 3 of 10
(1,661 Views)
Highlighted

Most of the people who participate in the Forums are volunteers who do so on their own time. Many of them do not respond on weekends, so please have some patience.

 

1. A table is a good way to have a user enter data. You can show column headers and place labels there which will prompt the users to put the data in the correct columns.

2. Because the table is a string control, you may need to validate the results before passing it to the power supply. If someone types "five volts" into the second column, the numerical output will be zero.

3. If you want the wait times to represent intervals rather than specific time of day or elapsed time in the experiment, then you need to add the intervals to create a cumulative time.

 

You do not need to index column zero a second time and convert that string array to numeric a second time. Just branch the wire. The code in both of these images produces the same graphs as yours.

 

Indexing.png

Table to graph.png

 

Lynn

Message 4 of 10
(1,653 Views)
Highlighted

Hi yes... I have done several tutorials and a lot of different application but here I stuck.

 

I tried also with "for loop" like this but as I told it before I have problems with auto inceremnting of rows for Time, Voltage, Current.

 

@ I think your last picture can not be used in my case as I need to define row and column for example excact value of voltage,current, time... (except for graphs ) -> thank you for that idea !

 

 

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 5 of 10
(1,646 Views)
Highlighted

Here is some code to give you a few ideas. This does not solve all your problems.

 

The while loop contains an even structure so that it only iterates when the table data changes or the Accept button is pressed.

 

The 2D numerical array is passed to the for loop after all the entries are made.

 

The for loop autoindexes through the rows in the array. Inside the loop Index array is used to get time, voltage, and current values from each row. The time is sent to a Wait function and the voltage and current values to indicators so you can see what it is doing. In your real program the values would be sent to the power supply.

 

Local variables are used to set the Writing to Power Supply boolean indicator.  In the real program I would use a different architecture which would not require locals.

 

Note that in the real program you probably need some error checking and some means to stop the output without waiting for the loop to autoindex through all the data.

 

Lynn

Message 6 of 10
(1,622 Views)
Highlighted

@ thanks for the idea.

 

Do you or anyone else know:

 

1. how to avoid that I always need to add some NEW values in table otherwise is not starting (even if I pressed Accept button). This I think is the problem of "empty array" which is send in the beggining or what? I want that old values which are already in table could start also the program...

 

2. I don't understand graphs 3&4

 

3. where I can set which values can be inserted on each column into table (for example into 4 column can be inserted just 0 or 1.... now I can insert whatever I want)

 

4. how can I changed time and graphs that I can insert time in this way:

 

time(s)     voltage (V)           .............

0                   5

5                   13

10                14

3                   13

 

that means->  at 0 s voltage is 5V then for 5 seconds at voltage 13V than for 10 seconds at voltage 14 and then for 3 seconds at voltage 13V.

 

 

5.

 

Note that in the real program you probably need some error checking and some means to stop the output without waiting for the loop to autoindex through all the data.

 If you mean with that error checking and safety stop of instrument before everything is executed -> yes this is in plan (driver for power supply is in progress)

 

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 7 of 10
(1,610 Views)
Highlighted

1. The simple demo program I posted uses the Table Control: Value Changed event to update the data in the table and graphs. If you have some default values that you want to use as a starting point, it takes a few steps. First place an array indicator on the 2D array of DBL coming out of the while loop. Run the VI. Enter the data you want to be the default into the Table Control. Press Accept. After the program stops, go to the block diagram and change the 2D array indicator to a constant. Use that to replace the empty array constant wired to the right terminal of the shift regsiter. Alternatively, your could just type the values into array constant whih is already there.

 

If you want to update the Table from previously saved data, look up the Configuration File VIs and learn how to use them.

 

2. Graphs 3 and 4 have exactly the same data as graphs 1 and 2 except that the x-axis values are the sum of the values in column 1. I did make one mistake which causes the graph to start at the end of the first time rather than zero. The attached VI corrects that.

 

I also changed the interpolation style on the graphs to show the voltage versus time more realistically.

 

3. The table is a string control. The user can type anything into the control. You can test what is entered in software and pop up a dialog telling the user to enter something acceptable or overwrite the data.  This can be somewhat simple or quite complex, depending on what you need to do. 

 

4. This is what I show in graphs 3 and 4 and on the meters at the output.

 

5. OK.

 

Lynn

Message 8 of 10
(1,600 Views)
Highlighted

Hello,

 

you didn't uderstand me what I was thinking...

 

1.  I don't want "default values" for me this is also not important (later I will try to add open/load from file for loading different sequences)....

 

What I want is when I run same sequence second time (press button "accept") is that program will run again, now nothing happened or VI stopped. So I need to add new value which I don't want.

For example try to run my .vi (which was already run once)

 

2. ok graphs 3&4 now I understand (the problem was that I never put 0,0, 0... in first row so it make little strange representation of data).

 

If I want that "waiting time" will work for ("left graphs") what i need to do?

 

So for example now it's

 

so that means at

0s it's 0V, then for

30s it's 5V and then for

5s it's 15V and then for

5s it's 15 V ....

 

I don't know which solution is the best for user when creating sequence for power supply? What you recommend ?

 

Thank you

_________________________
Rookie; LV 2011 on WIN 7
0 Kudos
Message 9 of 10
(1,592 Views)
Highlighted

Dear hlod,

 

The issue is happening because in this VI, the Event Structure would only give value to the output array if a "Table Value Change" event occurs. This way, you need to enter data in order for the output array stack to refresh, and if you do not do it, it will remain the same.

 

You could avoid this by haveing the Timeout Event also be able to trigger this function and adding a timeout value of for example 100ms.


If you want your VI to be able to execute multiple times, consider wrapping your whole code in a While Loop with a STOP button as a meaning of exiting this wrapper.

Please try, take your time and take a look at this code: https://decibel.ni.com/content/docs/DOC-25219

This is a secquencer which uses a great architecture, a simple state machine. In case of an application where you would drive a real-life instrument, I highly recommend you to start by using a State Machine and/or a more complex approach. This is adviced so that your application remains more scaleable, easier to read and more robust. 

 

Get back to us to see if you could make progress!

Have a nice day,

Peter

 

 

Peter L.
National Instruments Hungary
Applications Engineer
0 Kudos
Message 10 of 10
(1,544 Views)