Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger in software

I have a project where I want to have a software trigger, i.e. pressing a button in the GUI to start the measurements.
 
Right now I use one of the PFI signals to trigger the following tasks with help of an extern signal:
 
- Digital Input (using Analog input sampleclock)
- Digital Output (using Counter 0 as sampleclock)
- Analog Input (using internal analog input sample clock)
- Analog output (using internal analog output sample clock)
 
My problem is that I need to change the external trigger for a software trigger to start all of the tasks at the same time. Is it possibly to route one internal counter to the PFI-signal and still use the PFI as a trigger? If that is possibly, how?
 
I have a 6259 DAQ board and I'm using VC++.
0 Kudos
Message 1 of 10
(5,292 Views)
Hi Pek!
 
    I think you should do it another way.  You add a callback to a button, and in that callback code, you launch your measurement ( StratTask(), etc....).  Doing this, you can encounter problems because the callback associated with the button can be called several times for a click, so you can perform your measurment twice or three times if you don't filter event occurred!

   I usually program in LabWindows/CVI, so I'm not strong in VC++.  I don't know how to associate a callback to a button in VC++, and what are event passed, but I know there's a way to do this. So, you just should map what I've told you for VC++.

   Yes, of course you have to disable Hardware triggering!

    Please, let me know if this helps, and how you managed to solve this problem!

    Have a nice day!

graziano
0 Kudos
Message 2 of 10
(5,283 Views)

The problem is that I need to start all the tasks at the same time. One solution, which I have not tested yet, is to use the Analog Input Starttrigger ("ai/StartTrigger") to trigg alla the other tasks. I hope that the signal "ai/StartTrigger" will go high when I start the analog input task and then start the other tasks.

 

However one problem with that solution is that I always need to use the analog input task, even if I don't want to measure any analog signals. Therefor I'm looking for other possibly solutions to trigg all the tasks from software.

0 Kudos
Message 3 of 10
(5,281 Views)
Hi!
   I did, in the past, some programs for a NI 6251, quite similar to your 6259, but I haven't it anymore, so I can't test what I will say...

   The important thing is: why you have your task to start together?  If you need an effective SIMULTANEOUS sampling, I think you've not the right board, because it doesn't have separate A/D D/A converters for each channel.  For it, you should use the (more expensive) S-series card.  That's why the cost is higher!

   If you do not need this precision issue, (in most cases you don't need such a timing restriction!), you can add multiple channels to a single task. This way, all sampling start together.  But always remember that "together" means that samples from different channels are sligtly delayed in time.

   I don't know if this helps, let me know!

   Bye!

graziano
0 Kudos
Message 4 of 10
(5,282 Views)
To confirm this..... have you noticed that sampling rate differs if you're sampling one channel (1.25 MS/s) or multiple samples (1 MS/s)?
0 Kudos
Message 5 of 10
(5,274 Views)
The system is working exactly as I wan't it to do, the only thing I need to do is to create one software trigger to trigg four different (analog input / analog outout / digital input / digital output) tasks simultaneously. The tasks trigg simultaneously when I'm using a hardware trigger.
 
It's very important for the four tasks to trigg at the same time, but it's not critical that all the analog channels are measured simultaneous (that's why I'm using the 6259 because I need a lot of channels). The project is almost finished and both the DAQ and my program is working very well. I just need to do some updates, where one of them is to make it possible to start all the measurements wthout any hardware triggers.
 
 
Some background information:
 
One piece of the software consists of four tasks; Analog output task (only one channel), Analog input task (up to 32 channels), Digital input task (several channels), Digital output task (several channels).
The analog and digital outputs are stimuli to a testbench where we are going to do some tests. The analog and digital inputs collect measured values at given intervals.
 
All the tasks need to trigg at the same time for the outputs and the inputs to be synchronous, that's why I'm using the same trigger signal. When I'm using an external trigger (one of the PFI signals) everything works very well. All that I want to do is just to change that hardware trigger for a trigger in software.
 
 
Questions:
 
- Is it possible to route a counter output to one of the PFI signals, and use the counter as a trigger? Bacause all of the used tasks can be trigged by PFI-signals.
 
- Let's say I'm using one Analog Input task and no special trigger. Does the command "task->start()" have an influence on the signal "ai/StartTrigger"? Then one solution is to use the signal "ai/StartTrigger" to trigg all the other tasks simultaneously. 
0 Kudos
Message 6 of 10
(5,273 Views)

Answer:

Yes the sampling rate differs, I'm aware of that.

0 Kudos
Message 7 of 10
(5,274 Views)
Hi!

  If in your card you've a Counter out connection, of course you can wire it to the PFI in, externally. Then you have to configure the counter....

   If you mean INTERNAL routing, I don't know. You should refer to routing possibilities.  In CVI, a function for routing exists:


DAQmxConnectTerms ()

Creates a route between a source and destination terminal. The route can carry a variety of digital signals, such as triggers, clocks, and hardware events.

These source and destination terminals can be on different devices as long as a connecting public bus, such as RTSI or the PXI backplane, is available. DAQmxConnectTerms does not modify a task. When DAQmxConnectTerms runs, the route is immediately reserved and committed to hardware. This type of routing is called immediate routing.


Prototype

int32 DAQmxConnectTerms (const char Source_Terminal[], const char Destination_Terminal[], int32 Signal_Modifiers);


I don't know the equivalent in Measurement Studio, but it should be easy to find it.   the only problem is that not all the signal are routable to any signal terminal.  In this way, you could route a counter out to a PFI line.  Be careful, you create am Hardware connection!!!!


Another solution is to use a global variable.  that is, when you click to the button, this variabel is set to TRUE, and with this variable == TRUE, you call a function in which you change tasks properties, in particular you deselect HW triggering, and you start your four tasks by software command.  But this is a little bit messy, because to do so you should always check for your tasks to be stopped, change properties, and then restore HW trigger.  This can be a last chance....

Really hope you'll solve this problem!!!!  Bye!

graziano
0 Kudos
Message 8 of 10
(5,274 Views)
Hi,
  in M series help, under "Exporting Timing Output Signals Using PFI Terminals"  you find this:

Exporting Timing Output Signals Using PFI Terminals

You can route any of the following timing signals to any PFI terminal configured as an output.

Signals with a * are inverted before being driven to a terminal.


0 Kudos
Message 9 of 10
(5,252 Views)
Thank you for your help, I will do some tests tomorrow.
 
 
0 Kudos
Message 10 of 10
(5,248 Views)