Go to Post Just remember, FIRST isn't about the robot, just have fun, meet new people, and try to learn something new. Killing yourself with inhumane amounts of pressure just isn't fun for anyone. - Ian W. [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 15-04-2006, 13:26
intellec7's Avatar
intellec7 intellec7 is offline
108 programmer
AKA: Gustavo
FRC #0108 (SigmaC@ts)
Team Role: Programmer
 
Join Date: Sep 2005
Rookie Year: 2006
Location: Hollywood, Florida
Posts: 65
intellec7 is on a distinguished road
Send a message via AIM to intellec7 Send a message via MSN to intellec7
Reading interupt pin as Standard IO

I am trying to generate code that reads the pulswidth of a signal. I am avoiding use of Interupt pins 1 and 2 for later use. As my code is set up, I am trying to read the pulsewidth on pin 3. (BTW this is the Vex controller, I don't think it should make a difference though)
The code:
Code:
#define accel_x		rc_dig_int3

.......
  else if (INTCONbits.RBIF && INTCONbits.RBIE)  /* Ints 3-6 (RB4, RB5, RB6, or RB7) changed. */
  {
    int_byte = PORTB;          /* You must read or write to PORTB */
	if(accel_x){
		WriteTimer1( 0x00 );
		T1CONbits.TMR1ON = 1; // turn it on
	}
	else if (!accel_x){
			T1CONbits.TMR1ON = 0; // turn it off
			accel_xTilt= ReadTimer1();
			WriteTimer1( 0x00 );
		}
	

    INTCONbits.RBIF = 0;     /*     and clear the interrupt flag         */
  }
I had a suspicion that maybe I am reading the pin incorrectly, so I set up:
Code:
void Process_Data_From_Local_IO(void){
if(accel_x){printf("ON\n");}
else if (!accel_x){printf("OFF\n");}
}
It works, but it seems that there is a lag. Forexample I hooked up a normal switch to the pin. On the terminal I get
0n
0n
....
I then press the switch
0n
0n
0n
....................... (Ons for about another second)
Off
Off

It is the same for the 0ff to On transition.
I thought maybe for some reason my ISR was consuming to much time, explaining the delay, and so I took all of my code out an left the default:
Code:
...
 else if (INTCONbits.RBIF && INTCONbits.RBIE)  /* Ints 3-6 (RB4, RB5, RB6, or RB7) changed. */
  {
    int_byte = PORTB;          /* You must read or write to PORTB */
    INTCONbits.RBIF = 0;     /*     and clear the interrupt flag         */
  }                                        /*     to clear the interrupt condition.  */
Thanks for anyhelp.
 


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
VEX inputs Andrew Blair FIRST Tech Challenge 22 31-05-2006 18:17
Encoders and putdata theycallhimtom Programming 3 09-02-2006 19:24
Attatching an axel to a wheel Zoheb N Technical Discussion 36 12-12-2005 13:43
Dynamic Input/Output Changing Paolo Control System 6 23-09-2004 19:09
4 pin EDU PWM out power, red pin2 V in error Dale(294engr] Electrical 4 13-02-2004 03:03


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

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