LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

simulating a PLC function in Labview

I am currently developing a complete control and data acquistion program using LV7 and NIDAQmx drivers.

The data acquisition part was a breeze to develop. No problems.

However I am yet to start the Auto sequence part. To put simply it involves the following :

1. Wait for a user Start command and then start a sequence of events involving energizing and deenergizing some 8 different solenoids and outputting two Analog outputs based on the relevant part of the cycle.

2. As the cycle progresses, compare the Analog inputs ( there are about 5 of them ) with user configured limits and declare pass/fail verdicts.

Now all of the above is childs play for even a low level PLC. I am not sure which will be the best way to approach this auto sequencing. I am quite awawre of the different structures like event based, case based etc. Also all the user configured limit parameters are stored in a cluster that is Global in nature. So that these parameters have visibility for all the sub- VIs.

Thanks

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 5
(2,683 Views)
Hello Raghunathan,

There are numererous ways to program the desired behavior. In your case it will probably work best to use a state machine architecture. Please see the following links for more information on state machines as well as other possible architectures.

Application Design Patterns: State Machines

Using a State Machine (Event Driven) Architecture

LabVIEW Application Design Patterns

Regards,

Matt F
0 Kudos
Message 2 of 5
(2,664 Views)
Hello Matt,

thanks for the links. Emphasis seems to be on the Event triggered model and FSMs to save on CPU time.

But if you really look at my application I want to structure it like this : ( In fact it is currently running like this )

1. The Main.vi has the menu to select from 7 different sub VIs. The Main also has a 50ms timed loop within which are the DAQmx functions for DI, DO,AI and AO. These functions update a set of Global variables once very 50ms.

2. Out of the 7 sub VIs, only 3 have use for these hardware related variables.

3. When one of the above three VIs are called by the Main, the sub VIs get or put values into the Global variables, as per program demands.

Thus the machine sequence is controlled by these sub VIs via the Globals. Am I doing it right or its outright gibberish ?


While something in me tells that this way of passing variables through Globals is far from optimum, I can't do better as Im coding on LV only for the last 2 weeks or so. For a person like me who is reasonably proficient in assembly and VB programming, this graphic environment is too colorful to digest fast!

Thanks for your time.

Regards

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 5
(2,649 Views)
One of the key thought processes a text language programmer needs to adopt when learning LabVIEW is that LV is based on a DATAFLOW pardigm. This means that any node may execute when data is available at all its inputs. Almost all text based languages use control flow, meaning that the order of execution is the order of appearance of the statement in the text. These are very, very different. It takes some time to get used to the difference, but learning how LV works is important to becoming a proficient wireworker.

This is why experienced LV programmers tend to avoid globals - they make it hard to see how the data is flowing.

The FSM is used more for its power and flexibility than CPU time. It is easily modified and can be quite robust.

It is a lot to learn in a few weeeks. Keep trying. You will learn it.

Lynn
0 Kudos
Message 4 of 5
(2,611 Views)
Hello Raghunathan,

Welcome to the LabVIEW community!

Ideally it is best to avoid overusing variables in VIs as they by nature violate the dataflow model. With past experience in text based languages it is definitely understandable to use variables as they are a great parallel to other languages (I was the same way at the beginning).

Typically it is best to try using a state machine architecture in conjunction with shift registers or queues to pass status and control information between processes. Much of this will come naturally as you spend more time in the LabVIEW environment.

You may also be interested in the LabVIEW classes available through National Instruments. These classes are great for those new to LabVIEW and help students pick up a large amount of LabVIEW knowledge in a short amount of time.

You can find out more about them at the following link.

Training and Certification

Good luck with development.

-Matt F
0 Kudos
Message 5 of 5
(2,608 Views)