![]() |
How to implement an encoder with one speed clock, and one direction signal.
The encoder we are attempting to implement is not a quadrature encoder.
We are trying to use the Counter.h class in the WPILib to implement it. When we used the Get() method in the Counter class, it returned a one or two, based on if we were using a k1X or a k2X reading. When we used the GetDirection() method it returned a true, or false based on what direction the encoder is spinning. We can't get the encoder to count past one or two. Any help appreciated. |
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?
|
Re: How to implement an encoder with one speed clock, and one direction signal.
From what I'm reading, I'm guessing you're trying to implement an encoder that just counts the # of transitions from 1 to 0 or 0 to 1 off a single digital input, rather than an encoder and its two digital inputs.
In the past, my team has implemented such a thing by just having a fast-spinning loop in a separate thread (task) constantly checking the value of a DigitalInput. Code:
class SimpleEncoderBack in the day, you could implement something like this with an interrupt. You might still be able to (and it would be _far_ more efficient than the code above), but I'm not familiar with the (C|robo)Rio method of doing it. |
Re: How to implement an encoder with one speed clock, and one direction signal.
Quote:
|
Re: How to implement an encoder with one speed clock, and one direction signal.
Quote:
|
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. |
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 |
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.
|
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.
|
| All times are GMT -5. The time now is 12:00. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi