rotary encoders/digital pots  - Page 1
Forum section: electronics / projects

author: PStevenson
author_rank: Regular Contributor
timestamp: January 09, 2012, 12:06:10 am
content: I was wondering if anyone knew if it were possible to use a rotary encoder to control the wiper of a digital pot IC (eg the TPL8002-25) without using a microcontroller. because I have tried to get my head around microcontrollers and it just isn't happening, my brain just doesn't do software - not in the slightest.the application is for a synth control voltage circuit however all I really want to know is if anyone has any advice on the if and how of rotary to digital IC.obviously I've explored other alternatives but a 10 turn isn't enough and is too big where as a rotary encoder/digital IC would be perfect.thanks in advance - even if you can point me to a website that would deal with such a thing.

author: PeterG
author_rank: Frequent Contributor
timestamp: January 09, 2012, 12:26:02 am
content: A quick google turned up this.http://www.maxim-ic.com/datasheet/index.mvp/id/4065Regards

author: Rudolfo
author_rank: Contributor
timestamp: January 11, 2012, 10:11:51 am
content: You may take a look at the iC-MP(http://www.ichaus.biz/product/iC-MP)to get voltage output based on a rotating magnet above the encoder. More option underhttp://www.ichaus.biz/keyword/Magnetic%20Encoder%20iCs.Enjoy your design work.

author: ejeffrey
author_rank: Super Contributor
timestamp: January 11, 2012, 10:56:11 am
content: Quote10 turn isn't enough how? I get size and cost, but if you are interested in resolution you may have to look elsewhere. Most digital pots have no more than 256 taps. 1024 taps are available, but with fewer choices (esp. in terms of interfaces). You will need a 1024 tap unit to get near the resolution you can easily achieve with a good 10 turn pot.Many digital pots can take up/down pulses. It is pretty simple to use discrete logic to turn encoder pulses into up/down signals. You can also get quadrature decoder chips that do this for you. However, a quick search on maxim shows that all of their 1024-tap pots use SPI. If you need that kind of resolution you are likely stuck with a microcontroller. This is a really easy application of a microcontroller -- something like 20 lines of code in total, so I would recommend you look again at that.If you need better than 10 bit resolution you might have to look elsewhere. If you application is a simple voltage divider (like a volume control), you may do a lot better with a DAC. You could use an R-2R DAC with an external reference input. Send your input signal to the reference input, and then the DAC value becomes the signal multiplied by the DAC code.

author: daedalus
author_rank: Regular Contributor
timestamp: January 11, 2012, 05:25:31 pm
content: if you are trying to produce a CV signal for a synth, then you don't need a resistance which varies proportionally to encoder rotation, you need a voltage. I assume you are producing said voltage with a resistive divider circuit using a digipot currently. Why not just use a DAC? you could theoretically do all of this using discrete logic, but personally I would just grab a nice cheap micro and use that, as ejeffrey suggested.

author: sonicj
author_rank: Frequent Contributor
timestamp: January 12, 2012, 01:06:15 am
content: just wondering... specifically, what variable on your synth requires a resolution greater than what a 10 turn pot can provide? is it possible that you used a linear pot where you needed a logarithmic? or vice versa?-sj

author: Zad
author_rank: Super Contributor
timestamp: January 12, 2012, 02:23:19 am
content: Yes, use a multiplying DAC with parallel input. You feed the original signal into the (analogue) reference input. You then set the level in the digital port. They are available with parallel inputs if you want to drive it from a binary up/down counter linked to a rotary encoder. 16-bit (65536 levels) is quite possible.

author: amspire
author_rank: Super Contributor
timestamp: January 12, 2012, 03:36:42 am
content: There is a lot to say to diving in and using a micro, however painful it is. The code to read a rotary pot and to send it to another chip can be pretty brief, and you can probably get help here if you use a PIC micro or an Arduino.The thing is if you use a micro, you can have a digital pot based control that adjust in large steps when you turn it quickly, and the slower you turn it, the smaller the steps. With some fine tuning to the code, you can get a control that lets you do large changes very quickly, but also provides you with superfine resolution.

author: PStevenson
author_rank: Regular Contributor
timestamp: January 12, 2012, 05:00:26 pm
content: honestly, micros are not my friends, I've tried and tried to get my head around them - I just cannot stand coding and I can't find a way around that, I think I successfully programmed an Atmel to tell itself to fuck off (I was very frustrated at that point)I just haven't got the type of mind that can do micros so I stick to avoiding them and mostly I've not run into problems but the rotary pot is one I have run into - I'm trying PeterG's suggestion when that part arrives@Zad do you recommend a specific part for this? your suggestion sounds interesting.@daedalus it isn't a new design it's part of a restoration/user requirement so I'm trying to incorporate it as a kind of drop in@Rudolfo this also looks interesting, even if it didn't work for this it looks like it might be useful for something else I'm working on - cheers!

author: Zad
author_rank: Super Contributor
timestamp: January 12, 2012, 07:02:54 pm
content: Start from here:http://www.analog.com/en/circuits-from-the-lab/CN0025/vc.htmlAnalog Devices, TI, Maxim and Linear Devices (and probably lots of other manufacturers) make multiplying DACs that will do the job. Where you want to make the tradeoff in terms of IC packaging, speed, noise, price, interface etc is up to you. There are too many variables involved for me to make a decision about your application. For instance, it might be difficult to find one in a DIP package with full word width parallel programming, which has a resolution of more than 12 bits. But make it a serial interface or a non through-hole package and the options increase.

author: daedalus
author_rank: Regular Contributor
timestamp: January 12, 2012, 11:52:53 pm
content: @pstevenson: I have in the past done a bit of vintage synth repair work, if you can describe in more detail what you are trying to build, maybe we can be more help. It sounds very much like you want a dial to control a 1v/octave CV signal directly, am I right in thinking this?It really isn't that complicated a thing to do, and doesn't require anything exotic.1) convert the quadrature signal converted into a up/down signal2) use up/down signal to update a counter3) write counter value to a standard DAC. 12 bit should be more then enough for your application, as MIDI only ever supported 8 bit levels IIRC.Doing these in a micro is the smallest form factor, and easiest approach, but you can do the same with discrete logic pretty easily.If you are not happy writing the code for the above, why not bung £20 on one of the many freelancer websites and have someone else do it for you?

