EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Quadrature Inputs

Started by Paul Johnson March 8, 2003
"Paul Johnson" <> wrote:

[...]

>It sounds like this is a polling approach. I was thinking of doing

IMHO that's the most reliable way to do it.

>something similar to what Bob suggested, but attaching Quad-A to an
>interrupt which triggers on any transition, then checking the value of the
>other line in the ISR. I suppose that if the encoder was sitting right on a
>line, however, this might swamp the interrupt input, but I have not commonly
>seen this with encoders.

If you have an encoder with hysteresis, it will only occur if there is
mechanical vibration. Do you know whether the encoder used in the
application has hysteresis to avoid oscillation under any condition?

>With low interrupt latency, I would think this
>would be pretty reliable, no?

If the condition mentioned above is met... otherwise it's really
dangerous!

And with a high pulse rate, it will consume lots of CPU power.

If you you have a dedicated uC for the decoding, the loop approach is
much faster than the interrupt approach.

Oliver
--
Oliver Betz, Muenchen



Check out the TI TMS340 series. Fixed point DSP. It's pretty much made for
motor control and has quadrature decoding built in. A real fast, cheap
(about same as HC12) flash DSP. You'll love the Code Composer IDE - it
comes with real books that tell you how to use it, written by
technically-competent people whose primary language is English. Same story
for the hardware. You'll probably want to code in C. The assembly language
is amazing(ly complex). It has two ALUs, one just for address calculations.
Modified Harvard architecture. True 16-bit machine. It'll do a MAC in one
clock cycle. If I weren't stuck with a legacy product, I'd be using TI.
This is all from memory a few years old, so don't quote me.

Bob White

----- Original Message -----
From: "Paul Johnson" <>
To: <>
Sent: Sunday, March 09, 2003 8:16 AM
Subject: RE: [68HC12] Quadrature Inputs > It's pretty simple:
>
> In a loop: Concatenate the actual two bit encoder information with the
> saved two bits of the last round. From these 4 Bits you get 16
> combinations, forward, backward, no change and illegal (each four
> times).
>
> Use a jump table to increment/decrement the counter (accumulator) or
> signal an error.
>
> Use some kind of handshake to the host if you output parallel data:
> either a strobe signal triggered by the host, or a "data illegal" bit.
>
> With a 20MHz PIC, I got 4,5us cycle time IIRC.

It sounds like this is a polling approach. I was thinking of doing
something similar to what Bob suggested, but attaching Quad-A to an
interrupt which triggers on any transition, then checking the value of the
other line in the ISR. I suppose that if the encoder was sitting right on a
line, however, this might swamp the interrupt input, but I have not commonly
seen this with encoders. With low interrupt latency, I would think this
would be pretty reliable, no?

Paul
--------------------
">http://docs.yahoo.com/info/terms/



"whose primary language is English " LOL, I love that!!

wrote:

> Check out the TI TMS340 series. Fixed point DSP. It's pretty much
> made for
> motor control and has quadrature decoding built in. A real fast, cheap
> (about same as HC12) flash DSP. You'll love the Code Composer IDE - it
> comes with real books that tell you how to use it, written by
> technically-competent people whose primary language is English. Same
> story
> for the hardware. You'll probably want to code in C. The assembly
> language
> is amazing(ly complex). It has two ALUs, one just for address
> calculations.
> Modified Harvard architecture. True 16-bit machine. It'll do a MAC
> in one
> clock cycle. If I weren't stuck with a legacy product, I'd be using TI.
> This is all from memory a few years old, so don't quote me.
>
> Bob White
>
> ----- Original Message -----
> From: "Paul Johnson" <>
> To: <>
> Sent: Sunday, March 09, 2003 8:16 AM
> Subject: RE: [68HC12] Quadrature Inputs > > It's pretty simple:
> >
> > In a loop: Concatenate the actual two bit encoder information with the
> > saved two bits of the last round. From these 4 Bits you get 16
> > combinations, forward, backward, no change and illegal (each four
> > times).
> >
> > Use a jump table to increment/decrement the counter (accumulator) or
> > signal an error.
> >
> > Use some kind of handshake to the host if you output parallel data:
> > either a strobe signal triggered by the host, or a "data illegal" bit.
> >
> > With a 20MHz PIC, I got 4,5us cycle time IIRC.
>
> It sounds like this is a polling approach. I was thinking of doing
> something similar to what Bob suggested, but attaching Quad-A to an
> interrupt which triggers on any transition, then checking the value of the
> other line in the ISR. I suppose that if the encoder was sitting
> right on a
> line, however, this might swamp the interrupt input, but I have not
> commonly
> seen this with encoders. With low interrupt latency, I would think this
> would be pretty reliable, no?
>
> Paul >
> -------------------- >
> ">http://docs.yahoo.com/info/terms/ > Yahoo! Groups Sponsor
>
> <http://ads.x10.com/?bHlhaG9vaG0xLmRhd47239968%3eM$7865.3003379.4374531.2848452/D=egroupweb/S06554205:HM/A82387/R=147239968%3eM$7865.3003379.4374531.2848452/D=egroupweb/S06554205:HM/A82387/R=2" target="_blank" rel="nofollow">http://rd.yahoo.com/M$7865.3003379.4374531.2848452/D=egroupweb/S06554205:HM/A82387/R=0/*http://ads.x10.com/?bHlhaG9vaG0xLmRhd47239968%3eM$7865.3003379.4374531.2848452/D=egroupweb/S06554205:HM/A82387/R=147239968%3eM$7865.3003379.4374531.2848452/D=egroupweb/S06554205:HM/A82387/R=2 >
> -------------------- >
> ">http://docs.yahoo.com/info/terms/>.



The only things I could find on TI's website with TMS340 in the part number
were 32 bit graphics processors, all but one of which are listed as
obsolete. I didn't find anything like what you are describing.

Could it be a different series?

Thanks,

Paul

> -----Original Message-----
> From: Bob White [mailto:]
> Sent: Sunday, March 09, 2003 12:02 PM
> To:
> Subject: Re: [68HC12] Quadrature Inputs > Check out the TI TMS340 series. Fixed point DSP. It's pretty
> much made for
> motor control and has quadrature decoding built in. A real fast, cheap
> (about same as HC12) flash DSP. You'll love the Code Composer IDE - it
> comes with real books that tell you how to use it, written by
> technically-competent people whose primary language is English.
> Same story
> for the hardware. You'll probably want to code in C. The
> assembly language
> is amazing(ly complex). It has two ALUs, one just for address
> calculations.
> Modified Harvard architecture. True 16-bit machine. It'll do a
> MAC in one
> clock cycle. If I weren't stuck with a legacy product, I'd be using TI.
> This is all from memory a few years old, so don't quote me.
>
> Bob White
>
> ----- Original Message -----
> From: "Paul Johnson" <>
> To: <>
> Sent: Sunday, March 09, 2003 8:16 AM
> Subject: RE: [68HC12] Quadrature Inputs > > It's pretty simple:
> >
> > In a loop: Concatenate the actual two bit encoder information with the
> > saved two bits of the last round. From these 4 Bits you get 16
> > combinations, forward, backward, no change and illegal (each four
> > times).
> >
> > Use a jump table to increment/decrement the counter (accumulator) or
> > signal an error.
> >
> > Use some kind of handshake to the host if you output parallel data:
> > either a strobe signal triggered by the host, or a "data illegal" bit.
> >
> > With a 20MHz PIC, I got 4,5us cycle time IIRC.
>
> It sounds like this is a polling approach. I was thinking of doing
> something similar to what Bob suggested, but attaching Quad-A to an
> interrupt which triggers on any transition, then checking the value of the
> other line in the ISR. I suppose that if the encoder was sitting
> right on a
> line, however, this might swamp the interrupt input, but I have
> not commonly
> seen this with encoders. With low interrupt latency, I would think this
> would be pretty reliable, no?
>
> Paul >
> -------------------- >
> ">http://docs.yahoo.com/info/terms/ >
> -------------------- >
> ">http://docs.yahoo.com/info/terms/





Never mind, I think I found it. It's in the 320 series, but it matches the
description you give.

We'll be investigating this chip this week.

Thanks,

Paul

> -----Original Message-----
> From: Paul Johnson [mailto:]
> Sent: Sunday, March 09, 2003 6:10 PM
> To:
> Subject: RE: [68HC12] Quadrature Inputs > The only things I could find on TI's website with TMS340 in the
> part number
> were 32 bit graphics processors, all but one of which are listed as
> obsolete. I didn't find anything like what you are describing.
>
> Could it be a different series?
>
> Thanks,
>
> Paul
>
> > -----Original Message-----
> > From: Bob White [mailto:]
> > Sent: Sunday, March 09, 2003 12:02 PM
> > To:
> > Subject: Re: [68HC12] Quadrature Inputs
> >
> >
> > Check out the TI TMS340 series. Fixed point DSP. It's pretty
> > much made for
> > motor control and has quadrature decoding built in. A real fast, cheap
> > (about same as HC12) flash DSP. You'll love the Code Composer IDE - it
> > comes with real books that tell you how to use it, written by
> > technically-competent people whose primary language is English.
> > Same story
> > for the hardware. You'll probably want to code in C. The
> > assembly language
> > is amazing(ly complex). It has two ALUs, one just for address
> > calculations.
> > Modified Harvard architecture. True 16-bit machine. It'll do a
> > MAC in one
> > clock cycle. If I weren't stuck with a legacy product, I'd be using TI.
> > This is all from memory a few years old, so don't quote me.
> >
> > Bob White
> >
> > ----- Original Message -----
> > From: "Paul Johnson" <>
> > To: <>
> > Sent: Sunday, March 09, 2003 8:16 AM
> > Subject: RE: [68HC12] Quadrature Inputs
> >
> >
> > > It's pretty simple:
> > >
> > > In a loop: Concatenate the actual two bit encoder information with the
> > > saved two bits of the last round. From these 4 Bits you get 16
> > > combinations, forward, backward, no change and illegal (each four
> > > times).
> > >
> > > Use a jump table to increment/decrement the counter (accumulator) or
> > > signal an error.
> > >
> > > Use some kind of handshake to the host if you output parallel data:
> > > either a strobe signal triggered by the host, or a "data illegal" bit.
> > >
> > > With a 20MHz PIC, I got 4,5us cycle time IIRC.
> >
> > It sounds like this is a polling approach. I was thinking of doing
> > something similar to what Bob suggested, but attaching Quad-A to an
> > interrupt which triggers on any transition, then checking the
> value of the
> > other line in the ISR. I suppose that if the encoder was sitting
> > right on a
> > line, however, this might swamp the interrupt input, but I have
> > not commonly
> > seen this with encoders. With low interrupt latency, I would think this
> > would be pretty reliable, no?
> >
> > Paul
> >
> >
> >
> > --------------------
> >
> >
> >
> > ">http://docs.yahoo.com/info/terms/
> -------------------- >
> ">http://docs.yahoo.com/info/terms/
--------------------
">http://docs.yahoo.com/info/terms/


Depending on the edge rates, you can either use interrupts off the
appropriate port pins (if they are slow enough) or there are nice
single-chip solutions like the HCTL2000 from Agilent (the old HP).

Or, your favorite EPLD or FPGA if you need a lot of them...

/s/jar
http://www.mtritter.org
EMAIL DISCLAIMER

Please Note: The information contained in this message may be privileged and
confidential, protected from disclosure, and/or intended only for the use of
the individual or entity named above. If the reader of this message is not
the intended recipient, or an employee or agent responsible for delivering
this message to the intended recipient, you are hereby notified that any
disclosure, distribution, copying or other dissemination of this
communication is strictly prohibited. If you received this communication in
error, please immediately reply to the sender, delete the message and
destroy all copies of it.

Thank You


Also look at MC68HC16, and MPC500 series these have the TPU that can be configured for Quadrature detection.

What does the HCS12H have perhaps that can do quadrature as well? Andrew Lohmann AIIE
Design Engineer

Bellingham + Stanley Ltd.
Longfield Road, Tunbridge Wells, Kent, TN2 3EY, England.
Tel: +44 (0) 1892 500400
Fax: +44 (0) 1892 543115
Website: www.bs-ltd.com

----- Original Message -----
From: Ritter, Alan
To: '
Sent: Monday, March 10, 2003 3:50 AM
Subject: RE: [68HC12] Quadrature Inputs Depending on the edge rates, you can either use interrupts off the
appropriate port pins (if they are slow enough) or there are nice
single-chip solutions like the HCTL2000 from Agilent (the old HP).

Or, your favorite EPLD or FPGA if you need a lot of them...

/s/jar
http://www.mtritter.org
EMAIL DISCLAIMER

Please Note: The information contained in this message may be privileged and
confidential, protected from disclosure, and/or intended only for the use of
the individual or entity named above. If the reader of this message is not
the intended recipient, or an employee or agent responsible for delivering
this message to the intended recipient, you are hereby notified that any
disclosure, distribution, copying or other dissemination of this
communication is strictly prohibited. If you received this communication in
error, please immediately reply to the sender, delete the message and
destroy all copies of it.

Thank You

--------------------

--- Email Disclaimer --- Internet communications are not secure and therefore Bellingham + Stanley Ltd does not accept legal responsibility for the contents of this message. Any views or opinions presented are solely those of the author and do not necessarily represent those of Bellingham + Stanley Ltd unless otherwise specifically stated. If this message is received by anyone other than the addressee, please notify the sender and then delete the message and any attachments from your computer. --- End --- --- Email Disclaimer ---

Internet communications are not secure and therefore Bellingham + Stanley Ltd does
not accept legal responsibility for the contents of this message. Any views
or opinions presented are solely those of the author and do not necessarily
represent those of Bellingham + Stanley Ltd unless otherwise specifically stated.
If this message is received by anyone other than the addressee, please
notify the sender and then delete the message and any attachments from your
computer.

--- End ---


Hi,

Some years back i did a winch controle wire out and speed for a ship trawl
warps.
I used a 8051 then and did it as follows:

Used a D-type latch 74HCT74 with PRE/CLR connected to Vcc. The one phase
input connected to "D" input and the Q connected to a port pin (the /Q not
used).

The other phase goes to the Clock pin on the D type latch and at the same
time to a interrupt line on the processor.

Both phases should be buffered with hysterieses , barrier diode, caps etc.

IT WORKS AS FOLLOW:......78>))

The the one phase feeding into D and the other into the clock input of the
74HCT74 we obtain the phase leading or lagging so we can figure out what
direction the shaft turns. The Q output will indicate the direction "0" one
direction "1" other direction.

The one phase feeding straight into the CPU has to functions. First, it is
used to measure time intervals for measuring shaft speed. Second, it is used
as a pulse counter to measure length of wire. So we end up with 3 neat
variables, speed wire out and direction!!

Now just for the interrest of it. Do not place your sensors on the wire
drum!!! Place your sensors on a roler that has a consistant diameter to the
cable spooling.............

Frank van der Merwe(the info is free....)

