02-11-2021 08:31 AM
Hello community,
currently I am learning the state machine concept. What I fail to understand is how I would set up a continous data logging without the user pressing some button?
I want to have my hardware buffer read every 0.5 seconds. So my cycle should be something like this:
Initialize > Wait > 0.5s elapsed > Aqcuire > Analyse > Log > Wait
But how would I implement the "wait 0.5 s" event and how would I still have it responsive to user interactions?
Thank you for your advice
Martin
02-11-2021 08:42 AM
Hi mw,
you can check user actions after each state is executed. In this case reaction to user input may be delayed by 0.5s when there is a state like "wait(500ms)". Is this acceptable for your users?
Another option is to have a state "wait(100ms)" and call this state 5 times to realize a delay of 0.5s.
Third option is to have a state "wait(500ms)", but have a loop in this state which stops after 500ms or earlier, when a specific user action is detected.
There are so many options…
02-11-2021 09:14 AM - edited 02-11-2021 09:25 AM
@mw42 wrote:
Hello community,
currently I am learning the state machine concept. What I fail to understand is how I would set up a continous data logging without the user pressing some button?
I want to have my hardware buffer read every 0.5 seconds. So my cycle should be something like this:
Initialize > Wait > 0.5s elapsed > Aqcuire > Analyse > Log > Wait
But how would I implement the "wait 0.5 s" event and how would I still have it responsive to user interactions?
Thank you for your advice
Martin
How about a "Timer" or "wait" state?
The state waits for the scan interval to elapse and it also checks the day of the year.
IF the day of the year is not equal to the last time it checked go to the "Close File" state
Else go to "Measure" state
This is because I needed new file to be created every day. So when the day changes it closes the current data file opens a new one and then takes a measurement
Now polling a timer in a loop is probably not the best way, as you can't really do anything else at the same time.
But for simple data loggers it works fine.
02-12-2021 02:33 AM
Thank you both for your advice. I will try and implement all those suggestions and see if they work for me.
02-18-2021 06:35 AM
I have tried to modify the "event-drive state machine pattern" from the "LabView Core 2" course. Unfortunately it failed so far.
What I fail to understand is why my Streamchannel won't change the status of my "Time elapsed OUTPUT" indicator (in the screenshot, the indicator is outside of the event structure but this was only for testing, since it didn't work at either location)
My idea was to have a second while loop (as suggested for "elapsed time" purposes). Was my idea correct or does it have design flaws in it?
I've made two screenshots and attached my code.
02-18-2021 08:47 AM
Writing to a terminal will not cause an event. So your event structure is not seeing any events. Try using a User Event.
02-18-2021 09:27 AM
A stream channel seem a bit overkill for this application...
Try a Value(Signaling) Property Node for your Time Elapsed Output indicator and writing to that in your timer loop.
02-25-2021 06:17 AM
I think that I now understand the problem and have been able to fix it.
Attached is my working solution (the program adds "+1" every 0.5 seconds and there are "minus 1" and "plus 1" buttons for user interaction).
Any further advice on my design?