|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Encoders not changing...
i implemented the encoder file from Kevin's site... but it doesn't work. I plugged it in to what it said, and i update it with:
Code:
LeftWheelCount = Get_Encoder_1_Count();
RightWheelCount = Get_Encoder_2_Count();
|
|
#2
|
||||
|
||||
|
Re: Encoders not changing...
what other code is being implemented are you using the camera?...GTS?...timers?...other sensors?
make sure the encoder outputs are plugged into the correct inputs. make sure you are using the right type of encoder, I believe that kevin watson has his code set up for a quadrature encoder. also make sure that you call all the right functions in the right places ie. encoder_counter() in Interrupt_Vector_low(), encoder1_init() in user_init(). another problem that happened to me was overlapping interrupts. If you do a "find in project" for a bit in the register to see if they are used anywhere else, you may eliminate this problem. |
|
#3
|
||||
|
||||
|
Re: Encoders not changing...
Did you follow the steps in the readme that came with the encode code.. such as adding the initialization call?
|
|
#4
|
||||
|
||||
|
Re: Encoders not changing...
i did follow the steps in the initialization. i am also using the camera. I'll check the encoder type. Where do i find what kind they are exactly? I do call Initialize_encoders() in initialization, and i call interupt handler low from Default routine.
Last edited by paulcd2000 : 04-02-2007 at 11:23. Reason: grammar |
|
#5
|
|||||
|
|||||
|
Re: Encoders not changing...
Don't do that.
The interrupt handler is "called" by a hardware feature of the processor. You don't have to do anything more than define it as the interrupt handler. |
|
#6
|
||||
|
||||
|
Re: Encoders not changing...
k thanks... still haven't gotten a chance to test again
EDIT: nope, still doesn't work... Last edited by paulcd2000 : 04-02-2007 at 12:49. Reason: update |
|
#7
|
|||||
|
|||||
|
Re: Encoders not changing...
How do you know the encoders are not changing? Are you simply trying to print your xxxxWheelCount variables to a terminal and noticed they don't change?
If so, then that's likely the only problem and your encoders are just fine. Your variables are probably declared long int and, as such, you need to typecast them before printing. Try the following: Code:
printf("Left encoder = %d", (int)LeftWheelCount\r\n);
|
|
#8
|
||||
|
||||
|
Re: Encoders not changing...
actually, they're not longs. they're ints. a long can hold up to 2147483648, which is about a mile. i just used ints. they're printed using
Code:
printf("Left Encoder: %d\t Right Encoder: %d\r", LeftWheelCnt, RightWheelCnt);
|
|
#9
|
||||
|
||||
|
Re: Encoders not changing...
did anyone have to change their encoder code to get it working? what did you do? cuz ours still isn't working
|
|
#10
|
|||||
|
|||||
|
Re: Encoders not changing...
Quote:
That's it. It was painless. |
|
#11
|
||||
|
||||
|
Re: Encoders not changing...
does the type of encoder affect the code? where did you guys get your encoders?
|
|
#12
|
|||||
|
|||||
|
Re: Encoders not changing...
Are you sure the RC is reading the sensors correctly?
What I did to test our GTS's last year was put the last 4 PWMs in User_CCP mode (digital outputs should work equally well) and have the interrupt handler toggle that. I then hooked an oscilloscope to both the GTS and the CCP pin. The wave forms matched nearly perfectly. In terms of software, the GTS and encoders should be very similar, ignoring direction. Even just putting an LED on the output pin and watching its apparent brightness should be helpful. (You probably won't see flickering, as it goes too fast.) If that works, you may need to post your code so that we can look at it. |
|
#13
|
||||
|
||||
|
Re: Encoders not changing...
i've got one last test to determine if the problem is programming or electrical/mechanical at the root. In interrupt handler low:
Code:
else if (INTCON3bits.INT2IF && INTCON3bits.INT2IE) // encoder 1 interrupt?
{
INTCON3bits.INT2IF = 0; // clear the interrupt flag
#ifdef ENABLE_ENCODER_1
--> puts("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
--> puts("2");
Encoder_2_Int_Handler(); // call right encoder interrupt handler (in encoder.c)
#endif
}
|
|
#14
|
||||
|
||||
|
Re: Encoders not changing...
I finally fixed it!!!! yES!! But i have no idea why it didn't work. Oh well... Thank you, everyone, for your help!
|
|
#15
|
|||
|
|||
|
Re: Encoders not changing...
Any chance in sharing what you did (I know the post is late). We are having problems with the code as well, and have ruled out the possibility of a problem with the encoders with an oscilloscope.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Changing Fields? | Steve W | Championship Event | 8 | 08-04-2003 19:37 |
| Changing Chairman's | Jacqui Sutton | Chairman's Award | 1 | 03-04-2003 09:47 |
| Changing gears | archiver | 2000 | 1 | 23-06-2002 23:26 |
| ::CHANGING SERVERS:: | Brandon Martus | General Forum | 5 | 21-12-2001 10:33 |
| changing my name | Travis Covington | CD Forum Support | 1 | 09-10-2001 08:37 |