Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

cdaq and encoder -- loosing counts on measurements

I'm wondering if anyone has had any issues with trying to set up encoder measurements on CompactDAQ.
 
I'm working on taking position measurements with a cDAQ-9172 chassis with a NI-9401 high speed di module in slot 6 for my counters.  My encoder is a DRC optical linear encoder.  First thing I've noticed is my encoder only reads in properly if I choose two pulse counting, which doesn't make a lot of sense to me, but that is besides the point.  When I configure my LabVIEW code (v8.5), everything reads in fine, but I loose counts when i'm traveling.  My counter doesn't return to its starting point when i travel from stop to stop and back i don't always return to my starting point (in this case, 0).  I can't believe that i'm moving my encoder faster than the module itself can read.  However, if i move at speeds anything over about 4 inches per second (10000 counts per second), I will not return to the same count or distance that I started at.
 
I have a subvi setup that creates my encoder channel.  I've attached a jpg of the block diagram.  I just changed my sample rate for my sample clock to 1e7, from some other large random number.  If anyone has any ideas, or needs any more info, cause i'm not real good at conveying this stuff in an email, let me know.
0 Kudos
Message 1 of 21
(7,830 Views)

Hi,

How far are you off from your initial position? Is it off by the same distance or does it vary?

I used an additional DAQ card to generate an encoder signal that generates an equal number of leading/lagging pulses and it counts up from 0 then back down, regardless of how fast I go (tested up to 1 MHz clock rates).  I realize I have an ideal test setup though - have you monitored the digital signals to see if they are clean?

I've attached the code I used to generate the test encoder signal (Encoder Test), it's basically just correlated digital output on two lines so you should be able to generate it with an M-Series or another 9401 module in slots 1-4. It has some disabled code so you can see how I generated the output. I've also attached the VI I used to test the encoder signal on the 9401 - it's based off of the  "Meas Angular Position-Buffered-Cont-Ext Clk.vi" example. I just used an analog clock for this at 100khz. If you run that code as a feedback test, do you return to 0 or something else? Let me know if you don't have one of those options available, there may be a anotherway to make sure you read the same as I do.

Just to get some details, what rate are you clocking your AI? It shouldn't make a difference for the end value, but it would be good to repeat here. For completeness sakes, what AI module are you using?

If I had to guess now, I would point the finger at the signal not being clean but it's not completely clear yet. If you get screenshots of your signal and/or more details of your settings I'll do my best to repeat your setup and see what is wrong.

 

Cheers,

Andrew S

 

Download All
0 Kudos
Message 2 of 21
(7,818 Views)

Are you aware that you must connect the second track of your sensor on the second counter of the module to count up and down ?

After that, I agree with stilly32 : there is a example that works fine with a quad encoder.

Wilfried.
0 Kudos
Message 3 of 21
(7,808 Views)
Lets see if I can hit these both.  First of all, no, i was not aware I had to connect my "B" signal to the second counter in order for it to work.  That is what I will have to do.  In response to your questions stilly32, the distance I am off each time varies by how fast I move the tip of my encoder.  The faster i travel, the farther off i end up being.  I want to try setting it up as Wilfired mentions, connecting the second signal on the second counter.  Its more important that I have an accurate encoder than having two not so accurate encoders.  I am only setting up my AI to clock at 20 Hz.  I can certainly speed that up.  I'll give your suggestions a try a little later and see what i come up with ...
0 Kudos
Message 4 of 21
(7,803 Views)
The second track is used just to know the direction of displacement, it's not used to increase the accuracy. If you use the encoder just in one direction, it's not necessary to connect the second track ...
For the clock, you mean 20 MHz and not 20 Hz ?? I think you don't have to change the default value for the clock ...
To summurize : check your hardware connections with the product manual of your acquisition card and use a example available in Labview, without modification at all.
Wilfried.
0 Kudos
Message 5 of 21
(7,800 Views)
Hello Andrew,
I'm lookink for your encoder test.vi, but I get only the Lbv 8.2 version! Could you send the same in this version?
Thanks a lot                    Alain

