Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Interrupt issue with new code (http://www.chiefdelphi.com/forums/showthread.php?t=60608)

EHaskins 03-01-2008 21:37

Interrupt issue with new code
 
2 Attachment(s)
I've been trying to write the drive code for my current prototype drive, but I'm having issues.

This is the setup:
Hardware:
BaneBots gearbox connected to pwm01
Banebots encoder kit and encoder divider board installed on the gearbox.
Divider direction connected to rc_dig_in07
Divider speed connected to rc_dig_in03

Software:
Kevin's new code
In "interrupts.h"
#define ENABLE_INT_3_6 un-commented
In "teleop.c"
"Initialize_Int_3_6();" added to Initialization() where comments indicate.
Code:

void Teleop(void)
{
        static int i, j;
        i ++;
        j ++;

        if (i > 20)
        {
                printf("Encoder 1 Direction = %d\r\n", (int)ENCODER_ONE_DIRECTION);
                printf("Encoder 1 = %d\r\n\r\n", (int)Encoder_One_Count());
                i = 0;
        }

            //Run motor to demomstrate proper functioning
        if (j < 100)
        {
                Motor(1, 50);//in drive.c
        }
        else if (j < 150)
        {
                Motor(1, 0);
        }
        else if (j < 250)
        {
                Motor(1, -50);
        }
        else if (j < 300)
        {
                Motor(1, 0);
        }
        else
        {
                j = 0;
        }
        //Update_OI_LEDs();        // located in ifi_code.c
}

In "interrupts.c"
Call to "Encoder_One_Tick()"(in Drive.c) added in Int_3_Handler

EDIT: I attached the drive.c/.h files
The Direction displays correctly, but the count is always 0.

I'm sure I forgot something really simple, but I can't figure it out.

I'll send the complete project to anyone who wants to look at it.

billbo911 04-01-2008 01:32

Re: Interrupt issue with new code
 
Quote:

Originally Posted by EHaskins (Post 667333)
I've been trying to write the drive code for my current prototype drive, but I'm having issues.

This is the setup:
Hardware:
BaneBots gearbox connected to pwm01
Banebots encoder kit and encoder divider board installed on the gearbox.
Divider direction connected to rc_dig_in07
Divider speed connected to rc_dig_in03

Software:
Kevin's new code
In "interrupts.h"
#define ENABLE_INT_3_6 un-commented
In "teleop.c"
"Initialize_Int_3_6();" added to Initialization() where comments indicate.
Code:

void Teleop(void)
{
        static int i, j;
        i ++;
        j ++;

        if (i > 20)
        {
                printf("Encoder 1 Direction = %d\r\n", (int)ENCODER_ONE_DIRECTION);
                printf("Encoder 1 = %d\r\n\r\n", (int)Encoder_One_Count());
                i = 0;
        }

            //Run motor to demomstrate proper functioning
        if (j < 100)
        {
                Motor(1, 50);//in drive.c
        }
        else if (j < 150)
        {
                Motor(1, 0);
        }
        else if (j < 250)
        {
                Motor(1, -50);
        }
        else if (j < 300)
        {
                Motor(1, 0);
        }
        else
        {
                j = 0;
        }
        //Update_OI_LEDs();        // located in ifi_code.c
}

In "interrupts.c"
Call to "Encoder_One_Tick()"(in Drive.c) added in Int_3_Handler

EDIT: I attached the drive.c/.h files
The Direction displays correctly, but the count is always 0.

I'm sure I forgot something really simple, but I can't figure it out.

I'll send the complete project to anyone who wants to look at it.

I think you are right. The error looks simple to me as well. I think the reason you aren't seeing the count change is because the code in your ISR to do the increment/decrement is commented out. It looks like it should work correctly if the whack whacks and whack star and star whacks were removed.

Code:

void Encoder_One_Tick(void)
{
        //if (ENCODER_ONE_DIRECTION)
        //{
                _countOne ++;
        /*}
        else
        {
                _countOne --;
        }*/
}


EHaskins 04-01-2008 02:57

Re: Interrupt issue with new code
 
Quote:

Originally Posted by billbo911 (Post 667427)
I think you are right. The error looks simple to me as well. I think the reason you aren't seeing the count change is because the code in your ISR to do the increment/decrement is commented out. It looks like it should work correctly if the whack whacks and whack star and star whacks were removed.

Code:

void Encoder_One_Tick(void)
{
        //if (ENCODER_ONE_DIRECTION)
        //{
                _countOne ++;
        /*}
        else
        {
                _countOne --;
        }*/
}



I commented that out when I realized I was having issues. The Bolded line is not commented out.

Kevin Watson 04-01-2008 03:25

Re: Interrupt issue with new code
 
Quote:

Originally Posted by EHaskins (Post 667333)
I'm sure I forgot something really simple, but I can't figure it out.

No, I suspect it's the bug mentioned in this post:

http://www.chiefdelphi.com/forums/sh...0&postcount=78

-Kevin

EHaskins 04-01-2008 21:42

Re: Interrupt issue with new code
 
Quote:

Originally Posted by Kevin Watson (Post 667434)
No, I suspect it's the bug mentioned in this post:

http://www.chiefdelphi.com/forums/sh...0&postcount=78

-Kevin

I have corrected that, but it still isn't working. Any ideas?

EDIT: I tried changing to interrupt 1, but still nothing.

Kevin Watson 04-01-2008 23:25

Re: Interrupt issue with new code
 
If it'll help, here's the latest code with encoder support:

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

-Kevin

EHaskins 05-01-2008 00:27

Re: Interrupt issue with new code
 
Quote:

Originally Posted by Kevin Watson (Post 667947)
If it'll help, here's the latest code with encoder support:

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

-Kevin

Works great. I would have liked to know what I missed, but this works.:)

Thanks!


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

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