Graphical Robot C question

I’m relatively new to coding and am teaching a middle school class with Vex IQ. I am having an issue with one of my group’s codes, but the code seems very straight-forward. It seems to get stuck on a block and repeat the function beyond the instructions. For example, if the last block said “forward - 2 rotations”, the robot will continue moving forward until shut off. The most recent code has the claw arm coming up, but instead of moving back down, the motor continues to try to keep raising the arm.

We have reconfigured the motor and sensor setup, and disconnected sensors that are not being used. We have also rebooted the brain, the computer, updating firmware for each device. I had the students re-code a new program, and have replaced the brain. I’m at a loss, at this point. Any help is greatly appreciated!

I’m attaching a picture of the most recent code that is continuing to raise the arm even when it is fully extended up against the brain.
code

Remove lines 1 and 4. These lines turn on motors until there’s a stopotor command. When controlling motors, either use setmotor/wait/stopmotor, or functions like lines 2&3, but not both.

Thank you. We did try that before, but it creates a different issue. I removed them again, but now the first three functions work, but we get a high pitched whine from the arm motor, and the claw will not lift at all.

movemotor commands are executed one at a time, so it tries to move motor 7 (and can’t because motor 10 is not moving at the same time), so it gets stuck on line 5 waiting for the motor to rotate a revolution. So, to move the arm, you need to use “setmultiplemotor” commands instead of movemotor commands. Try this:
Setmultiplemotors, 50, 7, 10
Wait some short amount of time
Stopmultiplemotors, 7, 10

Thank you so much! I will try that tomorrow!

It may also be unable to complete one of the rotations. You alluded to the arm hitting a physical barrier (the brain)… well the code doesn’t know it can’t go any further so it keeps trying because nothing is telling it to stop. Try a half rotation just to see if it completes the code as written. If so… then figure out the exact number of rotations or switch to running the motors for time instead of rotations… the program will keep turning until it hits the amount of time you designated and then move to the next line regardless of any impediments.

We tried that before, actually. Tried it again, and it still is not working.

Weirdly, we tried a half rotation and it did the same thing as before. We changed it to a quarter turn, and the arm stopped about halfway up the first time. That was progress, but we could not get it to repeat itself again. We changed it to seconds instead of rotations, and are getting it dialed in.

The frustrating thing is that we previously ran through a lot of the challenges for RobotC using a full rotation on a lot of the codes and never had this problem.

Did you swap out the motor? Maybe the encoder is bad?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.