Log in

View Full Version : Inputs for the Encoder


petet4
19-01-2009, 10:26
Hi all, I have a quick question and if it is documented somewhere I have not been able to find it.

The question is can any of the digital inputs be used for reading the encoder? I have a USdigital encoder connected to digital inputs 10 & 11 in slot 4 and use the GetEncoder() function and it would read 0 or 1 while turning the encoder. The direction would work if I recall bit no increment or decrement of counts. Both encoder outputs were verified with a scope. After a bit of pondering I changed the wiring to use digital inputs 8 & 9 and then all works.

We are using Wind River with the C function call.

In summary are there specific inputs that are required to be used for various sensors, i.e. encoders?

Thanks,
-pete

jee7s
19-01-2009, 10:35
(I'm assuming you are using C++ for this...)

There are no specific inputs for the encoders. You specify the input module and channel in the constructor when you declare the encoder object. That declaration routes the channels to the appropriate part of the FPGA, which handles your counting and rate calculation.

-Jeff Erickson, FRC 41

petet4
19-01-2009, 13:26
The example was using C and the C libs, have not tried with C++. The digital inputs were defined in the function call.

if these are defined as 8 & 9 then everthing works,

static const UINT32 ENC_A = 10;
static const UINT32 ENC_B = 11;

In the Initialize function..
StartEncoder(ENC_A, ENC_B);

then in the OperatorControl function is
enc = GetEncoder(ENC_A, ENC_B);

GetEncoder() only returns a 0 or 1 for inputs 10&11 but if the inputs are moved to 8&9 and the code changed to reflect the input change all works.

I think there still might be some issues that need to worked out either in the WPIlibs (C) or in the hardware.

Will try with C++ and see is using inputs 10&11 still have issues

jee7s, Thanks for the above reply,

-pete