* Intelligent compiler identifies and helps correct common syntax errors. * Requires custom firmware in order to run. * Is intended for simple to advanced programs. * Has several tutorials designed to help users learn the programming language. * Uses text-based commands, commonly contrasted with, a graphical language also for the NXT.
ROBOTC IDE CODE
It allows users to move a code from one platform to another with little or no change in code.
ROBOTC IDE UPDATE
I would highly suggest you check the documentation to see if those values automatically update or if there is, in fact, a function you should be calling to read/write encoder counts and motor speeds.ROBOTC (trademarked as ROBOTC and frequently spelled RobotC) is a commercial Integrated development environment targeted towards students that is used to program and control LEGO EV3, VEX, LEGO NXT, RCX, and Arduino robots using a programming language based on the ANSI C programming language. I could absolutely be wrong it looks like you're using ROBOTC, and also it's VEX robotics, so there could 100% be a set of pre-defined keywords or key variable names that hold special meaning in that development environment, but again I'm just pointing out what I see versus what I would expect to see. Here too it looks like you're expecting the nMotorEncoder variable name to auto-magically update, where I would have expected you to need to call a function that returns an updated value, like the following: nMotorEncoder = GetEncoderCounts() Similarly, there is no function that returns an updated encoder count. For example, I would have thought you'd do something like the following: motor = 60 īut that last function, WriteMotorSpeed() never happens. I would have expected something more along the lines of a speed assignment followed by writing that speed to a function, but that second step never happens. You were NOT looking at the actual variables that control which case gets selected! Those variables are leftEncoder and rightEncoder.Īnd again, final warning - it looks like you're counting on things like motor and nMotorEncoder to be function names or keywords that do something, because otherwise it just looks like you enter an infinite loop that never actually writes any values to the motors. This is one of the tricky things with debugging - you have to be looking at the correct variables! In your video, you are looking at leftMotor and rightMotor, and what appears to be fields for those motors. Int rightEncoder = abs(nMotorEncoder) // leftEncoder)īy adding the two lines inside the while loop, now you are checking and updating the encoder counts every time you step into a new loop.
So, that said, try using the following: void GOforwards() I don't know about VEX robotics, but I'll caution you that your left and right encoders are based on nMotorEncoder and, just like how leftEncoder and rightEncoder doesn't get updated anywhere in your loop, nMotorEncoder doesn't get updated anywhere either. The exception might be if those variable names are actually protected variable names that have special meaning in your development environment - more on that later. The problem seems to be that maybe you're thinking that the left and right encoder values will update automatically, but that is generally not the case. It looks like you don't ever update the encoder values after you initialize them. much less why it runs off into oblivion when the code should exit the while loop once the right encoder's absolute value exceeds 2000.
I am not sure why the power to the wheels never changes, or why it seems to believe that the Encoder values are equal. This is a video of the code running from the debugger windows: When I run the code my robot runs without stopping and the Encoder values diverge quickly. *!!Code automatically generated by 'ROBOTC' configuration wizard !!*// #pragma config(Motor, port10, rightMotor, tmotorVex393_HBridge, openLoop, reversed, driveRight, encoderPort, I2C_2) #pragma config(Motor, port1, leftMotor, tmotorVex393_HBridge, openLoop, driveLeft, encoderPort, I2C_1)
#pragma config(Sensor, I2C_2,, sensorQuadEncoderOnI2CPort,, AutoAssign ) #pragma config(Sensor, I2C_1,, sensorQuadEncoderOnI2CPort,, AutoAssign ) This is my code: #pragma config(I2C_Usage, I2C1, i2cSensors) I have a standard VEX Clawbot, which I've been trying to make go straight for some time.