. .
Page 1 of 2 12 LastLast
  1. #1
    Took a while to discover what the output was, now how do I read it?

    It is a quadrature encoder fitted with a 100 step/rev detente that always parks you in the 00 condition.

    So when you try to buzz out the output you always get zeros

    As you turn it, you either get 01 11 10 00 or 10 11 01 00 depending on the direction.

    So how would you read it? Preferably on an interrupt!

    best

    Robin

  2. #2
    So I asked my elder brother who looks at me like I have gone senile and says, "You connect one line to the interrupt and read the other for direction".


  3. #3
    Neale's Avatar
    Lives in Plymouth, United Kingdom. Last Activity: 4 Hours Ago Has been a member for 9-10 years. Has a total post count of 1,729. Received thanks 295 times, giving thanks to others 11 times.
    Not sure that it's quite that easy! If you look at the data patterns there is no simple link between either data line and direction. And if you only interrupt on one data line, you will miss half the transitions.

    How about writing your interrupt code to read both data inputs and work out whether to increment or decrement an internal counter based on comparing current with previous state. Then set up "interrupt on change of state" on both input lines linked to same interrupt routine. The principle of quadrature inputs means that only one data line changes at a time so you should be able to handle one interrupt before the next arrives. How fast can a user turn the encoder knob?

    I need to do something similar for a device that currently uses a pot delivering an analogue input to an ADC input on an Arduino but my main processing loop is so fast (compared with rate at which data changes could happen) that I am planning to just use polling of the data lines. I need to do this because the pot is a bit noisy and my soldering iron temperature keeps jumping about...

  4. #4
    I didn't think it was that easy either, but it does explain why you get four transitions between each detente but only one counts

    What does your pot control?

    Robin

  5. #5
    Which processor? Arduino? Is there a library you could use?

  6. #6

  7. #7
    Neale's Avatar
    Lives in Plymouth, United Kingdom. Last Activity: 4 Hours Ago Has been a member for 9-10 years. Has a total post count of 1,729. Received thanks 295 times, giving thanks to others 11 times.
    That looks like the way to go. First rule of programming - find someone who has done it already and pinch their code! As the prophet says, pinch one man's work and it's plagiarism, pinch work from lots of people and it's research... Having those libraries available might get me going on my project again.

    About 20 years back, I rescued a Weller soldering iron from a scrap bin at work. It had a sticky label saying "display broken" but it turned out to be more than just that. It was quite a fancy temperature-controlled iron with an analogue temperature control, not the more common Weller magnetic bit style with a fixed temperature based on the particular bit you fitted. However, on inspection I reckoned there was a fault on the PCB which was a ceramic board with principal components under beads of something like epoxy. Not much chance of a repair so I ripped it all out and built a new Arduino-based controller using the original pot as an analogue input for temperature setting and an op-amp-based level converter reading the resistance of the temperature sensor somewhere in the iron. There was a triac switching the element (24V) with zero-crossing switching to avoid any transients - although why this worries me is still a mystery as I can't imagine why you would be soldering any sensitive electronics while live. Twiddle the pot and the display shows desired temperature and after a few seconds it goes back to reading actual bit temperature. However, now the pot seems rather noisy and the desired temperature keeps jumping about so the idea is to replace it with a cheap rotary encoder. I have the encoder but still haven't got round to fitting it and updating the code.

  8. #8
    Quote Originally Posted by JohnHaine View Post
    Which processor? Arduino? Is there a library you could use?
    I am using a pre-cambrian processor, hopefully without the explosion, the amazing Hitachi HD64180

    Robin

  9. #9
    I seem to remember that there's a hardware solution using a couple of exclusive OR gates and a counter.....

  10. #10
    Quote Originally Posted by Voicecoil View Post
    I seem to remember that there's a hardware solution using a couple of exclusive OR gates and a counter.....
    Yes there is, and maybe a D-type flip-flop too to sense direction. (XOR gates just double the pulse rate.) But you then still need to accumulate the pulses with an up/down counter and convert the counter to analogue to emulate the pot.

    If there's a C compiler for the processor I guess it should be possible to modify the library code.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Spindle pulses on shutting down.
    By John11668 in forum General Electronics
    Replies: 6
    Last Post: 22-08-2020, 11:45 AM
  2. Basic 540 CNC. Motors skipping pulses?
    By Skydeals in forum General Electronics
    Replies: 3
    Last Post: 18-10-2014, 06:56 PM
  3. Do you make stuff with knobs on?
    By D.C. in forum General Electronics
    Replies: 1
    Last Post: 20-02-2013, 11:04 PM
  4. servo control vs stepper control
    By Peter. in forum Motor Drivers & Controllers
    Replies: 24
    Last Post: 17-09-2012, 08:36 AM
  5. G-Code into stepper driver pulses?
    By HankMcSpank in forum Computer Software
    Replies: 5
    Last Post: 09-01-2010, 12:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •