LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop my program after a runtime of 30 seconds? My stop event is in an event structure.

Hello all!

I am a beginner in LabVIEW. Hence, I would like your suggestions on how to stop my program automatically after a runtime of 30 seconds. 
The VI has an event in the event structure that tests my device in about 30 seconds which is one cycle. I want to automate this process instead of pressing the stop button physically every 30 seconds. Currently I start the program by pressing the run continuously button and physically press the stop button after each cycle (30 seconds) and wait for it to run again.

Thanks in advance!

0 Kudos
Message 1 of 7
(176 Views)

Hi,

 


@kakprime wrote:

Currently I start the program by pressing the run continuously button and physically press the stop button after each cycle (30 seconds) and wait for it to run again.


This is a big NO-GO!

 

Learn about basic state machines and implement them with your requirements...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(173 Views)

As suggested please go through the LabVIEW StateMachineArchitecture.

 

https://www.ni.com/en/support/documentation/supplemental/16/simple-state-machine-template-documentat... 

 

Also share the code you have tried so far! to guide from there.

 

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 3 of 7
(127 Views)

Gerd seems to be better at reading between the lines, but it is really impossible to tell what you are actually doing, so start with attaching your VI so we can offer suggestions. There are many red flags in your description.

 

  • Run continuously is a debugging tool, not a way to run a VI. (It can e.g. be used for quick standalone testing of a subVI that does not have a toplevel loop)
  • An event structure cannot test devices. It is a structure. You did not even describe what triggers the event.
  • What exactly is the program state after 30 seconds?
  • You cannot "physically" press a virtual button.
  • What is your program architecture (if any!). Where is the event structure? What are the event cases? What else is there? What is inside or outside the cases? (e.g. a test that takes 30 seconds should never be inside an event case)
  • What is a cycle? (repeat same? new device? New settings?)
  • What determines the 30 second runtime (timer polling? natural duration for the test to complete?)

 

Message 4 of 7
(121 Views)

Thank you @Palanivel, @Altenbach and @Gerd for your inputs. I will check out State Machines. I'm currently trying to edit and introduce a looping event to a high level program created by my senior engineer. As I a beginner in LabVIEW, I'm trying to find a solution through trial and error.

 

The program tests a GSM - Gear Shift Module in a car, where it checks for Faults, DTCs, etc. It uses the CAN Bus to communicate with the module and initiates an ignition, after which it cycles through all the gears, logs any DTCs and checks for gear change inputs.

 

My task is to loop the test program, so when I start the program it starts the ignition and checks for faults and DTCs and switches off after every 30 seconds and starts the ignition and check for faults again. Currently this process is manual as I have to stop the whole VI and restart it every 30 seconds. I am trying to automate it.

 

I have attached the top level VI, but I can't attach any other sub VIs as it's fairly large list. I hope you can give some valuable inputs for this rookie. Thank you very much!

 

 

0 Kudos
Message 5 of 7
(117 Views)

One way to implement what you are trying to do, is to use a function to get time . Use it 2 times one BEFORE the start of the loop and one inside the loop, and measure the difference of both times, when the diffference is bigger than 30 seconds, then the loop stops. 

As it has been shared, don't use continuous buttons, preferably learn the basics of state machine and implement it on the code. 

 

LVNinja_0-1760538044436.png

 

0 Kudos
Message 6 of 7
(99 Views)

I hope here the 30 seconds is not the reference point you need to reiterate the Test again once the complete sequence for the  Test is completed.

 

Are there any Manual operations involved other than start and stop in your current approach?

 

1. It would be better to Re Architecture (Create a Enum with the Sequence of Operation)

 

1. Init

2. Start

3. IgnitionON

4. Gear 1

5. Gear N

6. Log DTC

7.Check Cycle Count if Less than the Requested count go to Step3

 

Repeat until you reach Cycle Count .

 

Next option would be to call ignition ON once the test operation is completed in the existing code.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 7 of 7
(87 Views)