11-18-2020 05:16 PM
Hi all,
I have some code that looks roughly like this, and it's working somewhat fine. It's a master/slave setup with a state machine acting as master.
The code itself is controlling a pneumatic actuator which is fatiguing a test specimen. I'm trying to figure out how to detect a failure in the specimen. The problem is that these methods of detection will require reading data from any of the first 3 loops, possibly in some combination of multiple loops. Currently, just to get the thing working, I have one failure detection mechanism lying inside the third loop, another hidden away in the first loop somewhere etc etc - it's become a pain to deal with and the code is ugly as sin.
Ideally, I'd like to have a 5th parallel loop that can take in the data from other loops as required and perform the failure detection. I don't want to use local variables to do this for reasons explained elsewhere in this forum.
I'm a bit lost on how I should go about implementing this from an architecture point of view. I don't think producer/consumer helps me as loops 1-4 would become producers to my consumer loop 5. What is the correct paradigm to use here?
Huge thanks to everyone for all the help.
11-18-2020 05:52 PM
Nobody here is good a debugging pictures. Since you made simple demonstration code, why not attach it?
Just looking at the picture, things seem somewhat fragile? There is no guarantee that notifications are not missed by any particular loop.
11-18-2020 06:20 PM
Hi Altenbach,
I didn't attach real code because this code doesn't do anything and won't run without me doing more busy work. I'll do it if required, but I don't believe it to be entirely necessary based on the fairly general nature of my question.
With regards to potentially missing notifications, I'm not concerned about that at all, and in fact it's desired in this case. All the loops in the real vi have been tweaked so that they won't take longer than the 10ms clock each. Also, I want the loops to only be performing based upon the latest notification - I want lossy queues and not lossless queues.
I really wanted all of these things to be in a single state machine initially, but then had issues with the hardware running serially rather than in parallel.
This actually leads to another question I have about how the parallelism REALLY works, but I'll save that for the moment.
11-18-2020 06:26 PM - edited 11-18-2020 06:30 PM
I think you'd be better served by a state machine / JKI state machine. That way you can keep all of your data in a single shift register and not worry about who has what.
Edit: just saw that you tried to use a single state machine but couldn't get the hardware working as you'd like. In that case, I might have one loop for each instrument you have and then get data from them periodically. These are often called "helper loops" but the main logic and analysis will be in your state machine loop.
11-18-2020 07:02 PM
+1 for the JKI State Machine. I link them together using user events.
not sure I understand the Wait function in the loops, the loops will run whenever they receive a notification. If busy and processing they can ignore the current notification.
mcduff
11-18-2020 07:18 PM
@mcduff wrote:not sure I understand the Wait function in the loops, the loops will run whenever they receive a notification. If busy and processing they can ignore the current notification.
The loops are free running, because he uses gets status instead of wait on..
11-18-2020 07:46 PM
@Gregory wrote:
I think you'd be better served by a state machine / JKI state machine. That way you can keep all of your data in a single shift register and not worry about who has what.
Edit: just saw that you tried to use a single state machine but couldn't get the hardware working as you'd like. In that case, I might have one loop for each instrument you have and then get data from them periodically. These are often called "helper loops" but the main logic and analysis will be in your state machine loop.
This is what I'm after. Thank you for the tip, (and thanks to McDuff for his seconding). I'll go away and do some reading.
Any other paradigms out there that might be beneficial? I'm Prince Charles - I'm all ears.
11-18-2020 08:56 PM
@altenbach wrote:
@mcduff wrote:not sure I understand the Wait function in the loops, the loops will run whenever they receive a notification. If busy and processing they can ignore the current notification.
The loops are free running, because he uses gets status instead of wait on..
Thanks. Don’t use notifications at all, didn’t recognize the icon.
mcduff