author: PStevenson
author_rank: Regular Contributor
timestamp: January 13, 2012, 01:22:42 am
content: it's alright to say it's the easiest approach to use a micro but for me it isn't and I'm not that keen on paying someone else to do it either because then I've learned nothing except how to outsource a job.I am completely dyslexic, attempting to learn/write code is like tearing my eyes out with rusty claw hammers.I can't really be anymore specific than I want to turn a rotary one way for a voltage to rise and turn it the opposite for it to go down and the reason for this is because it's not just one thing, it's quite a few things most of which I haven't really worked out yet. I just know what I need this part of it to do@zad I use mostly surface stuff so there was no shortage of choice on those sites, I've ordered a few parts that looked appropriate

author: daedalus
author_rank: Regular Contributor
timestamp: January 13, 2012, 10:40:36 am
content: I have given you a step by step list of things you need to do with either a micro or discretes, if you don't want to use a micro then use discretes instead, its more work but if it suits you better, go for it.Quadrature encoder-> clock decoder (eg LS7082N1)-> 12 bit up/down counter (eg made of 3x CD40193 chained together)-> parallel 12 bit dac (eg dac7621)-> opamp(with x2 gain for 0-10v output)plus whatever glue logic you need to operate the dac's interface (probably a single nor gate to drive dacload). EDIT: looks like you can just hold dacload low as its a transparent latch.Above will work on 1v/octave systems, if you have the other type of cv that doubles voltage per octave, then the scale will not be linear and you need to do more work.

author: sonicj
author_rank: Frequent Contributor
timestamp: January 13, 2012, 10:43:38 am
content: im somewhat dyslexic so i know where you're coming from. i really struggle with keeping track of the tops & bottoms of boards. i'll build something, look at it and realize i wired the whole chip backwards, re-do it, then realize i had it right the first time.anywho, no need to fear the µC with the availability of arduino. most of the code you'll need is already written for you as libraries & example code... you just gotta mash up the examples to fit your application.I modified some encoder code fromhereto match your application. I tested it on my board with a cheapo panasonic encoder with hardware debounce (to keep the code simple) and it runs great. Even gives you blinky leds when the knob is turning. Also, commented every line so you can get a idea of whats actually happening. If you use this as a starting point you'll be more than halfway done with the code. Pick out a DAC and it should only take a few more lines of code to make it work!Code:/* Encoder Sample Code* Requires: "Encoder.h" Available from:* Available : http://www.pjrc.com/teensy/td_libs_Encoder.html** This example code is in the public domain.*/#include <Encoder.h>const int ledGreen (2); //Set Digital pin for LED That Lights When Knob is Activeconst int ledRed (3); //Set Digital pin for LED That Lights When Knob is InactiveEncoder encoderKnob(5, 6); //Set digital pin as encoder inputsvoid setup() { //Set stuff up at bootSerial.begin(9600); //Start serial connectionSerial.println("Knobs Encoder Test:"); //Print that over serial connectionpinMode(ledGreen, OUTPUT); //Pin 2 is a ouputpinMode(ledRed, OUTPUT); //Pin 3 is a output}long positionKnob = -999; //Create Knob Position Variablevoid loop() { //This Looops Until a Rebootlong newKnob; //Create Variable newKnobnewKnob = encoderKnob.read(); //Read The Encoder Pinsif (newKnob != positionKnob) { //If The Encoder Pins See Activity, Do The Following:digitalWrite(ledGreen, HIGH); // set the Green LED ondigitalWrite(ledRed, LOW); // set the Red LED offSerial.print("Knob = "); //Print This over the Serial PortSerial.print(newKnob); //Print the new Knob Position overSerial.println(); //Move To Next LinepositionKnob = newKnob; //Store New Knob Position}else { //If Nothing is happening, Do The Following:digitalWrite(ledGreen, LOW); // set the Green LED offdigitalWrite(ledRed,HIGH); // set the Green LED on}}

