Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the function of "DAQmxCreateCIAngEncoderChan" to measure the angular velocity ??

hi all,

I hope to create an ANSI C program to measure the angular velocity of an electric motor by an normal encoder and a NI PCI card pci6251. However, I find that this card can't support the property of "DAQmx_Val_Velocity_AngEncoder" which seems means that the NI SDK only support the function "DAQmxCreateCIAngVelocityChan" but not the function of "DAQmxCreateCIAngEncoderChan" for this device. Oh,so bad...
I hope to use the function of "DAQmxCreateCIAngEncoderChan" to measure the velocity. Because it seems more better than using "edge count" directly. But I don't know how to do it...
Has anyone can give me any tips or advice?

Thanks a lot!
Best Regards

0 Kudos
Message 1 of 7
(5,210 Views)

hi all,

 

In fact, I hope to use the function "DAQmxCreateCIAngEncoderChan" to get the array of angular positions and use them to calculate out the angular velocity.
I found several messages in this board have been referred to this topic. Nearly all of the solutions are realized through the tool of LabVIEW. However, I am just a C/C++ programmer, I can't understand them.
I hope to use the method "v =delta(pos) / delta(t)" to evaluate the angular velocity. However, I still have some question about how to get the delta(t) and delta(pos) wanna to ask:
1) In the example of "VC_AngularPosition_Buff_Cont": if I use an external 10KHz sample clock and 1K samples for each channel to config the function the "DAQmxCfgSampClkTiming". When I get the returned positions from the function of "DAQmxReadCounterF64". Can I think :the time interval between two consecutive samples is fixed and equal to 1ms?
2) If I use the val of "DAQmx_Val_Ticks"(Timebase ticks) as the unit to config the function of "DAQmxCreateCIAngEncoderChan", Which timebase's ticks we will get from the function of "DAQmxReadCounterF64"? Can I think that the elements' val (number of ticks) of it's returned array is not data repeating ?
3) If I use the val of "DAQmx_Val_Degrees" as the unit to config the function of "DAQmxCreateCIAngEncoderChan", How to know how many pulses of channel A or B or Z have been counted by the when the degree value over the ranges [0~2pi] ?

 

thanks a lot!

best regards

0 Kudos
Message 2 of 7
(5,192 Views)

Hi,

 

For your C language, we could just provide you a few examples using PCI counter, please refer to the following path:

 

C:\Users\Public\Documents\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Counter

 

BR

 

NI AE

0 Kudos
Message 3 of 7
(5,070 Views)

hi,

       Thank you for your answer, However,

 

       Very bad support !!


       Could you tell me that rule is come from NI or you-self ? If it comes from NI, could you give me any references ?

       Could you tell me that rule is only for Chinese or all the people of the world ?

 

       I think this rule is unfair to the people who are using ANSI C.
       I think it is a rule with discrimination.
       I hope NI can explain it to all the customers

 

regards,
Lee

 

0 Kudos
Message 4 of 7
(5,066 Views)
Oh, sorry for misleading you.

I didn't mean there is a rule that NI do not give ANSI C support.

I just said for now I could only provide you with these examples for reference because I'm not a very good C programmer to be honest.

Please do not be worried, I'll follow this support for sure.

BR
0 Kudos
Message 5 of 7
(5,056 Views)

Hey, Lee

 

According to a LabVIEW example which corresponds to the ANSI C example you used.

 

The answers to your questions should be:

 

1) The interval between two consecutive samples depends on ‘Sample Rate’ instead of ‘Sample Clock Source’.

 

   Therefore, in the example 'VC_AngularPosition_Buff_Cont', function 'DAQmxCfgSampClkTiming(taskHandle,"/Dev1/PFI9",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000)'

   The sample rate is set to be 1000, which means time interval is 1ms.

   If you are using an external sample clock source, you can set these two parameters to be the same. If you do so, your guess is correct.

 

2) Timebase Ticks represents a period of your Sample Clock Source. In your situation, one timebase tick should be 1ms. Actually, 'DAQmx_Val_Ticks' is seldomly used in practical cases.

 

3) When you configure the function: DAQmxCreateCIAngEncoderChan(taskHandle,"Dev1/ctr0","",DAQmx_Val_X4,0,0.0,DAQmx_Val_AHighBHigh,DAQmx_Val_Degrees,24,0.0,"")

    The parameter '24' represents the number of pulses encoder generates per revolution. 

    For instance, if your returned value was 360 degrees(One revolution), pulses of channel Z counted should be 24.

 

For more information, please refer to LabWindows/CVI Help, which gives you all the input parameter definitions of these functions.

 

Hope this helps.

 

BR

0 Kudos
Message 6 of 7
(5,038 Views)

Hi,YueLiao

Your answers are useful, and I got a lot of information from it. But, I have a problem with NIDAQmx ReadFunction. I want get data from the counter whiich can tell me my roller structure is forward or backword. I have read the roller speed correctly. And I have used Measurement & Automation Explore to get the positive inversion information accuratly. Thanks a lot.

 

BR

Download All
0 Kudos
Message 7 of 7
(4,321 Views)