08-21-2020 06:50 PM
After opening a file or creating a variable within one state. Is it possible to pass that data to another state?
08-22-2020 11:38 AM
Hi Damian,
@damianhoward wrote:
Is it possible to pass that data to another state?
Yes, sure! Use shift registers…
08-24-2020 12:42 AM
It is illustrated in my example(s)
08-24-2020 02:19 PM
@daveTW
@daveTW wrote:
It is illustrated in my example(s)
Unfortunately, I am using labview 2017 and I am unable to see your examples. As well as a few of the others.
08-24-2020 02:24 PM
I have followed your advice, putting the different functions I plan to use in different loops. I am still running into issues though. Could you please take a look at my code and give me feedback? The top loop is for load control of a linear actuator and load cell. The middle loop is the state machine and the bottom loop is the querying of device output and writing to a file.
If there are any mistakes please point them out. My current issue is I cannot get past the idle stage of the state machine. When I click test active area. nothing seems to happen. I added the event structure to try and make it update based on the button presses but I can only seem to get to state 54 degree if the button is clicked when I start the program.
08-24-2020 03:03 PM
All of your Booleans that currently do something (Load Control, Record Active Area, Record 360) are outside any While Loops, meaning they will get read a single time when the VI starts and never again. You need to put them inside their respective loops if you want to continuously read them. That's probably the biggest thing keeping your code from executing as intended, probably.
Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.
08-25-2020
11:39 AM
- last edited on
05-13-2025
01:04 PM
by
Content Cleaner
I think the program architecture that you're using is not suitable. Since you have many parallel loop, did you try to use Producer/Consumer (Events) Design Pattern where you can have one producer loop which it keep the controls user interface responsive to your desired mode such as 'idle mode' like you have mentioned ?
In this way, you will just need to click your Boolean control button, then a message string 'idle mode' + a cluster of data that you want to configure will enqueue to another parallel loop which is consumer loop and dequeue from the channel wire (thick pink colour line) while the program is running. Channel Wire allow you to simplify the programming involved in data transfer between parallel loops.
Be aware that you should keep every controls inside the while loop especially when you want to update a new configurations while running your program. Because once program run, a while loop will not detect any changes that happen outside its loop.
Link to study Producer/Consumer (Events) Design Pattern:
I have attached the zipped producer/ consumer VI that I have done before when I want to acquire data from accelerometer but at the same time I want it able to do setting for my new configurations and change to idle mode when I'm not acquiring anything.
Kindly open the trial 2 VI in the 2 accelerometer file to have a look, the another VI is a general Producer/consumer VI only.
08-26-2020 03:12 AM
@damianhoward wrote:
@daveTW
Unfortunately, I am using labview 2017 and I am unable to see your examples. As well as a few of the others.
So this is the converted Version.
08-27-2020 06:22 PM
Thank you Wai and Dave for the producer/consumer examples. I am going to look over them the next couple of days and see how I can incorporate their structure in my code. I may some have some questions so I'd appreciate it if you guys look in on this thread from time to time.
I'm trying to get some more advice on my current design please see the attached.My question is, I have defined a function/process in the top loop. I was under the impression that labview can run multiple loops in parallel. However, when I run this vi the top loop doesn't run when the value of the boolean(load control) changes. Can someone help me understand why? Is the fix to put both the SM loop and the load control loop in one big loop? Last question. Say I wanted the following functionality:
1. Every time the state machine executes Idle the user specifies a new file for the serial data to be read into
2. Through out the execution of the state machine the data is recorded into the file the user specified
3. When returning to idle/right before idle the file is closed and the user is automatically prompted to open another file for a new run.
How would I achieve this? Is this something I should accomplish with the addition of another loop? and if so how do I ensure all the parallel loops run while the state machine is running?