Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

USB-6210 Quadrature encoder hookup

I am trying to find information on how to connect the quadrature signals from an encoder to the counter inputs on a USB-6210 for position measurement.

 

I haven't been able to find anything specific in the owners manual or the NI web site.

 

The DAQ assistant (LV 8.2) shows a hookup of - encoder A to PFI-8, B to PFI-10 and Z to PFI-9

but the 6210 manual only shows inputs PFI-0 thru PFI-7.

 

Any help would be appreciated.

 

Thanks

 

Brian

0 Kudos
Message 1 of 10
(7,536 Views)
According to MAX (open it and create a position measurement task for the USB-6210), the wiring is  :
  • CTR0 :
  • A = PFI0
  • B = PFI1
  • Z = PFI2
  • CTR1 :
  • A = PFI3
  • B = PFI2
  • Z = PFI1

Because B and Z use the same pins it seems that it would not be possible to connect two encoders to this interface...
Message 2 of 10
(7,529 Views)

JB,

Thank you.

Your hookup info works.

It's strange even after I created another position task in max it tells me to use the PFI's I don't have.

Thanks again.

Brian

 

0 Kudos
Message 3 of 10
(7,524 Views)
This thread suggests that two encoders are not possible with the USB-6210 but I don't see in the manual or routing table where

it would be a problem to route Ctr1 to other PFI terminals.

Here is what I think I should do:

///////////*** CODE***/////////////

DAQmxErrChk (DAQmxCreateTask("Inner",&innerTask));
    DAQmxErrChk ( DAQmxConnectTerms ("/Dev1/PFI4","/Dev1/Ctr1A",DAQmx_Val_DoNotInvertPolarity));
    DAQmxErrChk ( DAQmxConnectTerms ("/Dev1/PFI5","/Dev1/Ctr1B",DAQmx_Val_DoNotInvertPolarity));
    DAQmxErrChk ( DAQmxConnectTerms ("/Dev1/PFI6","/Dev1/Ctr1Z",DAQmx_Val_DoNotInvertPolarity));


    DAQmxErrChk (DAQmxCreateCIAngEncoderChan(innerTask,"Dev1/ctr1","innerencoder",DAQmx_Val_X1,1,0.0,DAQmx_Val_AHighBLow,DAQmx_Val_Degrees,2500,0.0,""));
    DAQmxErrChk (DAQmxCfgSampClkTiming(innerTask,"ai/SampleClock",4096.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,2));


    DAQmxErrChk (DAQmxCreateTask("Outer",&outerTask));
    DAQmxErrChk (DAQmxCreateCIAngEncoderChan(outerTask,"Dev1/ctr0","outerencoder",DAQmx_Val_X1,1,0.0,DAQmx_Val_AHighBLow,DAQmx_Val_Degrees,2500,0.0,""));
    DAQmxErrChk (DAQmxCfgSampClkTiming(outerTask,"ai/SampleClock",4096.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,2));


 ///////*****END CODE*******///////

My program throws this error:

------------------



DAQmx Error: Specified route cannot be satisfied, because it requires resources
that are currently in use by another route.
Source Device: Dev1
Source Terminal: PFI4
Destination Device: Dev1
Destination Terminal: Ctr1A

Required Resources in Use by
Source Device: Dev1
Source Terminal: PFI3
Destination Device: Dev1
Destination Terminal: Ctr1A

Status Code: -89137
End of program, press Enter key to quit

 --------------





I think what's happening is that I'm missing something about how ai/SampleClock is routed or how to change routes CreateCIAngEncoderChan sets up routes  but so far I am at a loss as to how to fix it.  It seems like there are additional PFI terminals in use or I'm unsuccessfully changing them.  Again, I'm clearly doing something wrong but can't figure out from the routing table what it is.
However it seems that two encoders can be done in principle with the USB-6210, at least using LabView:

http://forums.ni.com/ni/board/message?board.id=170&message.id=333065

So what's the story?  Can I use the API to set up two encoders simultaneously sampled using the internal ai/SampleClock for timing?  Is that impossible and I need to use some other clock?

My code and hardware work great with a single encoder.  The end application is to have a little DOS program that acquires two encoders while an

analog input task runs from Matlab.  This works exactly as expected using a single encoder.  It also works with an analog input task set up  inside the C code.

What am I missing about the second encoder channel?

Thanks,


Dan
0 Kudos
Message 4 of 10
(6,522 Views)

By the way, I have also tried

 

DAQmxSetCIEncoderAInputTerm() to try to change the pin routing on Counter 1 and get similar errors about routing.

0 Kudos
Message 5 of 10
(6,517 Views)

Hello N3OX,

 

You mentioned that you tried using the DAQmxSetCIEncoderAInputTerm function but still received an error.  What was the error that you received?  The reason I'm asking is because I tested this in LabVIEW (as I am more proficient in LabVIEW than I am in C) and was able to get it working without any errors.  What I did was use a property in LabVIEW, equivalent to DAQmxSetCIEncoderBInputTerm and DAQmxSetCIEncoderZInputTerm, to set both of those terminals on counter 1 to PFI 4 and PFI 5.  Terminal A doesn't need to be changed because it's default terminal (PFI 3) doesn't overlap any PFI lines on counter 0.  Once I did this I was able to resolve error 89137, but you will still receive an error stating that an external source must be used for the counter sampling clocks.  To resolve this I created an analog input task and used ai/SampleClock as the timing source for my counter tasks.  Try this out and let me know if you encounter any problems.

 

Regards,

0 Kudos
Message 6 of 10
(6,497 Views)

Brandon,

 

That partially works in the sense that it compiles and doesn't throw errors.  However, I get no "encoding" on the second encoder.    Now that I've tried it and know that I'm using the proper functions I think I see the problem more clearly.  I have a hardware problem.  What I don't know is if it is  a "hard" hardware problem or a "soft" hardware problem.  Here's what I mean:

 

On PFI3 (A) which I  set explicitly using DAQmxSetCIEncoderAINputTerm(), when I run the code and use a scope on that terminal to check the encoder signal,

I get a good 0-5V transition. On PFI4 and PFI5 (B and Z, set by the BInputTerm and ZInputTerm versions of above), I get only a signal of 0-100mV. It's not a problem with the encoder itself ... if I disconnect it from the USB-6210 those lines work fine. 

 

This implies that I'm running my lines into a fairly low load impedance, 10 ohms or so (I have 2.2kOhm pullups on my open collector encoder).

 

The manual seems to suggest that terminals 0,1,2, and 3 are inputs and terminals 4,5,6, and 7 are outputs.  This occurred to me but then I found the other thread I linked to, which suggests success with LabView.    I took that to mean that the whole solutiion worked, but I suppose that user never came back and said that everything worked out fully.  Maybe they just gave up?  The routing table implies that connections are possible.... but perhaps that is in error?

 

So, can the physical terminals corresponding to PFI4,5,6 and 7  *really* be used as inputs?   If so, is there another configuration (disconnection? direction change?  ) step required in software that needs  to

be explicit in C but is implicit in LabView?

 

I can swap out for a second USB-6210 without too much trouble to check to see if it's a "hard" hardware problem in the sense of

broken inputs, though to date the digital inputs on this box have never been used for anything so it's unlikely we broke them.

 

If the physical terminals for PFI 4,5,6 and 7  can only be used as PFI output, then there is no way to connect two working A/B/Z encoders to this unit.  

 

As it stands, if the unit is working properly, the 'scope suggests that I'm hooking input lines to low impedance digital outputs that are held at low level.

 

Thanks,


Dan Zimmerman

 

 

 

 

 

 

0 Kudos
Message 7 of 10
(6,493 Views)

Well I think the hardware does NOT actually allow two quadrature encoders to be used simultaneously on a USB-6210.

 

In my application, I only really need to know the speed of the second encoder, not direction or position, so I am going 

to use a Count Edges channel on PFI3 to count the A channel of one encoder in conjunction with the A/B/Z encoder channel.

 

This works fine.

 

Thanks for the help.

 

Dan Zimmerman

0 Kudos
Message 8 of 10
(6,473 Views)

Hi Dan,

 

As it turns out the USB-6210 FPI lines are input or output depending on which digital port they are on. So, PFI <0...3> are on port 0 which are Input PFIs only, and PFI <4...7> are on port 1, which are output only. This is why the default pins for those A, B and Z inputs on counter 1 are still on port 0. Unfortunately there is no way around this issue for the 6210. There are other 621x cards that have up to 8 input and 8 output FPIs, like the the 6218.

 

There is actually a little bug in the DAQmx driver, for this situation, which I reported to R&D. Currenlty, like your application and Brandon's, if you specify PFI 5 and PFI 6 to be used as inputs for the encoder measurement, the driver does not throw an error, however, it certainly should because PFI <4...7> should not be able to be able to be used as input lines, due to the fact that they are PFI output lines.

 

I'm sorry for the inconvenience, but I hope this clears things up.

 

Chris W 

0 Kudos
Message 9 of 10
(6,471 Views)

Chris, thanks.

 

  It's good to know for sure and useful to have in the forum archives that it is NOT possible to use two

simultaneous A/B/Z encoders with the USB-6210.

 

Thanks,

Dan

0 Kudos
Message 10 of 10
(6,467 Views)