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: 

subVI for each energy meters

hi to everyone,

 

I've got a project from my boss. its about power consumption monitoring. each power meter represents 1 subvi. if we want to add another power meter, he wants me to simply add that subvi in the LV project. he wants the design to be in this way so that the system is easy to handle and flexible.

 

unfortunately, we only used LV 8.5.1, no DSC, no OPC, no other NI devices, and power meters used modbus (serial/TCP) protocol.

 

please let me know from all of you guys if this kind of design is possible.

Ivel R. | CLAD
0 Kudos
Message 1 of 11
(3,192 Views)

Hi ivel,

The design you are talking about is possible. I know each person will have different solution What I will do is,

1)Define number of energy meters in a text file say 2

2)Make a naming convention for each energy meter vi say ENMETER_NO (e.g.. ENMETER_1)

3)Add both vi in project

4)At the start read text file for number of vis

5) Add a for loop and call ENMETER vis dynamically.

 

I hope this will help you

Best of LuckSmiley Happy

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
Message 2 of 11
(3,184 Views)

hi gaurav,

 

thanks so much for sharing your thoughts. i really dont know how to start this one. my previous program is a huge LV program for 2 energy meters in w/c is not flexible and hard to expand. i mean, if i want to add another vi, i need to delete wires and put this new program into the main program and put another control & indicators. it is specially difficult when i'm measuring too many electrical parameters.

 

your way makes sense. i just want to know few things,

a. do i need to update the text file manually? how can i read data from text file?

b. if i add another vi in the project, do i need to wire this in block diagram (we hope to do this automatically)? what i mean is, when i add the new subvi (subvi for energy meters) file, this subvi is automaticaly merge in the main vi.

c. how can i call subvi from main vi? do i need to use "sub panel" function?

 

thanks again for the time.

ivel

Ivel R. | CLAD
0 Kudos
Message 3 of 11
(3,178 Views)

Hi ivel,

I do not know your code so it is difficult to say straight away that it is possible. Lets put it in this way...

1) If your energy meter needs some data as an input and you are wiring it then if you add another vi definitely you need to wire data to the same as well.

2) If you can find another way to transfer data like global variable or functional global then you can call this sub vi dynamically. To call vi dynamically you can go to function palette>>Application control>> open vi ref .

3) Then using vi ref and invoke node you can run vi.

4)About text file, yes you need to update text file manually. Say today you have 2 energy meters so you will write 2 in the text file.

   Say later on you added another one then you can just update it in text file your code will call that vi.

5) I am attaching an example of text file. For text file related functions you can look in function palette>>File I/O>> Config file vis

 

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
0 Kudos
Message 4 of 11
(3,173 Views)

hi gaurav,

 

yes, i do have some inputs and outputs in my subvi (i.e. numeric indicator for power data).

so if i use functional global, i do not need to wire these inputs/outputs physically?

 

if i can call the subvi, i need this to show in my main vi.. all of my subvi should be show in my main vi.

 

or maybe i'll put it simple, all the power data for each subvi should be seen in main vi. if i add another subvi, another power data will show to the main vi. so, i need global variable in this application?

Ivel R. | CLAD
0 Kudos
Message 5 of 11
(3,163 Views)

Hi ivel,

Here is example of the way I would design this application.

I hope you will be able to understand it.

Best of luckSmiley Happy

Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved.
Message 6 of 11
(3,155 Views)

Hi ivel,

you should also think about using LVOOP. You can define a class for your power meter and create as many instances as you need at runtime. With this you only need to change the "text file" and your program would "automatically" load another instance at runtime.

 

Hope it helps.

Mike

Message 7 of 11
(3,150 Views)

I don't know that you really need to create a subvi for each device. You could use a cluster array that contains the device to read from, the addresses to read, the resulting data, boolean controls to enable reading from a device... Pass this cluster to a For loop and you can read each device without have seperate subvi's. Step back from things and look at how you will use the resulting data, displayed on a screen, written to a file,... Do you need to read from all devices from now to the end of time?? What happens when a device fails, cable breaks, how will you handle a timeout??

 

How will you handle each new device?? Separate text files with config info for each device, read all the files from a directory. Spreadsheet file with all of the config info as columns and devices in rows?? Do you want to be able to read from other sections while adding code for new devices?? How do you want to add new devices?? stop the vi and start again, read the config from a file before each loop starts to read data(this way you could modify the config text file in the background) and collect new data on the next scan of devices.

 

How often do you want to read the data?? Historical trending or database?? What happens when computer crashes or hard drive dies. How are you going to backup this data that you have collected? You also have to think about memory management while the vi is running. Having 50 or 100+ subvis running could result in a large amount of memory usage. Might be better to have several groups with 10-20 meters inside a group. How are the meters located physically in your plant??

 

OPC really would have been the best way to handle this, if your talking about more than 30-50 devices in the end.

Message 8 of 11
(3,127 Views)

I see two good solutions to your problem:

If the sub vi's are self contained and running the best way to start them is VI server, it's basically a path saying "start this VI as a separate process".

That can easily be done in a loop if you want to start several of the same type. As a side bonus you get a reference thread so you can reach into them should you need to. (for example to domino a stop button)

 

You can make an array or tab control with sub panels and insert the just started VI's into these. Why? Well, make your sub vi with the controls you fancy and each tab will have their own set of them.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 9 of 11
(3,112 Views)

hi gaurav,

thanks for making effort to create LV program just to describe your thoughts!. i appreciate it a lot.

 

to mike,

i might give a shot with this OOP later. i read some forums from ben (knight of NI) regrading this LVOOP and it seems its quite powerful tool but quite complicated also. Smiley Mad

 

to unclebump,

your comments makes me realize that i should use something more than just modbus VI if i want to have a good and reliable program for huge power monitoring system. i ask NI yesterday and he suggest me this "teststand" term. thanks for giving me a tip. for now, since this is just a demo trial for us, i might keep from using other software for this experiment (for now).

 

to yamaeda,

well, i haven't use VI server and subpanels before. i will study these functions and give it a try. thanks for suggestions!

Ivel R. | CLAD
Message 10 of 11
(3,086 Views)