Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Java Encoder Limitation? (http://www.chiefdelphi.com/forums/showthread.php?t=103423)

richwong 20-02-2012 19:31

Java Encoder Limitation?
 
Is there a limitation to the number of encoders we can have? When trying to add more than 4 in Java, we get the following exception:

[cRIO] Uncaught exception in Thread.run():
[cRIO] on thread edu.wpi.first.wpilibj.defaultCode.DefaultRobot - main
[cRIO] edu.wpi.first.wpilibj.util.AllocationException: There are no encoders left to allocate
[cRIO] at edu.wpi.first.wpilibj.Encoder.initEncoder(Encoder. java:76)

patrickviolette 20-02-2012 21:31

Re: Java Encoder Limitation?
 
the quadrature encoders seem to be throwing the exception (line 76 of the Encoder class).

it seems like you can allocate more encoders as long as they are 2x or 1x encoders.

patrickviolette 20-02-2012 21:40

Re: Java Encoder Limitation?
 
use the constructor Encoder(int sourceA, int sourceB, boolean reversed, EncodingType type) and pass in EncodingType.k2X and you can make as many encoders as you want. :)

richwong 21-02-2012 22:14

Re: Java Encoder Limitation?
 
Quote:

Originally Posted by patrickviolette (Post 1131300)
use the constructor Encoder(int sourceA, int sourceB, boolean reversed, EncodingType type) and pass in EncodingType.k2X and you can make as many encoders as you want. :)

Worked! Thanks!


All times are GMT -5. The time now is 09:53.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi