|
Re: Encoder trouble
Wiring review:
both encoders are getting +5 from the center pin (red wire on PWM cable)?
both encoders are getting gnd from the outer pin (black wire on PWM cable)?
both encoders are outputting two digital channels (A and B) to two inner pins (white wires)?
DSC has power and all three lights are on?
37-pin cable connected well?
Other things on DSC work? Other things that need 5v power (relays or some digital sensors) work?
Programming language:
In LabVIEW, you need to open two digital channels (A and B) then use ToDigitalSource, then feed that to the Open Encoder. Make sure you have them set right, as well as the scaling. The scaling should be a low decimal, on my robot that is .03 for inches with an AM Shifter 3:1 to the wheels, 1x decoding.
Graph the speed and distance output in LabVIEW. That helps to see what is happening.
Got an Oscilliscope? Try looking at the A or B output of one encoder and see what is happening. Or, create a LabVIEW program that has its own loop (like PeriodicTasks.vi or another loop in Robot Main) and graph the output of the digital line as fast as possible.
Maybe something is shorted somewhere - flipping your robot over and shaking it out usually fixes that.
The encoder software is interrupt-driven. It will only add to the counter when the value of the input changes. IF you have 1x decoding, that is only when the A phase goes high. If you have 2x decoding, that is either on both edges of the A phase or the rising edge of each phase, I don't know which. If you have 4x decoding, it is on both edges of both phases. If something shorts the pin high, then it won't count because the value won't change.
__________________
Kettering University - Computer Engineering
Kettering Motorsports
Williams International - Commercial Engines - Controls and Accessories
FRC 33 - The Killer Bees - 2009-2012 Student, 2013-2014 Advisor
VEX IQ 3333 - The Bumble Bees - 2014+ Mentor
"Sometimes, the elegant implementation is a function. Not a method. Not a class. Not a framework. Just a function." ~ John Carmack
|