----- Original Message -----
From: <>
To: <>
Sent: Saturday, March 08, 2003 8:04 PM
Subject: Re: [68HC12] Quadrature Inputs > In a message dated 3/8/03 8:52:38 PM Eastern Standard Time,
> writes:
>
> > I'm surprised, given the number of embedded applications
> > involving motor
> > control or data capture, that almost no micros out there support
> > quadrature
> > input. On our products, we use Xilinx FPGA's that provide 8 sets of
> > quadrature input and handle all the accumulation, etc.
> > However, on small footprint boards, with a simple task, it
> > would be very
> > desirable to lose the Xilinx and just read quadrature directly. Even
> > just
> > one pair of quadrature inputs would be fine.
> > Has anyone out there solved this problem?
>
> Just hook one of the encoder lines to an input with edge triggered
interrupt,
> arm for falling edge interrupt (for instance), read other encoder line in
> handler, inc on hi, dec on lo. >
>
> -------------------- >
> ">http://docs.yahoo.com/info/terms/




For PIC solution see JR Kerr's website jrkerr.com.
They offer PIC-ENC in a 20 pin 16C54.
I've used this inconjunction with their PIC-SERVO
to implement PID motor control.
Nick

> -----Original Message-----
> From: Paul Johnson [mailto:]
> Sent: Saturday, March 08, 2003 8:47 PM
> To:
> Subject: RE: [68HC12] Quadrature Inputs > > >I'm surprised, given the number of embedded applications
> involving motor
> > >control or data capture, that almost no micros out there support
> > quadrature
> > >input. On our products, we use Xilinx FPGA's that provide
> 8 sets of
> >
> > Ack, that's bad.
>
> I'm sorry, Oliver, I don't know what you mean. Do you mean
> that it's bad
> that we're using Xilinx's or that there are no micros out there with
> quadrature, or something different altogether?
>
> > >Has anyone out there solved this problem?
> >
> > Do you know the LS7183 from www.lsicsi.com ? It seems you
> could count
> > the up and down pulses with HC12 pulse counters.
>
> I didn't, and thanks for the reference. However the reason
> for quadrature
> is that it's so much more noise immune than clock and
> direction or dual
> clock. Still, on a small board, close to the micro, this
> might not be a
> problem.
>
> > I already used a small, cheap PIC for this task, these days I would
> > use a HC08.
>
> Yes, precisely, I am looking to do it with a PIC. I was
> hoping there was a
> solution out there so that I would not have to reinvent the
> wheel. Ideally,
> I would like a parallel interface to off-board accumulators.
>
> Regards,
>
> Paul > ------------------------ Yahoo! Groups Sponsor
> ---------------------~-->
> Get 128 Bit SSL Encryption!
> http://us.click.yahoo.com/xaxhjB/hdqFAA/xGHJAA/dN_tlB/TM
> --------------------------
> -------~->
>
> -------------------- >
> ">http://docs.yahoo.com/info/terms/



This has some limitations:
Noise susceptibility
At high motor speeds can use all the controller's bandwidth
Doesn't use the 4x advantage of quadrature encoding
Nick

> -----Original Message-----
> From: [mailto:]
> Sent: Saturday, March 08, 2003 11:05 PM
> To:
> Subject: Re: [68HC12] Quadrature Inputs > In a message dated 3/8/03 8:52:38 PM Eastern Standard Time,
> writes:
>
> > I'm surprised, given the number of embedded applications
> > involving motor
> > control or data capture, that almost no micros out there support
> > quadrature
> > input. On our products, we use Xilinx FPGA's that provide 8 sets of
> > quadrature input and handle all the accumulation, etc.
> > However, on small footprint boards, with a simple task, it
> > would be very
> > desirable to lose the Xilinx and just read quadrature
> directly. Even
> > just
> > one pair of quadrature inputs would be fine.
> > Has anyone out there solved this problem?
>
> Just hook one of the encoder lines to an input with edge
> triggered interrupt,
> arm for falling edge interrupt (for instance), read other
> encoder line in
> handler, inc on hi, dec on lo. >
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~-->
> Get 128 Bit SSL Encryption!
> http://us.click.yahoo.com/xaxhjB/hdqFAA/xGHJAA/dN_tlB/TM
> --------------------------
> -------~->
>
> -------------------- >
> ">http://docs.yahoo.com/info/terms/




The 2024 Embedded Online Conference