Jump to content
Sign in to follow this  

Parameter tables in a state machine

Recommended Posts

Hi all,

I'm trying to figure out the most efficient way to use a parameter table in a state machine.

Currently, I have converted the ~3x50 element parameter table into an array of the same size. The indexing element in this case happens to be a frequency. At each frequency I need to run the primary action/test.

In order to carry the current index through the test I am pulling the row out of the original array and placing it into a separate array that I'll call "Current Freq Index," perform the action, and then pull the next row, etc etc.

I like the modularity of the simple state machine but this method of carrying the index to operate on in a separate array seems clunky or inefficient.

How does everyone else handle something like this?

(The former version is just a for loop indexing off of each frequency, which is simple, but not as extensible as I'd like it to be)



Edited by Gulstaff

Share this post

Link to post
Share on other sites

You could try posting some example code to rattle something loose.. I remember reading through this and thinking that way was "good enough."

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Similar Content

    • By LewisG
      I have to develop an application and I would like some help designing the architecture.
      The system controls a number of pumps and valves to create flow around a network of pipes.  There are flow meters in the network which are used as feedback for PID to maintain a flow.  The network of pipes is gradually opened up to get flow and then PID kicks in to maintain a flow.  The test sequence is pretty much a big state machine.  For example:
      1.       Open valve 1
      2.       Wait for pressure to build
      3.       Ensure temperature is not over limit
      4.       Etc
      I will have a number of different screens which I want to load into a main sub-panel:
      ·         Main SCADA screen (show state of all valves pumps etc)
      ·         Test setup screen (configure tests)
      ·         I/O screen
      ·         Alarm screen
      I will also have a number of I/O processes:
      ·         Digital (valve sates)
      ·         Analogue (flow meters, temperature etc)
      ·         Modbus and serial devices (flow meters)
      ·         Digital Output – Valves etc
      ·         Analogue  - Proportional valves
      I want to use the Actor Framework because I’ve used it 3 times now and it is easy to spawn processes, make popups, inter-process messaging, error handling etc.  I can have all my processes separate (high cohesion) with separate user interfaces (if they have a UI) .
      My problem is that AF and State machines don’t really go that well together (correct me if I’m wrong).
      What happens when I want to do PID or loop in the same state?
      Time delayed message?
      A a VI for each state and enqueue the next or same state from within that VI?
      Does anybody know a good way to incorporate a state machine into AF or should I chose a different way of doing things?
      Any thoughts will be appreciated.
    • By Stormshadow
      I have done a few applications with the JKI State Machine, however I can never find a way to get into the "", "Idle" state in order to scan for Events.
      I tried passing various strings such as "", Idle or use an intermediary case event. Also tried modifying the Timeout on the event case.
      There's already an Event Case inside of JKI SM, so why would we need to add a another loop in order to control it as a Producer-Consumer for the front Panel to be responsive?
      I don't think the implementation of the Producer-Consumer on http://forums.jki.net/topic/1347-jki-state-machine-producer-consumer-loop/ would work since it does requires detecting an event.
      The only way I can think on how a P-C would work, it would require adding a "Add State(s) to Queue" between the "Parse State Queue" and the main case structure, where the data inserted would come from some kind of shared variable between the Procuder loop and the Consumer loop. Then you would still need to clear that variable and manage the new states to be added only on a change of the variable after it is added and cleared.
      How can we force the scan for Events when we want with the standard JKI SM loop?
      The only way that I see the JKI Events being useful is on single clicking applications, where the actions on the front panel always end up clearing the Queue. The while loop would only be used to keep the application active.
      The only workaround that I found is to add all local variables within the states that would break the sequence if modified. Which is bad because you will need to track every interface item manually.
      Here is an example:

      (Not sure if the image is working as they are blocked where I work so I added it also to attached files)
      This State loops on itself until an action is done to stop the loop, such as toggling the Read DMM or stopping the VI (I shouldn't even need to track those...). As you can see the issue remains that the front panel remains non responsive if I modify anything that is not one of those 2 buttons. I have tried forcing the Idle state through a Timeout case which sends "Idle" to the JKI SM.
    • By RaymondTeng
      Hi all,
      I am trying to use NI-USB 6259(BNC) to send Pulse signal to conduct position control of a servo motor with labview. The position control of servo motor follows these rules:
      1. The number of the pulse train determines how many degrees the motor rotate ;( e.g. the angular position of motor)
      2. The frequency of pulses determines how fast the motor rotate; (e.g. the speed of motor rotating)
      3. The digital determines the direction of rotation of motor e.g. clockwise or counterclockwise)
      My question comes when I need to generate continuously a finite plus train signal in a period of time. Below is a sample:

          Here is the explanation of this table, the motor keep rotating in clockwise direction during 0~1s. When the time reaches 1s, the motor just complete the rotation of 923 pulse signals. And then the motor starts to rotate in counterclockwise direction during 1s~2s. When the time reaches 2s, the motor just complete the rotation of 3540 pulse signals. So we can see that the rotating speed of motor in 0~1s is different from the speed in 1s~2s. Namely, the frequency of pulse signal in 0~1s is different from the frequency in 1s~2s.
      I have already use the counter output of DAQmx, it just can generate pulse signal with certain numbers and certain frequency in one time. The attachment is the vi which demonstrates how to generate a finite digital pulse train from a Counter Output Channel and the Frequency, Duty Cycle, Initial Delay, and Idle State are all configurable.
      How can I generate a series of pulse signal with varying numbers and frequencies during a certain period of time.
      Thanks a lot!

      Counter - Finite Output.vi
    • By Manudelavega
      I downloaded the JKI state machine toolkit and it's quite neat. For eons, I have been using state machines following a very similar structure, but always with enums instead of strings. In simple state machine, each state would define the next one (no queue), and in more complex ones, a queue would be used to allow some states to enqueue several ones (and some wouldn't enqueue anything). But always with an enum or a queue of enums, since it seemed this would prevent typos, and allow renaming a state at only one place (the enum typedef).
      However I am tempted to make the switch since I see the value in using a tool used by other advanced developer. Where do you stand on this? Is JKI's string-based design the best way for your state machines?
    • By Walter Gunter
      I am working on some labview code that I really want to use OOP.  I have some classes, ie, motor, relay, potentiometer, etc that I am using and wanted to incorporate in a state machine. I wonder if there are some good examples of this?  I found a thread on here discussing it http://lavag.org/topic/13064-object-based-state-machine-pattern/ , but I am not clear if it answers my question. 
      1. When I try to wire a class into a state machine (while loop with a case structure), I always get a broken wire in the while loop. It says the wire type is different?  Am I thinking of this incorrectly. I have a class object I put on the block diagram, i wire it to 'Initialize.Vi' and it breaks (there and on any vi from that class).

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.