0 Kudos
Message 6 of 21
(7,676 Views)
I've saved these as LabVIEW 8.0 files so that you and other should be able to use them.


Message Edited by Mark E on 11-30-2007 12:55 PM
Mark E.
Precision DC Product Support Engineer
National Instruments

0 Kudos
Message 7 of 21
(7,663 Views)
Hello Mark,
Thanks a lot for your answer, I try your vi on my Cdacq target, a 9172 Cdacq rack with a NI9401 card and différent other cards like digital I/O and analog I/O.
I look like for your vi, because on my application I acquire a encodeur withe the 100Khz Cdacq timebase, but a error -200141 occur my acquisition.This error don't arrive each time, but very offen and need to restart the application. 100Khz is to much for my application, 10Khz or may be 5 will be enough to do it. Bad lock, I can't realize this clock with your vi, I think NI9401 don't accept to work in acquisition in ctro and generation in ctr1 on the same card?
Do you have any experience with this card and this error, I can't find similar problem on the forum for this configuration.
At this time , I turn over?(excuse my english!) this error when I find it, I restart automaticly acquisition, but this solution don't satisfy my customer and me too.
If you need more explication I will return.
Analog I/O is syncrhonize on 9401 PFI0 cadencement source.
Thanks for your help                  Alain

0 Kudos
Message 8 of 21
(7,598 Views)

Hi Alain,

If I understand your problem correctly, you are using your NI 9401 module and the 100 kHz timebase provided by the NI 9172 cDAQ chassis to sample and record the position of an encoder. You are using the previous post’s attached “Measure Linear Position…” example for LabVIEW. However, when you run this example, you sometimes receive error 200141. There are other modules in your 9172 chassis, including an Analog I/O module. Is my understanding correct?

Error -200141 indicates that the position data you are writing to the module’s FIFO is filling the buffer faster than it can be moved to your computer’s RAM and data is being overwritten. Since the 100 kHz sample clock is not a requirement of your application, you can try utilizing another sample clock to fill the FIFO at a slower rate, allowing the data to be moved before it is overwritten and thereby removing this error.

A way to provide this sample clock is to create a mock DAQmx task in LabVIEW that uses a sample clock and then reference that sample clock in your counter task. Since you already have an Analog Input module in your cDAQ chassis, I would suggest creating an AI task. An example of how to modify the block diagram can be seen in the attached screenshot “Add mock AI Task.”

The AI task is configured and started, then cleared after the counter task is complete and no longer needs a sample clock. On the front panel of the example, in the Timing Parameters box, you would select the Analog Input Module’s sample clock as the Sample Clock Source. This can be seen in the attached Screenshot “Timing Parameter Front Panel,” where an AI module was in slot 3.

Good Luck, Mallori M.



Message Edited by mallorim on 12-11-2007 07:55 PM
Mallori M
National Instruments
Sr Group Manager, Education Services

ni.com/training
Download All
Message 9 of 21
(7,574 Views)
Hello Mark,
Thanks a lo four your reply. I'd some problem, in first with your vi, because I put in source "cdaq1/mod3/ai/sampleclock" and I got a error about material compatibility and the right way is "cdaq1/ai/sampleclock" mod3 is slot where is my ai card, but is to much in the cadencement source.
So, the application, now, run corectly.I used max to realise the task, so when this application will be complete, I will send my complete configuration, I think it's a good example about problems we can met on cdaq rack.
At this time, my customer give me a other challenge. I need to add a I/O input detection on my curve encoder acquisition, so I try to synchronise a front detection vi on ctr1 on my 9401 card who's don't use at this time, but I got a error (sorry I don't remeber the number)(I try count digital event.vi to do it).
I return on my customer place next year, in few time now!
I want to wish you a very good christmas and my best wishes for the new year.
Alain 
0 Kudos
Message 10 of 21
(7,473 Views)