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: 

Event structure or producer/consumer

Hi everyone, 

 

I just started writing a program which is controlled by the user. 

 

The LabVIEW program will control a stepper motor and there will be a pressure sensor and force sensor connected to a USB-6008. There will be different options to run the stepper motor (which will be chosen by the user in the front panel by pressing different controls), at the same time values from the pressure and force sensor will be read and saved. 

 

For the reading and storing or values, I will use a producer/consumer. But what I am not sure is how to implement the events which are decided by the user. I am choosing between two options, but I am not sure about the pros and cons of each of them. The implementations I've been thinking about is:

 

1. Only use event structure.

2. producer/consumer. With an event structure in the producer and a case structure in consumer for the different controls. 

 

Is one of the structures better than the other? Then which one and why, what are the pros and cons?

 

Grateful for some discussions!

0 Kudos
Message 1 of 7
(3,295 Views)

This is one of those times when the Project Templates really shine!

 

Personally I would start from "Continuous Mesasurement and Logging.lvproj" and add a "Control" Loop to handle the Stepper Motor commands from the "User" Event loop

Main_BD.png

The documentation is excellent and the developer Walk-through makes it easy to understand what is going on and how to expand it.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 7
(3,282 Views)

If you're reasonably sure that you won't decide 6 months down the line that there are 10 more things that you want your application to control, measure or log, then it's a fantastic template.

 

If you anticipate that kind of scope creep, save yourself 6 months and just head straight to the Actor Framework 🙂


GCentral
Message 3 of 7
(3,272 Views)

Thank you both for your replies, it is very appreciated and sorry my very late response. 

 

Actor framework sounds like a really good idea for my project since there will for certain be some more functions I want to add later. I started to dig deeper into that so I've been watching a lot of tutorials. And this week I wanted to write the program to post it here, but I haven't got that far yet since I bumped into some problems that the USB-6008 is not recognized. But I'll create another thread about that, and then get back to you how it went with the program. 

 

Thank you again!

0 Kudos
Message 4 of 7
(3,214 Views)

Good luck! Actor Framework is very useful in my opinion but if you can write an entire AF project in a week I'd be moderately surprised/think that you might have done it even faster with something else. Then again, maybe you're just lightening fast 😉

 

This thread might additionally help you getting started - Actor Framework for Dummies.


GCentral
0 Kudos
Message 5 of 7
(3,206 Views)

Haha, sorry I meant that I wanted to start writing the program this week (might have been unclear at that point). I don't know when I will finish it, but when I finish I will let you know if I made it.

 

And yes, actor framework seems to be handy.

 

Thank you for the link, I will have a look at that one as well while waiting for help with my other problem. So far I think I have an idea how to implement it. 

0 Kudos
Message 6 of 7
(3,204 Views)

Before you do anything, have a look at the “JKI state machine”, which is available on the tools network.  It is a very flexible event-driven loop.  You could use more than one and communicate between them with User-Event messages.

0 Kudos
Message 7 of 7
(3,191 Views)