|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Reading an encoder with interrupts
I started with EasyC, and then moved to MPLab using EasyC libraries. Now I am trying to get the same functionality by making the necessary changes to the VexCode source (user_routines.[ch] and user_routines_fast.c). I am trying to count clicks of the shaft encoder using an interrupt and I've been analyzing the user_routines_sensor_test_fast.c code as an example. The comment at the top that "Encoder not ready yet" had me worried but I saw a lot of code associated with it so I read on
With few comments in the code associated with the encoder, its tough for a beginner to work out the behavior. VexLabs makes it clear that they don't support the code so I thought I would ask and see if anyone here can lend some guidance.Has anyone here used this example successfuly? Would you mind explaining how the encoder interrupt handler works with the timer2 interrupt handler? Does anyone have another (possibly clearer) example they would like to share? Can someone explain why they would make this assignment: rc_dig_out11 ^= 1; rather than rc_dig_out11 = 1; ? Its a digital output so would there be a difference? I see quite a few uninitialized variables. EncoderDataTickCounter is an example. It is declared and incremented but never initialized. Must not be an issue for some reason. In the interrupt handler, EncoderDataFlag.bit1 is set but I don't see anywhere that it is cleared. The comment says it indicates that data is ready to be read. I will keep working on the problem and report back if I have anything useful for others in the same situation. Thanks for your time, -Glenn |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem with reading and writing EEPROM | DKolberg | Programming | 4 | 16-03-2004 19:29 |
| Help with pots/interrupts | mtrawls | Programming | 10 | 24-02-2004 17:01 |
| EDU Demo Code: Encoder Interfacing Using Interrupts | Kevin Watson | Programming | 4 | 08-01-2004 23:14 |
| help with Interrupts | thoughtful | Programming | 5 | 08-01-2004 16:07 |
| Problem with interrupts on the PIC | Mike Betts | Programming | 7 | 16-12-2003 21:26 |