Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   New C18 3.0+ Compatible FRC Code (http://www.chiefdelphi.com/forums/showthread.php?t=60377)

Kevin Watson 21-01-2008 16:03

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by comphappy (Post 682936)
Red light of death. Code compiles fine. I then go into programming mode open the loader give it the hex file and it attempts of load. The file is loaded in, but the code error light stays solid, reset, same thing. It is not really an issue for me, as I am sticking with the old code (early version of the v3 compiler), but I do not quite get what is going on. Do you want the hex file that i generate?

Make sure you have enabled the timer 4 interrupt in ifi_frc.h. Not doing this will cause the RLOD. Can you zip up your code and send it to me?

-Kevin

Guy Davidson 21-01-2008 18:25

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Kevin Watson (Post 680623)
Okay, here is a snapshot of the current build that includes support for encoders and gyro:

http://kevin.org/frc/ifi_frc_beta_4.zip

*Please* help me out and have a look at the code and documentation (start with readme.txt) and provide feedback before I go public with the code on my website, which I'd like to do on Friday or early Saturday. If you can, follow the directions in readme.txt to build the code and test with your encoder(s) and/or gyro and report any problems here. Thanks.

-Kevin

The link is broken. I'll be happy to test beta 4 once I can get my hands on it.

-Guy Davidson

billbo911 21-01-2008 20:09

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by sumadin (Post 683034)
The link is broken. I'll be happy to test beta 4 once I can get my hands on it.

-Guy Davidson

New and edited link on the first page. Or, go to his web site. The full and simple versions are up.

Jon236 21-01-2008 21:39

Re: New C18 3.0+ Compatible FRC Code
 
Kevin,

Now that I enabled the ISR's (grin) everything works fine. No need to include sonar code this year as the MaxBotix sensors have an analog output.

comphappy 21-01-2008 21:48

Re: New C18 3.0+ Compatible FRC Code
 
Hmmm i dont know what the issue was, (i did have ISR enabled) I just now recompiled the code and loaded it, no issues. Serial communications issue on the load... I dont know.

fffxc2 22-01-2008 19:03

Re: New C18 3.0+ Compatible FRC Code
 
Hello, this is my first year doing the programming on my team and we are having a very confusing problem. We are using an unmodified version of Kevin’s 2008 beta code with mplab v8 and c18 v3.1 and the code compiles fine and loads onto the robot fine, and it seems run on the robot, but the robot doesn't react at all. Its equally frustrating because when we load a copy of the 2007 code it works fine. It seems that no one else has had this problem (that I saw), though it seemed that Kevin referenced it in one of his posts.

Quote:

the LEDs are green, but nothing happens
Any help we could get would be much appreciated.

comphappy 22-01-2008 19:51

Re: New C18 3.0+ Compatible FRC Code
 
With out any code that is going to be hard to help you with, are you in teleop mode? What code do you have in your teleop function?

Kevin Watson 22-01-2008 21:06

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by fffxc2 (Post 683834)
Hello, this is my first year doing the programming on my team and we are having a very confusing problem. We are using an unmodified version of Kevin’s 2008 beta code with mplab v8 and c18 v3.1 and the code compiles fine and loads onto the robot fine, and it seems run on the robot, but the robot doesn't react at all. Its equally frustrating because when we load a copy of the 2007 code it works fine. It seems that no one else has had this problem (that I saw), though it seemed that Kevin referenced it in one of his posts.



Any help we could get would be much appreciated.

Because I don't know how you have your robot configured, you need to write this code yourself. Just open up teleop.c and scroll down to the teleop() function. Once there, you can map joystick inputs to motor outputs like this:

Code:


// map y-axis of the joystick on operator interface port #1 to the
// motor controlled by the Victor 883 attached to PWM output #1
pwm01 = p1_y;
 
// map y-axis of the joystick on operator interface port #2 to the
// motor controlled by the Victor 883 attached to PWM output #2
pwm02 = p2_y;

You can also use IFI's default robot code by uncommenting (remove the double slashes) in front of the call to Default_Routine() at the bottom of Teleop(). The code for Default_Routine() is located in ifi_code.c.

-Kevin

RyanN 23-01-2008 14:11

Re: New C18 3.0+ Compatible FRC Code
 
2 Attachment(s)
I'm having a variety of problems, with the new code(http://www.kevin.org/frc/ifi_frc_sensor_30.zip), and the old encoder code (http://www.kevin.org/frc/frc_encoder.zip).

First off, I'll talk about the problems we were having with frc_encoder. When I had MPLAB 7.20 installed and was using v2.4 of the C18 compiler, everything compiled, and the encoders worked great on the robot. Here was the problem... there seemed to be about a 1/2 second delay between the robot receiving data from the OI, so I would move a joystick, then it would take 1/2 a second for the motors to start moving. I would release the joystick, and it would take 1/2 a second to stop (I almost had a bad incident with our new 80lb robot running me over).

Okay, now for the 3.0 compatible code.
I have MPLAB 8.00 installed and version 3.10 of the C18 compiler.
I can compile the code as it is downloaded no problem, but when I try to initialize encoder 1 and encoder 2 using the code where i take out the //, it fails at the link step:

MPLINK 4.1, Linker
Copyright (c) 2006 Microchip Technology Inc.
Error - could not find definition of symbol 'Initialize_Encoder_2' in file 'C:\Robot Code\2008\ifi_frc_sensor_30\teleop.o'.
Errors : 1

If I comment out "Initialize_Encoder_2" it will say the same thing about encoder 1.

Is my MPLINK out of date, since it says 2006?

Here are some snapshots of MPLAB with my horrible hand-eye coordination with my trackpad: :D

Attachment 6102

Attachment 6107

The other 4 errors are with this part of code:
Code:

        // Remove the // below to initialize encoder #1
        Initialize_Encoder_1();

        // Remove the // below to initialize encoder #2
        Initialize_Encoder_2();

//Skipped a bunch of code here to save you time reading this.  The code exists in my version.


        if(i == 37 && j >= 191)
        {
                Encoder_Count = Get_Encoder_1_Count();
                printf("E1=%d\r\n",(int)Encoder_Count);
       
                Encoder_Count = Get_Encoder_2_Count();
                printf("E2=%d\r\n",(int)Encoder_Count);
       
        /*        Encoder_Count = Get_Encoder_3_Count();
                printf("E3=%d\r\n",(int)Encoder_Count);
       
                Encoder_Count = Get_Encoder_4_Count();
                printf("E4=%d\r\n",(int)Encoder_Count);
       
                Encoder_Count = Get_Encoder_5_Count();
                printf("E5=%d\r\n",(int)Encoder_Count);
       
                Encoder_Count = Get_Encoder_6_Count();
                printf("E6=%d\r\n\r\n",(int)Encoder_Count); */
        }

Hopefully this gives you enough information to solve my problem.

Kevin Watson 23-01-2008 14:30

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by RyanN (Post 684338)
First off, I'll talk about the problems we were having with frc_encoder. When I had MPLAB 7.20 installed and was using v2.4 of the C18 compiler, everything compiled, and the encoders worked great on the robot. Here was the problem... there seemed to be about a 1/2 second delay between the robot receiving data from the OI, so I would move a joystick, then it would take 1/2 a second for the motors to start moving. I would release the joystick, and it would take 1/2 a second to stop (I almost had a bad incident with our new 80lb robot running me over).

I'm not sure what you want me to do about this.

Quote:

Originally Posted by RyanN (Post 684338)
Hopefully this gives you enough information to solve my problem.

Yep, it appears you didn't follow the detailed instructions in readme.txt :rolleyes:.

-Kevin

RyanN 23-01-2008 14:36

Re: New C18 3.0+ Compatible FRC Code
 
Oops, I never saw the pesky README. :D I already see what I did wrong, and I will edit this post a bit later to tell you if I got it working.

Also, the link to the beta4 software doesn't want to work.

Thanks for the quick response though... I was hectically trying to get this code working because our programming mentor is about to go to Indonesia on business.

EDIT: I got it working! Thanks a bunch!

Mib 23-01-2008 18:05

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by Kevin Watson (Post 665235)
If I get the sense teams will use the new code, I'll create versions with support for some sensors.

-Kevin

We'll be using ultrasonic sensors as well as a gear count. Though, I don't think that teams that are already modifying your code should have too much of a problem reading data from the digital inputs.

Thanks a lot for the code, saves a great deal of time.

PhilBot 24-01-2008 00:13

Re: New C18 3.0+ Compatible FRC Code
 
I think I've found a bug in the Gyro code....

I know... it seems unlikely considering how long it's been in service, but this problem has been bugging me for a while and I finally got the clues I needed to locate it. Here is the function.

Quote:

int Get_Gyro_Rate(void)
{
// Return the calculated gyro rate to the caller.
return((int)((((long)gyro_rate * GYRO_SENSITIVITY * 5L) / ADC_RANGE)) * GYRO_CAL_FACTOR);
}
I was calling this function and displaying the return value, but it never got above 32 or below -32, and it seemed to flip signs at the oddest times.

I think the problem is that GYRO_CAL_FACTOR is defined as 1000/1000, but the multiplication is being done AFTER the prior expression is cast to an integer... Therefore if ((((long)gyro_rate * GYRO_SENSITIVITY * 5L) / ADC_RANGE)) calculates to anything above 32 or below -32, then multiplying it by 1000 will cause the number to exceed the valid range of an integer.

I think the second to last bracket is misplaced... I think it should be:

return((int)((((long)gyro_rate * GYRO_SENSITIVITY * 5L) / ADC_RANGE) * GYRO_CAL_FACTOR));

I'm going to try it tomorrow...

I'm just greatful I didn't have to write this code....
Thankyou Kevin... really.

Phil.

Kevin Watson 24-01-2008 03:04

Re: New C18 3.0+ Compatible FRC Code
 
Quote:

Originally Posted by PhilBot (Post 684799)
I think I've found a bug in the Gyro code....

Okay, I'll have a look at it. I'm working on what I hope is the final release, so now is a good time to fix any bugs. Assuming it's a real bug, thanks for finding it.

Quote:

Originally Posted by PhilBot (Post 684799)
I know... it seems unlikely considering how long it's been in service.

It's not too suprising. I think most, if not all, people are using the the Get_Gyro_Angle() function, which wouldn't be effected by a bug in the Get_Gyro_Rate function.

-Kevin

Manoel 24-01-2008 12:07

Re: New C18 3.0+ Compatible FRC Code
 
Kevin,

Would it be too much to ask for an updated library for the EDU-RC? ;)


All times are GMT -5. The time now is 10:12.

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