Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Issues with our code (http://www.chiefdelphi.com/forums/showthread.php?t=61619)

Richard McClellan 13-01-2008 21:14

Issues with our code
 
We're moving to WPILib this year and are having a few issues getting our code working with the FRC controller. We tested it out quite a bit on the Vex robots last fall and it worked great, but we tried downloading to last year's FRC bot for the first time today and couldn't get it to work.

The code below compiles and downloads, but does nothing after that. We were trying to get basic drive working first with the Tank2 function (We have one CIM motor on each side, plugged into PWM ports 13 and 15). Then we commented out the Tank2 function to see if we could just get the motors to turn on at all with the SetPWM function, and that didn't work either. Any ideas what we're doing wrong?

We are using MPLab v8.00, the C18 Compiler v2.40, and IFILoader v1.10.

Code:

#include "BuiltIns.h"

void IO_Initialization(void) {
        SetCompetitionMode(1);
}

void Initialize(void) {
        DefineControllerIO(INPUT, INPUT, INPUT, INPUT, INPUT, INPUT, INPUT, INPUT, INPUT,
                                          INPUT, INPUT, INPUT, INPUT, INPUT, INPUT, INPUT, INPUT, INPUT);
}

void Autonomous(void) {
        printf("Autonomous\r");
        while(1) {
                printf("In Autonomous\r");
                SetPWM(13, 50);
                SetPWM(15, 50);
        }
}

void OperatorControl(void) {
        printf("OperatorControl\r");
        while(1) {
                printf("In OperatorControl\r");
                SetPWM(13, 50);
                SetPWM(15, 50);
                //Tank2(1, Y_AXIS, 2, Y_AXIS, 13, 15, 0, 1);
        }
}

void main(void){
}


Branden Ghena 13-01-2008 21:19

Re: Issues with our code
 
Do you have your robot enabled on the operator interface? (done that WAY too many times)

Otherwise looks good. Are you getting your printf text?

Richard McClellan 13-01-2008 21:24

Re: Issues with our code
 
Yes, our robot was not disabled, but we have make that mistake before too :rolleyes:

We tried it both with and without the autonomous switch on and it didn't work either way.

And, the printf's do work. They run continuously, inside our while(1) loops. It prints "In Autonomous" when the our auto switch is on, and prints "In OperatorControl" when the auto switch is off.

Branden Ghena 13-01-2008 21:28

Re: Issues with our code
 
Are you sure it's not a physical problem?

i.e. are the fuses in, do the victors light up when the program is running, are your pwms plugged in all the way, do you have a fully charged battery?

I know, probably not your mistake, but I can't see anything wrong with the code.

Richard McClellan 13-01-2008 21:31

Re: Issues with our code
 
Well, the Victors are flashing orange, so they're not getting any signal at all. Does WPILib initialize all the pwm's to zero like the default code does? Should these be getting any signal?

We also tried loading our code from last year (default FRC code) and it worked fine, so I'm thinking it's not a hardware problem.

btgdaniel 17-01-2008 18:58

Re: Issues with our code
 
Did you ever get WPIlib to work? We are having the *exact* same problem. No outputs to PWMs, last year's code works fine. A little more info: (1) joystick input seems to work; (2) analog input works.

Redneck 17-01-2008 19:07

Re: Issues with our code
 
We've been having the same problem. Using WPI Lib, we cannot get any output on PWMs 13-16. We tried using the SetPWM() function, along with Motor(), Motors() and Drive(), all to no effect. We also tried using WPI Lib with the IFI header files and setting the PWMs using the aliases from ifi_aliases.h, and again 13-16 are non-responsive. When using the default IFI code by itself, we can control them just fine.

Richard McClellan 18-01-2008 03:03

Re: Issues with our code
 
Well, I'm not exactly sure what we did, but it is working now. Unfortunately, I don't know exactly what fixed it, but here's a few things to check:

Download the latest firmware to the RC, which can be found here:
http://www.ifirobotics.com/docs/frc-master-ver15.zip
Try tethering to the OI at least once first.
The OI needs to be on and communicating properly for the RC to output to anything.
Make sure you have your backup battery plugged in.

BradAMiller 18-01-2008 10:55

Re: Issues with our code
 
There are issues with the PWM ports 13-16 since they are controller by the user processor. Try the program with ports 1-12 instead. I think the motors will start working.

Brad

Richard McClellan 18-01-2008 11:15

Re: Issues with our code
 
That actually makes a lot of sense now! We got our code working on our new RC (using PWM 1&2), but the old one wasn't working (using PWM 13&15). We didn't originally change the old RC ports because on last year's robot it is very difficult to access and requires unscrewing a lot of electronic components. We're planning on making this year's much easier to access.

Does this mean that we will be limited to 12 PWM ports if we use WPILib? Or is there any way to use 13-16? Right now we're only planning on using 10 PWM ports, so we should be okay, but would we have room to expand to more than 12 ports?

BradAMiller 19-01-2008 10:07

Re: Issues with our code
 
Kevin Watson wrote some code last year that allowed control of the extra PWMs in your user program. It works with easyC and WPILib and can be integrated easily into an existing program. You can find the explanation here.

btgdaniel 19-01-2008 15:14

Re: Issues with our code
 
Thanks, Brad! That new pwm code fixed it! PWM's 13-16 are now good.

Ryan O 22-01-2008 12:20

Re: Issues with our code
 
Hi,

We are also having problems with our gyro. I plug it in to port one, as init, start it, ect. It gives zero for awhile, then starts increasing and doesn't stop, even if the gyro isn't moving. Any help would be great.

BradAMiller 22-01-2008 16:00

Re: Issues with our code
 
Quote:

Originally Posted by Ryan O (Post 683542)
Hi,

We are also having problems with our gyro. I plug it in to port one, as init, start it, ect. It gives zero for awhile, then starts increasing and doesn't stop, even if the gyro isn't moving. Any help would be great.

Make sure it's plugged into an analog port rather than a digital port.

The gyro returns the rate of rotation as an analog value - where no rotation is will return a value around 512 (center).

You can easily test if the gyro is working by running easyC and opening the Online Window. Load the Online code into the robot and look on the screen at analog port 1. Now you should be able to twist the gyro (or robot if it's attached) and see the analog values jump from a centered value around 512 to either smaller or larger numbers for left and right twists. Remember, the value will only change while the robot is moving since it is measuring rate of rotation, not the heading.

Ryan O 23-01-2008 13:45

Re: Issues with our code
 
Thank you. It is in an analog port, and we are using the WPILib function GetGyroangle(port), whcih is supposed to give us a heading through integration. Have you had any problems with that?


All times are GMT -5. The time now is 00:50.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi