Log in

View Full Version : Programming - Getting Started


Mark McLeod
28-10-2004, 15:02
With the advent of a new season and the influx of new programmers-to-be I decided to do a 1 or 2 page write-up on just how a programmer new to FIRST can get started. I wrote this up to bootstrap rookie team programmers. Sort of a how does one get started when they know absolutely nothing about where to even start programming the FIRST controller. It’s not intended to replace the IFI documentation, it’s more to direct new programmers to it. I tried to stay away from most "how to program" type stuff and more advanced topics like the Linux/Windows debate and configuration management. This is just to get newbies rolling. Anyone have suggestions, additions, corrections. Everything is up for debate.

P.S. I have enough tips now to continue the recent trend in “lists”, but I’ve created three lists: One for programming tips, another for tips specific to just the control system, and the third for quick starting new FIRST programmers.

Programming Quick Start

Beginners need the following to program the FIRST robot:

FRC (Full-size Robot Controller) RC Default Code
Microchip MPLAB & C compiler
IFI_Loader
A standard serial cable
A Windows PC with a serial port or USB-to-serial converter

All default code, updates, documentation, and support information is available at http://innovationfirst.com/FIRSTRobotics/documentation.htm (http://innovationfirst.com/FIRSTRobotics/documentation.htm), the Innovation FIRST (IFI) website, The default code “FRC RC Default Code” comes ready for basic driving and with a variety of sample I/O usages.
MPLAB is the FIRST supplied Windows based development environment (edit, compile, debug) that runs on your desktop computer and is usually provided to each team on a compact disk in the Robovation kit. MPLAB is free on-line at the Microchip website http://www.microchip.com/ (http://www.microchip.com/), but the C compiler is not free except via the Robovation CD and is only available online as a time-limited trial copy or for purchase. Manuals for using MPLAB come on the FIRST CD.
IFI_Loader (from the CD or IFI website above) is used to download the compiled code into the RC via a serial cable from your desktop or laptop computer.
Check the IFI website periodically for updates to the software that corrects issues fixes problems.
The programming language used is “C” or PIC assembly. Tutorials in C can be found on the web, in your local bookstore or on the FIRST website, e.g.,


C Programming Resource Library http://www.usfirst.org/robotics/C_help.htm (http://www.usfirst.org/robotics/C_help.htm)
Learn C Programming - Developed by Carnegie Mellon and the National Robotics Engineering Consortium specifically for FIRST, this interactive website will get your team prepared for the upcoming FIRST Robotics Competition season. http://www.rec.ri.cmu.edu/education/robot_builder/ (http://www.rec.ri.cmu.edu/education/robot_builder/)
FIRST Robovation - A Primer for Success Learning Modules http://www.usfirst.org/robotics/robovation/primer/index.html (http://www.usfirst.org/robotics/robovation/primer/index.html)

Newer laptops no longer come with serial ports. If you have this problem one solution is to use a USB/Serial converter. Various models are available at Radio Shack, CompUSA, or online.
Documentation is your friend. Take the time to at least leaf through each manual, so you have an idea of where information can be found. Most of the basic information beginners require can be found in the IFI documents or MPLAB documents:


IFI Programming Reference Guide – basic how to program and download to the RC, hookup switches and sensors and do normal robot operations.
IFI RC Default Code Reference Guide – description of how the default code is structured and where users can add their own custom code.
MPLAB v6.xx Getting Started – basic how to use MPLAB and set options.
MPLAB C18 Users Guide – table of max numbers each variable type will store, compiler options, error messages, detailed descriptions of pragmas and some other advanced topics.
MPLAB C18 Libraries – details on timers, interrupts, and various other utility functions available to the programmer.


More advanced documents are also available, e.g., 18Fxx20 Data Sheet (& Errata)– PIC assembly instruction set and details on EEPROM and other chip specific topics, and several others.

Programming limits to the 2004 RC:


30,720 bytes program space is available to the user, after 2004 IFI code.
1,343 bytes of ram available to the user, after 2004 code overhead.
256 bytes of global variables available within any one MPLAB file.
120 bytes of variables within a single routine.


The program and data space your code has used can be checked either by the status line at the bottom of the IFI_Loader window or via the optional .map file that MPLAB will generate for you.

Common beginner problems include improper MPLAB project setup, trying to pack too much code into the controller, printf misunderstands, using too small a variable type to hold the largest possible intermediate as well as the largest final value of a calculation, and lack of proper variable typecasting.
Visit the ChiefDelphi Programming forum for discussions on all programming topics, problems, and issues http://www.chiefdelphi.com/forums (http://www.chiefdelphi.com/forums).

Noah
28-10-2004, 17:06
1) Programming will take more time than you expect, especially if you want autonomous to work. Tell the team that the robot needs to be driving and in your (the programmer's) hands with at least three days before shipping.

2) Rookies: Don't program without sleep. Sure, you'll hear the experienced programmers bragging about a 36-hour code marathon, but all that means is that they are good at procrastinating. And working without sleep.

3) Don't forget to initialize a variable you are using as a PWM output to 127.

4) Increment your counters! (One year my robot span around in a circle for about three minutes...)

5) If at all possible, make sure the code works *before* dumping it into your robot

6) When testing your robot, lift it off the ground. Prop it up somehow. This can save lives! (well, shins, anyways)

Good Luck!

Jaine Perotti
28-10-2004, 17:23
you might want to add that sometimes serial to usb converters are really tempermental. Alot of people have trouble with them.
Maybe recommend a certain kind that is known to be more reliable than others?

Bharat Nain
28-10-2004, 17:43
1) Programming will take more time than you expect, especially if you want autonomous to work. Tell the team that the robot needs to be driving and in your (the programmer's) hands with at least three days before shipping.

2) Rookies: Don't program without sleep. Sure, you'll hear the experienced programmers bragging about a 36-hour code marathon, but all that means is that they are good at procrastinating. And working without sleep.

3) Don't forget to initialize a variable you are using as a PWM output to 127.

4) Increment your counters! (One year my robot span around in a circle for about three minutes...)

5) If at all possible, make sure the code works *before* dumping it into your robot

6) When testing your robot, lift it off the ground. Prop it up somehow. This can save lives! (well, shins, anyways)

Good Luck!
1) The dangers of killing people and dangerous situations etc can be avoided by using/making/building a dongle (http://www.innovationfirst.com/FIRSTRobotics/pdfs/Competition_Port_Pinout_Guide.PDF) .Trust me its worth building that.

2) Things in theory are not always right practically. You can calculate how far your robot will go in a certain time, but when you do it practically you might find different reasons. For that reason everyone tells you to reserve a lot of time for programming autonomous.

3) Most of the time if you find a problem, look Though a C guide for syntax, or the Innovation FIRST programming guide, simple mistakes can cause you to go crazy. I agree to Noah, sleep is important, it helps you take it easy and not go bonkers programming.

4) Step by step: Don't write the whole robot code in one shot and expect it to work, do it step by step i.e. part by part, drives first, then arm, then other stuff....

5) Will think up more and post later...

av11d
28-10-2004, 19:11
Download PowerPoint Module A:

http://www.usfirst.org/robotics/C_help.htm

It has a great overview of the programming process.

scitobor 617
28-10-2004, 22:37
1) Kill Switches: It's always a good idea to add drive/device kill switches.(If you have the time)

2) Limit switches can prevent an appendage from destroying itself. Last year my team constructed a poorly designed arm with the ability to destroy it self, limit switches are the only reason while that robot is still in one piece.

Astronouth7303
29-10-2004, 14:07
Don't make everything inline! It is a lot easier to maintain, expand, etc. if all the code that actually interacts with stuff is buried, because you only need to change it once.
The compiler is extremely weird. If you get syntax errors for no apparent reasons (after checking for things like parens, semi-colons, etc.), type the line again, including the line breaks on each side.
If you really can't figure it out, sleep on it. Meaning: Leave it be and come back tomarrow.
Use #define for I/O port references. Same as reason the first: If you change which port it's on, you don't have to go through all your code.

IMDWalrus
29-10-2004, 16:31
you might want to add that sometimes serial to usb converters are really tempermental. Alot of people have trouble with them.
Maybe recommend a certain kind that is known to be more reliable than others?
If at all possible, get an actual serial port. USB to serial connections are usually not fun to deal with.

