Jump to content

controlling and syncing multiple statemachines

Recommended Posts

Hello, I am new here. I am having a difficulty setting up a application. I have three vi's I am running to do some data acquisition, stage control and processing respectively. One of the vis is running on a 64bit labview platform. The other two are running on a 32bit platform. They all internally are statemachines, but I would like to design I way to activate certain states based on states from other vis.


For example here is what I am trying to do, below is a diagram of the internal states and how I would like them to communicate:


vi_A: 'Idle'->Do_SomethingA_1    -> Switch_vi_B_to_Do_Something_B_2 ->...

vi_B: 'Idle'->Do_Something_B_1  -> Wait_for: Switch_vi_B_to_Do_Something_B_2 -> Do_Something_B_2 ->...

vi_C: 'Idle'->Do_Something_C_1 -> ...

Link to post
Share on other sites

Are the 3 VIs running on 3 different computers and you like to synchronize them?

I would use one master VI/state machine, which sends simple requests to the three server-VIs.

The Server VIs would create a TCP-listener and wait for commands and execute them.

Link to post
Share on other sites

JKI has a presentation on how to do this using their state machine and user events. It's a convenient and simple way to expand on an already very useful architecture. You'll find the JKI state machine gets used a lot in the LabVIEW community.


Check it out here:


Link to post
Share on other sites

Sorry if I was not clear. All of the vi's for now run on the same machine. The problem is that I need to control the states of all three vi's based on what states they are in respective to each other, one waits for a 'trigger' from another vi inorder to progress. I have two vis in a 32bit version of labview and a vi running in 64bit labview.


I just installed JKI I will take a look. I am not sure what differentiates it from a standard state-machine although I know it must be more robust. 

Link to post
Share on other sites

I was just reading this topic and realized the suggestion to use Notifiers across LabVIEW instances (they have to be different instances between 64bits and 32 bits).  I never ran into a situation requiring this personally but does this mean that Notifiers (named) (and possibly Queues (named)) allow communication between LabVIEW instances?


I looked at the Help file and under Notifier, it says:

"Note If you obtain a notifier reference in one application instance, you cannot use that notifier reference in another application instance. If you attempt to use a notifier reference in another application instance, LabVIEW returns error 1492."


Doesn't this imply that it is not possible?


There might be something more fundamental I don't understand in this issue since I thought it was not possible to install and run both 32 and 64 bits on the same PC...

Link to post
Share on other sites

