Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

===how to transfer this code from VB6.0 to C#.NET?===

Solved!
Go to solution

VB code:

'     Add a counter input channel to the 6601 task.
'    DAQmxErrChk DAQmxCreateCICountEdgesChan(taskHandle_6601, "Dev2/ctr0", "" , DAQmx_Val_Edge1_Rising, 0, DAQmx_Val_CountDirection1_CountUp)
'
'    'set the source timebase of 6601
'    DAQmxErrChk DAQmxSetCICountEdgesTerm(taskHandle_6601, "Dev2/ctr0", "20MHzTimebase")
'
'    'set the sample clock of 6601
'    DAQmxErrChk DAQmxCfgSampClkTiming(taskHandle_6601, "/Dev2/PFI38", 20000#, DAQmx_Val_Rising, DAQmx_Val_AcquisitionType_ContSamps, 1000)

 

C# code:

                counterReadTask.CIChannels.CreateCountEdgesChannel(counterComboBox.Text, "", edgeType, Convert.ToInt64(initialCountTextBox.Text), countDirection);


               'set the source timebase of 6601

               how to transfer this line ???

 

                counterReadTask.Timing.ConfigureSampleClock(sampleClockTextBox.Text,
                    Convert.ToDouble(rateTextBox.Text), SampleClockActiveEdge.Rising,
                    SampleQuantityMode.ContinuousSamples, 1000);

 

 

thank you very much!

0 Kudos
Message 1 of 7
(4,696 Views)

Please refer to the explanation of this parameter:

 

public string CounterTimebaseSource { set; get; }
    Member of NationalInstruments.DAQmx.CIChannel

Summary:
Specifies the terminal of the timebase to use for the counter.

Exceptions:
NationalInstruments.DAQmx.DaqException: The NI-DAQmx driver returned an error.

 

This is a property configuration for DAQ counter task.

 

NI Application Engineer

Ben 

 

0 Kudos
Message 2 of 7
(4,671 Views)

hi ben, thank you for your reply.

I have tried it, but it doesn't work.

 

my code :

 

counterReadTask.CIChannels.CreateCountEdgesChannel(counterComboBox.Text, "", edgeType, Convert.ToInt64(initialCountTextBox.Text), countDirection);

 

counterReadTask.CIChannels.All.CounterTimebaseSource = "20MHzTimebase";

 

counterReadTask.Timing.ConfigureSampleClock(sampleClockTextBox.Text,Convert.ToDouble(rateTextBox.Text), SampleClockActiveEdge.Rising,SampleQuantityMode.ContinuousSamples, 1000);

 

result:

err.jpg

0 Kudos
Message 3 of 7
(4,668 Views)

counter card:  PCI-6601

task: Buffered Event Counting (6601user manual P3-11-P3-12)Figure 3-12.  Buffered Event Counting 

gete:  Dev2/PFI38  source:20MHzTimebase

 

hope you can give me a example code, thank you

0 Kudos
Message 4 of 7
(4,665 Views)

This property value is not supported. You can change the timebase source.

 

 

NI Application Engineer

Ben

0 Kudos
Message 5 of 7
(4,663 Views)

Ben

 

the VB code which I have given above can run correctly.

 

so, that means there must be a way to use 20MHzTimebase as timebase source, right?

 

I think you can help me to solve itSmiley Happy

0 Kudos
Message 6 of 7
(4,658 Views)
Solution
Accepted by topic author Sadover

I have solve it

 

CountEdgesTerminal =20MHztimebase

 

thank you Ben

0 Kudos
Message 7 of 7
(4,649 Views)