Log in

View Full Version : Encoder Limit


agough
11-02-2009, 19:42
Is there an encoder limit?
I ask because when we build our program with 5 encoders used throughout it builds fine and it downloads but when we start it up our program won't run and tells us:
"Cannot allocate any more ports" check Resource.cpp line 61
We found nothing in Resource.cpp that is relevant.This is function/line it tells us to check(_=Space):

UINT32 Resource::Allocate()
{
____for (UNIT32 i=0; i < m_size; i++
____{
__________if ( ! m_isAllocated[i])
__________{
__________m_isAllocated[i] = true;
__________return i;
__________} <-This is line 61
____}
____wpi_fatal(NoAvailablePorts);
____return 0;
}

If we comment out at least one encoder object creator and pointer(and it doesn't matter which one of the five we comment out) then the error doesn't show and everything else works.

Joe Ross
11-02-2009, 19:53
From the "C/C++ Programming Guide for the FIRST Robotics Competition"

There are four QuadratureEncoder modules in the FPGA and 8 Counter modules that can operate as
quadrature encoders. One of the differences between the encoder and counter hardware is that encoders
can give an oversampled 4X count using all 4 edges of the input signal. Counters can either return a 1X or
2X result based on one of the input signals. If 1X or 2X is chosen in the Encoder constructor a Counter
module is used with lower oversampling and if 4X (default) is chosen, then one of the four encoders is
used.