Comments are your friends. Use them, use them frequently, and use them intelligently. Try to document the code well enough so that someone who's never seen it before could understand it. There are certain things that you DON'T want to do - like, say, leaving excessive amounts of old code in the program but commented out, or copying and pasting PBASIC (!) into the comment sections - but it can't hurt to use them in most cases.

Try to understand the basic framework of the code ahead of time. It would be nice to have your programming team know how to map the controls to the robot fuctions, or how to set up a basic autonomous mode.

Be prepared to deal with time constraints. My team gets the robot with less than two weeks to go most years, and it can be hard to do what you want before you ship. Even if other teams are more efficient in getting the robot to the programmers, you'll still have to worry about making sure that your code works and that you'll have enough time to fix what doesn't.

Most importantly...have fun. The programmers tend to get less credit than they deserve, but the robot wouldn't run if we weren't there. :)

JoeXIII'007
29-10-2004, 19:19
This is an excellent overview, I'll have to make a copy for myself and the rest of the programmers on my team.

As far as programming is concerned, I have these few suggestions:

1.) LEARN BASIC or at least take a quick look. It will give you the basics of programming like logical, arithmetic, and relational operators, plus simple counter builds and other good basics.

2.) Then goto About.com's C Tutorial (http://cplus.about.com/library/blctut.htm) to learn the basics of C. How it's structured, done, etc. Try and find a simple compiler other than MPLAB while you're at it. I have Pacific C, but the site I got it from isn't working.

3.) Don't let all the script make you think it's difficult. Yes, there's a few difficult parts to get passed like the declaration of variables, knowing what they are, etc. The rest, however, is quite logical.

Otherwise, just remember that you ARE the most important group of people within your team, for it is the programming that makes it a robot and not just a highly modified RC car. :D Have fun!

CrashZero
31-10-2004, 00:48
This is a good overview. But all you people talking about having programming "teams" i ask you : how is it that you get a team, for my team its always just me. And new programmers out there don't be discuraged when you get blamed for *every* problem the robot has. And don't think that you will get any fame out of the robot even if it does work. Everyone else in the team gets that. But hey us programmers get to have all the fun so i soppose it's a fair trade. :D

phrontist
31-10-2004, 15:34
It's not ANSI C! It's funk-a-delic emaciated C!
Kill switches are not the way to go, IMO, "Live" switches are. Add some code such that if the trigger on your joystick is not depressed, the bot doesn't move. This way your driver just has to let go. How did I learn this? When Robots Attaaaaaack! (http://www.firstwiki.org/When_Robots_Attack)
Remember: That piteous mass of metal that the build team insists on fawning over is little more than a glorified RC car without you. You are gods amongst sniveling wretches!!!
Err... Um... Don't let programming go to your head ;)

EricS-Team180
31-10-2004, 18:35
you might want to add that sometimes serial to usb converters are really tempermental. Alot of people have trouble with them.
Maybe recommend a certain kind that is known to be more reliable than others?


Dr Joe has recommended a Bafo Technologies BF-810 if I recall correctly. From last year's experience, I have to concur that some are VERY tempermental.

Thanks everyone......this is a really good thread

Eric

fred
31-10-2004, 18:41
KISS- Keep It Simple Stupid

Example:

2003: Our robot, Miss Daisy II won the Galileo Division at Nats. Number of Speed Controllers: 3

2004: Our robot, Miss Daisy III didn't work at Chesapeake, didn't work very well at Drexel or Nats, and only started working in the offseason.
Number of Speed Controllers: 10-12 (too many)

Don't let the mechanics bully you into trying to add way too much stuff. Simple stuff can work quite well and it also gives time to write a nice autonomous program.

Mark McLeod
31-10-2004, 21:16
You are gods amongst sniveling wretches!!!
I knew there was a reason I get up every morning;)

I'll post the programming and control systems list later on in the week.
I almost pulled a gwross and have a sprained wrist, so typing is slower. It's hard to post fast enough to beat the time-out.

nehalita
15-01-2005, 18:41
this helped me soooo much. thank you all. this is our second yr competing and this is my first year in FIRST. i have a java background and a simple C background from 8th grade...but it was so long ago. :eek:

I'm the only one in charge of programming so when i was handed all these Cd's and codes and links and websites, i was pretty overwhelmed. i just learned about this today and I've spend the majority of the day looking through posts to answer my Q's

