Code will only go once

Hey whoever is reading this… I am on a robotics team and my code for vexiq isn’t working more than once. I will start the code and it will work, but then the second time I do it, it doesn’t do anything. ANY ADVICE
Sincerely- A stressed coder

you should change the topic to iq, it is currently in v5, which is edr.

And post your code…otherwise no one is able to understand the complete situation. What you trying to accomplish with it?

1 Like

ok… this is a really noob question because i’m a new coder on the team… but how do you post ur code

I’m trying to get the green cube on top… I know that our team should already have it but we have had a lot of problems with the code .

For blocks just post a picture

or you can press the download button and link us the code

image

this is such a great website and thnx for all of u guys’ help!!!

ok so what do you mean by that?

I mean that when I get the first green cube, it works, but then whenever I get the second green cube and do it again, it doesn’t

like it won’t even work

You are telling the motors to rotate to a certain position. They have done that in the first pass. So they don’t need to move in the second pass.

You need to set them back to zero to restart the movements.

1 Like

thnx ill try that. and I’ll have to get the other coder to do that because like I said i’m still new to this coding thing. before, I was a builder but I do a little bit of everything now

Looking at your code, I assume Motor4 is a lift motor… and that you are placing the robot backwards since you’re telling it to go backwards 9 inches (or you got your motors reversed in the setup) towards the green cube, rotate the lift 270 degrees to pick up the green cube, drive backwards 17 inches towards the lower platform, lower the lift 175 degrees to drop off the cube, then move forwards away 3 inches.

For your second attempt, are you simply just exiting out of your autonomous program on the brain. Then just go back to the brain, select autonomous programs, and re-run it again? That is what my daughter’s team does with their program and it works all the time.

Out of curiosity… why is the 2nd command to lower the motor4 245 degrees? Why is it not already at zero?

1 Like

thanks for the help… and yes our motor 4 is a lift motor. When we run the code, our forwards and reverse is actually backwards so that’s why it looks like we are starting it backwards. We lower our arm to 245 degrees because our robot has rubber bands that strengthens the robot so our arm lifts up easier, so when the brain is off, the arm is actually up. Its up when we start the code as well.

Whenever we select run again, it just lifts the arm down and doesn’t do anything else but make the whirring sound that means its on.

I would recommend you fix that in the motor setup and not adjust for it in code. Your code should always be based on what is intended for the robot to do. So, if it should drive forward, then you should use the drive forward command. It also helps the next programmer when they look at the code

You might be using too much rubber bands if it causes the arm to lift up when not powered. There’s an actual art form to how to put rubber bands on arms. It should be just enough to assist the arm when going up, but hold its position when the arm motor is not moving. You may want to look at designs from last season’s game, Next Level. A lot of teams used rubber bands on their arms to help during stacking and hanging (our team used it so we could have a 1:9 gear ratio and not struggle to hang). Also, if you search the forums there’s a lot of EDR posts on how to use rubber bands.

Also, with the cubes this season, an arm doesn’t need a lot of torque to lift the cube. A 1:3 ratio will be more than sufficient. What gear ratio do you have on your arm?

So, it never executes the “drive reverse for 9 inches” and commands below that? Odd… Maybe the rubber bands are providing too much tension when going down so the motor is fighting them unnecessarily. Again, whatever tension the rubber bands are helping when the arm lifts up, it’s providing that same amount of tension when the arm wants to go down. Key is to get the right amount of tension where it rests on its own.

1 Like

I’ll try all of those suggestions. thank you sooo much for the help…