LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI Scripting: wiring chart and data array (read from file)

Solved!
Go to solution

Hello,

I am using LabVIEW 2012 Student Edition and I am trying to write a VI that creates a new VI with imports some data from a text file and shows it in a chart. With the code in the photo #2 I am able to create a new VI with a chart and read the file, but when I use the code in the photo #1 I get the error "Specified objects cannot be wired together.". I am relatively new to LabVIEW and tried to follow the examples "Script Random Strip Chart with Diagram Cleanup" and "New VI Object - Location" but I was not able to get this VI working. How can I do this? Thanks

#1#1

 

#2#2

 

Message 1 of 10
(2,826 Views)

Well the error is coming up because you are trying to connect the waveform chart to itself (the terminal is the little nub that appears if you hover your mouse over the waveform chart on the block diagram). The wire source would be the thing you want to connect that terminal to (usually another terminal reference).

 

That being said, what exactly is your end goal here? I'm asking because VI scripting is usually not a topic you need to be concerned with if you're a newer developer and the task you have described doesn't really seem to fit the use case of VI scripting (although this could be a smaller portion of a larger project or just academic interest).

Matt J | National Instruments | CLA
Message 2 of 10
(2,796 Views)

Thank you, so how could I get a terminal reference from the array in order to connect it to the chart?

 

This is a small part of a project a part of which is to create new a new VI for each data file to be read.

0 Kudos
Message 3 of 10
(2,786 Views)

I think I was able to create an array constant and wire it to the chart, but I don't know how to import the data from the file into that array constant

4.JPG

 

0 Kudos
Message 4 of 10
(2,728 Views)

Use a Value property on another property node for the Array Constant.

Message 5 of 10
(2,722 Views)

It gives an error "The data type of the variant is not compatible with the data type wired to the type input."

 

5.JPG

0 Kudos
Message 6 of 10
(2,715 Views)

What does the array constant look like once the script places it on the block diagram?

 

I'm wondering if it needs another property node to enable the dimensions of the array, or even the type of data.

 

You know, if you attached your VI instead of just a picture of it, it would enable us to play with it ourselves.  😉

Message 7 of 10
(2,700 Views)
Solution
Accepted by topic author FDN98

Something strikes me as odd about this, but nonetheless I tend to give people what they want without dwelling on why.

 

CreateWaveformChart.png

 

This works just fine for me, and adapts to the datatype for 1D and 2D arrays that I tested.  Add a BD cleanup or deal with the terminal positions as you desire.

 

Attached version saved for LV12

Message 8 of 10
(2,684 Views)

@RavensFan

You're right, I should have attached it from the beginning. The files are:

  • data.txt, just a sample data file
  • empty.vi, the VI I used as a template
  • VI_1.vi is the one I should have attached 😅
  • VI_2.vi is another approach I tried to use by wiring the array directly to the chart value: apparently there are no errors but there is no data printed on the chart
Download All
0 Kudos
Message 9 of 10
(2,674 Views)

@Darin.K

Thank you, it works, can I ask you to explain me where is my mistake? 😅

 

Yes, it looks odd because almost certainly it is not the best solution for the problem (from a "main" VI I wanted to select a data txt file and open another window with a chart showing the data, and I wanted to be able to do this this for multiple data files, obtaining multiple windows, each one with the chart showing the data of the file for which it was launched).

0 Kudos
Message 10 of 10
(2,673 Views)