is there anyone here that i can directly e-mail or talk to if i have questions? (warning: I'm like a pet, i demand a lot of attn: i have questions everyday....or close to it) :(

also, everyone speaks about a "dongle" and i saw the picture and everything. but what exactly IS it? :confused:

Alan Anderson
15-01-2005, 19:27
also, everyone speaks about a "dongle" and i saw the picture and everything. but what exactly IS it? :confused:
The Operator Interface (OI) has a 15-pin Competition Port connector in the middle of the top. Pins on that connector are used when running on a competition field to enable or disable the robot, select the radio modem frequency, and control autonomous mode. The field also supplies power to the OI through that port.

Teams are permitted to connect to four specific pins on the Competition Port, in order to 1) enable additional frequencies for practicing with multiple robots, 2) activate autonomous mode for testing, and 3) disable the robot. Most teams build a box with two or three switches that connects to the port. That box is called a dongle. The Competition Port Pinout Guide (http://www.ifirobotics.com/docs/competition-port-pinout-guide-reva.pdf) shows how to construct one.

Mark McLeod
27-01-2005, 12:21
Here's an updated version for this year with 2005 links included.

Programming Quick Start

Beginners need the following to program the FIRST robot:


v FRC (Full-size Robot Controller) RC Default Code

v Microchip MPLAB & C compiler



v IFI_Loader
v A standard serial cable
v A Windows PC with a serial port or USB-to-serial converter




All default code, updates, documentation, and support information is available at http://www.ifirobotics.com/rc.shtml (http://www.ifirobotics.com/rc.shtml) and http://www.ifirobotics.com/oi.shtml (http://www.ifirobotics.com/oi.shtml) , the Innovation FIRST (IFI) website, The 2005 default code http://www.ifirobotics.com/docs/frc-code-1-12-2005v2.2.zip (http://www.ifirobotics.com/docs/frc-code-1-12-2005v2.2.zip) comes ready for basic driving and with a variety of sample I/O usages. Optional 2005 default code is also available for use with the CMU camera http://www.ifirobotics.com/docs/frc-code-1-12-2005v2.4.zip (http://www.ifirobotics.com/docs/frc-code-1-12-2005v2.4.zip). Consult the CMU documentation for other requirements. Useful software examples and documentation, as well as the demonstration code used at kickoff can be found at Kevin Watson’s website http://kevin.org/frc/ (http://kevin.org/frc/) .


MPLAB is the FIRST supplied Windows based development environment (edit, compile, debug) that runs on your desktop computer and is usually provided to each team on a compact disk in the Robovation kit. MPLAB v7.0 is also free on-line at the Microchip website http://microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002 (http://microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002) , but the C compiler is not free except via the Robovation CD and is normally only available online as a time-limited trial copy or for purchase. For a limited time the latest compiler is available from a link on http://www.usfirst.org/ (http://www.usfirst.org/) (bottom left of the page where it says “Microchip Software downloads”). After the link is removed the latest compiler must be obtained through FIRST.Manuals for using MPLAB come on the FIRST CD.


IFI_Loader (from the CD or IFI website http://www.ifirobotics.com/docs/ifi-loader-v1-0-10.zip (http://www.ifirobotics.com/docs/ifi-loader-v1-0-10.zip)) is used to download the compiled code into the RC via a serial cable from your desktop or laptop computer.


Check the IFI website periodically for updates to the software that corrects issues and fixes problems. For instance, the first update that must be performed is the downloading of a new Master Controller “patch” http://www.ifirobotics.com/docs/master-software-ver10.zip (http://www.ifirobotics.com/docs/master-software-ver10.zip) . Follow directions included with the download.


The programming language used is “C” or PIC assembly. Tutorials in C can be found on the web, in your local bookstore or on the FIRST website, e.g.,


v C Programming Resource Library http://www.usfirst.org/robotics/C_help.htm (http://www.usfirst.org/robotics/C_help.htm) has a great overview of the programming process.
v Learn C Programming - Developed by Carnegie Mellon and the National Robotics Engineering Consortium specifically for FIRST, this interactive website will get your team prepared for the FIRST Robotics Competition. http://www.rec.ri.cmu.edu/education/robot_builder/ (http://www.rec.ri.cmu.edu/education/robot_builder/)

v FIRST Robovation - A Primer for Success Learning Modules http://www.usfirst.org/robotics/robovation/primer/index.html (http://www.usfirst.org/robotics/robovation/primer/index.html)




Newer laptops no longer come with serial ports. If you have this problem one solution is to use a USB/Serial converter. Various models are available at Radio Shack, CompUSA, or online, however, some models can be temperamental and they generally take longer to download than a built-in serial port (60sec vs 10 sec). Good results have been reported using: Bafo Technologies BF-810 (~$15) and a Radio Shack USB-to-Serial port cable #26-183 ($42).


Documentation is your friend. Take the time to at least leaf through each manual, so you have an idea of where information can be found. Most of the basic information beginners require can be found in the IFI documents or MPLAB documents available from the websites:

IFI Quick Start and Overview documents, the 2004 versions apply to 2005 as well http://www.ifirobotics.com/docs/frc_system_quick_start_2004-1-14.pdf (http://www.ifirobotics.com/docs/frc_system_quick_start_2004-1-14.pdf)http://www.ifirobotics.com/docs/control-system-overview-2004-01-07.pdf (http://www.ifirobotics.com/docs/control-system-overview-2004-01-07.pdf)
IFI Programming Reference Guide – basic how to hookup, program and download to the RC, hookup switches and sensors and do normal robot operations. http://www.ifirobotics.com/docs/rc-ref-guide-2005-revnc2.pdf (http://www.ifirobotics.com/docs/rc-ref-guide-2005-revnc2.pdf)
Useful programming and compiler documents come with the tool installations or are available from the Microchip website. http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010014 (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010014) or http://microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002 (http://microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002)

v c18_getting_started_2.4.pdf http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB_C18_Getting_Started_51295d.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB_C18_Getting_Started_51295d.pdf)
v c18_libraries_2.4.pdf – details on timers, interrupts, and various other utility functions available to the programmer. http://ww1.microchip.com/downloads/en/DeviceDoc/C18_Lib_51297d.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/C18_Lib_51297d.pdf)

v c18_users_guide_2.4.pdf - table of max numbers each variable type will store, compiler options, error messages, detailed descriptions of pragmas and some other advanced topics. http://ww1.microchip.com/downloads/en/DeviceDoc/C18_UG__51288e.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/C18_UG__51288e.pdf)

v Microchip pic18f8520 data sheet - PIC assembly instruction set and details on EEPROM and other chip specific topics, and several others. http://ww1.microchip.com/downloads/en/DeviceDoc/39609b.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/39609b.pdf) and mistakes in the datasheet http://ww1.microchip.com/downloads/en/DeviceDoc/80157d.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/80157d.pdf)

v Microchip PICmicro 18C MCU Family Reference Manual – all things great and small (in excruciating detail) about the processor we use. http://ww1.microchip.com/downloads/en/DeviceDoc/39500a.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/39500a.pdf)

v MPLAB Quick Start Guide.pdf - basic how to use MPLAB and set options. http://ww1.microchip.com/downloads/en/DeviceDoc/51281d.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/51281d.pdf)

v MPLAB Users Guide.pdf http://ww1.microchip.com/downloads/en/DeviceDoc/51519a.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/51519a.pdf)




Programming limits to the 2004 RC:

30,720 bytes of program space is available to the user, after 2004 IFI code.
1,343 bytes of ram available to the user, after 2004 code overhead.
256 bytes of global variables available within any one MPLAB project file, such as user_routines.c
120 bytes of variables can be declared within any single routine.


The program and data space your code has used can be checked either by the status line at the bottom of the IFI_Loader window or via the optional .map file that you can set MPLAB to generate for you. Note: the .map file lists % of program space used, but the user will have only 90% available to him or her. The .hex is ASCII and file size is no indication of code size.
Visit the ChiefDelphi Programming forum for discussions on all programming topics, problems, and issues http://www.chiefdelphi.com/forums (http://www.chiefdelphi.com/forums)

katkana
01-02-2005, 16:06
*waves hand* hi... I'm another of the newbies with little (read, none) experience working with C. I am also the only one on my team doing the programming dance. At the moment I'm teaching myself from whatever tutorials I can find, but if anyone can spare a moment or ten through e-mail or IM to answer my questions, I would be muchly indebted to you.

AIM- daemonlvr856
e-mail- krystal_dragon9@yahoo.com

THANK YOU!!!

~kat

695programmer
09-02-2005, 19:02
I'm another newbie, with probably less experience than the other two and just as hopeful maybe someone could give me some time cause i'm running into problems i don't know how to solve. Any help is welcome via im or e-mail or anything.

Team 695

695programmer
09-02-2005, 19:37
I have another one i forgot about, when I try to build the error is that it can't locate the build tool, any insight?

russell
16-02-2005, 02:53
I really am a newbie. Heres proof. Can I call the function Limit_Mix as it exists in the v2.4 code from the autonomous mode section of user_routines_fast.c? I was under the impression that I can, but when I just tried to compile it gave me warnings about no function prototype (whatever that is :confused: ), but it seems to have compiled anyway. Anyone?

Mark McLeod
16-02-2005, 11:20
Can I call the function Limit_Mix as it exists in the v2.4 code from the autonomous mode section of user_routines_fast.c? I was under the impression that I can, but when I just tried to compile it gave me warnings about no function prototype (whatever that is :confused: ), but it seems to have compiled anyway. The compiler works on one c file in your project at a time. When it comes across a call to a function it's never seen in that particular file before it doesn't know if you are using it correctly (passing the right type of variables, getting the correct type back), so it gives you a warning that it cannot check on the validity of how you've used it in your code.

You just need to tell the compiler a little bit about the function Limit_Mix. A function prototype does this, and it can be added to the top of your user_routines_fast.c file, or better yet to the user_routines.h file that gets included by user_routines_fast.c,
like so:

unsigned char Limit_Mix (int);

Prototypes is one of the main uses of the .h files, so any other file that needs to use Limit_Mix for example, will just need to include "user_routines.h"

Matt_Kitts
19-02-2005, 12:19
can anyone help me out with programming the buttons on the joy sticks`

Mark McLeod
20-02-2005, 01:53
can anyone help me out with programming the buttons on the joy sticks`Each OI joystick port has the 2005 KoP joystick buttons available in the default code as follows:
For Joystick Port 1:

p1_sw_top - thumb button
p1_sw_trig - trigger button
p1_sw_aux1 - button to the left of the "hat" switch on the front face
p1_sw_aux2 - button to the right of the "hat" switch on the front face
The other Port buttons follow the same naming convention, e.g.,
p2_sw_top would be on joystick Port 2, p3_sw_top on Port 3, etc.

They are used in your code like this:

if (p2_sw_top == 1)
printf("Hello FIRST\r");
else
printf("Goodbye cruel world\r");


There are also two analog inputs unused by the KoP joystick and the analog "hat" switch (that returns odd values).

reilly
20-02-2005, 15:40
Mark:


Great review, could you post a link to the latest default code v. 2.4 for 2005; I downloaded the file from http://www.ifirobotics.com/rc.shtml#Programming
and upon extracting it there is nothing in the files.
Maybe someone else has a good copy.

Thanks. :ahh:

Mark McLeod
20-02-2005, 17:01
Mark:


Great review, could you post a link to the latest default code v. 2.4 for 2005; I downloaded the file from http://www.ifirobotics.com/rc.shtml#Programming
and upon extracting it there is nothing in the files.
Maybe someone else has a good copy.

Thanks. :ahh:I just downloaded it and got everything.
http://www.ifirobotics.com/docs/frc-code-1-12-2005v2.4.zip

maltz1881
21-02-2005, 14:21
I just downloaded it and got everything.
http://www.ifirobotics.com/docs/frc-code-1-12-2005v2.4.zip
Is there anybody out there who can help me ASAP. Our 1 and only programmer quit on us 2 days before shipping!!!. He is the only 1 on the team that knows anything about C. I have tried other teams in our area with no luck. They are all very bust in the crunch time which is very understandable. Our team is very small with only 8 members all of whom are new to FIRST. I welcome any help that anybody can give. I am amazed by the help that others are willing to give to other teams and I feel the whole world needs to take a lesson from FIRST. Thank you :confused:

RIgnazio
22-09-2005, 18:21
also, everyone speaks about a "dongle" and i saw the picture and everything. but what exactly IS it?
A dongle can be made with a RS-232 (serial) end, specifically the metal part. If you look at it, there are pins you can solder wires too. What you should do is solder a wire to each pin that would complete the circuit in the Pin Layout for the RC. Now, instead of just attaching a wire and having done it (the easy way) attach a push button switch that is normally in the off or open position. When you press it, (15 seconds), it will simulate the signal that the FIRST computer sends to the robots to start autnomous. When you let go, autonomous will be over and the robot will be live.

Now, why do you say use a switch you may wonder? And why use a normally off/open switch? If your robot goes on an evil plot to kill you and you start to run away, you will let go of the switch, and the robot won't do autonomous anymore.

OK, newcomers, there are a few tips that I myself have:

1. Programming takes time. If it doesn't work correctly/compile on the first attempt, and you can't figure out what is wrong, Save the file, close out MPLAB, and go do something for an hour then come back. It will probably hit you then.

2. Pay attention to the default code. It is your friend. It will tell you just about absolutely everything you need to know to program the robot.

3. Autonomous mode is not hard, you just need to think about it. Remember, there is a 40ms clock in the RC, so 1 second = 26.2ms. This would be a good time for a calculator.

4. NEVER DELETE OLD CODE.

5. Always put new code, even if you're only changing a comment, in a new folder. SAVE AN ENTIRE SEPARATE COPY!

6. NEVER DELETE OLD CODE.

Those should be your ground rules. Enjoy :)

Matt Krass
22-09-2005, 23:15
If your robot goes on an evil plot to kill you and you start to run away, you will let go of the switch, and the robot won't do autonomous anymore.


Funny, the guy we had holding our kill switch seemed oddly fascinated with the robots attempt to kill our teachers 7 year old son, so fascinated he held the switch tightly, preventing us from intervening and killing it. Until of course we realized we could just..unplug the dongle...yeeeeah.


3. Autonomous mode is not hard, you just need to think about it. Remember, there is a 40ms clock in the RC, so 1 second = 40ms. This would be a good time for a calculator.


I'm assuming you meant 1 cycle = 26.2ms

I'm not sure where you got 40ms, but my memory is bad, and I remember two loops running in the RC, perhaps you're referring to a separate one than I am.

Budster
30-09-2005, 17:04
>> 3. Autonomous mode is not hard, you just need to think about it. Remember, there is a 40ms clock in the RC, so 1 second = 26.2ms. This would be a good time for a calculator.

Maybe it should read 40MHZ clock in the RC.
There is a 26.2ms sample time in the outer/main loop where you get new input from the operator station so in 1 second that is 40hz, i.e. 40 samples per second (actually is 28.167...hz, but 40hz is probably close enough)? Not really sure what the intent was, I'm having trouble parsing the line.

Bud

Budster
30-09-2005, 17:37
I had some students that had the fundamentals of C and how to program it. They could build "hello world" programs with ease. But they quickly got lost when trying to implement the hardware control logic in C to use sensors or manipulate motors/actuators/etc.

In my first year as rookie mentor, what I found the hardest was that I spent 80% of my time trying to figure out how the hardware worked and how to program it to work effeciently. I spent 1% of my time helping write and debug C code and 19% of my time trying to figure out what the pecular limitations of the C implementations were and why sometimes the compiler generated some "unusual" and long/complex sequences of assembler.

I've been trying to put together a presentation on programming the hardware with examples to help out - but it quickly gets overwhelming and I have to start again.

Although you do have to start by learning the C language and how to construct programs... understanding which bits to twiddle and when to do so to control things seemed to take a lot more of the time than ramping up on C. In this respect the PIC18C and PIC18F manuals became my bed time reading for most of last year.

I am planning on spending some time this year teaching how to read hardware specifications to help students decipher some things on their own.

Bud

CJO
30-09-2005, 18:09
I think that it is really important to use some kind of content management (even if you are by yourself) because it allows you to roll back to previous versions. CVSDude offers free subversion/CVS accounts to non-profit organizaitons, and is very reliable.

Doing this can save you a lot of time by simply rolling back to an earlier version, and can even allow simultaneous development of different ideas (branches).

mallot1243
18-10-2005, 07:23
who knows which files are allowed to be transferred to the bot. ie <stdio.c>

Mark McLeod
18-10-2005, 10:55
who knows which files are allowed to be transferred to the bot. ie <stdio.c>

You are allowed to use any files in your project you like, even write your own as long as you include the ifi required libraries and supporting include files.

However, be aware that the PIC is limited in it's capabilities and will not support or fully support the functions you may want to use in a typical stdio.c file. You can't just drag one in from a PC and expect it to work. You can check the documentation (C:\mcc18\doc) to see what is supported by the C18 compiler.
The document that might interest you for the C18 v2.4 compiler is at:
http://ww1.microchip.com/downloads/en/DeviceDoc/C18_Lib_51297d.pdf

mallot1243
19-10-2005, 12:07
thanx

Joohoo
11-11-2005, 15:55
Right now I am one of two programmers on my team and we both can't figure this out(we're both rookies). We can write the code for the autonomous mode, build it, and transfer it, but how do we tell the FRC to execute the autonomous coding?? We copied everything and tried to mess around with Main.c but is there any less hazardous way to go about it?? :confused:

JamesBrown
11-11-2005, 16:08
JooHoo I got your private message but got errors when i tryed to send you one, it said you had selected not to recieve private messages. You should be able to fix this in the User CP.

I hope this answers your question.

To run your autonomous code you need to build a mock competition port (a couple of switches that attach to the competition port to allow you to use autonomous and to disable the robot.) You need a 15 pin serial adapter (i dont know if that id the right name but it is the thing that plugs into a serial port.)

The pinout diagram for the port can be found at http://ifirobotics.com/docs/competition-port-pinout-guide-reva.pdf

It is easy to make one (it took me about 10 minutes) and will make your programming much easier. Last season we didnt make one and that ment i couldn't teas my autonomous until a practice meet 2 days before ship. We mad one between our regional and the off season competitions and I was able to write 5 succesful autonomous codes in one day. It will save you alot of late build season stress.

Madison
11-11-2005, 16:20
I can find no member named JooHoo. Are you certain you tried to send your PM to the correct person?

Brandon, could this be an account that was recently deleted or suspended?

Mark McLeod
11-11-2005, 16:35
Joohoo (http://member.php?u=11578) aka http://www.chiefdelphi.com/forums/member.php?userid=11578 is an actual person:)
He has email enabled but not PM in his user profile.

Mark McLeod
11-11-2005, 16:45
... how do we tell the FRC to execute the autonomous coding?? We copied everything and tried to mess around with Main.c but is there any less hazardous way to go about it?? :confused:
Yes, there are more ways than you can shake a stick at :)

One is to build a competition port dongle that allows you to flip a switch and the code in main.c will react the same as in competition. There are lots of references to them in this thread and James Brown pointed you to the pinout diagram in another more personalized thread post (his post is here now). In the long run a dongle is a very important device to have as it also provides you with a DISABLE switch that overrides all autonomous programming errors!

Another is to simply pick a switch of your own, such as an unused button on a joystick and have the code in main.c set the autonomous bit as long as it sees that button pressed. There are lots of variations on this and it's certainly safer than hardcoding it within main.c. Use your imagination. Just remember to remove it from your competition code unless you come up with an interesting autonomous move that's useful in the middle of this year's game.;)

Madison
11-11-2005, 17:04
Joohoo (member.php?u=11578) is an actual person:)
He has email enabled but not PM in his user profile.

Okay, so I must be delirious. I checked the member list alphabetically and didn't see JooHoo anywhere -- see the attached screenshot :)

I looked at his profile and searched by his real name and didn't find that, either.

I'm sick, so it's entirely plausible that I'm also crazy, but I think I'm just overlooking something stupid here.

Mark McLeod
11-11-2005, 17:46
Okay, so I must be delirious. I checked the member list alphabetically and didn't see JooHoo anywhere --
That's really interesting! He doesn't showup for me in the member search or list either. Only when I go directly to his userid. I wonder if "Invisible mode" has that effect?
He's a ghost of ChiefDelphi. We can only see him when he posts something.

P.S. Thought you'd be interested. 810 Smithtown isn't registered this year. The team is still around and was in a recent parade, but the school budget went down and they're on an austerity budget.

