How To Use A Rotary Encoder Without Software

Sdílet
Vložit
  • čas přidán 31. 07. 2018
  • If you need to quickly get a rotary encoder project up and running and there's no time for setting up an Arduino or micro controller, if you have some basic digital logic chips there's several ways to get a prototype going.
    Patreon: / gadgetreboot
    Pinterest: www.pinterest.ca/GadgetReboot
    Twitter: @GadgetReboot / gadgetreboot
  • Věda a technologie

Komentáře • 37

  • @arenotdiy7280
    @arenotdiy7280 Před 3 lety +2

    I built it just as you designed with AND gates, and it worked fantastically on 5 volts, battery operated. I built my own rotary encoder breakout board with 2k ohm current limiting resistors, so maby that was what made the difference, but all I needed was a decoupling cap of one micro farad across a and b.
    Thanks for the info!

  • @petrakis1
    @petrakis1 Před 3 lety +1

    Exactly what I was looking for. Thank you

  • @akaludi
    @akaludi Před 3 lety +1

    Nice Explanation and brief

  • @ArjanvanVught
    @ArjanvanVught Před 5 lety +3

    Really great - thanks !

  • @WistrelChianti
    @WistrelChianti Před 4 lety +1

    Thanks so much! Having just been finding out about rotary encoders, my immediate question was "can we control two buttons with them (left/right)" without a microcontroller. And lo and behold your most excellent well paced and explained video! I'd already knocked up a simulation but was pondering what to put in the middle, I wasn't sure if normal logic gates were going to cut it as had a feeling some sort of "memory" was needed to stop them firing one after the other, and it looks like it was. Shame the answer turned out to be "at least 2 more chips and a custom circuit board". But at least it is possible.

  • @electronic7979
    @electronic7979 Před 6 lety +2

    Excellent

  • @jpdesroc
    @jpdesroc Před 2 lety +1

    I tried your circuit and it works pretty well ! The only thing I found is when a pulse get on one of the flip-flop output (ex: CW) the CCW output sometimes shows a very small glitch at the same time. That's not a problem by rechecking the interrupt pulse that just triggered the uC (CW or CCW) to see if it's a glitch (after a small usec delay check) or if the pulse is a steady one.

  • @efesstuff4936
    @efesstuff4936 Před 6 lety +3

    İ think you can use data and clock thingy and use peak detectors in both outputs with low capacitance and buffer them with a op amp. And you can put leds or another stuff on opamp outputs and have some fun!

  • @nigelworwood8530
    @nigelworwood8530 Před 2 lety

    Excellent.

  • @joemc4860
    @joemc4860 Před 3 lety

    Connect A and B to an exclusive-or gate and look at the output as you turn the shaft. Does it double the pulses per rev?

  • @mardav1545
    @mardav1545 Před 4 lety +2

    I just thought that I was confused until I watched this video. Now I'm thoroughly confused.

  • @norbithehun
    @norbithehun Před 2 lety

    Great video, thanks. One question: if my mechanic rotary encoder works only at every second step (both directions), is it the encoder fault itself, or it can be an other component on the board?
    Thanks for your help in advance.

  • @tablatronix
    @tablatronix Před 4 lety

    I wish you could buy nice logic probe wires like those, or good logic micro hooks

  • @GnuReligion
    @GnuReligion Před 6 lety +1

    Cool. You have all sorts of equipment there. The way I think about it in software, is when both leads are low, then you are midway between resting points (chip enable) ... and time to look for which side goes high first, that is the direction INC/DEC + CLK-UP. Both go high, chip disable, CLK-DOWN. Was hoping this could all be done with a quad NAND . A couple of gates would flip flop to store the enabled-ness.

    • @GadgetReboot
      @GadgetReboot  Před 6 lety +1

      I started out trying to use simple gates and then I kept realizing I hit a dead end trying to cover all the scenarios so the flip flop with supporting gates ended up being the easiest I could think of.
      I am already thinking about expanding my original single flip-flop version to actually control the digital pot so if I think of something there will be a video on that coming up but I don’t know if it can just be done with a few gates.
      Even when I try to think about the process in a software mentality about waiting for something to happen and then doing something else and having to control those three lines, I always end up in a spot where I need to latch and store one of those states and then make use of it later.

    • @GnuReligion
      @GnuReligion Před 6 lety

      Hehe, one could always give up and use an ATtiny13, that costs $0.30. All sorts of states there... A couple of inverters and resistors makes a flip-flop.

    • @GadgetReboot
      @GadgetReboot  Před 6 lety +3

      Yeah sometimes a task becomes more of an intellectual exercise than a practical ambition but it keeps the mind working and that can be maybe transferrable to a different problem that can be solved this way so I don’t mind thinking about it.
      I put some more thought into it and got road blocked again so I think to actually control the pot I will need to use some RC delays to generate in-between states so I’m going to think about if that’s practical and if so I will do a video.

    • @timshoo1627
      @timshoo1627 Před 4 lety +1

      @@GadgetReboot I found a way to get a step and direction output to a binary counter ic(theoretically turning it into an absolute encoder output) in a logic simulator(Logisim Evolution, definitely recommend)using a d-latch on each encoder output. Then XOR before and after each d-latch(A_New and A_Old get XORed, B_New and B_Old get XORed). Then XOR both of those XORs to get your STEP signal(connect to ENABLE pin of the counter). Then XOR either A_NEW and B_Old or A_Old and B_New to get DIRECTION output(connect to DIRECTION pin fo the counter). Finally attach an oscillator to all of the clock pins(d-latches and counter).
      If you manually pulse the clock, you will notice the DIRECTION output is active when you would think it should not be. In simulation at least, it only matters what is active when the clock switches.

  • @deepeshkushwah607
    @deepeshkushwah607 Před 3 lety

    Can you please help me to make a code for DMX stapper motor with optical encoder

  • @Flight2020
    @Flight2020 Před rokem

    Thanks so much. I was looking for this hardware solution for long time.
    But why on earth nobody yet developed a dedicated micro-chip for this task??? Or it exist and I just cannot find it?

  • @PrincePloppy
    @PrincePloppy Před 3 lety +1

    I have a question. Can you trigger a Rotary encoder with the use of a momentary footswitch by grounding either clock or data? IE: to go forward or back? I have a finger operated rotary encoder, which I want to keep, but wanted to add a footswitch.

    • @GadgetReboot
      @GadgetReboot  Před 3 lety +1

      If there are 2 foot switches they could be in parallel with an encoder and pressed in the same way an encoder would trigger the 2 signals, but doing it with just one switch sounds like it would need some sort of circuit to trigger both inputs, since both are needed to detect direction.
      It also depends on how software is reading the inputs to decode them, and depends if you need to be able to go both directions or just one.
      If the code is really only monitoring clock for changes, then checking to see if data is high or low to indicate direction of travel, if you just have a footswitch to ground on the data input, the system will never see any activity because nothing triggers clock. If you have clock on a footswitch and trigger it, data will be pulled high so you'll always see movement in whatever direction that represents unless you have another switch or circuit to change data. That's just based on one method of reading the encoders but eithe way 2 switches or a circuit are needed.

    • @PrincePloppy
      @PrincePloppy Před 3 lety

      @@GadgetReboot ty so much for your reply. I think a small capacitor should provide a brief delay as it now seems im gonna have to ground both to get movement. Im gonna poke around inside and see what gives. I need 2 switches anyway. 1 for up and 1 for down. (Clockwise n anti clockwise.

    • @GadgetReboot
      @GadgetReboot  Před 3 lety +1

      @@PrincePloppy It's a good idea to draw a schematic when thinking about how to make it work because things may become clear suddenly, like if needing to go both directions, one direction from each switch, then adding a capacitor to one of the lines may only work if you only ever needed to go one direction so you always delay one pin and have the other instant, and simulate one change following another a little later. But when you need to do the same in reverse, you may need a capacitor on both lines, which results in just delaying the whole system and it's back where it started.
      And by having it all wired up to 2 switches and trying to make the signals trigger in opposite directions with just switches and capacitors, it all may end up being a big short circuit type scenario! So it starts turning into a project circuit with maybe transistors doing the actual signal switching, and the foot switches controlling the transistors, capacitors controlling how fast the transistors come on for delaying one of the pulses. Then the transistors provide the isolation between the two connection schemes for each direction and nothing conflicts. I wonder if there's already a circuit like that somewhere online.
      I saw this: blog.gypsyengineer.com/en/diy-electronics/transistor-delay-circuit.html#:~:text=After%20some%20time%2C%20the%20voltage,of%20the%20variable%20resistor%20R3.
      I haven't tested but if I were to use it on an encoder, I'd remove LED1 and R1 because we're not turning on a light, and instead connect the transistor collector to one of the encoder clock or data lines. The 3V power source would be whatever is powering the encoder so probably 3.3v or 5v from the main circuit.
      The value of R2 is probably not critical so can be experimented with, and the main delay would be controlled by R3 and/or C1.
      It looks like when the switch is pressed, after a delay the transistor would bring the encoder line to ground when the capacitor charges enough to turn on the transistor.
      When the switch is released the capacitor will drain as it tries to keep the transistor on and it will eventually release the encoder signal.
      So that would provide a delay on one line as a concept of how I think a capacitor would have to be implemented rather than directly connecting it and then everything is messed up possibly. This way, it's just an Open Collector circuit on the encoder input and it's as if nothing is really there, or else it's being pressed to ground, and it's all isolated. Then you'd figure out how to connect up the one switch to control both the lines and a second switch with more of the circuits to control in the other direction (might turn into
      a big project)

    • @PrincePloppy
      @PrincePloppy Před 3 lety +1

      @@GadgetReboot thank you so much for the time you've taken explaining this to me. I truly do appreciate it. I think however this is wat beyond my skill level. So i have decided to shelve this idea. lol I did subscribe though, so maybe I'll learn a lot more about electronics watching your videos. You are a good teacher

  • @test_channel_eg
    @test_channel_eg Před 3 měsíci

    Hello bro
    Can you help me with a encoder
    Just your projects

  • @browaruspierogus2182
    @browaruspierogus2182 Před 6 lety +1

    Many devices have hardware pulse counters - what we need is hardware button push up down.

    • @GadgetReboot
      @GadgetReboot  Před 6 lety

      Yeah there is a few standalone chip options like the LS7XXX
      lsicsi.com/datasheets/LS7083N_LS7084N.pdf
      But this was supposed to be a more fast solution when other options aren’t available so in my case I don’t have a dedicated encoder chip but I have lots of separate logic gates.
      Can you elaborate on that hardware button situation? How would that be used and what does it need to do?

    • @browaruspierogus2182
      @browaruspierogus2182 Před 6 lety

      So is there a standalone tiny IC for rotary encoder? I know they sell encoders with spi circuits but if you have many encoders that's costly

    • @GadgetReboot
      @GadgetReboot  Před 6 lety +1

      The LS7083/LS7084 are smaller eight pin devices that look at the two encoder signals and then depending on the chip they generate different outputs but I’ve never used it so I’m not sure.
      Just looking at the timing waveform it looks like it generates A clock for every time there’s an encoder change so there will be multiple clocks within a single rotation.
      Maybe there’s a way to only get a single clock out for a single position change or maybe there’s a better chip to do that but for a custom application we still may sometimes need a custom circuit.

  • @101Gabriel_M.
    @101Gabriel_M. Před 4 lety

    Can i have this schematic diagram? :"D
    I really not wanna start learn programing as well, so the hardware made version is looks easier and more stable for me...
    I wanna replace the shitty DIP buttons on a device to rotary encoder, because faster, fancier, more comfortable.
    OC if i get dedicated A/B pulse lines to directions of turns, the next is just a FET or BJT to replace te buttons.

    • @WistrelChianti
      @WistrelChianti Před 4 lety

      yeh here for the same reason, but it looks like a custom board with at least 3 chips on sadly.... still might be a fun challenge to figure/layout.

  • @andrewferg8737
    @andrewferg8737 Před 4 lety

    Great video!!! I'm wondering how to use a rotary encoder or perhaps a hall sensor (without a microcontroller) for my current project: czcams.com/video/6bwtA_dc6JA/video.html Any ideas would be appreciated as I've no experience yet with using these components.

  • @backlash00
    @backlash00 Před 4 lety +1

    Nice manipulation of logic to achieve what you wanted. I don't know what you will be using the pulses for but if all you need is to know encoder direction then feed A and B into D and Clk of FLIP-FLOP. Q will be low for one direction, high for the other. Arduino can read that. One DIP with leftovers.

    • @GadgetReboot
      @GadgetReboot  Před 4 lety

      I can’t remember what I was trying to accomplish at the time but I think I needed two separate outputs and maybe even some sort of logic debounce, I just remember spending a bunch of time on a whiteboard at the kitchen table a couple of years ago.