Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Edge counting with digitial pause trigger

Hi
 
I should write a program for edge counting with digital pause trigger in visual basic.  I have found an example of using pause trigger in edge counting but it is written in C#.
 
Steps in the program followed is:
 
1) creating task
2) creating count edge channel objecy
3) configuring thr trigger ( where i have been strucked)
 
code in c # is:
 
taskname.triggers.pausetrigger.digitalleveltrigger ( source, level)
 
When i tried to look for trigger function and to configure it in Visual Basic, I have not found any trigger function to set/configure in the function library
 
Thanks
 
 
0 Kudos
Message 1 of 52
(5,728 Views)
Hey there,
 
I'm looking into this for you, but before I go into too much detail with it.  What versions are you using?
What Hardware are you using?
What version of VB are you using?
What version of DAQmx are you using?
and
What device are you trying to set the Pause trigger up on?
 
I think the properties you are looking to set are in the "DAQmx.DAQmxSetDigLvlPause~" options.
 
But with more info I can't be sure. Have a look at those properties. 
 
Thanx
 
AdamB
 
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 2 of 52
(5,716 Views)
Hi Adam,
 
Thanks for your response.
 
DAQmx version: 8.3
VB version: VB 6.0
Hardware: PCI 6602
I am trying to use one of the counters to act as trigger  (say counter 0) , which I would like to use it as a trigger (Gate) for other 7 counters. In one of my other post I got a reply that I can use PFI to set up trigger instead of RTSI signal,  I am new to all these things, it will be great if i am getting some explanation of using trigger in counters. In that C# example, I tried to use the trigger source, with and without connecting to source supply, but still I am getting counts when the gate level is High, So could you suggest me about setting up the source as well. If any explanations needed, I am happy to state my problems clearly. This project I am converting from Traditional DAQ to DAQmx, I have attched my VB program and also the example C# program which I got from NI website for pause trigger.
 
Thanks

Message Edited by Support on 07-16-2007 10:52 AM

0 Kudos
Message 3 of 52
(5,708 Views)
Hi,
 
Have you had a look at the function I showed you?
These are the three setting you need to set in VB for the pause trigger:
 
DAQmxErrChk DAQmx.DAQmxSetPauseTrigType(taskHandle As Long,data As DAQmxTriggerType4)
DAQmxErrChk DAQmx.DAQmxSetDigLvlPauseTrigSrc(taskHandle As Long,data As String)
DAQmxErrChk DAQmx.DAQmxSetDigLvlPauseTrigWhen(taskHandle As Long,DAQmx_Val_Level1_High/Low)
 
The "taskHandle" is the Handle for the counters task. 
DAQmxTriggerType is deciding whether you need digital trigger,analog etc.
In the "..TrigSrc..." function the "data" is the string value of the line you are using as the source for the trigger
and "...TrigWhen..." sets the trigger level you want to start and stop the trigger. "DAQmx_Val_Level1_High" or "DAQmx_Val_Level1_Low"
 
Hope all this helps
 
AdamB
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 4 of 52
(5,688 Views)
Here's the code I made
 
AdamB
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 5 of 52
(5,685 Views)
Hi Adam,
 
Thanks for your response, I am not able to open the file you sent, as there is no .frm or .bas files in it. It has only one .vbp file. Could you please make sure all the files has been zipped?
 
Thanks
0 Kudos
Message 6 of 52
(5,681 Views)
Hi,
 
Thanks for your swift response, I am not able to open the VB project as there is no form in it. And also could you give some description about how the pause trigger works on that C# example, bcoz i tried using source connected to the pause trigger, but it gives same result irrespective of connection of source.
 
Regards
0 Kudos
Message 7 of 52
(5,668 Views)
Hi there,
 
Here is the code in text format.  That's pretty much all you need.  I took the example code called CntDigEvents.vbp and added the following code before the start task function call:
 
    DAQmxErrChk DAQmx.DAQmxSetPauseTrigType(taskHandle, DAQmx_Val_TriggerType6_DigLvl)
    DAQmxErrChk DAQmx.DAQmxSetDigLvlPauseTrigSrc(taskHandle, "PFI0")
    DAQmxErrChk DAQmx.DAQmxSetDigLvlPauseTrigWhen(taskHandle, DAQmx_Val_Level1_High)
 
As for the C# code I am not familiar with C# so I don't think I can be a great help on that one.
myTask.Triggers.PauseTrigger.ConfigureDigitalLevelTrigger(triggerSourceTextBox.Text, gateLevel)  This function is the main call for the pause trigger and all it is doing is setting the properties.  triggersource should be along the lines of "PFI0" or "Ctr0" and gate level defines whether the gate level is "high" or "low)
 
How is the VB code going?
 
AdamB
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 8 of 52
(5,665 Views)

Hi Adam,

This has been a great help to me, I am writing an application in VB, so this is fine. I am writing a project with edge counting and using the pause trigger functions you have noted me. So hopefully there should be some process in my project. As you might have seen my traditional DAQ program which I have attached before,  I just want to write the same functionality as our hardware, requirements and programming language has not changed except the driver ( DAQmx). Hope this could be a good start for to make the trigger work with edge counting function. I have written another project in VB for Pulse train generation, So the idea is giving the output of the pulse train as the terminal for pause trigger and giving the trigger output ( gate output) to other 7 counters. Does is make sense ? or is there any other way around to solve this issue?

Thanks

0 Kudos
Message 9 of 52
(5,663 Views)

Hi Adam,

I have written the program and it seems to be fine. but when i am stopping the task, I have two functions in it

If taskIsRunning = True Then
      1)   DAQmxErrChk DAQmxStopTask(taskHandle)
       2)  DAQmxErrChk DAQmxClearTask(taskHandle)
    End If

 

I am getting an error " Error: - 200088 Task specified is invalid or does not exist. There is some error been generated when accessing cleartask.

 

Thanks

0 Kudos
Message 10 of 52
(5,654 Views)