EricH
11-11-2005, 18:12
That's really interesting! He doesn't showup for me in the member search or list either. Only when I go directly to his userid. I wonder if "Invisible mode" has that effect?
Same here. And invisible mode has no effect on viewing in the members list. There may be a way to change something like that, but I can't find it in the user cp options.

brianoconnor2f2
09-01-2006, 18:22
Hey Thanks fellas This is my first year and I'm a programmer and am used to C++, C isnt much different but I still need all the help I can get. Thanks.

-Matt

Mark McLeod
15-01-2006, 20:26
2006 Programming Quick Start

1. Beginners need the following to program the FIRST robot:

FRC (Full-size Robot Controller) RC Default Code
Microchip MPLAB & C compiler or intelitek Easy C
IFI_Loader
A standard serial cable
A Windows PC with a serial port or USB-to-serial converter
2. Where to get everything:

Basic default code, updates, documentation, and support information is available on the Innovation FIRST (IFI) (http://www.ifirobotics.com/rc.shtml) website, in particular:

2006 default code (http://www.ifirobotics.com/docs/frc-code-1-04-2006.zip) comes ready for basic driving and with a variety of sample I/O usages.
Robot Controller (http://www.ifirobotics.com/rc.shtml)
Operator Interface (http://www.ifirobotics.com/oi.shtml)
CMUCam2 (http://www.ifirobotics.com/camera.shtml)

The Camera default code for use with the CMUCam2 camera is available at the developer Kevin Watson’s (http://kevin.org/frc/) website. While there you’ll also find code examples for using other benefical sensors. This default code may have the normal driving mode disabled.
MPLAB is the FIRST supplied Windows based development environment (edit, compile, debug) that runs on your desktop computer and comes in the Kit-of-Parts wrapped inside the MPLAB notepad. Manuals for using MPLAB come on the CD and are also found on-line at the Microchip (http://microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002) website.
IFI_Loader v1.0.12 (http://www.ifirobotics.com/docs/ifi-loader-v1-0-12.zip) (also on the KOP CD) is used to download the compiled code into the RC via a serial cable from your desktop or laptop computer.
EasyC from Intellitek can be used instead of MPLAB or as a rapid prototyping tool. The Main Contact of each team received an email from FIRST on 1/10/06 with directions on downloading the software.
3. National Instruments Labview came in the kit-of-parts, but you need the very useful special applications for the camera and OI dashboard that have been provided in this Chiefdelphi thread (http://www.chiefdelphi.com/forums/showthread.php?t=41214).

4. Check the IFI website periodically for updates to the software that corrects issues and fixes problems. For instance, new Master Controller “patches” if any, will be made available there. Directions will be included with any download.

5. The programming language used is “C” or PIC assembly. Tutorials in C can be found on the web, in your local bookstore or on the FIRST website, e.g.,

C Programming Resource Library (http://www.usfirst.org/robotics/C_help.htm) has a great overview of the programming process.
Learn C Programming (http://www.rec.ri.cmu.edu/education/robot_builder/) - Developed by Carnegie Mellon and the National Robotics Engineering Consortium specifically for FIRST, this interactive website will get your team prepared for the FIRST Robotics Competition.
6. Newer laptops no longer come with the serial port required to download code to the Robot Controller. If you have this problem one solution is to use a USB/Serial converter. Various models are available at Radio Shack, CompUSA, or online, however, some models can be temperamental and they generally take longer to download than a built-in serial port (60sec vs 10 sec). Good results have been reported using: Bafo Technologies BF-810 (~$15) and a Radio Shack USB-to-Serial port cable #26-183 ($42). You can also use the converter that comes with the Radio Shack Vex Programming Kit.

7. Documentation is your friend. Take the time to at least leaf through each manual, so you have an idea of where information can be found. Most of the basic information beginners require can be found in the IFI documents or MPLAB documents available from the websites:

The 2005 IFI Control System Overview (http://www.ifirobotics.com/docs/legacy/control-system-overview-2004-01-07.pdf) version applies to 2006 as well.
2005 IFI Programming Reference Guide (http://www.ifirobotics.com/docs/rc-ref-guide-01-31-2005.pdf) – basic how to hookup, program and download to the RC, hookup switches and sensors and do normal robot operations.
Useful programming and compiler documents come on the Kit provided MPLAB CBOT CD with the tool installations or are available from either Kevin Watson’s (http://kevin.org/frc/) website or the legacy section of the Microchip website.

c18_getting_started_2.4.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB_C18_Getting_Started_51295d.pdf)
c18_libraries_2.4.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/C18_Lib_51297d.pdf)– details on timers, interrupts, and various other utility functions available to the programmer.
c18_users_guide_2.4.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/C18_UG__51288e.pdf) - table of max numbers each variable type will store, compiler options, error messages, detailed descriptions of pragmas and some other advanced topics.
2004/2005 RC Microchip pic18f8520 data sheet (http://ww1.microchip.com/downloads/en/DeviceDoc/39609b.pdf) - PIC assembly instruction set and details on EEPROM and other chip specific topics. Mistakes in the datasheet. (http://ww1.microchip.com/downloads/en/DeviceDoc/80157d.pdf)
2006 RC PIC18F8722 (http://ww1.microchip.com/downloads/en/DeviceDoc/39646b.pdf)datasheet and Errata (http://ww1.microchip.com/downloads/en/DeviceDoc/80221b.pdf).
Microchip PICmicro 18C MCU Family Reference Manual (http://ww1.microchip.com/downloads/en/DeviceDoc/39500a.pdf) – all things great and small (in excruciating detail) about the processors we use.
MPLAB Quick Start Guide.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/51281d.pdf) - basic how to use MPLAB and set options.
MPLAB Users Guide.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/51519a.pdf)

8. For the CMUCam2 sensor delivered in the Kit-Of-Parts (KOP):


Use the special Labview Calibration application mentioned here. (http://www.chiefdelphi.com/forums/showthread.php?t=41214) to focus and test the camera.
Use Kevin Watson’s (http://kevin.org/frc/) camera baseline program and his collection of camera documentation, but remember it only solves the headache of working the camera for you it doesn’t drive your robot.
Visit the ChiefDelphi Programming (http://www.chiefdelphi.com/forums) forum for discussions on all programming topics, problems, issues, and ideas.

Ryan M.
15-01-2006, 20:47
Hey Thanks fellas This is my first year and I'm a programmer and am used to C++, C isnt much different but I still need all the help I can get. Thanks.

-MattThere are many very willing people on CD... just remember we aren't mind readers. When you run into a question you can't find an answer to, ask that specifically. :)

Packmon's_girl
16-01-2006, 16:09
I tried to get a look at the dogle, and sorry for spelling mistakes now, but the link would not work.

Mark McLeod
16-01-2006, 16:28
Here’s an AndyMark dongle (http://www.andymark.biz/mode-switch.htm) you can purchase.

Here’s the wiring schemati (http://www.ifirobotics.com/docs/competition-port-pinout-guide-reva.pdf)c so you can make your own.

MattK
19-01-2006, 16:22
Here’s an AndyMark dongle (http://www.andymark.biz/mode-switch.htm) you can purchase.

Here’s the wiring schemati (http://www.ifirobotics.com/docs/competition-port-pinout-guide-reva.pdf)c so you can make your own.

Will these work with the '06 controler? Will a dongle bridging 5 and 8 activate autonomous?

pclements
21-01-2006, 11:35
This is a good overview. But all you people talking about having programming "teams" i ask you : how is it that you get a team, for my team its always just me. And new programmers out there don't be discuraged when you get blamed for *every* problem the robot has. And don't think that you will get any fame out of the robot even if it does work. Everyone else in the team gets that. But hey us programmers get to have all the fun so i soppose it's a fair trade. :D

I think that every body works hard as a team, there is no programmers if their is no robot! i think that some people need to get their priorities straight. if the robot is not built properly then their is no reason that programmers are needed. I have been trying to tell that to my fellow programmers that think their super man too.

Mark McLeod
22-01-2006, 11:32
Will these work with the '06 controler? Will a dongle bridging 5 and 8 activate autonomous?
Yes, the disable and Autonomous switches work on the '06 RC.
The "Practice" switch in the schematic no longer serves a purpose in post-2004 controllers.

aaronm_k
20-05-2006, 06:04
1) Programming will take more time than you expect, especially if you want autonomous to work. Tell the team that the robot needs to be driving and in your (the programmer's) hands with at least three days before shipping.
Or, more realistically, expect to spend all of your first Regional testing and debugging the code, since the robot wasn't finished even as it was being put in the crate.

2) Rookies: Don't program without sleep. Sure, you'll hear the experienced programmers bragging about a 36-hour code marathon, but all that means is that they are good at procrastinating. And working without sleep.
True, you won't be productive without sleep. Still, there's a certain perverse pleasure in being able to say "I slept no more than 4 hours in the 4 nights I spent at Nationals!"

6) When testing your robot, lift it off the ground. Prop it up somehow. This can save lives! (well, shins, anyways)
Better yet, have the mechanical team build a cart that allows the wheels to spin freely. If you're traveling by car or bus, you can bring it to the Regionals, where they don't let you drive your robot in the pit area. Also, have someone on the OI tether cable or radio modem cable at all times, ready to unplug it if the robot goes crazy. It really does keep people from getting run over by a 150lb robot!

Matt Krass
20-05-2006, 11:41
SNIP!
Also, have someone on the OI tether cable or radio modem cable at all times, ready to unplug it if the robot goes crazy. It really does keep people from getting run over by a 150lb robot!

For that purpose you should really develop an autonomous/disable dongle. The schematic is available from IFIs website here:
http://www.ifirobotics.com/docs/competition-port-pinout-guide-reva.pdf

This allows you to kill the robot from the OI instantly, with no doubt, and test autonomous mode as if the field activated it, so you don't need to play with the autonomous activation code and risk accidentally starting it mid-match (Been there!). I highly recommend a dongle for every team and if you're not confident in your skills at making one you can purchase from AndyMark here:
http://andymark.biz/mode-switch.htm

Some people also go with spring loaded switches, so all you have to do is let go and the robot is disabled, problem with those is they become a pain for longtime testing.

Eric Finn
15-09-2006, 19:16
A few basic tips:

Remember, your entire program is basically a loop. As such, you do not need to use loops, just ifs. And anyways, using loops will cause Bad Things™ to happen.
Counters should be static.
The fast user routines need to be executed in the alloted time. As such, do not do too much inside the fast user routines. You can increment a counter inside the fast user routines and do calculations with it in the slow user routines. If the fast user routine code takes longer than it is allowed to, Bad Things™ will happen.
On Software Testing/Ship Day, come early, bring lots of caffeine, bring lights and extension cords, and make sure some electrical and mechanical people are there, along with the tools they need. Do not expect to get to software testing until later in the day. Losing your cool on Software Testing/Ship Day can cause Bad Things™ to happen.
Document everything very well.
Do not work with input/output (I/O) ports by calling them by name. Use #define. Also, all the names of I/O ports are in IFI_aliases.h.
Convert analog input to digital.
kevin.org
Don't reinvent the wheel.
Many software problems can be solved by plugging wires in.
Kevin Watson hasn't figured out the accelerometer yet. He was working on it during the 05-06 build season.
If you use comment blocks, don't comment out code blocks. Use preprocessor commands (#if 0, #if 1, #else, #endif). If there is a comment block inside a commented-out code block, Bad Things™ will happen.
Spelling, semicolons, parenthesis, curly braces.
Syntax errors appear on the lines below missing semicolons.

Bored
16-01-2007, 17:23
Our main programmer that did most of the work went to a different school so I'm actually going to have to learn to code C this year.
This topic is a real help thanks guys.

udzap
16-01-2007, 17:28
Cool this is perfect for a beginner programmer as I.

marccenter
16-01-2007, 20:04
Mark,
I have already looked for some articles on autonomous programming and have found a few. Do you have a favorites list or best list for less experience autonomous programmers?

slloyd
17-01-2007, 00:40
hi peoples,

i just registered so that i could thank kevin for his work on the software and making it as dummy proof as possible - believe me i need it!

this is the first year our team has used the camera and it is quite the challenge. your code is readable, i can follow along with your train of thought & our team has a pretty bright student handling the guts of the camera work (i give him the hard stuff, while i just read manuals :o ). with these three things i think we have a fighting chance at getting a camera functional AND useful!

thx again, keep up the great work!

slloyd

Brad Voracek
17-01-2007, 00:51
Where do you guys get your D15 pin connectors for making the autonomous dongle? And also for game ports so you can wire switches to your control box etc... I can't seem to find these anywhere.

Phalanx
17-01-2007, 00:58
Where do you guys get your D15 pin connectors for making the autonomous dongle? And also for game ports so you can wire switches to your control box etc... I can't seem to find these anywhere.

Everything you should need can be had from Jameco:
15 Conductor 24 AWG Bulk Cable 100ft
http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&storeId=10001&catalogId=10001&productId=31844

Solder Cup D-Sub Connector, DB15 Male
http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&storeId=10001&catalogId=10001&productId=15035

Assembled Hood Kit, DB15/HD26 Gray
http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&storeId=10001&catalogId=10001&productId=15019

Toggle Switches - 2 State
http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&storeId=10001&catalogId=10001&pa=76523CG&productId=76523

Toggle Switches - 3 State
http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&storeId=10001&catalogId=10001&pa=21910CG&productId=21910

slavik262
20-01-2007, 12:07
Something else that's amazingly helpful is WPlLib. WPIlib simplifies programming a great deal by storing a vast majority of the code in a library file that is automatically called when ever you need it. No default code is needed. Further description, documentation, and downloads can be found here (http://users.wpi.edu/~bamiller/WPILib/). A thread on the subject is located here (http://www.chiefdelphi.com/forums/showthread.php?t=42237&highlight=WPIlib).

Mark McLeod
21-01-2007, 09:51
Overdue for updated links and accounting for 2007 changes...

2007 Programming Quick Start
1. Beginners need the following to program the FIRST robot:
v FRC (Full-size Robot Controller) RC Default Code
v Microchip MPLAB & C compiler (only from the Kit-of-Parts (KOP) CD) or Intelitek Easy C also in the KOP.
v IFI_Loader v1.1.0 (from the KOP CD)
v A standard serial cable
v A Windows PC with a serial port or USB-to-serial converter

2. Where to get everything:
-Basic default code, updates, documentation, and support information is available on the Innovation FIRST (IFI) (http://www.ifirobotics.com/rc.shtml) website, in particular at:
v 2007 default code (http://www.ifirobotics.com/docs/frc-code-2007-8722.zip) comes ready for basic driving and with a variety of sample I/O usages.
v Robot Controller (http://www.ifirobotics.com/rc.shtml)
v Operator Interface (http://www.ifirobotics.com/oi.shtml)
v CMUCam2 (http://www.ifirobotics.com/camera.shtml)
-The Camera default code for use with the CMUCam2 camera comes in two versions, one for the MPLAB native C programming environment and the other for the EasyC development environment.
The MPLAB version is available at the developer Kevin Watson’s (http://kevin.org/frc/) website. While there you’ll also find code examples for using other beneficial sensors. This default code may have the normal driving mode disabled.
-MPLAB is the FIRST supplied Windows based development environment (edit, compile, debug) that runs on your desktop computer and comes in the Kit-of-Parts wrapped inside the small clipboard. Manuals for using MPLAB come on the CD and are also found hosted on-line at Kevin Watson’s (http://kevin.org/frc/) website.
IFI_Loader v1.1.0 (http://www.ifirobotics.com/docs/ifi-loader-v1-1-0.zip) (also on the KOP CD) is used to download the compiled code into the RC via a serial cable from your desktop or laptop computer.
-EasyC from Intellitek can be used instead of MPLAB or as a rapid prototyping tool. It came in the KOP in the bag with the robotics magazines. The Main Contact of each team received an email from FIRST a software key to activate one installation of the software.
-- The EasyC version of the Camera default code for use with the CMUCam2 camera is available at Intelitek's (http://www.intelitekdownloads.com/easyCPRO/)website.

3. National Instruments Labview came in the kit-of-parts and has some optional special applications for the camera and OI dashboard among others have been provided in this Chiefdelphi thread (http://www.chiefdelphi.com/forums/showthread.php?t=41214) and discussions can be followed in the Chiefdelphi"]Chiefdelphi (http://[/SIZE) EasyC Pro forum.

4. WPI has developed a potentially useful approach to programming your robot. Details are at WPILIB (http://users.wpi.edu/~bamiller/WPILib/Versions.html)and discussions can be followed in the Chiefdelphi (http://www.chiefdelphi.com/forums/forumdisplay.php?f=157) WPILIB forum.

5. Check the IFI website periodically for updates to the software that corrects issues and fixes problems. For instance, new Master Controller “patches” if any, will be made available there. Directions will be included with any download.

6. The programming language used is “C”, EasyC, or PIC assembly. Tutorials in C can be found on the web, in your local bookstore or on the FIRST website, e.g.,
-- C Programming (http://www.usfirst.org/community/frc/content.aspx?id=482)Resource Library (http://www.usfirst.org/community/frc/content.aspx?id=482) has a great overview of the programming process.
-- Learn C Programming (http://www.rec.ri.cmu.edu/education/robot_builder/) - Developed by Carnegie Mellon and the National Robotics Engineering Consortium specifically for FIRST, this interactive website will get your team prepared for the FIRST Robotics Competition.

7. Newer laptops no longer come with the serial port required to download code to the Robot Controller. If you have one of these laptops a solution is to use a USB/Serial converter. Various models are available at Radio Shack, CompUSA, or online, however, some models can be temperamental and they generally take longer to download than a built-in serial port (60sec vs 10 sec). Good results have been reported using: Bafo Technologies BF-810 (~$15) and a Radio Shack USB-to-Serial port cable #26-183 ($42). You can also use the converter that comes with the Radio Shack Vex Programming Kit.

8. Documentation is your friend. Take the time to at least leaf through each manual, so you have an idea of where information can be found. Most of the basic information beginners require can be found in the IFI documents or MPLAB documents available from the websites:


The 2004 IFI Control System Overview (http://www.ifirobotics.com/docs/legacy/control-system-overview-2004-01-07.pdf) version applies to 2007 as well.
2005 IFI Programming Reference Guide (http://www.ifirobotics.com/docs/rc-ref-guide-01-31-2005.pdf) – basic how to hookup, program and download to the RC, hookup switches and sensors and do normal robot operations.
Useful programming and compiler documents come on the Kit provided MPLAB CBOT CD with the tool installations or are available from either Kevin Watson’s (http://kevin.org/frc/) website or the legacy section of the Microchip website.
v c18_getting_started_2.4.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB_C18_Getting_Started_51295d.pdf)v c18_libraries_2.4.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/C18_Lib_51297d.pdf)– details on timers, interrupts, and various other utility functions available to the programmer. v c18_users_guide_2.4.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/C18_UG__51288e.pdf) - table of max numbers each variable type will store, compiler options, error messages, detailed descriptions of pragmas and some other advanced topics. v Microchip pic18f8722 data sheet (http://ww1.microchip.com/downloads/en/DeviceDoc/39646b.pdf) - PIC assembly instruction set and details on EEPROM and other chip specific topics. Mistakes (https://webmail.provide.net/Redirect/ww1.microchip.com/downloads/en/DeviceDoc/80221c.pdf) found later after the datasheet was published.

v Microchip PICmicro 18C MCU Family Reference Manual (http://ww1.microchip.com/downloads/en/DeviceDoc/39500a.pdf) – all things great and small (in excruciating detail) about the processor we use. v MPLAB Quick Start Guide.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/51281d.pdf) - basic how to use MPLAB and set options. v MPLAB Users Guide.pdf (http://ww1.microchip.com/downloads/en/DeviceDoc/51519a.pdf) Visit the ChiefDelphi Programming (http://www.chiefdelphi.com/forums) forum for discussions on all programming topics, problems, issues, and ideas.

jesusescobar
21-01-2007, 19:20
Im experienced in programming but im new on FRC is that an advantage???

jesusescobar
21-01-2007, 19:52
I need help how can i program the robot controller to have my team number



how do i put my team number on a FRC Robot Controller

that is my question please help:confused:

Mark McLeod
21-01-2007, 21:36
You set your team number using the binary dip switches on the Operator Interface (OI) labeled "Team Number."

--Tether the OI and RC together.
--Power up the RC (the OI will get it's power through the tether).
--Press the "Select" button on the OI three times and it will display the current team number setting. As you change the dip switches you will see the team number display also change, so it's easy to verify you've set your team number correctly.
-- The left most dip switch is the most significant bit.

Each switch is "1" if the front is pressed down and "0" if the back of the switch is down.
You can figure out the binary number of your team, or start with all the switches set to zero then beginning at the left flip the switches one at a time. If the number you get after you flip a switch to "1" is lower than your team number, keep it. If the resulting number is higher put that dip switch back to zero and go to the next one on the right.

Mark McLeod
21-01-2007, 22:27
Sorry Marc. I didn't notice this right away.

I have some books I've taken excerpts from for the kids to read, such as
Programming Robot Controllers by Myke Predko
The Personal Robot Navigator by Miller, Winkless, and Bosworth
and some random articles I've used with students.
Obviously covering state machines, but also some behavioral programming, waypoint navigation, that type of thing.

I've found most kids respond most rapidly to programs structured as a series of lessons of increasing complexity where they can get down to experimenting with autonomous driving their first day on the job so to speak. (I purposely use robots that don't have remote controls.)

Mark,
I have already looked for some articles on autonomous programming and have found a few. Do you have a favorites list or best list for less experience autonomous programmers?

I'll have to think about a favorite articles list.

htwiz2002
25-01-2007, 11:24
Our main programmer that did most of the work went to a different school so I'm actually going to have to learn to code C this year.
This topic is a real help thanks guys.

Cool this is perfect for a beginner programmer as I.

Hopefully it will help now that more than one person is doing it :yikes:

Mib
28-01-2007, 14:10
this helped me soooo much. thank you all. this is our second yr competing and this is my first year in FIRST. i have a java background and a simple C background from 8th grade...but it was so long ago. :eek:

I'm the only one in charge of programming so when i was handed all these Cd's and codes and links and websites, i was pretty overwhelmed. i just learned about this today and I've spend the majority of the day looking through posts to answer my Q's

is there anyone here that i can directly e-mail or talk to if i have questions? (warning: I'm like a pet, i demand a lot of attn: i have questions everyday....or close to it) :(

also, everyone speaks about a "dongle" and i saw the picture and everything. but what exactly IS it? :confused:


its usually a piece of hardware (USB flash drive) that a program needs to be used in order for it to work

some programs allow them to be "virtual dongles" or a software dongle, but usually its a hardware device.


--------second point---------

New programmers might also check out Kevin's code and test it out. Testing and checking is a must!

Astronouth7303
05-02-2007, 22:56
its usually a piece of hardware (USB flash drive) that a program needs to be used in order for it to work

some programs allow them to be "virtual dongles" or a software dongle, but usually its a hardware device.

Usually when we, here, speak of "the dongle" or "a dongle", we refer to what connects to the competition port to enable/disable the robot and turn autonomous mode on/off. You can get the schematics from http://www.ifirobotics.com or buy one from AndyMark (http://andymark.biz/am-0016.html). They should be in the kit, since they are as much a safety precaution as a debugging aid.

When talking about the USB/Serial hardware, we usually use the term "adapter" (as in a USB-Serial adapter).

We rarely use the term "dongle" to describe a license device, since none of the software teams use requires one. (Correct me if I'm wrong.)

ProgrammerMike
10-01-2008, 18:01
ok, i have read all of this and it seems helpful for coding the robot in C....But we have easyC and it seems simple enough to just drag and drop and get teh code to the controller but i can't get it to do anything. I belive i have tried just about all options with it and still no results. Maybe i should give up eacyC and go with an actual C compiler. I don't know....i could really use some help....

This is my first time in any kind of robotics activity ever. Programming languages i know are VB, dark basic(not useful but jsut fun!), and a little bit of C++...Im the only programmer on my team so i really could use some help

Mark McLeod
10-01-2008, 18:47
Don't give up on EasyC.
You just need some direction.

Easy C Pro, the version FRC teams work with has it's own forum over here: http://www.chiefdelphi.com/forums/forumdisplay.php?f=164

Post your questions there.

Red Mage
16-01-2008, 18:51
I believe that the name EasyC is misleading, C is not that easy.

ShotgunNinja
31-01-2008, 18:59
What happened to the coder's update post for '07-'08? Look at the post dates.

And does anyone know how they want us to handle the new '08 version of Autonomous Mode, with the 4-button controller? The code platform for the older versions of MPLAB and even the code in the ROBOTC package just released doesn't seem to have the codes for interfacing with the 4-button controller, just the old Autonomous Mode codes. Is this just a futile question? Am I just completely not making any sense? :confused: Please help.

psy_wombats
31-01-2008, 19:04
You might want to try looking on the countless threads kicking about regarding the IR sensor... There should be a decent amount of information there, although, as far as interfacing the sensor, I believe it's a matter of four digital inputs and then just synchronizing the signal? Don't know, there are a lot of threads around, though.

ROFLcopter
18-02-2008, 21:21
We have hit a programmers worst nightmare. A cyber brick wall. No communication between the RC board and the computer. It's worked before, but for some reason, it took a giant dump on itself. We are so frustrated right now most of us just feel like dropping the tools and going home... :mad:

We are using a very noob friendly program called RobotC. This program is used for VEX but has an option to be used for FRC instead. Any other compatible programming is like a foreign language and we have no clue how to use it. If anyone has a miracle, we will display your name and achievement in big letters on our bumpers.

aerophd2001
09-03-2008, 10:56
*****************************
** The Rookie Programmer's Primer **
***** by Dr. Andrew Winslow ******
*****************************


What follows is a guide/list of do's and dont's for Rookie Teams to
help them get a focus of how to approach the programming process for
their "First" robot.

This guidebook is basically a list I've come up as I helped mentor
my First (USFirst.org *and* first-time mentor hehe) team. The team
itself was a Rookie team just as I was a Rookie mentor. Needless to
say, it was a tremendous learning experience for all involved.


Here we go:


************************************************** ********
************************************************** ********

Job #0: Access Code

Your zero'th job as a programmer will be to understand your programming
environment (EasyC, MPLAB, LabVIEW, etc..). You will need to know how
to use While Loops, If/Then/Else Statements, Declare Variables, create
Timers and Waits, and create Subroutines. All of these functionalities
of the language should be well understood to where you can perform them
with ease. You will also need to know how to download your code down onto
your bot's controller. Trust me when I say you will be doing this a lot,
so you should be able to push your code at a moments notice.

Note: COMMENT YOUR CODE!!! Placing comments throughout your code will
make your job easier and will also aid anyone else that may need to look
through your code. It is a real life-saver during debugging.

************************************************** ********
************************************************** ********

Job #1: Sunday Driver

Your first job as a programmer will be to get a basic driving program
written for your bot. Typically, most teams approach their chassis first,
so you should get this code going asap. Having a driveable bot will be a
great sense of achievement for your whole team and will fuel the desire
for more success. The team I was on was able to (in a 12 hour day),
complete the chassis and drive train, and get a basic 2-joystick tank
drive program downloaded onto the bot's controller. It was a wonderful
kickoff for our team and injected loads of enthusiasm that kept us coming
back for more.

************************************************** ********
************************************************** ********

Job #2: I Sense Trouble

Your second job as a programmer (after getting your chassis driving)
should be to start work on understanding all of the sensors shipped
in your First Kit. The benefit of this is that it is a programming task
that can be performed in parallel with the mechanical/electrical design
and fabrication. Here's the order I would recommend tackling them in:

1) Gear Tooth Sensors -

As a rookie team, you will likely not have time to work on the
more advanced sensors like CMU Cameras and such. This pair of
sensors, to be mounted near the drive sprockets on either side
of your bot, will ultimately enable you to have a bot that can
drive (roughly) straight, and then be able to turn corners at
programmed distances. This is the primary sensor needed to get
a basic program written to have your bot be able to run a
pre-programmed course *autonomously*. The 'pre-programmed' part
will take a bit of work and will require *dedicated access* to
a working chassis, so for starters, just work on understanding
how to measure the sensor. Once you have a program that can
measure this sensor properly, move on to the next sensor.

2) Contact Switches -

Contact Switches (a.k.a. Limit Switches) are integral to the
design of many bots. They will allow you to sense when an arm
or other moving part has reached a given location or attitude.
They can also be used on bumpers or other parts of your bot to
detect if it has contacted a wall or other obstruction.

3) IR Board -

This board will allow you to send up to 4 commands to your bot
using a common stereo or tv remote control. The team I was
mentoring never had time to get this sensor working and I greatly
regret not seeing the value it would have given to our bot.

4) Yaw Rate Gauge and Accelerometers -

Note: YOUR BOT WILL BE HIT! This is an unwritten fact. However,
successfully measuring these sensors will be able to tell you how
much your bot has been turned and moved by the collision. You can
then feed this information back to your Gear Tooth Sensor code to
be able to correct for the wheel-slippage and thus get you back
on track. If understanding these sensors starts taking too long,
they can be dropped and you can just run your bot autonomously
using a lot of faith and luck.

There may be more sensors your team has sketched into your design. If
the sensor is critical to the success of your bot, tackle them as well.
If it begins to take too long though to get them running, put them on
the back burner and move on to the next phase.

A side note on sensors: Have your electrical design such that the
robot controller board is easily removed from the bot. This will allow
the programming team can yank it out while the mechanical/electrical
teams are working on the rest of the bot. While it is removed, you can
connect your pc up to the programming port on it, connect your sensors,
and toy around with them without interfering with the other parts of
your team.

************************************************** ********
************************************************** ********

Job #3: It's All About Control

After getting your sensors up and running, you will need to start work
on the Controls for your bot. This involves all physical actions your
bot needs to do to perform its assigned task and includes all of your
bot's motors, actuators, and pneumatics. You should tackle these in
order of importance to your bot's design. If you have a lifting arm
that does most of the work, make sure you understand how to accurately
drive its motor so the arm gets where it needs to go. If you have
pneumatics, learn how to make your pistons extend and retract properly.

A design note here: For the actionable parts of your bot, try to
envision whether they will need to be controlled via analog or digital.
Any given action needs to be able to be set to either a range of values
(analog) or to purely on/off, up/down, or forward/backward values
(digital). Be sure to count all your inputs (sensors) and outputs
(controls) and make sure that the robot controller board has enough
I/O ports for the task.

************************************************** ********
************************************************** ********

Job #4: System Integration

This is the last step of the fabrication process. It is the process of
bringing all the parts together into a working whole. If all teams have
been working in parallel with one another, hopefully everyone should
reach this phase at nearly the same time (I did say *hopefully*).

Granted, the programming team may be a bit behind the others. This will
be due to the fact that you've been trying to write code for something
that you haven't had dedicated access to. This will likely be your
crunch time. Late nights will be spent here so be sure to stock up on
your favorite caffeinated beverage and memorize the phone number to the
local pizza delivery guy.

************************************************** ********
************************************************** ********

Job #5: This Is Just A Test

The final phase is testing. Test - Refine Code - Deploy - Lather - Rinse -
Repeat. One good thing about this phase is that you've already memorized
the phone number to the local pizza place. You may need to restock on
sodas though.

************************************************** ********
************************************************** ********


I hope this information can be used to help future Rookie Teams be able
to achieve as much success as can be had.

Good Luck!!!


- Andy

starsROBOTICS
27-03-2008, 21:16
can anyone tell me what macros, constants, and stuff like that are for? as in, what do they modify-Relays,PWM or what? and can i have an example of a code and tell me what it does to the robot?

SL8
28-03-2008, 13:28
can anyone tell me what macros, constants, and stuff like that are for? as in, what do they modify-Relays,PWM or what? and can i have an example of a code and tell me what it does to the robot?

I believe someone has said it before, but macros are basically find and replace commands that occur at compile time.
Instead of changing

pwm01=150;
to
pwm03=150;

You would just change a value assigned to the macro like
Left_wheel_pwms pwm03
It save a lot of time spent on hunting errors.

A constant is user defined such as
pi 3.14

and helps the compiler catch errors.

Sorry, can;t give code right now,no computer and I don't type very fast.

XXShadowXX
16-04-2008, 20:58
where can i find a gear tooth sensor code? Just post the link.
thank you in advance, team 2604.

Alan Anderson
16-04-2008, 22:21
where can i find a gear tooth sensor code? Just post the link.

Use the encoder (http://kevin.org/frc/frc_encoder.zip) code. Either ignore the Phase B connections, or tie the signal pins to +5, or change the interrupt service routine so that it always increments the counter without even looking at the Phase B signal.

whytheheckme
16-04-2008, 23:37
*****************************
** The Rookie Programmer's Primer **
***** by Dr. Andrew Winslow ******
*****************************


This should be stickied. It rocks!

Thanks Andy!!!!

Jacob