View Single Post
  #1   Spotlight this post!  
Unread 11-02-2006, 18:38
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,185
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Serial Driver and 2K6 Encoder Driver Not compatible

Has anyone else had this problem?

The 2k6 encoder driver works fine on its own. The 2k6 serial driver works fine on its own. Combining them would be easy enough, right?

We have combined them with the interrupt handler below. When what should be interrupt 1 fires (Dig In 1), the Encoder 2 count goes up. (When E2 is positive, E1 is -1. When E2 is negative, E1 is 0) When what is supposed to be Encoder 2 (dig in 2) fires, the Encoder 4 count changes, and the same pattern happens on E3 that happed on E1.

Also, no matter what the tick delta is, E4 always fluctuates in the same direction (backwards in relation to the bot.

Code:
#pragma interruptlow InterruptHandlerLow save=PROD,section("MATH_DATA"),section(".tmpdata")

void InterruptHandlerLow()     
{
	if (PIR1bits.RC1IF && PIE1bits.RC1IE) // rx1 interrupt?
	{
		#ifdef ENABLE_SERIAL_PORT_ONE_RX
		Rx_1_Int_Handler(); // call the rx1 interrupt handler (in serial_ports.c)
		#endif
	}                              
	else if (PIR3bits.RC2IF && PIE3bits.RC2IE) // rx2 interrupt?
	{
		#ifdef ENABLE_SERIAL_PORT_TWO_RX
		Rx_2_Int_Handler(); // call the rx2 interrupt handler (in serial_ports.c)
		#endif
	} 
	else if (PIR1bits.TX1IF && PIE1bits.TX1IE) // tx1 interrupt?
	{
		#ifdef ENABLE_SERIAL_PORT_ONE_TX
		Tx_1_Int_Handler(); // call the tx1 interrupt handler (in serial_ports.c)
		#endif
	}                              
	else if (PIR3bits.TX2IF && PIE3bits.TX2IE) // tx2 interrupt?
	{
		#ifdef ENABLE_SERIAL_PORT_TWO_TX
		Tx_2_Int_Handler(); // call the tx2 interrupt handler (in serial_ports.c)
		#endif
	}
	if (INTCON3bits.INT2IF && INTCON3bits.INT2IE) // left encoder interrupt?
	{ 
		INTCON3bits.INT2IF = 0; // clear the interrupt flag [91]
		Left_Encoder_Int_Handler(); // call the left encoder interrupt handler (in encoder.c)
		stdout_serial_port=SERIAL_PORT_ONE;
		printf("int 1\r");
		stdout_serial_port=SERIAL_PORT_TWO;
	}
	if (INTCON3bits.INT3IF && INTCON3bits.INT3IE) // right encoder interrupt?
	{
		INTCON3bits.INT3IF = 0; // clear the interrupt flag [91]
		Right_Encoder_Int_Handler(); // call right encoder interrupt handler (in encoder.c)
		stdout_serial_port=SERIAL_PORT_ONE;
		printf("int 2\r");
		stdout_serial_port=SERIAL_PORT_TWO;
	}



}
Any ideas?