author: PStevenson
author_rank: Regular Contributor
timestamp: January 13, 2012, 11:44:01 pm
content: @sonicj aye I've got the arduino, MSP430 and a PICKIT2 I could just never get into it.however when I had a starting point I could sometimes get something going so I'm going to give that a gothankyou so much for doing that, it would be rude not to give it another go!when I see the code written down like that, I can sort of see whats going on but whenever I've cracked outMPLAB, flowcode4 or that sketch thing for arduino I just can't figure out where to start.I'm just hoping one day they write a program for uC's for retards like me where it has a group of input peripheralswith a group of what they can do and some kind of "relationship" library ie "if you turn this knob - depending on it'sposition it lights up this many LEDS"but seriously dude, thanks for doing that if I'm ever in the position to help you I will do.

author: sonicj
author_rank: Frequent Contributor
timestamp: January 14, 2012, 12:40:28 am
content: no problem! again, all of the hard work was already done. (library + sample code) i just trimmed it down from 2 encoders to 1 and added the blinky leds. arduino is probably as close as to microcontrollers for dummies. anywho....3 things... first, make sure you download the encoder library which is in the link i provided earlier, unzip it, open that folder and place the "Encoder" folder into your "libraries" folder which is inside you arduino sketch folder.also, the code isn't setup to avoid negative integers or top out at any specific value. but we can fix that once you pick out a DACafter you paste the code into a blank arduino sketch and upload it to your board, go to "Tools > Serial Monitor" to view the results on your computer.holla if you have any questions getting it going! good luck!-sj

author: PStevenson
author_rank: Regular Contributor
timestamp: January 14, 2012, 01:22:39 am
content: that's fantastic, I've actually gotten it to do something with my rotary encoder - it outputs a constant high on one output untill you turn the knob then it goes low and on the alternative output the opposite happens - there maybe hope for uC's and me yet.now I'll have to wait for my rapid orders!

author: sonicj
author_rank: Frequent Contributor
timestamp: January 14, 2012, 03:22:03 am
content: pretty cool huh?in addition to the high and low toggling... if you have your Arduino software open, you can go to "Tools" and select "Serial Monitor" you should be able to see the value increment and decrement on your computer screen as your turn the knob.-sj

author: PStevenson
author_rank: Regular Contributor
timestamp: January 14, 2012, 10:06:29 am
content: Quote from: sonicj on January 14, 2012, 03:22:03 amyeah I used that before I bothered with getting an LED out - I had a hammer out hovering over the arduino board you seeso today I'm going to experiment with outputting to digipots and so on

author: ciccio
author_rank: Frequent Contributor
timestamp: January 14, 2012, 03:47:40 pm
content: Quote from: daedalus on January 12, 2012, 11:52:53 pmMaybe out of topic, but can you please post a link to some of these sites?sometimes I build complicated circuits to avoid using a micro, because of my lack of programming skills and of my laziness.Best regards

author: daedalus
author_rank: Regular Contributor
timestamp: January 14, 2012, 09:23:25 pm
content: @ciccio: there are several freelancer sites that cater for electronics. odesk.com and vworker.com would be two suitable recommendations.if its a small amount of work and you are flexible as to delivery times, then you can usually find people moonlighting there who are willing to do work at good hourly rates. Quality varies from person to person as you would expect, but both sites provide good protection for the 'buyer'. Note you can get almost any eda work done at these places, i trawl them from time to time when I'm running low on hobby projects to do.