|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
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){
}
Last edited by Richard McClellan : 13-01-2008 at 21:15. Reason: typo |
|
#2
|
|||||
|
|||||
|
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? |
|
#3
|
||||
|
||||
|
Re: Issues with our code
Yes, our robot was not disabled, but we have make that mistake before too
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. |
|
#4
|
|||||
|
|||||
|
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. Last edited by Branden Ghena : 13-01-2008 at 21:30. Reason: I can't stand typos |
|
#5
|
||||
|
||||
|
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. |
|
#6
|
||||
|
||||
|
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.
|
|
#7
|
||||
|
||||
|
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.
|
|
#8
|
||||
|
||||
|
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. |
|
#9
|
|||
|
|||
|
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 |
|
#10
|
||||
|
||||
|
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? Last edited by Richard McClellan : 18-01-2008 at 11:21. Reason: added second paragraph |
|
#11
|
|||
|
|||
|
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.
|
|
#12
|
||||
|
||||
|
Re: Issues with our code
Thanks, Brad! That new pwm code fixed it! PWM's 13-16 are now good.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| EasyC master code issues | Joe G. | Programming | 2 | 14-12-2007 11:28 |
| Code Flashing Issues | bluenp | Programming | 4 | 07-11-2007 23:43 |
| need help with our default code | coolguybigt | Programming | 14 | 19-02-2007 10:17 |
| Issues with encoder code | jgannon | Programming | 7 | 26-03-2006 15:12 |
| Issues with MPLAB 7.30 | gnirts | Programming | 4 | 25-01-2006 22:57 |