|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Does anyone know how to go about using the optical encoders (as in a mouse) w/interrupts in our new controllers?
I have two for each axis coming out of the mouse I got at the WRRF programming seminar, and I'd like to use them. Thanks! |
|
#2
|
||||
|
||||
|
Along these lines...
a) What encoders from Digikey have teams had success with? What part numbers? Are these up for the rigors of competition? b) Where do most teams mount encoders on the wheel shafts? on a special gear for encoding? c) How counts per revolutoin (CPR) do most teams use? What design strategy do most teams use when seleteting CPR and encoders in general? d) Custom circuits? Or us RC PIC interrupts directly? What the trade-offs? Just curiuos. |
|
#3
|
||||
|
||||
|
Re: Optical Encoders
Quote:
-Kevin |
|
#4
|
|||||
|
|||||
|
Re: Optical Encoders
Kevin, Great work on the interupt coding. You saved be a good deal of time looking for the names of the bits I needed to set. I think I noticed an error where the bits for timers 3 and 4 were polled in user_routines_fast.c:
else if (PIR1bits.TMR1IF) // timer 3 interrupt? { PIR2bits.TMR3IF = 0; // clear the timer 3 interrupt flag [93] Timer_3_Int_Handler(); // call the timer 3 interrupt handler (in interrupts.c) } else if (PIR1bits.TMR2IF) // timer 4 interrupt? { PIR3bits.TMR4IF = 0; // clear the timer 4 interrupt flag [94] Timer_4_Int_Handler(); // call the timer 4 interrupt handler (in interrupts.c) } Should it be "else if (PIR2bits.TMR3IF)" and "else if (PIR3bits.TMR4IF)"? I do things like that all the time after copying chunks of code. Thanks again. |
|
#5
|
||||
|
||||
|
Re: Optical Encoders
So wait, I don't quite understand how to use interrupts. Are those macros you're using to refer to interrupt pins? Do I have to write code that invokes the handler?
|
|
#6
|
||||
|
||||
|
Re: Optical Encoders
Quote:
Ugh, you're right and it does look like I just copied the lines above and forgot to change the if() statements. Thanks for catching that. I've updated the code on the website. -Kevin |
|
#7
|
||||
|
||||
|
Re: Optical Encoders
Quote:
Quote:
What you do need to do is configure the interrupt hardware so it knows how to behave (e.g., interrupt on the rising-edge or falling-edge of the signal on the interrupt pin). Have a look at the interrupt initialization routines for a description of the various ways to configure an interrupt. Also have a look at user_routines_fast.c because this is where the interrupt handlers are mapped to the different types of interrupts. My goal is to get folks using interrupts, so if you have additional questions, ask away. -Kevin |
|
#8
|
||||
|
||||
|
Re: Optical Encoders
Okay, I'll post questions as I come across them.
To start, how are all those structs in picdefs 'memory mapped'? |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Who used wheel encoders | CyberWolf_22 | Technical Discussion | 12 | 04-05-2003 15:37 |
| optical sensors | majormusic2005 | Electrical | 5 | 11-03-2003 21:32 |
| Q&A Discuss: optical sensors | CD47-Bot | Extra Discussion | 0 | 15-02-2003 22:58 |
| optical sensors | great_one411 | General Forum | 1 | 15-02-2003 19:54 |
| range of optical sensors | Allie | Technical Discussion | 1 | 29-01-2002 09:09 |