Vex Files

Here is my problem. I want to create a program for my Vex bot using MPLAB, so I go to project → project wizard select the right PIC processor, then select Microchip C18 toolsuite. Now, I cannot find a good tutorial on how to use MPLAB, so I was wondering what files do I need to put in a new project? Do I have to have EasyC installed too because it contains some files that I need? Can someone who knows MPLAB help me out, please? Thanks in advance!

I always start with a copy of the Vex Starter Code available on the downloads page.

It’ll take some exploring to figure it all out, but basically you insert your code in user_routines.c. There are comments that guide you where to put various elements of your code. If you need interrupt handlers or other fast-loop code, you generally put that in user_routines_fast.c.

After you’ve gotten familiar with the lay of the land, you’ll probably start to customize things a bit more.

Be warned that if you want your robot to work without an active radio link, you have to make a few changes to enable autonomous mode. Underdark provides the details in this post.

Cheers,

  • Dean

Thanks much Dean. I’ll look over these things, and I hope to report that all is going good (yeah right, like that will ever happen). Thanks again!

Question: Can I delete everything in that user_routine_fast.c (I think that is the name of it) file then and put in my own code?

BTW I have not had much time to read through the code, so sorry if this is a dumb question.

There isn’t very much in there to begin with. If you don’t plan to use interrupts at all, you can eliminate InterruptVectorLow() and InterruptHandlerLow() completely … the low priority interrupt is disabled by default, so this will never be called unless you jump through a few hoops to enable it.

User_Autonomous_Code() only gets called from main() if the autonomous_mode bit is set. If you remove that function, you’ll need to also comment out or remove it’s reference in main.c.

Process_Data_From_Local_IO() is the one you generally add code to, but you can get rid of that too if you want, and also remove it’s reference in main().

Whatever you remove, just remember to fixup the user_routines.h header to match or you will get compile errors.

I actually merged user_routine_fast.c entirely into user_routine.c so I only have one file to edit. I then moved all the helper routines that never change from user_routines.c into a new library file. Now, user_routines.c just contains my code that varies from project-to-project.

Cheers,

  • Dean