LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Encoders with Counter Channel

Solved!
Go to solution

All,

I am writing code to read angular position from encoders. Unfortunately, I don't have the encoders available yet, so I cannot hook them up. Given the lack of hardware, should I expect to get Error -200284 telling me that "Some or all of the samples requested have not been acquired?" If so, is there a way I can set up my system so I can test my code before I get ahold of the encoders? I tried to set up a pulse output channel and wire it to the counter input, but I got the same error.

I am attaching images of the NI MAX set up pages for the counter channel. Unfortunately, I cannot post my code.

Thanks in advance for your help.

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
Download All
0 Kudos
Message 1 of 3
(2,386 Views)
Solution
Accepted by topic author diarmaede

Given the config you show, you're counting on the presence of an actively running AI task, from which you are "borrowing" the ConvertClock signal.  I'm guessing that you're testing the encoder task code at a time that there is no active AI task to get that signal from.  Thus, the encoder task doesn't buffer up any samples and you get that particular error.

 

Note: while the ConvertClock *might* be a reasonable choice for you app, it's probably more likely that you'd want the AI task's SampleClock signal.  The ConvertClock rate will vary with the # of channels in the task, while the SampleClock won't.

 

Meanwhile, before running your encoder test code, open and run one of the shipping examples for continuous AI.  I'd recommend setting up only 1 channel in the task (because this way the ConvertClock rate will match the SampleClock rate).

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 2 of 3
(2,345 Views)

Thanks (again) for your help, Kevin.

I ran into resource conflicts with the AI SampleClock, but I set up a DI task appropriately, with the same sample rate as my counter task, and used the DI SampleClock as my external clock when I set up the counter task in NI MAX.  My VI starts the counter task first, then the DI task. Now, everything seems to work fine.

Forbes Black
Lapsed CLAD, LV 5 - LV 2022 (Yeah, I'm that old...)
0 Kudos
Message 3 of 3
(2,322 Views)