Searching \ for 'quadrature decoding' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/io/sensors.htm?key=quadrature
Search entire site for: 'quadrature decoding'.

Truncated match.
PICList Thread
'Quadrature decoding'
1998\12\08@045425 by

flavicon
face
Just had a request from someone for a PIC to decode the output of a rotary
encoder with quadrature output to a serial DAC.

Just wondering what would be the best way to implement the quadrature
encoding?  This application is purely for a product evaluation board so
processor choice/cost is not much of a problem.  I say this because if I
went for a mid range part (maybe a 16F84) I could use the interupt pin to
detect a rising edge on one of the quadrature signals and in the ISR read
the state of the other signal.  However, I suspect I could probably get away
with just polling the lines in a reasonanbly fast loop so I could use one of
the cheapo 16C5X devices without interupts.

Has anyone done this?  Any hints/comments?

Regards

Mike Rigby-Jones
spam_OUTmrjonesTakeThisOuTspamnortelnetworks.com

1998\12\08@052612 by keithh

flavicon
face
Rigby-Jones, Michael [PAI01:4837:EXCH] wrote:
>
> Just had a request from someone for a PIC to decode the output of a rotary
> encoder with quadrature output to a serial DAC.

Done that.
Scope the signals and see why they're not fit to use as interrupts.
My rotor data sheet says the bounce is 3ms.
At maximum rated rotation, the stable states are about this long!

So I poll them every millisecond, and if they're the same for two
consecutive samples I consider them stable and shift them into
a software shift-register. If I see these stable values change,
I interpret the transition.

For thrift, the switches go straight into the CPU.

I'd have preferred to do some signal conditioning with
a pair of Schmitt triggers, to filter out most of the cak.

This advice should save you a lot of wasted time!

1998\12\08@064946 by Pavel Korensky

flavicon
face
At 09:51 8.12.1998 +0000, you wrote:
>Just had a request from someone for a PIC to decode the output of a rotary
>encoder with quadrature output to a serial DAC.
>
>Just wondering what would be the best way to implement the quadrature
>encoding?  This application is purely for a product evaluation board so
>processor choice/cost is not much of a problem.  I say this because if I
>went for a mid range part (maybe a 16F84) I could use the interupt pin to
>detect a rising edge on one of the quadrature signals and in the ISR read
>the state of the other signal.  However, I suspect I could probably get away
>with just polling the lines in a reasonanbly fast loop so I could use one of
>the cheapo 16C5X devices without interupts.
>
>Has anyone done this?  Any hints/comments?

I did this and after several experiments, I decided not to use the PIC at all.
My final solution was to use ISP1016 GAL from Lattice. In one chip, there
is enough space for 4 channel quadrature decoders and digital filters :-))
Whole thing is Field programmable and development software is freely
downloadable.
The cost of chip is around 10-15 USD is single quantities.

Best regards

PavelK

**************************************************************************
* Pavel KorenskyÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ *
* DATOR3 LAN Services spol. s r.o.ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ *
* Styblova 13, 140 00, Prague 4, Czech Republic      ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ *
*ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ *
* PGP Key fingerprint:Ê F3 E1 AE BC 34 18 CB A6Ê CC D0 DA 9E 79 03 41 D4 *
*ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ *
* SUMMA SCIENTIA - NIHIL SCIREÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ *
**************************************************************************

1998\12\08@094408 by Steve Landas

picon face
If you run one output into the D input of a flip flop and the other output
into the clk of the same flip flop; then the flip flop output will be
direction. Then pick either input and input it to an up down counter that you
clear each time you poll it. You can poll this less often so it won't be as
software intensive. Just another way of doing it.

1998\12\08@121158 by Jeff Jolie

flavicon
face
Mike,
HP makes a nice quadrature decoder chip, HCTL-20XX.  The HCTL-2000 has a
12bit counter and the HCTL-2016 & 2020 have 16bit counters.  This chip has
sure made my life easier on more than one occasion.  They also give a count
& direction output if you are only interested in the quadrature decoder part
of it.  I've brought the count and direction into an onboard counter on a
Seimens controller.  Not sure if any PIC counters support up/down counting
this way.  HP puts out an app note on interfacing the HCTL-20XX to the Intel
8051.  The HCTL cost around $15. Hope this helps.

-----------------------------------
Jeff Jolie
New England Automated
Machine Engineering, Inc.
Deep River, CT
.....jeffKILLspamspam@spam@neame.com
-----------------------------------

{Original Message removed}

1998\12\08@131716 by Gavin Jackson

flavicon
face
part 0 462 bytes
I'm doing the same thing at the moment. I used the HP HCTL2020 which are very
good. The serial D-to-A is from Burr Brown PCM56P. The SPI port can be used
to send the info to the D-to-A making interfacing much easier. By the way both
are 16-bit devices. I used a 17C43 for the interfacing but any PIC would work.

Regards

Gavin
--------------------------
vulcanspamKILLspamihug.co.nz
ICQ# 18675389
www.geocities.com/TheTropics/Cabana/2625
--------------------------

1998\12\10@034014 by

flavicon
face
Many thanks to all those that have given comments and various bits of code
for quadrature decoding.  It seems the most important part is filtering the
contact bounce/detecting invalid state changes.