Therefore, my recommendation for drbrittain would be to use the TCP/UDP communication method.  I personally use the AMC (http://zone.ni.com/devzone/cda/epd/p/id/6091) library from NI a lot within a single LabVIEW instance but there are VIs in there to communicate seamlessly accross different machines over UDP I believe.  You will need to tweak the code wherever "AMC_UPD port.vi" is called to use two different ports since you are on the same IP address.


Otherwise, I just did a quick test with Shared variables and they successfully communicate accross LabVIEW instances (2009-2011) and should also work between 32 and 64 bits.  You can use a few variables to allow each process to know what the other processes are currently doing.  You can even use those as queues if you configure them as FIFOs. (http://www.ni.com/white-paper/4679/en)

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.

  • Similar Content

    • By jhoehner
      Hello All,
      First time LAVA poster here with my first question. Why do some LabVIEW programmers insist on wiring the error cluster to the bottom of their VI as opposed to the sides as shown in most NI documentation. Is there any benefit to it? Is it 100% a preference thing? Is there a way to make LabVIEW connect error wires like this automatically?
      I've only seen it in advanced LabVIEW code from experienced programmers and some parts of the Actor Framework.
      Your insight and experience is appreciated! 

    • By the_mitten
      The introduction of parallel, read-only access for DVRs in LabVIEW 2017 adds a great deal of flexibility to using DVRs to monitor values in parallel executions of code. Fo\The downside of this, of course, is the necessity of using the In Place Element (IPE) throughout your code simply to read the value. Having IPEs throughout your code just to read a value both takes up block diagram real estate and also takes more clicks than desirable to insert.
      Similarly, though less frequently, there are times when you only need to update the value within a DVR without actually performing any logic inside of the IPE.  This situation is less frequent, at least for me, as I am usually using arrays or classes with DVRs such that I actually need to modify the existing data rather than simply replacing it.
      A more preferable solution to the above situations would be to have Read/Get and Write/Set VIs for the DVRs to simplify the process of working with them. This way, and IPE on the block diagram would only be needed when you were actually modifying the existing data within the DVR, rather than simply overwriting or returning the current value.
      Thanks to the power of malleable VIs and the type specialization structure that is now officially released in LabVIEW 2018, a better solution is now available. I’ve created two malleable VIs, Read  DVR Value (Parallel) and Write DVR Value that allow you to perform a write and a parallel read on any DVR data type.
       Now, you can use a single VI that you can insert via Quick Drop to read or to write DVR values.  
      Download the attached ZIP file to access the two malleable VIs and example code, and please let me know your thoughts in the comments!

      DVR Read and Write VIs 1.0.0.zip
    • By takanoha
      I have a simple program which has only 2 buttons for the user interface. When the user clicks OK I want the program to get into the event structure case called "OK Button". Once it is inside there is a loop which continuously waits for 1 second until "Stop Button" is called from the user. 
      But because once the user presses the "OK Button" the program gets into the event and therefore I can not call the "Stop Button". 
      Is there a way to call the "Stop Button" even if the program is inside the event ?

    • By Huqs
      Hello Labview Users, 
      I happen to have thousands of csv data file that I work with. The only way I recognize them is putting their characteristics in the file name. Which brings the problem of making the names too long and Microsoft doesn't like to accept long name. So I wanted to build a database for all my files. I am in the preliminary stage of building it ( I have attached the file and some of you may have seen it before). 
      What I want to do is, have all my files in the database with random names and list them based on their characteristics. I want to do that in my application in the place of 'file' box. So that I can click on the file and run it (double-click on the file in application to make them work in active file). based on the parameters listed on the database I want to filter them to find any specific file. How the interface of database should look like is shown blow (Image) . 
      It doesn't have to be a real database, just a directory application. I am trying to make it without the database toolkit.  If anyone can help me out and guide me out or guide me in the right direction then that would be great. Thanks. 

      Multicolumn list box v1.5.vi
    • By Zyl
      Hi everybody,
      I'm actually running on a problem with a  TCP connection between 2 cRIOS.
      One cRIO is a server which writes 76 bytes long messages every 10ms (today, but can be anything between 1ms and 1s) using STM Write VI (so at the end it pushes 82 bytes long message in the TCP write function). I want that message to be sent only if the client as time to read it, so I set the timeout to 0.
      The other cRIO is a the client with tries to read on the TCP link at a speed of 1000Hz (1ms, Wait next Multiple used to ensure that the loop is not running faster). I use the STM Read VI to get the data sent from the other cRIO. The read function has a timeout of 100ms.
      What I was expected is that the client loop would actually runs at 10ms rate (server writing rate) due to the 100ms timeout. And if the server writes faster, it would follow the server rate. If the server rate is greater that 100ms, error 56 would be fired, and I would handle it.
      What happens is that the server writes the 82 bytes every 10ms. But the client loop is always getting data and runs at 1ms ; which means that the timeout is not respected ! I disabled Nagel algorithm on the server side to be sure that the message is sent when requested, but it didn't help. The client acts like there is always data in the read buffer. Even if it can be right for the first iterations, I would expect that running at 1ms rate, the client would empty the buffer rapidly, but it seems that it never ends... Moreover, the longer the server writes, the longer it takes for the client to see empty buffer (timeout reached again and error 56) when the server is stopped (but connection not closed).
      Does somebody already ran into this issue ?
      Any idea on how I can solve this ?
      Server code is attached to the post. 2 TCP connections are established between the server and client (so same IP address, but different ports), but only one is used (upper loop). The other opens and close immediately because EnableStream boolean is always false.

  • Create New...

Important Information

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