Other things to do in Easy C

So I’ve pretty much mastered the basics of easy C, templates, sensors, RC, various other simple things, and I was wondering if there was something else that I could learn to do. Any suggestions? Thanks.

Learn to simplify complicated codes. In the long run, it will make your robotic experience much more enjoyable.


completely agreed, why not make some helpful templates or something for newbies?

or make yourself a really really hard autonomous challenge

Try making multiple auto modes in one file switchable with different jumpers. Another Idea control the robot with jumpers.

How about exploring the interplay between R/C and autonomous? Learn to read the Channels and make different outcomes based on the Channel readings (basically treating the Channels as if they were sensors) . For example, if the operator is pushing the joystick up on Channel 2, make it do nothing, but if it’s pushed down, turn a motor (this is useful if you want a motor to go in one direction but not the other).

Congratulations!!! You are ready to start moving on to Coding ‘C’ without EasyC…

Look at the ‘C’ code that EasyC generates, the actual code that is sent to the PIC C compiler.
Look at some ‘C’ tutorials like Sams Teach Yourself C in 24 Hours, or the ones I have here on this page, ‘C’ Programming.

Download the MPLAB IDE and install it on your computer, you can use the MCC18 Compiler already installed with your EasyC to compile the Vex Default/Starter Code.

Download the Vex Starter Code from the Vex Download Page. Request the “Vex Default Firmware” by sending an e-mail to [EMAIL=“[email protected]”][email protected]. These two ZIP files will let you build the Vex Default Firmware for the User Processor.

Load the VexUserCode.mcp Project into the MPLAB IDE

Look at the function “Default_Routine” in Source Module “user_routines.c” to see how the Sticks and Buttons on the Vex Controller are programmed to match the Charts in Appendix E, Pages 1-18 of the Inventor’s Guide.

Make Changes and re-compile to see what happens…

Ask Questions here… We like to help other people out… :wink:

I have an issue that is related to some of the great suggestions in this thread.

In our program, I need to mimic certain behavior found in the default code. Namely, the operation of a motor needs to be inhibited in one direction when a limit switch is pressed, during RC operation. This prevents robot damage in case the operator is not paying attention. (Three repairs is enough!)

Currently, the hardware is all set up, and it works fine with the VEX default code. However, I have not found a way to duplicate the limit switch/motor interaction in EasyC. Athough the basic concept is easy, there doesn’t seem to be a function block in EasyC to restrict the motor commands to a certain range. Any ideas? For practical reasons, I am stuck with EasyC. In case anyone is wondering, we have to do a custom program to support autonomous + RC. Otherwise, we would use the default code.

If we can’t mimic the default code behavior exactly, we might temporarily invert the direction in the motor control function block. But I was hoping to not add complexity to this program.

Any insights would be helpful.

You can use GetRxInput(channel) to read the position of each channel. For example, reading one of the joysticks will yield a number between 0 and 255, where 0 is pushed up as high as possible, 255 is pushed down. You can then use this reading to decide whether or not to activate the motors.

We typically use the Tank or Arcade commands inside a continuous loop to activate the motors using r/c channels.

A pseudocode example which does nothing when a sensor is pressed and joystick is pushed up, but which enables the joystick pushed down:

While sensor is pressed
If (stickposition<126) // if stick pushed up, 126 as “up” threshold
[INDENT]SetMotor(1, 127) // stop motor 1
while (stickposition<126) //keep motor stopped until stick is pushed down
[INDENT]stick position = GetRxInput(2)[/INDENT]
end while[/INDENT]
Else Tank (…)//If stick pushed down, enable r/c[/INDENT]
End while

We had a similar problem last year – a stick-happy driver kept pushing the controls up, grinding gears, even when it was clear the arm could move no further. We needed a way to enable the arm to come back down if the limit was reached without allowing it to move up any further.

Thanks. That actually looks pretty simple, now that I see the pseudocode. Will give it a try!

ManicMechanic - Thanks again for the suggestion. It works like a champ! No more stripped gears for us.

Great – glad it worked! Now to replace those 12 broken gears we have from last year…:o