Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Pause task

Solved!
Go to solution

Hello?

 

I wish to pause AI task for changing the sampling setting whenever my customer wants. I used a boolean value to stop displaying acquired data on the screen but actually it keeps acquiring data while its setting is being modified by user. Then just after it tries to apply new setting, it shows me an error message "task is reserved"

 

How can I pause the task?

I'm converting DAQ to DAQmx..from Parkoz.com
0 Kudos
Message 1 of 7
(8,382 Views)
Solution
Accepted by topic author anarkie

Hi, Anarkie.

 

Unfortunately, there is no way to pause a task and then change the sampling rate.  In order to change the sampling rate after the sampling clock has been configured, you must stop the task, configure a new task and then run the new task.  The screenshots (taken from the attached code) display how to do this. 

 

The first screenshot displays the event that occurs when the rate is modified by the user.  When the "rate" control has a value change, the task is stopped, the sampling clock is reconfigured at this new rate, and the new task is started.

 

 screenshot.JPG

The second screenshot displays the event that occurs when the rate is unchanged.  If no change in the rate control occurs after 10ms, data is acquired (as expected) from the previous configuration.

screenshot2.JPG

Let me know if you need any more help.  I hope you're having a great day!

 

 

Regards,

Sara Lewandroski
Applications Engineer | National Instruments
Message 2 of 7
(8,355 Views)

Hi, Anarkie.

 

I just noticed that this forum was on the Measurement Studio board.  I accidentally responded with LabVIEW related code.  The concepts behind the programming are basically the same, but if you need any more information regarding programming with Visual Basic, respond to this post.  I apologize for the mistake.

 

I hope you're having a great day!

Regards,

Sara Lewandroski
Applications Engineer | National Instruments
0 Kudos
Message 3 of 7
(8,344 Views)

Ok, but do you have any idea about start trigger?

 

Looks like DAQ works with a repeative digital pulse,

but DAQmxCfgDigEdgeStartTrig(taskHandle, "/Dev1/PFI0", DAQmx_Val_Rising) only works with a single mono digital spike.

 

If I connect a repeative digital pulse on it, DAQmx doesn't work.

But if it is connected a single digital spike, it works.

 

 

Do you know why?

 

I'm converting DAQ to DAQmx..from Parkoz.com
0 Kudos
Message 4 of 7
(8,322 Views)

Hi, Anarkie.

 

I'm confused.  Are you referring to retriggerable acquisition?   Basically, a finite number of analog input signals are acquired each time that a digital trigger is received, as depicted in the following image:

screenshot.png

As you can see, four samples are acquired every instance that a digital trigger pulses.  Is this what you mean?  Do you want to retrigger a finite analog acquisition after the user types a new value into the sample clock rate control?

 

If this is the case, you're going to need a counter task that is configured for finite retriggerable pulse generation.  Here is the NI Developer Zone where the code associated with DAQmx- Retriggerable AI using Retriggerable Counter can be found.

 

Let me know if this is correct or incorrect, and I'll provide you with more information.  I hope you're having a great day!

Regards,

Sara Lewandroski
Applications Engineer | National Instruments
0 Kudos
Message 5 of 7
(8,305 Views)

Thanks for reply. The reason why I was asking single peak pulse, I inserted a single peak into PFI0, it started acquisition

but it keeps showing free running signal wave. Even if after connected to TTL repeative digital puls, it shows the same free running signal.

 

That's why I wonder DAQmx function only detects the first single pulse.

 

BTW, I use even and odd array buffers to display one and acquiring the other at the same time. I was told that DAQmx sets buffer size

automatically. I wish to access buffer and assign them one of those even and odd buffers to display.

 

Thanks anyway.

I'm converting DAQ to DAQmx..from Parkoz.com
0 Kudos
Message 6 of 7
(8,288 Views)

Hi, Anarkie.

 

DAQmx can do both:  trigger on the first pulse of a digital trigger line and trigger on every pulse of a digital trigger line.  The reason that the acquistion started after a single pulse is because only a Digital Start Trigger was configured.  The Tips and Techniques in Data Acquisition Triggering - NI-DAQmx Knowledgebase gives a great explanation of the concept of triggering.  I think the confusion may lie in what purpose triggering serves.  Triggering is used to initiate data acquisition. For example, when a digital pulse is received on PFI0, acquisition on line AI0 can begin; this is an example of post-triggered acquisition.  The image below gives a good representation of this action:

 

trigger.jpg

 

As you can see, when the start trigger (digital signal on PFI0) sends a pulse, the input signal will be acquired, until either there is no more data to acquire or you define when the acquisition should stop.  If you were to use a pulse train as a start trigger (digital signal on PFI0), the input signal will start being acquired on the first edge (rising or falling) of the digital signal.  This defines a start trigger.  Note: You can allow for retriggerable acquisition (as referenced in my previous post).

 

If the free-running signal does not correspond to the signal that you're expecting to acquire, then that's an entirely different issue.  The signal may not be connected correctly; the configuration settings may be incorrect; the hardware could have been damaged; etc.

 

What do you want to see when connecting a repetitive TTL signal to PFI0?

 

In response to your question about buffer size:

DAQmx determines the buffer size based on the configured sample rate.  In order to manually change the allocated buffer size, the DAQmx Configure Input Buffer VI (or in your case, the DAQmxSetBufInputBufSize function) will get the job done.  Check out the How Is the DAQmx Buffer Size Allocated for a Finite or Continuous Acquisition Knowledgebase for more information regarding how the buffer size is determined by DAQmx and how you can override this setting.

 

Let me know if you need any more information.  I hope you're having a great day!

Regards,

Sara Lewandroski
Applications Engineer | National Instruments
0 Kudos
Message 7 of 7
(8,277 Views)