The guy who I am doing this for needed some NV storage so I persuaded him
the 16F84 was the part for the job, and that he should order a few
extra...hint, hint :o)  Actually he decided to use a DAC with a parallel
data bus so I only just have enough pins now, without using any fancy
multiplexing.  He also wants some fancy control laws put in so that if the
encoder is turned above a certain rate for a fixed time, the step size is
increased, much like the 'jog' control on various instruments and hi-fi's.
Have you noticed that what starts as a relatively simple project can rapidly
spiral out of control when a someone with no software knowledge is giving
the orders?  Oh yes, it's needed some time last week as well.

A question to all you users of PIC C, are there any library functions that
come with the compiler for writting to the e2prom on the 16F84 etc, or do I
have to roll my own? (not hard, I know, but why re-invent the wheel?)

Also, on my last project (A PID controller on a 16C62A) which had quite a
lot of code, the compiler crashed when I enabled full optimisations (-O
-Zg1).  Has this been seen before?  The code compiled and ran perfectly
without these flags and speed wasn't actually an issue, I was just running
out of memory.

Regards

Mike Rigby-Jones
.....mrjonesKILLspamspam.....nortelnetworks.com

1998\12\10@055013 by Ricardo Seixas

picon face
Mike Rigby-Jones Wrote:

On the CCS Compiler there's a built in function to do this:
       read_eeprom(address);
       write_eeprom(address);

Ricardo Seixas

...
>A question to all you users of PIC C, are there any library functions that
>come with the compiler for writting to the e2prom on the 16F84 etc, or do I
>have to roll my own? (not hard, I know, but why re-invent the wheel?)

...

1998\12\10@092553 by Walter Banks

picon face
> A question to all you users of PIC C, are there any library functions
that
> come with the compiler for writting to the e2prom on the 16F84 etc, or do
I
> have to roll my own? (not hard, I know, but why re-invent the wheel?)

It is a standard library function in Byte Craft's MPC.

1998\12\10@154625 by uter van ooijen / floortje hanneman

picon face
> >A question to all you users of PIC C, are there any library functions
that
> >come with the compiler for writting to the e2prom on the 16F84 etc, or
do I
> >have to roll my own? (not hard, I know, but why re-invent the wheel?)

These are my routines (in JAL with embedded assembly,
so I appended the assembly output).
Mayby this helps,
Wouter.

var volatile byte eedata at 8
var volatile byte eeadr  at 9

procedure eeprom_get( byte in a, byte out d ) is begin
  eeadr = a
  d     = eedata
end procedure

procedure eeprom_put( byte in a, byte in d ) is begin
  var volatile bit ee_write        at 8 : 1
  var volatile bit ee_write_enable at 8 : 2

  -- preparation
  eeadr            = a
  eedata           = d

  -- the magical eeprom-write sequence
  ee_write_enable  = on
  eeadr            = 0x55
  eeadr            = 0xAA
  ee_write         = on

  -- wait for completion
  while ee_write loop end loop

  -- disable writing to prevent accidental writes
  ee_write_enable = off
end procedure


This is the corresponding assembler output:

;; 301 : procedure eeprom_put( byte in a, byte in d ) is begin
; var H'010:000' a
; var H'011:000' d
proc_2271_eeprom_put ; 000B

;; 302 :    var volatile bit ee_write        at 8 : 1
; var H'008:001' ee_write

;; 303 :    var volatile bit ee_write_enable at 8 : 2
; var H'008:002' ee_write_enable

;; 306 :    eeadr            = a
 movf    H'10',w                         ; 000B: 0810 ; a
 movwf   H'09'                           ; 000C: 0089 ; eeadr

;; 307 :    eedata           = d
 movf    H'11',w                         ; 000D: 0811 ; d
 movwf   H'08'                           ; 000E: 0088 ; eedata

;; 310 :    ee_write_enable  = on
 bsf     H'08',2                         ; 000F: 1508 ; ee_write_enable

;; 311 :    eeadr            = 0x55
 movlw   H'55'                           ; 0010: 3055 ; 85
 movwf   H'09'                           ; 0011: 0089 ; eeadr

;; 312 :    eeadr            = 0xAA
 movlw   H'AA'                           ; 0012: 30AA ; 170
 movwf   H'09'                           ; 0013: 0089 ; eeadr

;; 313 :    ee_write         = on
 bsf     H'08',1                         ; 0014: 1488 ; ee_write

;; 316 :    while ee_write loop end loop
while_2336_again ; 0015
 btfsc   H'08',1                         ; 0015: 1888 ; ee_write
while_2336_body ; 0016
 goto    while_2336_again                ; 0016: 2815 ; while_2336_again
while_2336_beyond ; 0017

;; 319 :    ee_write_enable = off
 bcf     H'08',2                         ; 0017: 1108 ; ee_write_enable
end_2271_eeprom_put ; 0018
 return                                  ; 0018: 0008 ;

;; 296 : procedure eeprom_get( byte in a, byte out d ) is begin
; var H'012:000' a
; var H'013:000' d
proc_2247_eeprom_get ; 0019

;; 297 :    eeadr = a
 movf    H'12',w                         ; 0019: 0812 ; a
 movwf   H'09'                           ; 001A: 0089 ; eeadr

;; 298 :    d     = eedata
 movf    H'08',w                         ; 001B: 0808 ; eedata
 movwf   H'13'                           ; 001C: 0093 ; d
end_2247_eeprom_get ; 001D
 return                                  ; 001D: 0008 ;

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...