Hi, You can implement a simple "no missing states" QD using a 74XX74 D-type latch. Feed sya a into D and input B into CLK and also to a interrupt pin on your micro. Feed Q into a input pin on your micro. Connect PRE and CLR on the 74XX74 to Vcc. This way, with a interrupt you can pretty much examine the direction very accuratly. Also pulse input will give you "length" count and pulse length will give you "speed". I implemented this on a ships main trawl warps for large fishing ships.The net is attached on both end with 2 drums of cable, these cables works syncronously. Just imagine the cable going out over a 1km length and when hauled back in, it reads different lengths............"oops captain, I can explain.......have you ever heard of quadrature encoding, eh?" This implementation stood the test of time. With TIs little logic you can buy a single tiny D-latch these days. All you still need is filtering. Gogetit Frank ----- Original Message ----- From: "John Dammeyer" <> To: <> Sent: Friday, June 04, 2004 11:47 AM Subject: RE: [68HC12] 9S12DG256 Quadrature Encoder Support. > Hi William, > > Well written! And even doing all this with a Micro and interrupts means that the maximum jitter or > encoder speed can't exceed the entire interrupt routine latency. > > John > > > -----Original Message----- > > From: William M. Derby Jr. [mailto:] > > Sent: Friday, June 04, 2004 11:30 AM > > To: > > Subject: Re: [68HC12] 9S12DG256 Quadrature Encoder Support. > > > > > > The problem is that a valid "count" consists of a complete > > sequence of A and > > B pulses - you can't just take an arbitrary edge and be done > > with it! There > > are a bunch of pathological cases that real encoders produce > > have that will > > mess up the "simple" solution. (This would be the voice of > > experience.) > > > > Consider an encoder sitting still -- well actually slightly > > vibrating like > > everything really does. You have a A and a B output which are > > generally > > produced by something blocking a light. Since the output is > > mechanically > > generated, you can easily have the start of a count pulse say > > A -- then the > > encoder direction reverses and A drops - -there is no B pulse at all! > > > > Valid Counts::: > > A__---------______ > > B____---------____ > > > > or in the other direction > > > > A____---------____ > > B__---------______ > > > > Singleton, non- count events...... > > > > A____---------____ > > B_______________ > > > > or in the other direction > > > > A_______________ > > B____---------____ > > > > > > Of course you can get a zillion of these if the encoder is > > just sitting on > > the edge of a transition.. > > Depending on you implementation each one may show up as a > > count! But wait > > there's still more. > > You can also get non-overlapped A-B pulses if the encoder > > rotates little > > further before backing up.. > > This will lead to: > > > > A __|-------------|_____ > > B_____------_________ > > > > or in the other direction... > > > > A_____------_________ > > B __|-------------|_____ > > > > There are other cases as well -- In short, there is a reason > > for the special > > encoder chips (like the > > LSI7183, which I use) and others mentioned which take care of > > these bizarre > > cases. Also remember that the pulse width will decrease with > > the speed of > > the encoder.. In extreme (high speed) cases, the pulse width > > will dip below > > the "allowable" pulse width (300ns on the 7183) and be > > considered noise and > > thrown out! If your encoder moves really fast in one > > direction and slow in > > the other, the position will appear to back up, each time the machine > > cycles! > > > > Bill > > > > > > ----- Original Message ----- > > From: "Gary Olmstead" <> > > To: <> > > Sent: Friday, June 04, 2004 11:03 AM > > Subject: RE: [68HC12] 9S12DG256 Quadrature Encoder Support. > > > > > > > I'm not clear on what the big deal is. Two inputs, one > > interrupt. At > > > every (choose one) falling/rising edge, generate an interrupt which > > > examines the level of the other input. One level > > increments a counter, > > the > > > other level decrements the count. Shouldn't take long, > > even at 20K Hz. > > > > > > And the problem is.....? > > > > > > Gary Olmstead > > > Toucan Technology > > > Ventura CA > > > > > > > > > At 09:05 PM 5/31/04, you wrote: > > > >John, > > > > > > > >I too have found this very annoying shortcoming on HC12 > > counters. The > > > >320F24x is far nicer ;-) > > > > > > > >The only solution I have thought of, but not tested is to use a > > > >PIC12C508 or ATtiny12 (I have code for the PIC) to decode > > the quadrature > > > >into count and direction. The outputs of this device are > > > >up-clock/down-clock. Then feed these clocks to the alternate pulse > > > >accumulators (PA and PB) on a 9S12D device. The pulse accumulator > > > >difference is the current count. The tricky bit seems to > > be that you > > > >would need to reset these counters before they overflow > > (no big deal), > > > >but making the read-reset operation indivisible to the > > external clock > > > >may lead to lost counts. > > > > > > > >My application can require 10KHz to 20KHz counting, so > > interrupts put a > > > >very heavy load on the processor. > > > > > > > >I will be curious to know how you solve the problem. > > > > > > > > > > > > > > > > > > --------------------To > > learn more > > about Motorola Microcontrollers, please visit > > > http://www.motorola.com/mcu > > > o learn more about Motorola Microcontrollers, please visit > > > http://www.motorola.com/mcu > > > > > > Yahoo! Groups Links > > > > > > > > > > > > > > > > > > > > > > > > > > ------------------------ Yahoo! Groups Sponsor > > --------------------~--> > > Yahoo! Domains - Claim yours for only $14.70 > > http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/dN_tlB/TM > > -------------------------- > > ------~-> > > > > --------------------To > > learn more about Motorola Microcontrollers, please visit > > http://www.motorola.com/mcu > > o learn more about Motorola Microcontrollers, please visit > > http://www.motorola.com/mcu > > > > Yahoo! Groups Links > > > > > > > > > > > > > > > > --------------------To learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > o learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > > Yahoo! Groups Links |
Re: 9S12DG256 Quadrature Encoder Support.
Started by ●June 4, 2003
Reply by ●May 31, 20042004-05-31
Hi all, Lately whenever I've had to do quadrature support I must admit I've been kind of spoiled. In the past we've used an LSI chip that takes quad A,B in and produces a count and an UP/DOWN signal. That device was selected because the 80C51 counter could take a count and up/down input. That was the ATMEL 8051CCO1 with built in CAN. Then the TMS320F2812 has not just 1 but 2 quadrature inputs dedicated to dealing with two separate encoders. No need for external signals to do the direction handling. Real nice. Enter this project with the 9S12 and I thought I read somewhere that it too could deal with quadrature A,B inputs and handle encoder direction. Have I lost track of an application note for this or is it just not possible without interrupting on edges and checking the other signals level? The old fashioned PIC micro-processor way. Thanks, John Dammeyer Wireless CAN with the CANRF module now available. http://www.autoartisans.com/products Automation Artisans Inc. Ph. 1 250 544 4950 |
|
Reply by ●June 1, 20042004-06-01
John, I too have found this very annoying shortcoming on HC12 counters. The 320F24x is far nicer ;-) The only solution I have thought of, but not tested is to use a PIC12C508 or ATtiny12 (I have code for the PIC) to decode the quadrature into count and direction. The outputs of this device are up-clock/down-clock. Then feed these clocks to the alternate pulse accumulators (PA and PB) on a 9S12D device. The pulse accumulator difference is the current count. The tricky bit seems to be that you would need to reset these counters before they overflow (no big deal), but making the read-reset operation indivisible to the external clock may lead to lost counts. My application can require 10KHz to 20KHz counting, so interrupts put a very heavy load on the processor. I will be curious to know how you solve the problem. Jonathan Masters JEMTECH Pty Ltd -----Original Message----- From: John Dammeyer [mailto:] Sent: Tuesday, June 01, 2004 1:23 PM To: Subject: [68HC12] 9S12DG256 Quadrature Encoder Support. Hi all, Lately whenever I've had to do quadrature support I must admit I've been kind of spoiled. In the past we've used an LSI chip that takes quad A,B in and produces a count and an UP/DOWN signal. That device was selected because the 80C51 counter could take a count and up/down input. That was the ATMEL 8051CCO1 with built in CAN. Then the TMS320F2812 has not just 1 but 2 quadrature inputs dedicated to dealing with two separate encoders. No need for external signals to do the direction handling. Real nice. Enter this project with the 9S12 and I thought I read somewhere that it too could deal with quadrature A,B inputs and handle encoder direction. Have I lost track of an application note for this or is it just not possible without interrupting on edges and checking the other signals level? The old fashioned PIC micro-processor way. Thanks, John Dammeyer Wireless CAN with the CANRF module now available. http://www.autoartisans.com/products Automation Artisans Inc. Ph. 1 250 544 4950 --------------------To learn more about Motorola Microcontrollers, please visit http://www.motorola.com/mcu o learn more about Motorola Microcontrollers, please visit http://www.motorola.com/mcu <http://rd.yahoo.com/SIG940080p/M)5196.4901138.6071305.3001176/D=gr oups/S06554205:HM/EXP86146742/A!28215/R=0/SIGse96mf6/*http:/c ompanion.yahoo.com> click here <http://us.adserver.yahoo.com/l?M)5196.4901138.6071305.3001176/D=group s/S=:HM/A!28215/randD0386676> _____ > Service. |
|
Reply by ●June 1, 20042004-06-01
All: There are a couple of solutions that I have used in the past with good success. One is the HP HCTL2016 series quadrature decoder IC. It is basically a counter, which is fed filtered and processed quadrature pulses from an encoder. You can simply read the counter in either 8 bit or 16 bit format. The device is made to reside on the Data Bus, but if you are not using expanded mode you can run it off an 8 bit port. Just read the counter value on a timed interrupt, a few to a few hundred milliseconds, depending on your encoder speed. The device will keep track of all movements in either direction in the meantime. Also has the advantage of multiplying quadrature resolution by X4. The other is the LSI Inc. LS7082/3/4 series quadrature converters. These 8 pin chips convert quadrature encoder inputs to either pulse and direction, or up clock and down clock signals. They are configurable to X1, X2, or X4 operation, and are very simple to use. However, they have no internal counter, so the pulses must be processed immediately. > I too have found this very annoying shortcoming on HC12 counters. > The 320F24x is far nicer ;-) > > The only solution I have thought of, but not tested is to use a > PIC12C508 or ATtiny12 (I have code for the PIC) to decode the > quadrature into count and direction. The outputs of this device > are up-clock/down-clock. Then feed these clocks to the alternate > pulse accumulators (PA and PB) on a 9S12D device. The pulse > accumulator difference is the current count. The tricky bit seems > to be that you would need to reset these counters before they > overflow (no big deal), but making the read-reset operation > indivisible to the external clock may lead to lost counts. > > My application can require 10KHz to 20KHz counting, so interrupts > put a very heavy load on the processor. Regards, Darrell Norquay Datalog Technology Inc. Calgary, Alberta, Canada Voice: (403) 243-2220 Fax: (403) 243-2872 Email: Web: www.datalog.ab.ca |
Reply by ●June 1, 20042004-06-01
The data sheet for the HP HCTL2000/16/20 gives a comprehensive
description of the hidden mechanisms and internal secrets of their chip including examples of interfacing to the 'HC11. The only quibble that I have with the HP decoder is its parallel interface so you may have to do a bit of interface design. Just treat its data port as a ram chip. Once you understand the operation of quad encoders you should be able to interface it directly to the 'HC12 FOR LOW FREQUENCY OPERATION. Just invest the time needed to learn IC and OC operations and have at it. Actually, the quadrature decoding only takes a couple of XOR gates and perhaps a couple of inverters after the digital filtering that is inherent in the HCTL2000 encoders. THIS FILTERING IS IMPORTANT, especially in industrial environments. The actual decoding is almost trivial in software. Just build yourself a little state machine to determine whether you just had an up or a down transition and bump the counter the right direction. Its a fun little project to play with. Best wishes, Bob Smith --- Avoid computer viruses, Practice safe hex --- -- Specializing in small, cost effective embedded control systems -- http://www.smithmachineworks.com/embedprod.html Robert L. (Bob) Smith Smith Machine Works, Inc. 9900 Lumlay Road Richmond, VA 23236 804/745-2608 ----- Original Message ----- From: "Darrell N." <> To: <> Sent: Tuesday, June 01, 2004 12:50 PM Subject: RE: [68HC12] 9S12DG256 Quadrature Encoder Support. > All: > > There are a couple of solutions that I have used in the past > with good success. One is the HP HCTL2016 series quadrature > decoder IC. It is basically a counter, which is fed filtered > and processed quadrature pulses from an encoder. You can simply > read the counter in either 8 bit or 16 bit format. The device > is made to reside on the Data Bus, but if you are not using > expanded mode you can run it off an 8 bit port. Just read the > counter value on a timed interrupt, a few to a few hundred > milliseconds, depending on your encoder speed. The device will > keep track of all movements in either direction in the meantime. > Also has the advantage of multiplying quadrature resolution by > X4. > > The other is the LSI Inc. LS7082/3/4 series quadrature > converters. These 8 pin chips convert quadrature encoder inputs > to either pulse and direction, or up clock and down clock > signals. They are configurable to X1, X2, or X4 operation, and > are very simple to use. However, they have no internal counter, > so the pulses must be processed immediately. > > I too have found this very annoying shortcoming on HC12 counters. > > The 320F24x is far nicer ;-) > > > > The only solution I have thought of, but not tested is to use a > > PIC12C508 or ATtiny12 (I have code for the PIC) to decode the > > quadrature into count and direction. The outputs of this device > > are up-clock/down-clock. Then feed these clocks to the alternate > > pulse accumulators (PA and PB) on a 9S12D device. The pulse > > accumulator difference is the current count. The tricky bit seems > > to be that you would need to reset these counters before they > > overflow (no big deal), but making the read-reset operation > > indivisible to the external clock may lead to lost counts. > > > > My application can require 10KHz to 20KHz counting, so interrupts > > put a very heavy load on the processor. > Regards, > Darrell Norquay > > Datalog Technology Inc. Calgary, Alberta, Canada > Voice: (403) 243-2220 Fax: (403) 243-2872 > Email: Web: www.datalog.ab.ca > > --------------------To learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > o learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > > -- ------ > Yahoo! Groups Links > > a.. To |
|
Reply by ●June 1, 20042004-06-01
Yes, on the last project I did we used the LS7084 and chose a processor (the
Temic now Atmel 8051) that had Count and Direction inputs. On overflow/underflow interrupts, we decrement the external 8 bit high order byte to give us a 24 bit counter. With a 400 line counter and x4 we don't miss a pulse. I was just hoping that I had really seen an app note from Motorola on configuring their counters to do quadrature like the TI devices. Ah well such is life. Thanks for the info. John Wireless CAN with the CANRF module now available. http://www.autoartisans.com/products Automation Artisans Inc. Ph. 1 250 544 4950 > -----Original Message----- > From: Bob Smith [mailto:] > Sent: Tuesday, June 01, 2004 10:04 AM > To: > Subject: Re: [68HC12] 9S12DG256 Quadrature Encoder Support. > The data sheet for the HP HCTL2000/16/20 gives a > comprehensive description > of the hidden mechanisms and internal secrets of their chip including > examples of interfacing to the 'HC11. The only quibble that > I have with the > HP decoder is its parallel interface so you may have to do a bit of > interface design. Just treat its data port as a ram chip. > > Once you understand the operation of quad encoders you should > be able to > interface it directly to the 'HC12 FOR LOW FREQUENCY > OPERATION. Just invest > the time needed to learn IC and OC operations and have at it. > > Actually, the quadrature decoding only takes a couple of XOR gates and > perhaps a couple of inverters after the digital filtering > that is inherent > in the HCTL2000 encoders. THIS FILTERING IS IMPORTANT, especially in > industrial environments. The actual decoding is almost > trivial in software. > Just build yourself a little state machine to determine > whether you just had > an up or a down transition and bump the counter the right > direction. Its a > fun little project to play with. > > Best wishes, Bob Smith > --- Avoid computer viruses, Practice safe hex --- > > -- Specializing in small, cost effective > embedded control systems -- > > http://www.smithmachineworks.com/embedprod.html > Robert L. (Bob) Smith > Smith Machine Works, Inc. > 9900 Lumlay Road > Richmond, VA 23236 804/745-2608 > > ----- Original Message ----- > From: "Darrell N." <> > To: <> > Sent: Tuesday, June 01, 2004 12:50 PM > Subject: RE: [68HC12] 9S12DG256 Quadrature Encoder Support. > > All: > > > > There are a couple of solutions that I have used in the past > > with good success. One is the HP HCTL2016 series quadrature > > decoder IC. It is basically a counter, which is fed filtered > > and processed quadrature pulses from an encoder. You can simply > > read the counter in either 8 bit or 16 bit format. The device > > is made to reside on the Data Bus, but if you are not using > > expanded mode you can run it off an 8 bit port. Just read the > > counter value on a timed interrupt, a few to a few hundred > > milliseconds, depending on your encoder speed. The device will > > keep track of all movements in either direction in the meantime. > > Also has the advantage of multiplying quadrature resolution by > > X4. > > > > The other is the LSI Inc. LS7082/3/4 series quadrature > > converters. These 8 pin chips convert quadrature encoder inputs > > to either pulse and direction, or up clock and down clock > > signals. They are configurable to X1, X2, or X4 operation, and > > are very simple to use. However, they have no internal counter, > > so the pulses must be processed immediately. > > > > > > > I too have found this very annoying shortcoming on HC12 counters. > > > The 320F24x is far nicer ;-) > > > > > > The only solution I have thought of, but not tested is to use a > > > PIC12C508 or ATtiny12 (I have code for the PIC) to decode the > > > quadrature into count and direction. The outputs of this device > > > are up-clock/down-clock. Then feed these clocks to the alternate > > > pulse accumulators (PA and PB) on a 9S12D device. The pulse > > > accumulator difference is the current count. The tricky bit seems > > > to be that you would need to reset these counters before they > > > overflow (no big deal), but making the read-reset operation > > > indivisible to the external clock may lead to lost counts. > > > > > > My application can require 10KHz to 20KHz counting, so interrupts > > > put a very heavy load on the processor. > > > > > > Regards, > > Darrell Norquay > > > > Datalog Technology Inc. Calgary, Alberta, Canada > > Voice: (403) 243-2220 Fax: (403) 243-2872 > > Email: Web: www.datalog.ab.ca > > > > > > > > --------------------To > learn more > about Motorola Microcontrollers, please visit > > http://www.motorola.com/mcu > > o learn more about Motorola Microcontrollers, please visit > > http://www.motorola.com/mcu > > > > > > > > > > > > > > > > > > > > > -------------------------- > ------------ > ------ > > Yahoo! Groups Links > > > > a.. To > > > > > > ------------------------ Yahoo! Groups Sponsor > --------------------~--> > Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar. > Now with Pop-Up Blocker. Get it for free! > http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/dN_tlB/TM > -------------------------- > ------~-> > > --------------------To > learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > o learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > > Yahoo! Groups Links > > |
Reply by ●June 4, 20042004-06-04
I'm not clear on what the big deal is. Two inputs, one interrupt. At
every (choose one) falling/rising edge, generate an interrupt which examines the level of the other input. One level increments a counter, the other level decrements the count. Shouldn't take long, even at 20K Hz. And the problem is.....? Gary Olmstead Toucan Technology Ventura CA At 09:05 PM 5/31/04, you wrote: >John, > >I too have found this very annoying shortcoming on HC12 counters. The >320F24x is far nicer ;-) > >The only solution I have thought of, but not tested is to use a >PIC12C508 or ATtiny12 (I have code for the PIC) to decode the quadrature >into count and direction. The outputs of this device are >up-clock/down-clock. Then feed these clocks to the alternate pulse >accumulators (PA and PB) on a 9S12D device. The pulse accumulator >difference is the current count. The tricky bit seems to be that you >would need to reset these counters before they overflow (no big deal), >but making the read-reset operation indivisible to the external clock >may lead to lost counts. > >My application can require 10KHz to 20KHz counting, so interrupts put a >very heavy load on the processor. > >I will be curious to know how you solve the problem. |
|
Reply by ●June 4, 20042004-06-04
The problem is that a valid "count" consists of a complete
sequence of A and B pulses - you can't just take an arbitrary edge and be done with it! There are a bunch of pathological cases that real encoders produce have that will mess up the "simple" solution. (This would be the voice of experience.) Consider an encoder sitting still -- well actually slightly vibrating like everything really does. You have a A and a B output which are generally produced by something blocking a light. Since the output is mechanically generated, you can easily have the start of a count pulse say A -- then the encoder direction reverses and A drops - -there is no B pulse at all! Valid Counts::: A__---------______ B____---------____ or in the other direction A____---------____ B__---------______ Singleton, non- count events...... A____---------____ B_______________ or in the other direction A_______________ B____---------____ Of course you can get a zillion of these if the encoder is just sitting on the edge of a transition.. Depending on you implementation each one may show up as a count! But wait there's still more. You can also get non-overlapped A-B pulses if the encoder rotates little further before backing up.. This will lead to: A __|-------------|_____ B_____------_________ or in the other direction... A_____------_________ B __|-------------|_____ There are other cases as well -- In short, there is a reason for the special encoder chips (like the LSI7183, which I use) and others mentioned which take care of these bizarre cases. Also remember that the pulse width will decrease with the speed of the encoder.. In extreme (high speed) cases, the pulse width will dip below the "allowable" pulse width (300ns on the 7183) and be considered noise and thrown out! If your encoder moves really fast in one direction and slow in the other, the position will appear to back up, each time the machine cycles! Bill ----- Original Message ----- From: "Gary Olmstead" <> To: <> Sent: Friday, June 04, 2004 11:03 AM Subject: RE: [68HC12] 9S12DG256 Quadrature Encoder Support. > I'm not clear on what the big deal is. Two inputs, one interrupt. At > every (choose one) falling/rising edge, generate an interrupt which > examines the level of the other input. One level increments a counter, the > other level decrements the count. Shouldn't take long, even at 20K Hz. > > And the problem is.....? > > Gary Olmstead > Toucan Technology > Ventura CA > At 09:05 PM 5/31/04, you wrote: > >John, > > > >I too have found this very annoying shortcoming on HC12 counters. The > >320F24x is far nicer ;-) > > > >The only solution I have thought of, but not tested is to use a > >PIC12C508 or ATtiny12 (I have code for the PIC) to decode the quadrature > >into count and direction. The outputs of this device are > >up-clock/down-clock. Then feed these clocks to the alternate pulse > >accumulators (PA and PB) on a 9S12D device. The pulse accumulator > >difference is the current count. The tricky bit seems to be that you > >would need to reset these counters before they overflow (no big deal), > >but making the read-reset operation indivisible to the external clock > >may lead to lost counts. > > > >My application can require 10KHz to 20KHz counting, so interrupts put a > >very heavy load on the processor. > > > >I will be curious to know how you solve the problem. > --------------------To learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > o learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > > Yahoo! Groups Links > |
|
Reply by ●June 4, 20042004-06-04
Hi William, Well written! And even doing all this with a Micro and interrupts means that the maximum jitter or encoder speed can't exceed the entire interrupt routine latency. John > -----Original Message----- > From: William M. Derby Jr. [mailto:] > Sent: Friday, June 04, 2004 11:30 AM > To: > Subject: Re: [68HC12] 9S12DG256 Quadrature Encoder Support. > The problem is that a valid "count" consists of a complete > sequence of A and > B pulses - you can't just take an arbitrary edge and be done > with it! There > are a bunch of pathological cases that real encoders produce > have that will > mess up the "simple" solution. (This would be the voice of > experience.) > > Consider an encoder sitting still -- well actually slightly > vibrating like > everything really does. You have a A and a B output which are > generally > produced by something blocking a light. Since the output is > mechanically > generated, you can easily have the start of a count pulse say > A -- then the > encoder direction reverses and A drops - -there is no B pulse at all! > > Valid Counts::: > A__---------______ > B____---------____ > > or in the other direction > > A____---------____ > B__---------______ > > Singleton, non- count events...... > > A____---------____ > B_______________ > > or in the other direction > > A_______________ > B____---------____ > Of course you can get a zillion of these if the encoder is > just sitting on > the edge of a transition.. > Depending on you implementation each one may show up as a > count! But wait > there's still more. > You can also get non-overlapped A-B pulses if the encoder > rotates little > further before backing up.. > This will lead to: > > A __|-------------|_____ > B_____------_________ > > or in the other direction... > > A_____------_________ > B __|-------------|_____ > > There are other cases as well -- In short, there is a reason > for the special > encoder chips (like the > LSI7183, which I use) and others mentioned which take care of > these bizarre > cases. Also remember that the pulse width will decrease with > the speed of > the encoder.. In extreme (high speed) cases, the pulse width > will dip below > the "allowable" pulse width (300ns on the 7183) and be > considered noise and > thrown out! If your encoder moves really fast in one > direction and slow in > the other, the position will appear to back up, each time the machine > cycles! > > Bill > ----- Original Message ----- > From: "Gary Olmstead" <> > To: <> > Sent: Friday, June 04, 2004 11:03 AM > Subject: RE: [68HC12] 9S12DG256 Quadrature Encoder Support. > > I'm not clear on what the big deal is. Two inputs, one > interrupt. At > > every (choose one) falling/rising edge, generate an interrupt which > > examines the level of the other input. One level > increments a counter, > the > > other level decrements the count. Shouldn't take long, > even at 20K Hz. > > > > And the problem is.....? > > > > Gary Olmstead > > Toucan Technology > > Ventura CA > > > > > > At 09:05 PM 5/31/04, you wrote: > > >John, > > > > > >I too have found this very annoying shortcoming on HC12 > counters. The > > >320F24x is far nicer ;-) > > > > > >The only solution I have thought of, but not tested is to use a > > >PIC12C508 or ATtiny12 (I have code for the PIC) to decode > the quadrature > > >into count and direction. The outputs of this device are > > >up-clock/down-clock. Then feed these clocks to the alternate pulse > > >accumulators (PA and PB) on a 9S12D device. The pulse accumulator > > >difference is the current count. The tricky bit seems to > be that you > > >would need to reset these counters before they overflow > (no big deal), > > >but making the read-reset operation indivisible to the > external clock > > >may lead to lost counts. > > > > > >My application can require 10KHz to 20KHz counting, so > interrupts put a > > >very heavy load on the processor. > > > > > >I will be curious to know how you solve the problem. > > > > > > > > > > > > --------------------To > learn more > about Motorola Microcontrollers, please visit > > http://www.motorola.com/mcu > > o learn more about Motorola Microcontrollers, please visit > > http://www.motorola.com/mcu > > > > Yahoo! Groups Links > > > > > > > > > > > > > ------------------------ Yahoo! Groups Sponsor > --------------------~--> > Yahoo! Domains - Claim yours for only $14.70 > http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/dN_tlB/TM > -------------------------- > ------~-> > > --------------------To > learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > o learn more about Motorola Microcontrollers, please visit > http://www.motorola.com/mcu > > Yahoo! Groups Links > > |
Reply by ●June 4, 20042004-06-04
Gary, Scaleability. Probably unfair to have thrown in the 20Khz figure. But by way of example, my first application uses a 2.5mm pitch belt running over a 16 tooth pulley: 40mm linear belt movement/rev. This is coupled to a 500ppr encoder and maximum linear speed is specified at 200mm/sec or 5 revs/sec = 2500counts/sec. Since a quadrature device provides four edges per count this is 10Khz. An AVR design at 8Mhz handles this and some actual control functions OK. Suddenly I have a customer trying to use the device with a 2000ppr encoder because this is the only encoder available on the machine and there is nowhere else to mount one and he wants to use hundreds and can't I do something. This failed on the AVR and certainly the 10Khz won't work on my HC12 design which is busy also trying to talk CAN to another HC12, manage 96IO points (80 of which are interface by three SPI ports and all tested at 1ms intervals) and RS232 to my host etc etc. A little bit of hardware help here goes a long way! Regards, Jonathan. -----Original Message----- From: Gary Olmstead [mailto:] Sent: Saturday, June 05, 2004 1:04 AM To: Subject: RE: [68HC12] 9S12DG256 Quadrature Encoder Support. I'm not clear on what the big deal is. Two inputs, one interrupt. At every (choose one) falling/rising edge, generate an interrupt which examines the level of the other input. One level increments a counter, the other level decrements the count. Shouldn't take long, even at 20K Hz. And the problem is.....? Gary Olmstead Toucan Technology Ventura CA At 09:05 PM 5/31/04, you wrote: >John, > >I too have found this very annoying shortcoming on HC12 counters. The >320F24x is far nicer ;-) > >The only solution I have thought of, but not tested is to use a >PIC12C508 or ATtiny12 (I have code for the PIC) to decode the quadrature >into count and direction. The outputs of this device are >up-clock/down-clock. Then feed these clocks to the alternate pulse >accumulators (PA and PB) on a 9S12D device. The pulse accumulator >difference is the current count. The tricky bit seems to be that you >would need to reset these counters before they overflow (no big deal), >but making the read-reset operation indivisible to the external clock >may lead to lost counts. > >My application can require 10KHz to 20KHz counting, so interrupts put a >very heavy load on the processor. > >I will be curious to know how you solve the problem. --------------------To learn more about Motorola Microcontrollers, please visit http://www.motorola.com/mcu o learn more about Motorola Microcontrollers, please visit http://www.motorola.com/mcu <http://rd.yahoo.com/SIG9kbf85o/M)8184.5022502.6152625.3001176/D=gr oups/S06554205:HM/EXP86447635/A!64330/R=0/SIGeamf8g4/*http:/w ww.netflix.com/Default?mqso`183350> click here <http://us.adserver.yahoo.com/l?M)8184.5022502.6152625.3001176/D=group s/S=:HM/A!64330/randP6941908> _____ > Service. |