Connect with us

Why don't counter chips have a polarity sign?

Discussion in 'Electronic Design' started by Product developer, Feb 6, 2004.

Scroll to continue with content
  1. After designing a few quadrature interfaces using a variety of
    counters from the usual suspects to the Agilent HCTL line I have yet
    to find a chip with a polarity sign bit. One would think that there
    are enough machine control applications where direction reversal will
    require counting in a negative direction. Granted the index occurs
    during zero of both direction's output allowing detection of the first
    leading edge to set a flop for polarity but why this isn't a standard
    function on the counter chip is beyond me.
  2. Tim Wescott

    Tim Wescott Guest

    Those chips count up or down depending on the shaft direction -- if you're
    implementing a controller based on that you can just look at how much the
    count has changed to know the magnitude and direction.
  3. legg

    legg Guest

    Surely, if you've got a counter that can count either up or down, then
    the polarity bit is the bit instructing the count's direction.

  4. Paul Burke

    Paul Burke Guest

    Don't quite get what you mean. You can get direction of count by taking
    two successive samples and subtracting. The MS bit of the binary output
    word (2s comlpement) gives you the sign of the integrated position
    (since last index of course). Perhaps you mean an output giving the
    instantaneous direction of count? Easy enough to design your own with a
    PLD, and probably a lot cheaper than HP anyway.

    Paul Burke
  5. Doesn't the HCTL2020 have a pin 5 that gives U/D output signal?
    Or do you want a signal telling the encoder has reversed past
    the index again? That would cause problems if the size of the
    counter is too small, once the counter overflows, it could never
    detect that same spot again, and your signal is unreliable.

    Such things are better done in software, or additional logic
    that deals with the situations at hand.
  6. (I think) he means that the accumulated count should go
    -3,-2,-1,0,1,2, 3 etc. like on a machine tool DRO. Firmware or PLD..

    Best regards,
    Spehro Pefhany
  7. Use an U/D counter and define the MSB as the sign bit.
  8. Are you sure?
  9. Sure, the coding wasn't specified (I chose 2's compliment). ;-)

    FD = -3
    FE = -2
    FF = -1
    00 = 0
    01 = 1
    02 = 2
    03 = 3
  10. If you're happy enough with two's complement. I think there's
    typically a transformation that happens between the "raw" count on a
    DRO and what gets displayed to the hairy-eared machinist, so it might
    be as good as anything. For example, you want to switch between inches
    and mm, and offset by some arbitrary amount. If there is no scaling
    operation, counting in signed BCD or packed BCD might be more
    sensible, as long integer to bcd is a pretty slow conversion.

    Best regards,
    Spehro Pefhany
  12. Oh, I use sprintf for that ;-)
  13. I don't think the "product developer" is going to be happy with the
    sprintf "overhead" either. ;-)
  14. I know what would make him happy, a controller with a
    build-in quadrature decoder !
  15. Which one do you suggest? I think the Motorola TPU module can do it.

    BTW, if it's just for indication, the sprintf may be just fine, once
    you uncouple the maximum counting frequency frome the display update
    rate. The former might be 1MHz on a CNC machine doing a rapid,
    whil[e|st] updating a digital display more frequently than about 10Hz
    is a waste (and sometimes bad in other ways).

    Best regards,
    Spehro Pefhany
  16. You got it. In a dual direction system like a planetary in an vacuum
    chamber there are times when you will want to reverse direction and
    count below the index which will be a negative number. All counter
    modules I know of have this feature built in. A polarity sign will
    change from pos to neg when you go below zero or index.

    In other words there are applications where you need to know what side
    of the index you are on. If all you are doing is going continously in
    one direction that is straight forward. You count from 0 to say 1,999
    in a 2,000 CPR setup and every time you get an index you reset the
    count which provides absolute position. In situations where you will
    be traversing the index in both directions without completing a full
    rotation you would get counts on either side of the index and without
    polarity there is no way of knowing which side of the index you are
    on. If the index is at 12 o'clock and the rotation of the wheel goes
    back and forth from 10 o'clock to 2 o'clock you get the same count at
    each position yet the position is not the same. A polarity or "sign"
    bit would give this indication without the need for secondary decoding
    of the index to direction relationship.
  17. Seems so, after a brief check. Strange that a QD is not (yet)
    amongst the common standard peripherals found on controllers.
    Thousands have been fighting this problem, and it can only
    be done in software for digital encoder type *potentiometers*
    or encoders with a low rpm and low resolution. The HCTL
    solution are imo too expensive. So what we want are AVR's,
    PIC's, SX's, 8051's with build-in QD's.

    Good advice. I tend to write software so that it does only
    things once when nothing has changed, and do it at a rate
    not faster than needed. The cycles saved are greatly appreciated
    later ;) A few hundred years ago, on an apple][, I wrote a loop
    that continously wrote a string with some numbers to the screen.
    When it runned, it showed all kinds of funny artefacts, like
    crossfading and disappearing, coming back again etc. Magic!
  18. We can blame Woz for not buffering the data properly, I think.

    Best regards,
    Spehro Pefhany
  19. Not to mention Nipkov, Baird and Zworykin ;)
  20. CBarn24050

    CBarn24050 Guest

    several of the hitachi h8s and fujitsu 162lx chips have qdcounters
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day