Hello, we have been programming our autonomous. We are using two Quad Encoders for the lift. They work fine when told to raise until a value is reached, however, it will not work when going to a negative number. Does anyone know a fix to this problem?
Once it gets to the line that’s causing problems, the program just stops altogether. It won’t continue anything after that… I lifts, drives forward, and then the program ends.
I’m wondering what happens if the reading on your encoder counts is going by so fast the code doesn’t update the count fast enough and therefore doesn’t “see” -50 but only sees -55… -56… or whatever. Is that possible?
My kids recently had something like that happen. After hours of trying everything they could think of, they finally shut down their program, restarted their computer, and reloaded the program, re-uploaded their code, and from then on it worked fine.
We had this issue eariler before. The way we resolved it was by using a preset of 1000 instead of 0. That way you are always using positive numbers. lifting up and down.
Imagine this
while(goal-encoder>20)
This means while I am more than 20 ticks away keep trying to get closer.
now if the goal is below the encoder goal-encoder will be negative and never above 20.
So normally it needs to be written as
while(abs(goal-encoder)>20)
I wrote this before I realized you were using the easyC fancy blocks but it seemed to be worth keeping because people run into this issue a lot.
Lol woops. When you didn’t include the function definitions I doubted my original idea.
In that case its probably what I said. I remember reading about the fancy new easyc blocks that are named very similarly to your function.
The general case functions you wrote really should be less general case. Its not the end of the world to have a lift to height function. This also means your code is easily adaptable to add a P controller later on.
Can you post the entirety of your custom lift function (including parameter definitions) for us to debug? We’ll need this code in order to see what could be causing the issue in the code.
I thought the wait function was yours. I haven’t used those much.
I would also recommend using the sensor names rather than the sensor ports when calling the untilencoder function. This will allow more readable code which is not only good for us but actually good for you debugging as well.