View Single Post
  #7   Spotlight this post!  
Unread 04-02-2008, 10:46
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 323
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Re: Ultrasonic sensors on digital ports 3-6 problems

In my ISR in user_routines_fast.c I have:

Code:
else if(INTCONbits.RBIF && INCONbits.RBIE)
{
       int_byte = PORTB;
       INTCONbits.RBIF = 0;
       Ultrasonic_Interrupt_Routine(int_byte);
}
That and in my initialize are the only places that I look at the actual register

I tried two things so far, so I am thinking maybe its a problem where I am comparing the 1-0 or 0-1 change on each? Also from what you are saying, there can be multiple changes at once, saying that I should have a different variable for the different sensors because if two of them change, the last port checked will get the data back. Here is what is happening as of now. I have two variables that I have printing back in the ISR. One where it looks for a 1 and one where it looks for a 0.

Code:
if(Triggered_Port & 0x10)
        {
            if(int_byte & 0x10)
            {                
                //reset the timer;
	           TMR3H = 0x00;
	           TMR3L = 0x00;
	           phasetest++;
            }
            else
            {
                //turn off the timer
                T3CONbits.TMR3ON = 0;
                Ultrasonic_Number=3;
                //INTCONbits.RBIE = 0;				
            }
        }
I switched the if and else around and instead of getting 35 and 25 I get a much higher number. I guess that means that it is getting a fairly static time? I also unplugged the sensor while it was running and the values went to 0, so atleast my interrupts are firing somewhat correctly. The two variables move up by 2 at the same time if I have a fairly long delay between my ping() and getdistance() calls.

Thank you very much for your help so far!


Edit: When I changed sensors to make sure it worked my output value changed by about 20, I guess that means that it is timing some set thing about the sensors?
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -

Last edited by wt200999 : 04-02-2008 at 10:49.