where do i start with c18

Hi guys, thanks for the help on the first problem. I know this is a silly question (indeed, as a CS student I am embrass by this).

I followed this tutorial called Program Vex Robot for FREE, a member from this forum made it for rookies like me.

I went over and was able to download my first script to the controller
the main.c according to the tutorial

#include "API.h"
#include "BuiltIns.h"
void main(void)
{
SetPWM (1, 255);
SetPWM (2, 0);
Wait (3000);
SetPWM (1, 127);
SetPWM (2,127);
}

Once it was completed, a window pop-up. It was some kind of terminal?? I don’t know the use of it.

I did not notice anything happen with the robot either, so my best guess is that this script will run if I have a pin stick into the autonomous mode (13, 14??)

My questions are:

  1. Where can I find a very good start-up tutorial on this programming?
  2. Do I have to put this robot in autonomous mode all the time?
  3. Can I run A.M without using the pin, I want to run it with the code??

Thanks.

http://robotics.hideho.org/data/first/2007/Fall2007Workshops.pdf

So according to this, I am actually writing a c code…
I mean I am confused. In the pdf above, it said easyC Pro. I know easyC Pro is another IDE, but how come they share same syntax?

How exactly and what exactly am I writing?

Thanks…

Yes, you are…

I am working on a MUCH LONGER response to your first post…

Hang on… :wink:

LOL Thanks mark
In the mean time I will continue reading the slides and other c related resources, thanks,

Please, Don’t Be Embarrassed… Most ALL Computer Science Programs DO NOT teach any Embedded Programming. There are some Notable Exceptions, like the Robotics Schools, Massachusetts Institute of Technology (MIT), Carnegie-Mellon University (CMU) and my chosen Engineering School, Oregon State University (OSU).

Yes, I am very familiar with this Tutorial, in fact some of my “additions” were added to the last Update of it, and it is in need of further updating with the Changes in Version 8.40 of the MPLAB IDE.

BTW, it is Extremely Unfair to call it a Script… This is a real ‘C’ Program, that is Compiled into Machine Code for the Microchip PIC 18F8520, that is then Downloaded to the Flash Memory of the Microcontroller.

For some of the background on the Vex Robotics System’s Programming Options, please read the thread, Which is the best programming software?.

You might also read these Threads:

Beginner Programming Question
mplab compatability
Mplab programming

One of the Functions in the WPILIB is “PrintToScreen ( … )”, that can be used to display Text or Data in the Microcontroller, on a Terminal Screen…

A String Constant like, " PrintToScreen ( “Hello User\n” ) ;" can be displayed, or the Value of a Variable, like “PrintToScreen ( “The Value of Counter is → %d\n” , (int)counter ) ;”

What should have happened, is if you have Two Vex Motors, One in Motor Ports #1 and One in Motor Port #2, they should have run Full Speed, in Opposite Directions, for a Duration of 3000 Miliseconds (3 Seconds), and then Came to a Full Stop.

If the Motors did not run, check to see which Motor Ports they are connected to. Also, there might need to be an update of the Vex Master Code… Sometimes the Vex Controller needs to be Power Cycled after a User Code Download…

There is no need to Insert an Orange Vex Jumper in the I/O Block or Interrupt Block for the Above Code…

Answer #1)
There are Tutorials for the Vex Controller and its Cousin the FRC Controller used from 2004-2008 at Chief Delphi, plus some Tutorials at Vexrobotics, found on the page EDR Resources » General Resources. You will also want to search the Various Thread in the Vex Forums. Search for a Given Topic, like “Ultrasonic”

Answer 2)
No you don’t. A “typical” Vex Competition has an “autonomous” section and an “tele-operated” section. The Orange Jumper, is to Force, or Ignore the “autonomous” section, for Testing Purposes. You can Chose to ONLY HAVE “autonomous”, or ONLY CHOSE “tele-operated”.

Answer #3)
Yes, you can… If you make your Code ONLY “autonomous”, then there is no reason to have it selectable with an Orange Jumper.

To answer your Second Post…

For Programming the Vex Controller, Version V.5, There are 3 Development Systems…

EasyC, RobotC, and the Native MCC18 Compiler, usually used with the MPLAB IDE, but that is not required to make Vex Controller Programs.

EasyC is a Drag and Drop Interface, that uses the MCC18 Compiler to make the Machine Code that gets Downloaded to the Vex Controller.

EasyC come in Three Version for the Vex Controller, Version 1.x, that is now been replaced with EasyC 2.x, and the EasyC Pro version. Some of us Old Timers have EasyC Version 1.x, but this Version is not Allowed for Vex Competitions.

RobotC generates Code for a Byte Code Interpreter, that is Downloaded before you Download your first RobotC program.

Please note that the new Cortex Controller and the ARM 9 Controller will have a Version of EasyC, a Version of RobotC and some sort of “native” compiler support for the ARM Microcontrollers…