Not enough resources to create a counter

Hi we encountered a problem today when we added four more counters to our command based robot. For some reason on the fourth addition the counter can not be created and throws an error from HAL saying something about insufficient resources. (I’m sorry i don’t have the exact error with me right now)

If we remove one of the counters the code runs fine. We can swap around the order of allocation of the counters and it always throws the exception after creating a fixed number of them (I think on the 8th counter)

Any thoughts on what may be causing this??

Tia -



There are 8 Up/Down Counter units contained in the FPGA which can each operate in a number of modes based on the type of input signal:

If you are using any encoders in 1x or 2x mode, changing them to 4x will keep them from using counters.

We’re just using them with switches (DigitalInput).

Hi - nevermind. We have solved this problem indirectly by moving our switches to the CANTalons. We can read them using isFwdLimitSwitchClosed () and isRevLimitSwitchClosed ().

Thanks just the same…


Why not use the digital input class directly?

Hi Joe - we are using digitalinputs but thought to be safe we would read them though counters in case we move past them too quickly (they are reed switches)

Seems surprising to me that we could run out of them.

I was referring to moving the switches to the Talon SRXs. I suspect that using the Digital Inputs on the roboRIO will have less latency then reading them on the Talon SRXs.

Hmm - could be that the roboRIO reading a DI will be faster than roboRIO asking CAN to read the limit switch.

One interesting observation since we got this working: the CANTalon shuts off the motor auto-magically when the limits switches are reached. I expect this is reacting faster than Java could switch it off.

The limit switches can be disabled, but not sure if that just disables the auto-shutoff of the motor or disables your ability to read the switch.

Clearly much more to be learned with the CANTalons - and the JavaDocs are not even fully generated yet - so some things are just trial and error.