I saw “hall effect is only giving counts” from my other topic.
but when i try to use them(Counter’s command from “ edu.wpi.first.wpilibj.Counter ”,the the program will have some bug.
they made the robot stop working.
if i use the wrong command?
or I should use other command to made it works? Where can i find them?
Can you describe what the behavior of the robot you are currently seeing is? Or, if you are getting error messages in the driver station Console (or rioLog in VSCode), what are the errors?
One additional experiment to try: comment out all lines of code related to counter. Does the behavior persist? If so, the addition of counter was not the source of your issues.
I have also been struggling with implementing the Bosch motor encoder. when I add the counter to the program it builds and deploys, but crashes upon startup. the error statement is the “robots should not quit, but yours did” when I comment out the counter it starts right up, and I can see the digital input in the livewindow when the motor is running. Ive tried several different ways of invoking the counter from the examples. Hopefully someone with more experience can weight in.
Correct, that message indicates software execution encountered an error at runtime.
There are other messages before the Robots should not quit line which indicate the type of error and the lines of code on which it occurred. Can you post those?
I was able to make some progress tonight, I started un-commenting the counter code one piece at a time and redeploying until I recreated the crash. looking at the error messages it was crashing while initializing the digital inputs. I am using robot builder and command based robot, so I had initially created as a digital input in robot builder, then added the counter in VScode. what happened was the allocations were fighting each other,
Code: -1029. HAL: Resource already allocated"
because my code was:
hall = new DigitalInput(5); <=from robot builder
addChild(“hall”,hall); <= from robot builder
tick = new Counter(5);
so by commenting out the first 2 lines it seemed to work.
@medwin, try commenting out :
counter.setUpSource(1);
since it is the same as :
private Counter counter= new Counter(1);
and see if referencing the same channel twice is causing your issue.