Shop OBEX P1 Docs P2 Docs Learn Events
Quadrature Encoder — Parallax Forums

Quadrature Encoder

T ChapT Chap Posts: 4,223
edited 2006-10-06 01:27 in Propeller 1
Hello. I have been searching for some code to count quadrature encoder inputs(2 pins), I heard there was an object but have not found one yet.

If you know of something please point me to it.

Thanks

Post Edited (originator99) : 10/3/2006 4:55:02 AM GMT

Comments

  • kelvin jameskelvin james Posts: 531
    edited 2006-10-03 05:16
    There is program included with the editor called rotary encoder. It may take a little tweaking, but looks like what you want.

    kelvin
  • T ChapT Chap Posts: 4,223
    edited 2006-10-03 06:23
    Yes I found it in the folder and felt like a dunny for posting. The encoder has a resolution of 200. The rotary object is reading 4x the pulses, unless that is intentional. I can always divided it down to keep the same ppr as the motor outputs. The object is exactly what I have spent at least 8 hours trying to create.

    What I mean is, if I tell the motor to turn 1 rev=200 pulses, the object returns the position as 800.

    My understanding of the encoders operation from talking to US Digital is that you can decode it at 1x, 2x, or 4x, as there are 4 events per cycle. I'd prefer it to be 1x without having to divide it, but I am happy with this as is for now. If dividing down and there is an original value that is not a multiple of 4, then it is going to get messy.

    Post Edited (originator99) : 10/3/2006 6:46:25 AM GMT
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2006-10-03 14:24
    An encoder may have 200 slots but is has two sensors and counts the edges, that means a 200 line encoder has a resolution of 800 ppr after quatrature decode.

    Graham
  • TCTC Posts: 1,019
    edited 2006-10-05 00:26
    You could check out this site· http://www.usdigital.com/products/ics.shtml

    There are some IC's that have X1 or X2 or X4 resolution multiplier.

    TC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    We all make mistakes when we are young………That’s why paste is edible!
  • pjvpjv Posts: 1,903
    edited 2006-10-05 01:52
    Hi TC;

    Actually they are not resolution multipliers, but reducers; the number of states available in a quadrature encoding scheme (four) are divided by a factor of 2 or 4, to become 2 or 1.

    The Propeller can easily deal with the 4 quadrature levels..... downgrading the resolution is likely not desirable.

    Cheers,

    Peter (pjv)
  • T ChapT Chap Posts: 4,223
    edited 2006-10-05 02:55
    TC I am using the USDig E2. I looked at their decoders and spoke to their techs about the products you ,entioned, but decided to use the Prop for the decoding, which is working very nicely with the encoder object. I'll just multipy the motor pulses by 4 when I need to compare.
  • TCTC Posts: 1,019
    edited 2006-10-05 03:19
    Please let me know how it goes, in my spair time I am working on a poor-man's CNC. (three cheep 12V drills, some all thread, and three incoders). right now not spending much time on it.

    TC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    We all make mistakes when we are young………That’s why paste is edible!
  • T ChapT Chap Posts: 4,223
    edited 2006-10-05 04:33
    I am rebuilding a new machine that never worked right for me, the mechanism is fine but their controller was problematic. I decided to stop wasting time with their controllers issues and build my own closed loop 3 axis controller. I am almost done, the current regulation was tough to get right. But I am almost there. You are welcome to the file when it is ready.
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2006-10-05 19:18
    Well its my turn to feel a bit dumb now, I looked at the object and saw the words gray code so I thought it would need too much tweaking to bother with, as such when I needed to read a quadrature encoder today I wrote my own object not realising that 2-bit gray code is the same thing.

    Anyway here is is attached, it may be faster as it is less general. There is also a test program for TV output I was using today to read two encoders, at the moment I have to use a cog per encoder which is fine by me as I need lots of speed.

    Graham
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2006-10-05 19:20
    p.s. on my implementation the pins can be arbitrary not just contiguous
  • T ChapT Chap Posts: 4,223
    edited 2006-10-06 01:27
    I read the gray code part, but ignored it and hooked it up anyway. As far as I can tell it is reading fine. I can send the motor X steps, the read the encoders count which is always X4 the motor steps. I do like the noncontiguous approach though. Thanks for posting it, I'll test it later tonight.
Sign In or Register to comment.