|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Problems Combining Camera Code and Driving Code
I have both the camera code and the driving code working independently
, but I've been having some trouble combining them. I've added both user_SerialDrv.c and user_SerialDrv.h to the camera code and uncommented the IFI code in user_routines.c as well as in user_routines_fast.c. I've also tried to change the pwm output assignments of either our two drive motors or the camera servos. When I left the servos on pwm01 and pwm02 and changed the pwms for the motors the camera worked and the driving didn't. When I switched them the driving worked and the camera didn't, in fact, the camera just sat there and twitched. Then, I assigned the servos to pwm01 and pwm02 and the motors to pwm05 and pwm06. The camera froze in home position and the driving worked for about 30 seconds before halting and displaying a code error. If anyone has any idea how I can fix this I'd really appreciate it.Thanks |
|
#2
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
Quote:
-Kevin |
|
#3
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
I'm kind of in the same boat, and will be working on combining them this week. If I discover the secrets, I'll post...
I'll be eager to see if you find anything out as well! |
|
#4
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
Quote:
(1) As Kevin says, the camera's serial code needs serial.c and serial.h from his code, and not the user_SerialDrv.c/h. You need to remove those from the project. (2) Similarly, Kevin's serial code requires the interrupt routines in user_routines_fast.c to be correct (if you don't have this correct, you'll get the red light of death). If you aren't using other special interrupt code (encoders or the gyro), just copy user_routines_fast.c from Kevin's camera code and try that. Otherwise, you'll have to make sure all the appropriate interrupt handlers are in place for all the codes you are using. This can be done, our bot's testbed code now has the camera, gyro, shaft encoders, and two additional ADC channels running at the same time, but it's tricky and requires careful reading of the adc_readme.txt, encoder_readme.txt, camera_readme.txt, etc. (And we didn't get it right the first time, as you can see if you look the other places I've posted). |
|
#5
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
Quote:
-Kevin |
|
#6
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
Quote:
|
|
#7
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
Thanks
The problem was definately with SerialDrv.c/.h I didn't have problems with user_routines_fast.c because I started with the camera code and adapted that for driving. Thanks for all your help. It works wonderfully now and the next challenge is getting the camera to track using the motor on our rotating turret. Thanks again and thanks for all the great code Kevin. You rock. |
|
#8
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
Quote:
When combining the camera and interrupt code, how many timer interrupts are required? Any other details? So far I'm still getting the RLOD!!!! Jon Mittelman Team236 |
|
#9
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
Quote:
We do use all of those, and it's working fine. Here's our InterruptHandlerLow: Code:
#pragma code
#pragma interruptlow InterruptHandlerLow save=PROD,section(".tmpdata")
void InterruptHandlerLow(void)
{
unsigned char Port_B;
unsigned char Port_B_Delta;
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.TMR2IF && PIE1bits.TMR2IE) // timer 2 interrupt?
{
PIR1bits.TMR2IF = 0; // clear the timer 2 interrupt flag [92]
Timer_2_Int_Handler(); // call the timer 2 interrupt handler (in adc.c)
}
else if(PIR1bits.ADIF && PIE1bits.ADIE) // ADC interrupt
{
PIR1bits.ADIF = 0; // clear the ADC interrupt flag
ADC_Int_Handler(); // call the ADC interrupt handler (in adc.c)
}
else if (INTCON3bits.INT2IF && INTCON3bits.INT2IE) // encoder 1 interrupt?
{
INTCON3bits.INT2IF = 0; // clear the interrupt flag
#ifdef ENABLE_ENCODER_1
Encoder_1_Int_Handler(); // call the left encoder interrupt handler (in encoder.c)
#endif
}
else if (INTCON3bits.INT3IF && INTCON3bits.INT3IE) // encoder 2 interrupt?
{
INTCON3bits.INT3IF = 0; // clear the interrupt flag
#ifdef ENABLE_ENCODER_2
Encoder_2_Int_Handler(); // call right encoder interrupt handler (in encoder.c)
#endif
}
else if (INTCONbits.RBIF && INTCONbits.RBIE) // encoder 3-6 interrupt?
{
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?
{
#ifdef ENABLE_ENCODER_3
Encoder_3_Int_Handler(Port_B & 0x10 ? 1 : 0); // call the encoder 3 interrupt handler (in encoder.c)
#endif
}
if(Port_B_Delta & 0x20) // did external interrupt 4 change state?
{
#ifdef ENABLE_ENCODER_4
Encoder_4_Int_Handler(Port_B & 0x20 ? 1 : 0); // call the encoder 4 interrupt handler (in encoder.c)
#endif
}
if(Port_B_Delta & 0x40) // did external interrupt 5 change state?
{
#ifdef ENABLE_ENCODER_5
Encoder_5_Int_Handler(Port_B & 0x40 ? 1 : 0); // call the encoder 5 interrupt handler (in encoder.c)
#endif
}
if(Port_B_Delta & 0x80) // did external interrupt 6 change state?
{
#ifdef ENABLE_ENCODER_6
Encoder_6_Int_Handler(Port_B & 0x80 ? 1 : 0); // call the encoder 6 interrupt handler (in encoder.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
}
}
|
|
#10
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
Quote:
Any other thoughts? Jon |
|
#11
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
Quote:
|
|
#12
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
Quote:
Sure, here it is Jon |
|
#13
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
Quote:
|
|
#14
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
Quote:
Jon |
|
#15
|
||||
|
||||
|
Re: Problems Combining Camera Code and Driving Code
I took the camera code and adjusted that for driving, but I've just been using the camera project so there already is no srl_dvr.c/h or whatever the exact name is. Everything works great except that p2_y does nothing and I cant figure out why. I commented out the camera stuff in Process_Data_From_Master_uP and now it works fine so i know they are conflicting, but i can't find where. I thought at first it was with the pwm's but I already changed the defaults to 5 and 6 for the camera as our motors use 1-4. I'm not really familiar with the tx and rx and interupt stuff you guys were talking about. I mean i know what tx and rx datas are, but idk what u guys are talking about messing with them, I just leave that stuff alone cuz im not quite that advanced.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| heres the code. y this not working | omega | Programming | 16 | 31-03-2004 15:18 |
| What is wrong with this code???? It won't Compile and I don't know why? Please Help | CrashZero | Programming | 23 | 26-03-2004 09:44 |