|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||||
|
|||||
|
Re: IR Sensor-tracker.zip
Quote:
tracker.c tracker.h Use the routines in the tracker s/w as a guide to changes in the rest of the code. Add in user_routines.c: Code:
#include "receiver.h" #include "tracker.h" Code:
Initialize_Receiver(); /* not required as it's also called by Initialize_Tracker() */ Initialize_Tracker(); Code:
else if (INTCONbits.RBIF) // external interrupts 3 through 6
{
Port_B = PORTB; // remove the "mismatch condition" by reading port b
INTCONbits.RBIF = 0; // clear the interrupt flag
Port_B_Delta = Port_B ^ Old_Port_B; // determine which bits have changed
Old_Port_B = Port_B; // save a copy of port b for next time around
if(Port_B_Delta & 0x10) // did external interrupt 3 change state? - IR sensor 1
{
Int_3_Handler(Port_B & 0x10 ? 1 : 0); // call the interrupt 3 handler (in receiver.c)
}
if(Port_B_Delta & 0x20) // did external interrupt 4 change state? - IR sensor 2
{
Int_4_Handler(Port_B & 0x20 ? 1 : 0); // call the interrupt 4 handler (in receiver.c)
}
if(Port_B_Delta & 0x40) // did external interrupt 5 change state? - IR sensor 3
{
Int_5_Handler(Port_B & 0x40 ? 1 : 0); // call the interrupt 5 handler (in receiver.c)
}
if(Port_B_Delta & 0x80) // did external interrupt 6 change state? - IR sensor 4
{
Int_6_Handler(Port_B & 0x80 ? 1 : 0); // call the interrupt 6 handler (in receiver.c)
}
}
Code:
static unsigned int Old_Clock = 0;
if (Clock > Old_Clock) // stay synchronized to beacon data updates (this is important)
{
Track_Beacon(LEFT); // allow the left beacon tracker state machine to run
Track_Beacon(RIGHT); // allow the right beacon tracker state machine to run
if ((Tracker_Data[left].Status == BOTH_IN_VIEW) &&
(Tracker_Data[right].Status == BOTH_IN_VIEW))
{
// both trackers have an angular solution; calculate beacon vector
// here using the known baseline distance between the trackers and
// angles derived from the two Tracker_Data[].Position variables
// calculate new drive motor PWM values here
}
// finally, update the servo motor positions
LEFT_TRACKER_SERVO = Tracker_Data[left].Position;
RIGHT_TRACKER_SERVO = Tracker_Data[right].Position;
Old_Clock = Clock; // take a snapshot of the clock
}
Last edited by Mark McLeod : 03-02-2004 at 14:31. |
|
#2
|
||||
|
||||
|
Re: IR Sensor-tracker.zip
Quote:
-Kevin |
|
#3
|
|||||
|
|||||
|
Re: IR Sensor-tracker.zip
Quote:
I guess it's hard to #include files you forgot to add in. Thanks Kevin! |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|