LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with state machine on myRIO

Solved!
Go to solution

Hi,

I am working on a state machine for communication via myRIO, I have started from the "simple state machine" template available in Labview where I currently only have initialize, wait for event and stop as events. However, it does not stop when it should stop, when I press stop the idea is that it should go into the Stop case. but it does not, however, when I move all VIs and states.ctl to the computer via project toolbar it stops when it should. See picture: 

 

antje668_1-1656525195541.png

 

 

Does anyone know where I am going wrong?

 

 

0 Kudos
Message 1 of 9
(1,230 Views)
Solution
Accepted by topic author antje668

Hi Antje,

 


@antje668 wrote:

Does anyone know where I am going wrong?


Yes.

 

Did you read the comments in the block diagram of your mainVI?

Especially those of the event structure?

There it says:

Use an Event Structure to monitor the user interface

 

Now the surprise: your myRIO doesn't offer any user interface (aka GUI)!

When there is no GUI, then there are no events related to UI elements!

 

Infact most RIO devices are considered "headless", which means they don't offer or support a GUI. And so they don't support the event structure with all their functionality as a regular Windows computer target does…

 

When you are looking for examples then you should use File->New… and select one of those examples for RIO devices (aka Realtime projects)!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(1,225 Views)

Hello GerdW,

 

Thank you are a fast and informative answer.

 

Is it any way where I can get around this problem maybe or should I just stick to the templates you recommended? Cause I do need to have a user interface where the states changes depending on which button the user press on the UI.

 

For example I want to be able to switch between configure data, acquire data, reset data, stop and so on.

0 Kudos
Message 3 of 9
(1,219 Views)

Hi Antje,

 

when you want to handle several targets within your project (Windows computer + myRIO), then you should start with a RealTime project.

 

In those example projects it is explained how to handle a GUI on your Windows computer together with a RIO target doing the "statemachine stuff"…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 9
(1,211 Views)

Maybe this is exactly what I'm looking for? (See attached picture)

 

 

0 Kudos
Message 5 of 9
(1,200 Views)

Hi Antje,

 


@antje668 wrote:

Maybe this is exactly what I'm looking for?


Yes, start with this example and learn from it...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 9
(1,183 Views)

Hi Gerdw,

I have another perhaps stupid question. Do the VIs called "host" and "target" have to run at the same time?

The "host" can be seen as the UI, so anything I press or parameters specified are sent for appropriate action to myRIO.

 

My interpretation at first was that only the "host" located on the PC needed to be run, then the PC and myRIO communicate via shared variable. But I'm starting to wonder if both VIs need to run after all.

 

I have attached the project and a picture of the tree structure.

 

I have used the template for RT state machine that we talked about yesterday.

 

 

 

Download All
0 Kudos
Message 7 of 9
(1,135 Views)

Hi Antje,

 


@antje668 wrote:

I have another perhaps stupid question. Do the VIs called "host" and "target" have to run at the same time?

The "host" can be seen as the UI, so anything I press or parameters specified are sent for appropriate action to myRIO.

 

My interpretation at first was that only the "host" located on the PC needed to be run, then the PC and myRIO communicate via shared variable. But I'm starting to wonder if both VIs need to run after all.


There are no stupid questions, but only stupid answers…

Yes, they both need to run at the same time!

 

You need to keep in mind: your Windows computer and the myRIO are two (2) computers on their own!

So when you want to send data from host to target then it's not sufficient to only run the host transmitter, there also needs to run a target receiver…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 9
(1,125 Views)

Hello, Antje.

 

Welcome to the "interesting world" of LabVIEW Real-Time.  Before worrying about the complexities of managing two computers running at the same time and needing to communicate with each other and exchange data between themselves, it would be a good idea to have spent a few months (or years?) getting some level of expertise in LabVIEW, itself.  You should be able to:

  • Have a reasonably-good understanding of DAQmx (the technology behind Data Acquisition and Control functions).  This means knowing how to acquire data from NI's DAQ devices without using the Dreaded DAQ Assistant (DDA), but only a hand-full of DAQ functions.  [Do a Web search for "Learn 10 Functions in NI-DAQmx and Handle 80 Percent of your Data Acquition Applications".  Skip the first point that talks about the DDA].
  • Be able to create a State Machine "from scratch", including an Event Loop that handles "Start", "Pause", "Read", and "Stop" buttons.
  • Understand "parallel processing" à la LabVIEW, such as how to code a Producer/Consumer Pattern to simultaneously acquire (say) Analog data and (in a parallel loop) stream it to a disk file.
  • Understand how to safely stop a multi-loop LabVIEW routine.

When you start dealing with a LabVIEW Real-Time Project, you are necessarily dealing with two computers, the Host PC and the LabVIEW Real-Time Target, running two Operating Systems (typically Windows and NI Real-Time Linux), and potentially running two independent LabVIEW programs.  It is possible to write a LabVIEW RT Project that only has a Real-Time component, but then you need to figure out how to communicate with it, including how to start and stop it.

  • Starting it is often straight-forward -- you can build your Real-Time code into a Real-Time Executable, download this onto the Real-Time Target, and set it to run when the Target boots up.  Now every time you turn on the power to the Target, after a few seconds (or a minute), the code starts running and doing whatever you programmed it to do.
  • The code will stop running when (a) you cut the power to the Remote Target, the LabVIEW code reaches a "Stop" condition and just stops running, or (ideally) you have a way to communicate with the Target and request it to stop.

Communication with Real-Time Targets are usually done through TCP/IP channels.  In the few such routines I've developed, I have use LabVIEW's Network Streams routines to set up Host/Target two-way communications.  While in Development mode, the LabVIEW Project uses TCP/IP to allow you to deploy and test your LabVIEW RT Code on the attached Target.

 

Bob Schor

 

0 Kudos
Message 9 of 9
(1,101 Views)