LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is It smarter to dynamcially call Sub VIs or Reformat Code so that 1 Shift Register Controls SSM

Hi, first of all I just wanted to say thank you to this community for all your help so far.

 

I am trying to operate a simple state machine and I have set up all my states, but I want them to be able to switch between them automatically. I realized I can only have 1 shift register that connects to the ssm case structure selector, but I am wondering if it would be more prudent to refer to the Sub VIs i created dynamically instead of creating a complex structure of boolean operators that allow for one conncection to the shift register. I was hoping for some council on which would be the better option?

 

Also, I am trying to edit my graph settings to fit the window and increase the font size and thickness, but it keeps coming out off center.

 

0 Kudos
Message 1 of 16
(1,176 Views)

I think that calling states conditionally from the current state is just fine, if that's what you were wondering.  I have to admit that I wasn't clear on what you were trying to do.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 16
(1,167 Views)

Hi billko,

 

Thanks for reaching out. I have been researching how do to both, but if I could keep it in the current SSM setup that would be best. I am just having an issue with how wire up the sub VIs cause only 1 shift register can control the state selector. I thought I just needed a shift register for each sub VI. I have wired 3 shift registers (one for each sub VI gateway the governs which state to select), but now my SSM no longer switches between states anymore. So, I was wondering what would be the best approach to keeping the Sub VI gates to the other states and connect to one shift register so that my SSM starts switching states again.

 

Regards,

Vance 

0 Kudos
Message 3 of 16
(1,154 Views)

@vanceblake wrote:

Hi billko,

 

Thanks for reaching out. I have been researching how do to both, but if I could keep it in the current SSM setup that would be best. I am just having an issue with how wire up the sub VIs cause only 1 shift register can control the state selector. I thought I just needed a shift register for each sub VI. I have wired 3 shift registers (one for each sub VI gateway the governs which state to select), but now my SSM no longer switches between states anymore. So, I was wondering what would be the best approach to keeping the Sub VI gates to the other states and connect to one shift register so that my SSM starts switching states again.

 

Regards,

Vance 


What are you trying to do? A state machine can only go to one state at a time. Without digging too deep into your code (which needs to be cleaned up, by the way) it would appear that you don't have enough states. Are you wanting to launch different states in parallel? Perhaps if you explained what you're trying to do rather than how you're trying to do it you could get better help.

0 Kudos
Message 4 of 16
(1,126 Views)

Hi johntrich1971,

 

Thanks for reaching out. Yes, SSM can only be in one state at a time which is what I am looking for. I have conditions set in each of the sub VI icons, and when those conditions are met then it should go into the corresponding calibration mode. I am measuring the CO2 Gas PPM of calibrated gases for sensors. The concentrations of interest are 400 PPM 1000 PPM and 5000 PPM. Each concentration has its own sub vi gate that should trigger its corresponding calibration mode. Zero is for 400 PPM. Span 1 is for 1000 PPM, and Span 2 is for 5000 PPM. The sub VIs were created to tidy up and package the case structure gateways to each of the states. However, I made them with 3 different pairs of shift registers because I thought that was the proper method to pass the desired state from each sub VI to the SSM case selector. I now know that method was incorrect, but I am struggling to wire up my case structure gateways (specifically their enum outputs) to one shift register which is the limit for the type of SSM I am want. Single state, single activation path.

 

Regards,

Vance

0 Kudos
Message 5 of 16
(1,101 Views)

@vanceblake wrote:

Hi johntrich1971,

 

Thanks for reaching out. Yes, SSM can only be in one state at a time which is what I am looking for. I have conditions set in each of the sub VI icons, and when those conditions are met then it should go into the corresponding calibration mode. I am measuring the CO2 Gas PPM of calibrated gases for sensors. The concentrations of interest are 400 PPM 1000 PPM and 5000 PPM. Each concentration has its own sub vi gate that should trigger its corresponding calibration mode. Zero is for 400 PPM. Span 1 is for 1000 PPM, and Span 2 is for 5000 PPM. The sub VIs were created to tidy up and package the case structure gateways to each of the states. However, I made them with 3 different pairs of shift registers because I thought that was the proper method to pass the desired state from each sub VI to the SSM case selector. I now know that method was incorrect, but I am struggling to wire up my case structure gateways (specifically their enum outputs) to one shift register which is the limit for the type of SSM I am want. Single state, single activation path.

 

Regards,

Vance


I'm still not entirely clear on what you're trying to do, but I'm going to take a stab at it to see if I understand. I think that what you want is to run the different calibrations when thresholds defined in your subvis occur. If so then one way to do it is to put your Sample Gas PPM case code into a subvi and change your states to something like the following:

 

1. Waiting for Zero Calibration (contains Sample Gas PPM.vi and first subvi)

2. Zero Calibration

3. Waiting for Span 1 Calibration (contains Sample Gas PPM.vi and second subvi)

4. Span 1 Calibration

5 Waiting for Span 2 Calibration (contains Sample Gas PPM.vi and third subvi)

6. Span 2 Calibration

 

This is what I meant when I said that you do not have enough states.

Message 6 of 16
(1,092 Views)

Hi johntrich1971,

 

I see what you mean. I didn't even consider doing it that way! But, I will give it a shot cause that allows me to combine all the pieces that are working independently and keep a one to one relationship between the various states and calibration modes. Thank you for this idea!

 

Best Regards,

Vance

0 Kudos
Message 7 of 16
(1,083 Views)

Is it possible to retain the default state I currently have and have buttons that allows me to change from the default state to a waiting for calibration state, and then just transition from waiting to calibration and then from calibration finally back to the default state? With the last two transitions happening automatically?

0 Kudos
Message 8 of 16
(1,076 Views)

Hi I am trying to run my VI with minimum user input. I want it to sample gas PPM until the user hits one of the 3 buttons that allow it to enter one of the 3 calibration states. However, the event structure example I found online https://forums.ni.com/t5/LabVIEW/Connecting-boolean-array-to-case-structure/m-p/237065#M129632 requires constant input from the user each loop.

 

I tried to implement it without the event structure but the case structure was deemed unwired even though I had a boolean structure with the button names labeled. Any help is greatly appriecated as I am very close the functionality I need.

 

Thanks!

0 Kudos
Message 9 of 16
(1,120 Views)

Hi Vance, 

 

I am not sure what you mean with 'I tried to implement it without the event structure but the case structure was deemed unwired even though I had a boolean structure with the button names labeled'. However, looking at the code you attached and the original question, I think a queued message handler might be useful - Using a Queued Message Handler in LabVIEW - NI. There is a LabVIEW template for it that is very easy to get started with. The main difference between that and what you are currently doing is that you would have a separate event handling loop to manage user events. The event loop can trigger cases in the main loop and the main link can queue up cases in itself independently of the event structure.

 

Many Thanks, 

 

Riley 

0 Kudos
Message 10 of 16
(1,071 Views)