10-20-2016 01:25 PM
Hi,
I apologize if this post is in the wrong place. I am a student learning Labview as part of my pursuit of an EET degree. I have to design a soda machine as a project for my Labview class. I am researching how to start the prgramming (I am overwhelmed) and am trying to learn about case, and event structures. My professor gave us the task of designing the machine, with no further instructions or guidance. I have been scouring the internet for examples of code, but really haven't found anything I can use to understand how to prgram this machine.
My question is, when using a case structure, does it always have to be initialized? Can I write the structure to just wait for the user to start entering money, as you would in the real world? All of the tutorials I am watching show an initialize case as part of the prgramming. If I use event structures, inside of a while loop, will this more realistically model a mchine found in the real world?
I have been trying to get started on this project for a couple of weeks, and am really confused, so I appreciate any and all help / advice.
Thanks very much,
George
Solved! Go to Solution.
10-20-2016 01:29 PM
Hey George,
Along with looking through the basic labview tutorials, a lot of it is can be learned by trying and failing. In this case though, you're looking for a state machine where it initializes to a "default" state, which there is an example of here: http://www.ni.com/tutorial/7595/en/
Hope this is helpful in explaining your task,
Anthony
10-20-2016 01:36 PM
Hi Anthony,
Thanks very much for your reply. The page you linked is very helpful. I am still confused as to whether I should be using this version of the state machine, as oppsed to using event structures, which I understand use less CPU, and is a more streamlined way of programming the machine.
I will go through that page very carefully, and see if I can implement the techniques to get the outcome I am looking for.
Thanks for your time.
George
10-20-2016 02:21 PM
Here is a skeleton example of an architecture that I often find useful.
10-20-2016 02:29 PM
Thank you Paul for including that file. It looks like Greek to me, but maybe I can make some sense of it! 🙂
George
10-20-2016 03:10 PM
Look under the section "Looking for Free Training" for some basics tutorials which may help you get started.
10-20-2016 03:13 PM - edited 10-20-2016 03:14 PM
I am still confused as to whether I should be using this version of the state machine, as oppsed to using event structures, which I understand use less CPU, and is a more streamlined way of programming the machine.
Quite frankly as a new programmer I would suggest you avoid event structures, as event based programming breaks the "data flow" paradigm LabVIEW is based on. You know I have been programming LabVIEW for well over a decade and can count the number of times I have used event structures on one hand.
A state machine is one of the most versatile architectures there is and I use it probably 95% of the time in my programs. Next useful is probably the Producer/Consumer architecture, and you will probably notice the Producer/Consumer is often also a State Machine.
Also you might want to take a look at this: https://decibel.ni.com/content/docs/DOC-2145
10-20-2016 03:22 PM - edited 10-20-2016 03:23 PM
Thanks very much OEM_Dev!
George
10-20-2016 03:24 PM
Hi RTSLVU,
Thanks for the advice. I will steer clear of the event structure for now.
Thanks again!
George
10-20-2016 03:26 PM
@gsrokmix wrote:I have been scouring the internet for examples of code, but really haven't found anything I can use to understand how to prgram this machine.
George
That's very suprising considering it's probably the most popular way to make a tutorial about state machines. I just searched "Labview soda machine" and came up with pages of tutorials, example code and videos. The Soda Vending Machine was even a CLD test if I remember right. Don't be tempted to just copy the first example code you find and turn it in though. Some of them are deceptively simple looking but really pack in a lot to learn about state engines. This knowledge is critical to advancement in LabVIEW so don't gloss over it too quick. Look at many tutorials and play around and modify them so you can code a state machine without looking at any references.
You can get the benefits of a state machine and the efficiency of the event structure together by simply putting the event structure in an idle (waiting for user input) state or putting it in a separate loop and communicating through queues. Once you get the basics down, advanced techniques likt that will seem obvious. Just take it a step (state? ) at a time...