Last Minute Programmer - Need Help!

Hi,
Our teams programmer has the flu and will not be able to attend our first regional, the VCU regional. noone else knows how to program the bot. Does anyone know any really good quick start tutorials for programming the bot that i could look at? Obviously i can’t program our real code until thursday, but if anyone could point me to resources to show me how to take standard joystick inputs (the variable parts and the button parts) and do random math and conditional logic on them to set some outputs (to either a victor or a spike) i would really appreciate it. I’ve programmed in other languages before but have never touched the Robots 1’s and 0’s before. THanks in advance for all your help, while i wait for a response i will look through the standard code and any resources i find from FIRST.

Also, if anyone has some spare time tonight and wants to talk me through some stuff my AIM is alboo2002, and i would love to chat :slight_smile:

You are going to be hard pressed to learn how to program in a night… if you have wired robots before, it might be possible to learn the basics. How familiar are you with the robot’s electrical system? (PS my AIM is in my profile and I would be happy to help, but I may be a bit distracted… I am working on an AP Computer Science program right now) I’ll also be at VCU, in case you need some help while you are there, just drop by 587’s pit and ask for Luke.

I know there are wires going in with inputs and wires leaving to the spikes and victors with outputs. Ive been looking over the standard code some already tonight. is it as simple as taking the input values from the joysticks (either a -127,127] or a [0,1]), doing math on them, and setting outputs to victors and spikes as -127,127] and [0,1] respectively?

EDIT: and we arent using pnumatics, so i think that simplifies things

Sort of. The joystick analogs give values from 0->254 and the pwms also run on a 0->254 scale, with 0 being full reverse and 254 being full forward. Spikes are a bit different. There are two program variables used to control them, a rev and fwd for each spike. You set one to zero and the other to one to give power in a direction and zero to both for neutral. (1 for forward and 0 for reverse makes gives a full forward output, for example)

EDIT: What I am saying is relevant to MPLAB code using IFI or Kevin’s codebases. I don’t know anything about RobotC or EasyC… and its been a while since I used WPIlib.

ok cool, thanks. MPLAB, is that free form anywhere so i can poke around with it? what specific applications and/or libraries should i download tonight?

What are you using now to look through the default code?

(Why do I get the strange feeling his next question is going to be “Default code? What’s that?”)

OK, it depends on what you’re most comfortable with, but if time is of the essence, not elegance or finer control, then consider Easy-C. You can literally write joystick control for 2 or 4 Victors plus some random controls for Spikes in less than 15 minutes.

It is drag & drop, with just some simple parameterization.

On the other hand, with a complex bot, you run out of flexibility soon enough.

On Thursday morning at VCU, the **first thing you must do **is go to Pit Administration and send an announcement for “Major programming help”, you’ll get a few good offers, and at least get the bot rolling while you learn and code the finer points.

Don

I would agree that Easy-C would be the way to go right now as long as what you need done is simple enough. Btw you should have your programmer run through his code with you ( unless there isn’t any). There are tutorials in Easy-C. The program should have come in the kit. What have you all been using? ( I have a feeling that you have not programmed much yet.

MPLAB is Free!
However… I don’t believe this version will work with version 2.40 of the C18 compiler (a compiler is what takes the code you write, and converts it to code the robot understands) The C18 compiler is not free, but you should have received it in the kit.

As for the default code, you have 3 choices

  1. IFI’s Default Code
  2. Kevin Watson’s Code
  3. Make Your Own (very bad decision for 3 days left)

I’ve used IFI’s code in the past, and it works perfectly…
I’ve also used Kevin’s Code, and it works perfectly…
I haven’t tried to make my own code from scratch, nor do I even want to imagine it…

I would start with IFI’s code as it already has code to make the robot move, and a lot more sample code. Basically, a PWM output will range from 0 to 255 A spike has 2 inputs relayX_fwd and relayX_rev. To make it go forward, fwd must equal 1, and rev must equal 0, and vice versa. If both equal 1 or 0, then the spike will turn off.

Remember semicolons after almost everything;

In a condition statement, remember to use double equal signs == and when setting something, use only one equal sign = if (xvariable == 0) reset = 1;]

With Kevin’s code, the MPLAB shown above will work. I’m not sure where to quote where it says that you must use MPLAB version 7.4 or below with IFI’s code, but I’m pretty sure it says that somewhere (it’s not a rule, but the code won’t compile with a version 7.4 with IFI’s code).

My best advice would be to to go the school and work on an old robot. Put the robot on blocks so it doesn’t run off on its own with a computer dragging behind it.

Hopefully this isn’t too messy and will aid you in your hard time.

thanks everybody, especially john from 587, I’ll throw something together thursday morning at VCU then hopefully someone with the compiler can help me out and i can see how many errors i made :slight_smile:

i still dont fully understand interrupts, but it looks like these things might come together for me. thanks everyone, especially 587, for the help!

if pwms 4 and 5 are your left drive motors, and 6 and 7 are your right drive motors, you can do this for a single joystick drive (assuming you use IFI’s code):

pwm04 = pwm05 = Limit_Mix(2000 + p1_y - p1_x + 127);
pwm06 = pwm07 = Limit_Mix(2000 + p1_y + p1_x - 127);

That will get you some basic drive capabilities with the port1 joystick. Keep in mind, if you use IFI’s default code, that all the variables to control the robot that you would ever need are in “ifi_aliases.h”.

interrupts are like tiny peices of code that will execute in response to something. With an interrupt, though, the code that is currently running is ‘interrupted’, and the processor will jump to another part of the code, do what it needs to, and jump back. That ‘another part of the code’ is the “interrupt_handler_low()” routine in user_routines_fast.c. Configurating an interrupt to work in the first place is half the battle… i would suggest taking a look at kevin watson’s encoder code to get an idea how to set one up.

HEY!

Slow down for a minute!

Hopefully your programmer has given you the basics of the code in the robot in the box. Was it written in MPLAB or Easy C?

The default code will give you general control of the robot in tele-operating mode. Hopefully, this capability is already done for you.

It’s important to have a map. Get to know what the PWM signals used are doing. What are the Digital I/O signal pins and Analog signal pins connected to?

Without this, you cannot write effective software in either language platform.

If your teammates are looking to you to write autonomous, good luck in MPLAB. You would be wise to find a guru or alliance partner willing to help you to write a routine that could get you a few points based on your sensor capabilities.

If your tele-operated code is already in Easy C, Then it’s is easier for you. Find another guru versed in Easy C to help.

My experience is someone knowing Easy C may not have the skills necessary to write Code in MPLAB, but someone knowing MPLAB may be able to convert code from Easy C to MPLAB. You are better selecting a platform to use and sticking to it. I have no success in combining the two into one effective program. The libraries are totally different.

It is far more difficult to convert from MPLAB to Easy C than vice versa.

Look at your base code and understand it’s capabilities before tinkering with it and ALWAYS back up the software before making ANY changes. You will be glad you did.

Good Luck a VCU.