Search the Community

Showing results for tags 'rotary'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • GadgetBox Universal IoT Hardware
    • GadgetBox General Discussion
  • Papilio Platform
    • Papilio General Discussion
    • Papilio Pro
    • Papilio One
    • Papilio DUO
    • Papilio Wings
    • DesignLab IDE
    • DesignLab Libraries
    • RetroCade Synth
    • Papilio Arcade
    • Papilio Loader Application
    • Papilio Logic Sniffer
    • Retired
  • Electronics
    • Modules
  • Soft Processors
    • ZPUino
    • J1 Forth
    • AVR8 Soft Processor
  • Community
    • Gadget Factory
    • Documentation
    • FPGA Discussions
    • Community Projects
    • Pipistrello
  • Open Bench
    • Open Bench Logic Sniffer at Dangerous Prototypes
    • OpenBench Logic Sniffer at Gadget Factory
  • Gadget Factory Internal Category


  • Papilio Platform
    • Papilio One
    • Papilio Plus
    • Papilio Wings
    • LogicStart MegaWing
    • ZPUino
    • Papilio Pro
  • Papilio Arcade
  • RetroCade Synth
  • Logic Sniffer
  • FPGAs
  • DesignLab
    • Example Projects
    • Libraries


  • Papilio FPGA
    • Papilio UCF (User Constraint) Files
    • Papilio Bit Files
  • Papilio Arcade
  • RetroCade Synth
  • General
  • Beta (Test) Releases
  • Books

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 1 result

  1. Emperor Napoleon

    Am I Doing This Right?

    I wanted to decode a quadrature rotary signal, so I started with the quadrature decoder code from opencores,quadraturecount I was never able to get that code to count, even after ruling out other sources of problems So I modified the code in a way that made sense to myself, it turned out much shorter then the original and best of all it works correctly Yes, It's not enough that it works, I need outside confirmation that I did not do something bad. My question is, did I get lucky, and am I ignoring possible timing issues, race conditions? Under what conditions can I know that writing to a signal visible to outside circuits is safe? My head kind of hurts from thinking about it. Code follows, thanks library IEEE;use IEEE.STD_LOGIC_1164.ALL;use IEEE.STD_LOGIC_ARITH.ALL;use IEEE.STD_LOGIC_SIGNED.ALL;library work;--How we 'talk' to the outside world:entity QuadratureCounterPorts is Port ( clock : in std_logic; --system clock, i.e. 10MHz oscillator QuadA : in std_logic; --first input from quadrature device (i.e. optical disk encoder) QuadB : in std_logic; --second input from quadrature device (i.e. optical disk encoder) CounterValue : out std_logic_vector(23 downto 0); --just an example debuggin output setCount : in std_logic_vector(23 downto 0); writeEnable : in std_logic );end QuadratureCounterPorts;--What we 'do':architecture behave of QuadratureCounterPorts is signal Count : unsigned(23 downto 0); signal clockD : std_logic; signal Quad : std_logic_vector(1 downto 0); signal lastQuad : std_logic_vector(1 downto 0); function gray(a:std_logic_vector) return std_logic_vector isbegin if a="00" then return "00"; elsif a="10" then return "01"; elsif a="11" then return "10"; elsif a="01" then return "11"; end if; return "11";end function; begin --architecture QuadratureCounter -- do our actual work every clock cycle process(clock) begin --keep track of the counter if ( rising_edge(clock) ) then lastQuad <= Quad; Quad <= gray((0=>QuadA,1=>QuadB)); if((unsigned(Quad) = unsigned(lastQuad)+1)) then Count <= Count + 1; end if; if((unsigned(Quad) = unsigned(lastQuad)-1)) then Count <= Count - 1; end if; if(writeEnable = '1') then --Count <= unsigned(setCount); end if; end if; --clock'event CounterValue <= std_logic_vector(Count); end process; --(clock) end behave;