From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

OnDemand Encoder Measurement

I'm trying to implement in C# the same configuration I did previously in SignalExpress.

I measure the Counter Angular Position of an encoder in OnDemand Aquisition mode. I use the counter 0 of the card PCI-6232 to accomplish this task.

 

In SignalExpress it works just fine, but there is no example in C# for that task. The example of C# code that do exists uses external clock and buffering that I don't need nor can't to do because of my card is not supports such behaviour.

 

Does anybody have that piece of code I need so much?

Thanks in advance

 

Ivan

0 Kudos
Message 1 of 3
(4,984 Views)

The commnents in the code specify why an external sample clock is necessary and potential ways around this. The comment is as follows:

 

Note: An external sample clock must be used. Counters do not
* have an internal sample clock available. You can use the
* Dig Pulse Train-Continuous example to generate a pulse
* train on another counter and connect it to the Sample
* Clock Source you are using in this example.

Ian M.
National Instruments
0 Kudos
Message 2 of 3
(4,965 Views)

Thank you for your answer lanidas300.

 

The problem is my current card does not support such kind of routing. I can't set counter 1 to be external clock for counter 0. When I try to set it I receive error. Besides what I need to do is to read counter OnDemand, I don't need buffering.

 

Eventually the solution was found.

You have to use Count Digital Events example and replace original channel setting

 

myTask.CIChannels.CreateCountEdgesChannel(counterComboBox.Text, "Count Edges",
              edgeType, Convert.ToInt64(initialCountTextBox.Text), countDirection);

 

to settings from Meause Angular Position with Buffered External clock example

 

myTask.CIChannels.CreateAngularEncoderChannel(counterComboBox.Text,
                    "",encoderType,zIndexEnable,zIndexValue,encoderPhase,pulsePerRev,
                    0.0,CIAngularEncoderUnits.Degrees)

 

Also don't forget to copy required variables definitions like encoderType, zIndexEnable, zIndexValue, encoderPhase, pulsePerRev.

 

That's all! 

 

0 Kudos
Message 3 of 3
(4,960 Views)