rotary encoder with counter - Page 1
Forum section: electronics / projects

author: mj21
author_rank: Regular Contributor
timestamp: February 19, 2014, 11:19:49 pm
content: I am trying to feed a rotary encoder output to a binary counter, i am using two 4516 up/down counter chained together to get 8bit. It works ok. The second counter gets its direction pulses from the first counter carryout and the two share the same clock. As can be seen from the diagram. Now i am feeding the 8bit to a dac0800. The voltage output goes from 0 to 5volt. The problem i am having is the dac out put dips few milivolts before it goes up for every 8 bit word. Also the second counter output jumps every now on then. Can some one let me know if there is a better way of doing this. I dont wanna use micro controller.

author: uwezi
author_rank: Unknown
timestamp: February 19, 2014, 11:28:01 pm
content: You are using ripple counters, which means that each bit on the output essentially updates asynchronously from the other bits. When the carry from the lower 4-bit counter to the upper counter happens e.g. when going from 15 (01111) to 16 (10000) there is a very brief moment when the four outputs from the lower counter are already reset to 0 while the upper counter hasn't realized yet that it should update.Stop the press!It's past midnight here and I could also blame that I am not familiar with the 4xxx series of CMOS devices (I am more a 70s guy)...Obviously your 4516 is a single 4-bitsynchronouscounter and all 4 bits of each counter should update simultaneously. But this is not necessarily true for the signal linking the two counter stages together!Just a question: do you have decoupling capacitors at all the chips' supply pins? If not this could explain the mV glitches. How does the +5 V supply look?A better way would be to introduce a buffer stage in the form of an 8-bit latch and to make sure that the DAC only reads the input when you can be sure that all stages of the counter have updated their output. Since the DAC0800 doesn't have its own latch, you should use something like an 74HC573 (it nicely puts all inputs on one and outputs on the other side of its package) and trigger the latching through a (short) delay, e.g. by a monoflop triggered from the same source as the CLK of the lower counter.Another probable cause: in spite of your RC filtering of the encoder's outputs you still might (and probably do) get glitches and bounces. A fast double clock signal could lead to both counters advancing two steps, which would mean for the full value to advance by 17 instead of 1.

author: mj21
author_rank: Regular Contributor
timestamp: February 20, 2014, 12:04:17 am
content: Great. Thank for quick response. I will try this tomorrow. One more question. In the datasheet of the dac0800 the inputs of the dac are all conected via a resistor to positive rail.and the also resistores from the out put of the counter to the input of the dac. I have not done that. What are the resistores for. Could this be a reason i get a voltage dip before the voltage climes high a step?

author: mj21
author_rank: Regular Contributor
timestamp: February 20, 2014, 12:24:20 am
content: Yep got 0.1uf for every chip and 5vlot supply is clean. I ran the encoder signal thro a 7414 to clean it up. Looking at it with the scope it lookes clean, i cant find what the dip in the voltage is for, i even used a function gen to simulate the clock pulse from the encoder. Even then about few second before the counter out put goes one bit high or low the voltage of the dac dips then when the bit has changed the dac goes high. For example. The dac output is at 2.400 volts. Few second before the output should jump to 2.410 volts the output goes to 2.380 volts then it jumps to 2.410

author: fcb
author_rank: Super Contributor
timestamp: February 20, 2014, 02:05:38 am
content: optical rotary encoders tend to play nicely, mechanical contact based encoders will exhibit contact bounce.You will probably need to start by debouncing the encoder.

author: Kirigozo
author_rank: Contributor
timestamp: February 20, 2014, 07:41:14 am
content: @mj21what sort of encoder have you got there?I've never seen one with 1 clock pin and 1 direction pin.

author: uwezi
author_rank: Unknown
timestamp: February 20, 2014, 08:52:51 am
content: Quote from: mj21 on February 20, 2014, 12:24:20 ama fewseconds?Your circuit can predict the future!!!I thought you were talking about dips which you would see on the oscilloscope and which would be on a microsecond scale...The resistors on the digital inputs are calledpull up resistors:http://en.wikipedia.org/wiki/Pull-up_resistor

author: woodchips
author_rank: Frequent Contributor
timestamp: February 20, 2014, 10:42:35 am
content: The data sheet uses the direction control wired to all counters, and the count out connected to the count in. Your circuit has count in on the second chip floating, not a good idea for 4000 CMOS.Parallel pins 1, 9, 10 and 15 on all counters, pin 5 to 0V on counter 1 and pin 7 to pin 5 between the counters.

author: dannyf
author_rank: Super Contributor
timestamp: February 20, 2014, 04:07:16 pm
content: It would be fairly easy to do all that on a mci.if you have to do it with logic ic, how about using a flip flop to detect direction and feed an up/down counter?

author: mj21
author_rank: Regular Contributor
timestamp: February 21, 2014, 08:21:57 am
content: Sorry i have connected thoes pins to ground. I have now sorted the problem out. I ran the output of the rotary encoder to a 7414 hex inverter with schmitt trigger which has sorted the debounce problem. I now get clean signal and there is no more mis-count . Now as for the count in and count out pins. The first counters count in is conected to ground and its count out to second counter count in. The count out of the second counter to count in of the third. I am using three counters to get 12bit. I have decided to use R2R lader resistor network for my DAC and a ad711 as the voltage follower. The entier counter circuit uses 15 miliamp of current, now what have done is runing the whole counter circuit from a precision voltage ref. I have lots of PMI ref01 at hand. Its a 10volt precision ref. I am using two 12k 0.01% as voltage divider from the out put of the ref01 to ground and runing it to an voltage follower AD 711. I am getting 5.001 out which i am using to run the counter circuit. After letting it run for 24 hour the output voltage of the R2R lader DAC only changed by .001 mili volt on my meter. Once i have done more test i will post a clear diagram. The resistor value for my r2r is 10k and 20k. I am using two 10k to make the 20k and they are all 0.01%. I got them at boot sale. Lol i dont think the guy knew what they where as i got them cheaper than chips.

author: Rudolfo
author_rank: Contributor
timestamp: February 22, 2014, 01:00:43 pm
content: If you have forward/backward coded AB signals from the encoder you need to decode and drive an up/down counter(seehttp://ichaus.biz/wp2_simple_measurement).