|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Re: How to implement an encoder with one speed clock, and one direction signal.
What encoder are you using? How do you have it wired to the roboRIO?
|
|
#2
|
|||
|
|||
|
Re: How to implement an encoder with one speed clock, and one direction signal.
It's a trackball encoder, with the clock signal wired to the first input, and the direction signal wired to the second input.
|
|
#3
|
||||||
|
||||||
|
Re: How to implement an encoder with one speed clock, and one direction signal.
I'm not familiar with trackball encoders, and couldn't find any description of one that uses a clock and direction outputs. Can you point to a datasheet?
|
|
#4
|
|||
|
|||
|
Re: How to implement an encoder with one speed clock, and one direction signal.
Quote:
We are trying to use the Counter::SetExternalDirection method. According to the source codes comments: /** * Set external direction mode on this counter. * Counts are sourced on the Up counter input. * The Down counter input represents the direction to count. */ When setting the counter for k1X, the Get() method returns a 0 or a 1. The GetDirection() method return true or false, according to the direction of rotation. We cannot get the Get() method to count more than 0 or 1. Any help appreciated. |
|
#5
|
||||
|
||||
|
Re: How to implement an encoder with one speed clock, and one direction signal.
Quote:
-If input A is 1 and input B is forward, then return 0 -If input A is 0 and input B is forward, then return 1 -If input A is 1 and input B is backwards, then return 0 -If input A is 0 and input B is backwards, then return 1 Something like Code:
class FakeQuadrature : public DigitalSource
{
public:
// construct/pass in things, override other DigitalSource virtual functions...
bool Get()
{
bool count = trackBallCount.Get();
bool dir = trackBallDirection.Get();
if(count && dir) return 0;
else if(count && !dir) return 1;
else if(!count && dir) return 1;
else if(!count && !dir) return 0;
return 0;
}
private:
DigitalInput trackBallCount;
DigitalInput trackBallDirection;
};
|
|
#6
|
|||||
|
|||||
|
Re: How to implement an encoder with one speed clock, and one direction signal.
I've never tried external direction mode on a counter, but the documentation I have read suggests that you should be able to make it work using an Encoder in 1x or 2x mode.
|
|
#7
|
|||
|
|||
|
Re: How to implement an encoder with one speed clock, and one direction signal.
You shouldn't need to fake anything like others are saying. The counter directly supports external direction. Simply select that mode.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|