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: 

how to make it simple on my complex program

hi all, i create a program for my machine, its need 4 device that support rs-485 communication for 1 machine. i make a complex program for this project, my program now just for 1 machine, but for future i`ll make it for 12 machine (4 x 12 machine = 48 device) its will be 12x complex program, i want to make its a simple program by use subVI, the different for every machine is just on peripheral number of device (Serial Parameter)

SubVI.png

 

please help me how to made simple program by subVI, i try subVI on while loop its over than 28 connector, any idea ?

i hope you understand what i mean. thanks~

0 Kudos
Message 1 of 6
(3,279 Views)

I would recommend to start learning LabVIEW a bit more. You should be able to build something which is scaleable.

The question is not only about subVI usage, but many other things. For example you should learn how to create and program a state machine. Also, how to choose the right framework for your actual task.

You can find tutorials here:

https://decibel.ni.com/content/docs/DOC-40451

If you have access to the Core1-2-3 online learning material, you could go through these...

 

For your actual project:

I think you should first create your own "driver" for your machine(s). Learn about Action Engines (AE), and you will see how to create an AE subVI which can perform the following actions on your machines:  "Initialize", "Read data", "Close resources", etc...The actual structure of the AE depends on several things, for example: do you need to init and use ALL the available machines with their 4 "ports" at the same time? Or you need to stop and re-initialize some of them during runtime? Etc...

 

You can read very useful things about AEs here:

http://forums.ni.com/t5/LabVIEW/Community-Nugget-4-08-2007-Action-Engines/td-p/503801

Also, it can be helpful to "Wrapping It Up" the AEs, see the above link...

 

After you have an appropriate AE-set, you can start to work on the "sceleton", the framework of your project. You have to choose which way you wanna go? Simple state machine? Producer consumer with Queues + using Event structure? etc .......

 

edit:

" i try subVI on while loop its over than 28 connector, any idea ?"

If I understand your problem here, then read about clusters. Specially about type definied clusters!

 

0 Kudos
Message 2 of 6
(3,250 Views)

i still didnt understand whats AE, that i need only make my complex program to be simpler as possible (like subVI i think). can you give me example how to make my program simpler ? some part of my program then i`ll develop it my self. thanks

0 Kudos
Message 3 of 6
(3,218 Views)

"i still didnt understand whats AE"

So maybe it would be beneficial to learn more LabVIEW?

For sure you (or someone else) can make a dirty solution/modification out from your actual code, but a state machine would be more elegant / more scalable (or even better a producer consumer with events, with separated file logging from GUI, etc...).

 

I am also worried about your timing in the while loop. You have a "Wait (ms)" function, but how much execution time the recent 4 Read (Read input register) functions take? What is the recent iteration time of your loop?

If you have 48 Read functions, the iteration time can be huge. Actually I have no idea about your hardware, and these NI Modbus functions, so I cannot really give advice here (can the comm be parallel?). I never worked with Modbus, sorry...

 

Lets wait for someone else with more experience...

 

 

0 Kudos
Message 4 of 6
(3,207 Views)

forget about wait ms and all about the loop, i just want to make my program simpler as possible, that program that i`ve made is just for 1 machine, when you see my program is so complex isnt right ? it just for 1 machine, and for future i`ll make it for 12 machine in one program (one block diagram one front panel), maybe i`ll copy program, all of program will be same just different on numbers of RTU (Serial Parameter) for every machine,please see red circled. 

 

"I am also worried about your timing in the while loop. You have a "Wait (ms)" function, but how much execution time the recent 4 Read (Read input register) functions take? What is the recent iteration time of your loop?

If you have 48 Read functions, the iteration time can be huge. Actually I have no idea about your hardware, and these NI Modbus functions, so I cannot really give advice here (can the comm be parallel?). I never worked with Modbus, sorry..."

 

okey i can change the wait ms (delay) its no problem how long to take a delay, because my program is for monitoring OEE for 24 hours nonstop so i just need how the result is it. about read input register it will be executed in the same time, modbus serial communication. yes it can.

0 Kudos
Message 5 of 6
(3,190 Views)

Create a FOR loop, and initialize 12 VISA references for your 12 "machines" (autoindex into the FOR loop the 12 serial COM port as an array, and you get the VISA refs autoindexed out as a VISA ref array).

 

Create a subVI out of your 4 Modbus Read functions, with an input terminal of a single VISA reference!

Put this subVI into a FOR loop, and connect your VISA ref array into it with autoindexing. Inside this FOR loop, connect the autoindexed single VISA ref to your subVI. Your subVI will give out a 1D array of the results of the actual machine of the 12. If you autoindex this out through the FOR loop, you get a 2D array of results. How you want to form your data, it is just up to you...You could also use an array of typdefinied clusters (the array elements are the machines, the cluster elements are the local results of each machines).

 

After your while loop, you can use again a FOR loop, to close your 12 VISA references.

 

Still, this VI what you show is poor in style, and does not have any error handling!

0 Kudos
Message 6 of 6
(3,176 Views)