LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programming Suggestions Needed for a Control Application

Good day!

 

I'm an electronics engineer with a fair bit of programming experience in assembly on Microchip PICs. My company is now looking to design PC based instrumentation for control, for which we have bought a USB6008. The company already owns a LabVIEW 8.5 license from around 2 years back.

 

Anyway, the project is to be done by me and I'm  a novice when it comes to LV.

 

Project Description:

I need to design a control and data logging application using the USB6008. The USB6008 interfaces to a 4 sensors board (temperature from RTD, temperature from a silicon sensor, pH & conductivity) which 'signal-conditions' to give 0 to +5V outputs for all four. On the output side is a motor that needs to be controlled from 100-1000 RPM, a few relays and some indicator LEDs. The motor speed is read through a 16-tooth gear and a hall-effect sensor.

 

The instrument runs this way:

1. The front panel gives the user choices:

1a. Does the user want to calibrate the sensor measurements systems (each sensor calibration needs a different calibration process)? According to the choice, open another interface (maybe a window or a tab or something else) that leads the user through the calibration process.

1b. Does the user want to input the set parameters? If yes, open another interface and through numeric controls/knobs input the values?

1c. Does the user want to start the control?

 

So far I've designed an interface that uses tabs:

 

Interface Calib.jpg

 

And the block diagram:

 Interface Calib Block.jpg

 

The calibration part shown above seems to work. To describe the process... A flat sequence is inside a Tab Control. The first frame waits for the user to input the number of buffers. It then measures the sensor output with this buffer and also asks user to input the buffer value in pH terms. It repeats this using a FOR loop equal to the number of buffers input in the earlier step. Finally, in the last frame it displays these values in an array and asks the user if the data needs to be saved.

 

Once the calibration happens, I would like to switch the control back to the "PROCESS RUN" tab.

 

Now, I'm finding it hard to think in terms of LabVIEW. I'll be asking quite a few questions in the next few days so please bear with me.

 

My first set of questions:

1. Should I be using Tabs?

2. Should I be using Flat Sequences like the way I'm doing it right now?

3. Should it something else - Producer/Consumer, State Machine etc.? Reading about each of these, I think they are all suitable. 🙂

4. How do I switch between Tabs on the press a Cancel or OK button?

5. Am I asking the right kind of questions?

 

Could somebody please just point me in the right direction? I think I can create all the individual sets separately, but I just don't know what to do to put them together in one application.

 

Thanks in advance,

Trog.

 

Using:

LabVIEW 8.5 & USB6008.

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

Hi Trog,

 

I would consider using the PID toolkit to control the motor.

 

The NI site has a good article on this, PID Theory Explained.It shows how to use the VIs and how to implement it using the DAQmx VIs which you need to interact with the USB6008. 

 

This image sums the design up,

 

But, for a more basic implementation you could replace the PID block with your own code - but it must perform its calculations quickly to give you a quick input to output response.

 

Then, as your design has several states (calibration.. running..) I would suggest using an event based architecture. Where the above loops goes within the running state. 

Capture.JPG

For a more detailed reference I would suggest looking in the NI Community site. This is a good starting point, 

Sending Data from Consumer to Producer Loop with User Events. 

 

In summary I'll answer these:  

 

My first set of questions:

 

1. Should I be using Tabs? 

If you want to! The are a good way to hide items until you want the user to use them/see them. You can programmatically control the tab control using a property nodes. One solution is: Programmatically Setting the Active Page of a Tab Control in LabVIEW

 

 

2. How do I switch between Tabs on the press a Cancel or OK button?   See link above.

 

 

 

3. Should it something else - Producer/Consumer, State Machine etc.? Reading about each of these, I think they are all suitable. 🙂  Think I have tried to suggest the way I would implement it. 

 

  

4. Should I be using Flat Sequences like the way I'm doing it right now? There is nothing wrong with using sequence strucutres - IF the code must execute in order. Normally you can enforce data flow using the error clusters, but not everything has them. WARNING labview is very parallel, thus very powerful. If your whole application was in a sequence structure then it maybe wouldn't be as parallel as it could be. I.E two loops in labview can run at the same time, but not if one loop was in the first frame, and the second in the second frame. IN YOUR CASE, it does appear that you need to get user inputs first ( I would maybe use an event called start, run and save. I would replace the frames in the sequence with states in the case structure. 

 

 

I hope that the above was clear, but please post any questions you have and I'll try to look back soon.

 

5. Am I asking the right kind of questions? 

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 2 of 6
(3,208 Views)

I should add some comments that probably can help.

 

1. troglodyte, there is nothing wring in your approaches. However, they are good if you want a "quick-fix solution"; i.e. if you need to solve the problem and forget about  the project and about the whole LabVIEW. LabVIEW allows (and actually marketed for) such quick-fixes (among more advanced purposesSmiley Happy). However, if you plan any long-term marriage with NI and LabVIEW, do not use Express VI-s, be suspicious about the sequence structures, and generally, use style of Hillman.

 

2. If you want your tabs be switchable during execution of the program, include the terminal in a loop. Connect conditional terminal of the loop to a "Stop" button.

 

3. Including all in one loop or creating a producing-consumer structure depends on the purpose. But IMHO there is no need in complicated structures if your problem can be solved without them in a simple way.

_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP
Message 3 of 6
(3,197 Views)

Good day!

 

Continuing after modifying and reprogramming...I've another problem:

 

Lets say the vi front panel has the first tab highlighted. I run the program with front panel showing this tab, and it works. However while this tab is active running, if I click on another tab, the vi on that tab won't work.

 

Similarly, if the second tab has a vi running, then on pressing the first tab, the vi in the first does not run.

 

Kindly have a look at the vis (block diagram) and let me know how to let tabs run even while switching between tabs.

 

 BLOCK DIAGRAM FOR FIRST CASE

Block1.jpg

 

 

 

 

 BLOCK DIAGRAM FOR SECOND CASE

 Block2.jpg

 

 

 

Once again, let me know how to let tabs run even while switching between tabs. 

 

Regards,

Trog.

0 Kudos
Message 4 of 6
(3,152 Views)
I would recommend that you consider using a producer/consumer architecture (which is effectively what Hillman was suggesting) for your overall application architecture. You should also consider using a state machine for your process controll. It is much more flexible than your current structure of fixed cases with embedded sequence structures. In general you should avoid using sequence structures in LabVIEW applications. Embrace the power that data flow programming provides. Over use of sequence structures is akin to forcing square pegs into round holes.


Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 6
(3,146 Views)

Use an Event structure inside of a state machine .  Please see the attached example.  Extract the llb into a directory, put the configuration file in the same directory and change its extension to "dvs".  Otherwise when you start the top level VI, "HMI Data Viewer Main.vi", it will tell you the configuration file is invalid.  Or you can just OK the error box and then browse to wherever the configuration file is.

 

In the Event structure you could detect TAB control changes and then load up a series of states to execute.  In the attached example, this occurs in the "User" case.  However, it does not have a TAB control.  Let me know if you have any questions.

Download All
0 Kudos
Message 6 of 6
(3,124 Views)