|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Third Encoder Channel
Yo. I'm new to encoders. From what I can understand, the default code at Kevin Watson's website only allows for two channels: the first channel uses analog inputs 1 & 6, and the second uses analog inputs 2 & 8. Does anyone know how to create a third encoder channel? Any help will be highly appreciated. Thank you.
|
|
#2
|
||||
|
||||
|
Re: Third Encoder Channel
Quote:
|
|
#3
|
|||||
|
|||||
|
Re: Third Encoder Channel
Quote:
We're using three encoders. Two of them are on pins 1&7 and 2&8, using essentially Kevin's code. The third is on pins 3&9, with a few lines of interrupt initialization and service routine copied from Kevin's interrupts.c to dispatch the third encoder's handler when INT4 occurs. There is also an extra check to call the handler only when INT4 was triggered by a falling edge of the signal on pin 3. (That part of the code seems a little inconsistent, as if the input pin were going low and then high again before we had a chance to look at it. I'm considering wiring in a hardware pulse-stretch circuit to deal with it.) To avoid extra interrupts that we would just have to ignore, we have nothing connected to pins 4-6. |
|
#4
|
||||
|
||||
|
Re: Third Encoder Channel
Quote:
The simplest way to do this is with a D-type flip-flop (e.g., 74ACT74, 74HCT74, 74LS74, etc.). The encoder's phase-A signal goes to the the clock input and the RC interrupt input. The phase-B signal goes to the flip-flop's D input and the Q output goes to the RC digital input formally used by the phase-B signal. I prototyped this circuit and saw a pretty dramatic increase in the maximum count rate that the RC could handle. -Kevin |
|
#5
|
||||
|
||||
|
Re: Third Encoder Channel
Quote:
1) Must interrupts 3-6 be enabled/disabled as a package? i.e. you cannot ONLY enable 3, but not 4-6? I am using two encoders and the Hall Effect sensor, and need only 3 interrupts, and would rather not have to enable 6 of them. 2) If Q1 is true, and we enable 3-6, should we move the phase-B signal on I/O 6 to 7 in order to avoid unnecessary interrupts? 3) Does phase stretching circuit described in the threads above allow a faster count rate because it prevents the phase-B state from changing (to the wrong state) before the interrupt is serviced? I know some of these should be pretty obvious, but Team 188 is running the Grayhill 63R256 encoders, and our count rates are pretty high. I'm hoping to stave off any interrupt issues that might arise =). -SlimBoJones... |
|
#6
|
||||
|
||||
|
Re: Third Encoder Channel
Quote:
Quote:
Quote:
Quote:
-Kevin |
|
#7
|
||||
|
||||
|
Re: Third Encoder Channel
Quote:
-Kevin |
|
#8
|
|||
|
|||
|
Re: Third Encoder Channel
Quote:
|
|
#9
|
|||||
|
|||||
|
Re: Third Encoder Channel
Quote:
Initialization is easy (easier than the other two interrupts, because there's no rising/falling edge selection). Testing to see which pin caused the interrupt involves remembering the state of PortB between interrupts and comparing the current state to see where they differ. My software also specifically checks to make sure the pin is in the proper state, so that I'm only calling the service routine on the desired edge of the signal. |
|
#10
|
||||
|
||||
|
Re: Third Encoder Channel
Quote:
It runs great!!! Thanks! -SlimBoJones... |
|
#11
|
|||
|
|||
|
Re: Third Encoder Channel
Hmmmm...is it possible to have a fourth encoder channel. How do I check for which Interrupt's (3-6) logic state has changed if I used a fourth encoder? Thanks.
|
|
#12
|
||||
|
||||
|
Re: Third Encoder Channel
Quote:
Here are our encoder files which will help you. Jon Mentor Team236 |
|
#13
|
|||
|
|||
|
Re: Third Encoder Channel
Quote:
|
|
#14
|
|||
|
|||
|
Re: Third Encoder Channel
Quote:
Thanks for the help. I see you have a robot.h included in your user_routines_fast.c. Is there something in it that we would need to get it all to work? -Gary Team 1008 |
|
#15
|
||||
|
||||
|
Re: Third Encoder Channel
Quote:
We were unable to get the scripts to work as advertised. What finally worked was changing the list of commands into a switch...case series of statements that stepped through the commands in much the same way as the code in robot.c does. We used variables for the parameters which are then used by the called function. We did use the functions in robot.c and wrote additional ones for our arm. Jon Team236 "It's in the blood!" |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| encoder vs. motor | stephenthe1 | Programming | 55 | 06-01-2005 22:07 |
| Updated Encoder Code Available | Kevin Watson | Programming | 2 | 04-01-2005 01:00 |
| Choosing an Encoder for the Drive-train | MikeDubreuil | Electrical | 11 | 21-10-2004 00:50 |
| The Science Channel to broadcast FIRST documentary | Andy Baker | General Forum | 49 | 01-03-2004 14:03 |
| how to add steps in the provided encoder program for the edu | Zaramel2002 | Programming | 3 | 11-02-2004 08:35 |