LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to Implement Start/Run/Stop Tasks in a DLL Without Using Loops in LabVIEW?

Hi everyone,
I'm developing a custom component for my company using C DLLs + LabVIEW, and I need some clarification on the expected behavior.

Goal

I want to create a simple component with three tasks, all implemented in a C DLL:

  1. Start Task — runs once when the component starts

  2. Run Task — runs continuously and outputs data every iteration

  3. Stop Task — runs once when termination is triggered, and it must stop the Run Task

These three functions will be wrapped into a custom subVI that a client user will place inside their own While Loop in the final application.

The Problem

I was told that inside my subVI’s block diagram I am NOT allowed to use any loops (no While Loop, no For Loop).
But my Run Task must execute continuously

I asked:

If I don’t include any loop inside my subVI, how does the Run Task run continuously?

The answer I received was:

The client user will place your subVI inside THEIR While Loop, so your Run Task will be executed repeatedly by the user’s loop.

 

this is from the vi im doing , i tried to use a for loop but this is not how it must be done , im not allowed to use any type of loops 

thesara_0-1763556489935.png

 

0 Kudos
Message 1 of 5
(177 Views)

The "requirements" that the "calling routine" calls three LabVIEW VIs to Start, Do Once, and End the LabVIEW DAQ task sacrifices the strengths of LabVIEW to run its code concurrently.  Better would be to have the caller send "Start", "Run", and "Stop" commands, where "Run" has the LabVIEW code (how do I say this, run) until it receives the "Stop" command (there might be an extra "loop", but that should be easy to handle).  With luck, this will run concurrently with the rest of the program, preserving accurate timing within the multiple "Run" states.

 

The description of the LabVIEW routine sounds like a State Machine, a very common and powerful LabVIEW construct used for Data Acquisition and Data "Generation" (i.e. Waveforms, etc.) where deterministic timing is important.  If timing is not important (take a sample, wait some ill-defined time, take another sample, wait, etc.), then having the non-timed C loop call the well-timed LabVIEW function can be employed, but timing will (probably) not be accurate.

 

Bob Schor

0 Kudos
Message 2 of 5
(159 Views)

@thesara wrote:

I was told that inside my subVI’s block diagram I am NOT allowed to use any loops (no While Loop, no For Loop).
But my Run Task must execute continuously

I asked:

If I don’t include any loop inside my subVI, how does the Run Task run continuously?

The answer I received was:

The client user will place your subVI inside THEIR While Loop, so your Run Task will be executed repeatedly by the user’s loop.

 

this is from the vi im doing , i tried to use a for loop but this is not how it must be done , im not allowed to use any type of loops 

thesara_0-1763556489935.png

 


 

According to your picture, the iteration is done in the caller, all three modes of your dll must do their task and return immediately. the Run mode is called continuously, not running continuously internally. I guess that's how they are planning to use it. If everything should be done with the same dll, you simply need an input that defines the desired mode. (e.g. an Enum with 0:Start 1:Run, 2:Stop)

 

Of course what you show us is one ugly VI with a completely pointless value property node. Using the terms "iteration" and "no loops" in the same paragraph is contradictory and silly. 

 

Maybe you want to go back and fully show the requirements document. How are they planning to use the code? What's the purpose? How much LabVIEW knowledge and experience do you and they have?

0 Kudos
Message 3 of 5
(128 Views)

Well it seems like all they want you to do is put the proper DLL inside a "LabVIEW wrapper" (a VI)

 

I would make three separate VIs using the parts I circled 

newCapture.PNG

 

You could name them "Start Task.VI", "Run Task.VI", and "End Task.VI"

 

Don't use the Property Node in the Run Task VI just a standard indicator.

 

Then it's up to your client to use them properly in their program. 

 

I have to add that you are basically making a "LabVIEW Instrument Driver" and you might want to take a look at the Instrument Driver Guidelines for tips

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 5
(109 Views)

i dont understand the requirnment exactly but what i have been told is :

your system should detect whene to start based on the excution button of labview and then excute starting task one time only and then the run task will start excuting continuesly and it will stop with the stop excutin button of the labview , i cant just put the running task inside a while loop cus its not eparable ,its one subvi :

thesara_0-1763892426815.png

so i dont really understand what to do eaxctly 

0 Kudos
Message 5 of 5
(32 Views)