Go to Post ...before we ship the robot, they have to make me understand how it works. - Beth Sweet [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 17-02-2005, 22:20
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Interrupt not occuring.

I've spent a couple days looking at this.. and I can't figure out why the one interrupt will not fire. We have 2 of the hall effect sensors being used as wheel encoders. The hardware on both is working fine, thats not the problem. (I swapped the cables around, and got values). The problem I'm having is one of the interrupts will not fire at all.

Code:
void InterruptHandlerLow()
{
	unsigned char int_byte;
	if (INTCON3.bitsINT2IF && INTCON3bits.INT2IE) {
		INTCON3bits.INT2IF = 0;
		right_enc++;
	}
	if (INTCON3bits.INT3IF && INTCON3bits.INT3IE) {
		INTCON3bits.INT3IF = 0;
		left_enc++;
	}
}


void Initialze_Encoders(void) {
	TRISBbits.TRISB2 = 1;
	INTCON3bits.IN2IP = 0;
	INTCON2bits.INTEDG2 = 1;
	INTCON3bits.INT2IE = 1;
	
	TRISBbits.TRISB3 = 1;
	INTCON2bits.INT3IP = 0;
	INTCON2bits.INTEDG3 = 1;
	INTCON3bits.INT3IE = 1;
}
The interrupt on digital IO 1 will not fire. They are both set as inputs.. the second one works, but not the first. I'm certain its not the RC or the encoder, as I've tried on the 2004 and 2005 RC, and swapping which input they are in makes whichever is on port 2 work.

I'm out of ideas.. can't see why one works and not the other.

(Yes, I know increasing the variable there is probably not a good idea.. but once I get it working, I'm going back to the other encoder functions)
  #2   Spotlight this post!  
Unread 17-02-2005, 22:45
Kris Verdeyen's Avatar
Kris Verdeyen Kris Verdeyen is offline
LSR Emcee/Alamo Game Announcer
FRC #0118 (Robonauts)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 2001
Location: Houston, TX
Posts: 699
Kris Verdeyen has a reputation beyond reputeKris Verdeyen has a reputation beyond reputeKris Verdeyen has a reputation beyond reputeKris Verdeyen has a reputation beyond reputeKris Verdeyen has a reputation beyond reputeKris Verdeyen has a reputation beyond reputeKris Verdeyen has a reputation beyond reputeKris Verdeyen has a reputation beyond reputeKris Verdeyen has a reputation beyond reputeKris Verdeyen has a reputation beyond reputeKris Verdeyen has a reputation beyond repute
Re: Interrupt not occuring.

Quote:
Originally Posted by devicenull
INTCON3bits.IN2IP = 0;

Should it be INTCON3bits.INT2IP ? Dunno if this typo is in your code - it seems like it oughtn't compile if that were the case.

I checked all of the silly things - it looks like all of the bits are in the correct registers, but again, that's more of an assembly problem, not a C problem - the complier would catch it if it was wrong.
__________________
...Only a few people are awake and they live in a state of constant total amazement. -JP Shanley, Joe vs. the Volcano
  #3   Spotlight this post!  
Unread 18-02-2005, 19:38
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: Interrupt not occuring.

Sorry, that was from me typing it into the box. in the code its what you said.

They still aren't working correctly.. even when it should be. Anything else I can try?
  #4   Spotlight this post!  
Unread 18-02-2005, 21:02
Manoel's Avatar
Manoel Manoel is offline
Registered User
FRC #0383 (Brazilian Machine)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 2000
Location: Porto Alegre, RS, Brazil
Posts: 608
Manoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond reputeManoel has a reputation beyond repute
Send a message via ICQ to Manoel Send a message via MSN to Manoel
Re: Interrupt not occuring.

Quote:
Originally Posted by devicenull
Sorry, that was from me typing it into the box. in the code its what you said.

They still aren't working correctly.. even when it should be. Anything else I can try?
How do you know they do not fire? Are you simply printing your right_enc and left_enc variables? If that's the case, then maybe your problem isn't related to the interrupt, but to your printf statement. We had the same problem described in this post, maybe you are making the same mistake. Check it out.
__________________
Manoel Flores da Cunha
Mentor
Brazilian Machine
Team # 383
  #5   Spotlight this post!  
Unread 18-02-2005, 21:46
devicenull devicenull is offline
Robot? We need a robot?
no team
 
Join Date: Sep 2004
Rookie Year: 1234
Location: n/a
Posts: 359
devicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nicedevicenull is just really nice
Re: Interrupt not occuring.

Quote:
Originally Posted by Manoel
How do you know they do not fire? Are you simply printing your right_enc and left_enc variables? If that's the case, then maybe your problem isn't related to the interrupt, but to your printf statement. We had the same problem described in this post, maybe you are making the same mistake. Check it out.
Yea, that was it, don I feel stupid now
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems Initializing Serial Driver... neilsonster Programming 0 13-02-2005 23:27
heres the code. y this not working omega Programming 16 31-03-2004 15:18
Timer interrupt hic-cupping - HELP roknjohn Programming 9 15-03-2004 17:56
Interrupt Handlers and Variable Scope kaszeta Programming 2 14-02-2004 18:30
Interrupts Questions mightywombat Programming 0 03-01-2004 14:50


All times are GMT -5. The time now is 19:16.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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