Beginner : Rotary switch (quad sw)

Spartan 3E starter kit: I tried (like all beginners) to read rotary switch (knob) using FSM with 8 states, 4 for CW and 4 for CCW movements. I did not debounce phased switch inputs. It works fine. But I remember seeing much debate on this issue and claims of success with 4 FF's (plus debouncers). My design created 3 FFs and works fine without debouncers. What have I done wrong? Do "Spartan 3E starter kits" already have debouncers? Another question: When I include something like a

Reply to
meralonurlu
Loading thread data ...

How do you suppose an async up/down counter would be implemented? Possibly with adders and stuff?

A problem with async elements under mechanical control is that the switch-generated clock is never guaranteed to be free of runt pulses or pulses that violate the minimum clock period. In general, an asynchronous design is prone to many problems unless the single element is the only thing the designer is putting into the circuit (which is quite a waste of an FPGA!),

Resynchronizing outside controls like the mechanical switch eliminates many of the problems associated with unpredictable clocks and allows a full system to be integrated without the complexities of combining asynchronous elements.

- John_H

Reply to
John_H

The smallest possible Quad design uses 2 FFs, so you have done nothing wrong. The earlier discussion here included an optional 'anti-flicker' state engine of 2 more FF's that could have some merit for user interfaces (but added backlash, so less ideal for machine control) The Two FF design, effectively overlays the state follower, with the two LSB bits in the counter. It is also a design decision, on what you do with the illegal states.

Check your report file. If you avoided syncronisers, and have more than one state bit dependent on an async pin, then you _could_ have aperture errors

- in a hand control, it will be hard to even spot this, but in a machine control, it could cause serious control problems.

-jg

Reply to
-jg

Starting on April 20 this year there was a 3-week long thread about quadrature decoding. 85 postings!!! Let me summarize for a beginner: You should assume that the quadrature input is asynchronous, can have totally undefined duty cycle (down to pulses below 1 ns) and will have undefined bounce whenever it makes or breaks contact. You can however assume that, when one contact changes, the other one will be stable. Then you have to decide how many counts you want to decode: One count per any change, or one count per full cycle. Then you must decide whether a one-quadrature or 2-quadrature ambiguity is acceptable. You can also call that backlash. Manually operated switches are very forgiving, robotics shaft encoders can be far more demanding. I put two designs into the Xilinx forums or blogs, but various people had widely varying opinions. I think this here is a fair synopsis. Peter Alfke, Xilinx Applications.

Reply to
Peter Alfke

I had the foresight to connect the encoder with 6" of unshielded cable. ;)

Reply to
MikeWhy

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.