what does the Get function in Encoder class return? detailed explaination if you can, please
from Encoder.cpp:
/**
* Gets the current count.
* Returns the current count on the QuadEncoder.
* @return Current count from the QuadEncoder.
*/
INT32 Encoder::Get(void)
{
INT32 value = m_encoder->readOutput_Value(&status);
wpi_assertCleanStatus(status);
return value;
}
It returns the number of pulses received since the encoder was initialized or the count was reset.
Your other option is GetPeriod, which:
“Returns the period of the most recent Quad Encoder pulse in microseconds.”
well, but what happened if I change the direction, will the Get function give me the duplication of ticks or maybe the distance it passed?
Get Encoder does not get “ticks”. It reads the number of counts from it’s initialization/last reset. As the encoder turns in its forward direction it increases the encoder counts, as it turns in its reverse direction it decreases the encoder counts (even going negative).
I am not sure if GetPeriod will return a negative encoder period or not.
No, GetPeriod will not return a negative number. It simply returns time passed between the last two pulses.
And yes, Daniel is right about the values Get() returns.