### Author Topic: FV-1: Pot as Faux Rotary Switch?  (Read 1873 times)

#### thehallofshields

##### FV-1: Pot as Faux Rotary Switch?
« on: April 24, 2017, 05:37:21 PM »
Hey guys, I'm brand new to DSP, planning on going through the FV-1 tutorials, and had a couple quick question.

1.) What do you call the rotary that switches between resistors vs the kind that just knows if you went Right (CW) or Left (CCW) ?

2.) Is it possible to 'trick' the FV-1 and use a pot or trimpot as a 'Mode Selector' type rotary switch?
[Like... define a range of resistance values for each mode rather than fixed resistances.]

#### ElectricDruid

##### Re: FV-1: Pot as Faux Rotary Switch?
« Reply #1 on: April 24, 2017, 07:37:51 PM »
Hey guys, I'm brand new to DSP, planning on going through the FV-1 tutorials, and had a couple quick question.

1.) What do you call the rotary that switches between resistors vs the kind that just knows if you went Right (CW) or Left (CCW) ?

The first one sounds like a genuine rotary switch, and the second one is known as a "rotary encoder".

Quote
2.) Is it possible to 'trick' the FV-1 and use a pot or trimpot as a 'Mode Selector' type rotary switch?
[Like... define a range of resistance values for each mode rather than fixed resistances.]

Yes. The pot is set up as a voltage divider, and the FV-1 will read the incoming voltage from the pot with the internal ADC. Essentially, the pot's position gets turned into a number. I don't know the FV-1 in detail, but say it's an 8-bit value, 0-255. I use the PIC, and you can get a 10-bit value from 0-1023 there if you want it. It doesn't much matter.
We're only interested in the top 3 or 4 bits of that value. the top three bits give us values from 0 to 7. The top 4 bits give us values from 0-15. Beyond that, you can't really adjust a pot with that much detail, unless you put a huge knob on it.

The only difficulty is dealing with the borders where it jumps from one value to another. For example: An ADC value of 63 has 001(1) as the top three bits, but 64 has 010 (2). A little tiny bit of noise is enough to make the value jump from one to the other and although that's only one least-significant-bit, it's still enough to change the upper three bits.

The simplest way I know to deal with this is to take the input value (call it "A") and add an offset onto it (+4 maybe). Call the result "B". Now, if A and B give you the same top three bits, you're safe to use them. If they give different values, don't change anything. This is a basic algorithm for hysteresis, and it works well.

HTH,
Tom

#### robthequiet

##### Re: FV-1: Pot as Faux Rotary Switch?
« Reply #2 on: April 24, 2017, 07:39:07 PM »
It's been done in other applications, I believe, but engineering the control to recognize specific ranges of resistance to lock in on a digital number might be more trouble than it's worth. The peril I see is having an undefined value between settings, as Tom said . There might be hacks using an LM3914 bar graph display driver, but you're still kludging an infinitely variable analog value into a digital selector [not so great after I gave it more thought] by which time getting a rotary encoder set up would save you some time. There's no reason not to try, though, so getting an R2R ladder set up for testing would be my first step.
« Last Edit: April 24, 2017, 09:39:40 PM by robthequiet »

#### ElectricDruid

##### Re: FV-1: Pot as Faux Rotary Switch?
« Reply #3 on: April 24, 2017, 08:25:44 PM »
It's been done in other applications, I believe, but engineering the control to recognize specific ranges of resistance to lock in on a digital number might be more trouble than it's worth.

No, honestly, it's simple. At the most basic, all you do is right-shift the value down to get left with just the top few bits (2, 3, or 4 as you see fit). You don't need to muck about with specific ranges of resistance at all. In fact, it doesn't even matter what value the pot is, since it's only a potential divider. I've used 10K, 47K, and 100K interchangeably.

Adding hysteresis is a nice touch, and not much more complicated.

I'd post some examples, but all mine are in PIC ASM, not FV-1 SPIN-ASM or whatever they call it. Not much different, but not the same.

Tom

#### robthequiet

##### Re: FV-1: Pot as Faux Rotary Switch?
« Reply #4 on: April 24, 2017, 09:27:47 PM »
Hey, Tom  -- I guess the part I'm missing is the translation into 3-bit words from the divider -- am I being confused by the "Mode Select" vs. "Program Select"? I'm a total believer in ADC, just a bit stuck on the idea that you'll get bounciness between settings.

#### ElectricDruid

##### Re: FV-1: Pot as Faux Rotary Switch?
« Reply #5 on: April 25, 2017, 09:49:35 AM »
Hey, Tom  -- I guess the part I'm missing is the translation into 3-bit words from the divider
Ok, we'll look at that in a sec.

Quote
am I being confused by the "Mode Select" vs. "Program Select"?
I don't know. What's the difference between those two? I thought we were talking about how you'd use a pot to select between 4 or 8 options. I used the technique to select waveforms on my TapLFO chip, for example:

http://electricdruid.net/tap-tempo-lfo-taplfo-v2d/

Quote
I'm a total believer in ADC, just a bit stuck on the idea that you'll get bounciness between settings.
Well, get it working first, then worry about the bounciness, if there is any. The FV-1 samples the ADC very slowly, which helps, and also filters it internally, I think, which helps too. So you may not have any problems.
On the PIC, with a much higher sampling rate and no filtering, I could only get it to jitter if I carefully balanced the pot right on the boundary.

Ok, let's have a look at the conversion. We've got an 8-bit value coming in, 0 to 255. In binary that's:

00000000 up to
11111111 (255)

We want just the first (say) three bits of that, so we'll get:
000 (=0)
111 (=7)

If we use a right-shift instruction, all the bits in the byte will be moved over one place, like this:

abcdefgh becomes
0abcdefg

Note that the lowest bit (h, whatever it was) gets lost off the RH end, and a zero gets shifted in at the LH end.
If we repeat this operation five times, we get this:
abcdegfh (initial value)
0abcdefg ( 1 shift)
00abcdef (2 shifts)
000abcde (etc)
0000abcd
00000abc (5 shifts, final result)

So you can see how our initial value has been reduced to the range we need. If you've got a larger value (say, 10-bit) you can do the same thing, but you just need a couple of extra shifts.

Tom

#### amz-fx

##### Re: FV-1: Pot as Faux Rotary Switch?
« Reply #6 on: April 25, 2017, 11:58:30 AM »
The FV-1 has 3 pins that are used to select the current patch being used by the chip; S0, S1 and S2. They are digital pins and not analog, so they need a low or high input (0 or 1) to select the address of the patch. There are 8 patches, numbered 000 through 111.

You can do this with a special encoder that turns the rotary position into a binary output. It will have 8 positions with 1 input pin and 3 output pins (which are the digital address). I've used this type of component but don't have the manufacturer's name in front of me.

You can also use a microprocessor with an analog input to turn the position of a potentiometer into a 3 bit output. PIC or ATtiny or many others will do the job with a short bit of code. I've used the ATtiny13 to do this since I have a lot of them on hand.

A ressitor divider would still need to go into the ADC of a micro, so it would be simpler to just use a potentiometer.

regards, Jack

#### robthequiet

##### Re: FV-1: Pot as Faux Rotary Switch?
« Reply #7 on: April 25, 2017, 03:54:40 PM »
Thanks Tom. I don't mean to hijack the thread. Obviously the PIC is a better model as you can interface the 16 possible programs using 3 program select and one internal/external mode pin, extensible to multiple FV-1s  if one had to. Had to make myself read the data sheet again, of course.

With the  rotary encoder you and pull the program select pins to ground in Grey Code easily enough. Bourns and ALPS have these but a bit tricky find the right one in stock. Small Bear might have them.

#### ElectricDruid

##### Re: FV-1: Pot as Faux Rotary Switch?
« Reply #8 on: April 25, 2017, 04:50:55 PM »
Aah, ok, sorry, I was missing the crucial detail - you're talking about how to get the three bit program selection for the chip, not how to use the ADC values inside the chip to select different things.

Yes, you could use a potential divider and a short PIC/AVR program like Jack suggested, in which case hysteresis and avoiding jitter is a good idea, and easily done. Or you could use a grey-coded or hex-coded encoder. Either would work.

Tom

#### robthequiet

##### Re: FV-1: Pot as Faux Rotary Switch?
« Reply #9 on: April 25, 2017, 05:41:54 PM »
No worries, Tom, for a second I thought we had a bit of alchemy going. Many ways to skin a cat

#### amz-fx

##### Re: FV-1: Pot as Faux Rotary Switch?
« Reply #10 on: April 26, 2017, 10:48:23 AM »
I looked it up and Grayhill was the brand of encoder that I first used. Very expensive but easy to implement.

There is another way to select the binary address with a simple 1P8T rotary switch and a bunch of small signal diodes to do the encoding. The V+ goes into the common of the rotary switch. At each switch position, there are diodes to steer the voltage to the relative pin...  at 000 there are no diodes and S0,S1,S2 are pulled to ground by resistors connected to each pin. At 001 there is one diode pulling S0 high. At 010 there is one diode pulling S1 high; at 011 there are two diodes pulling S0 and S1 high, and so on with the binary encoding.

There is also a 74HC series encoder chip that will convert the 8 switch positions to binary encoded outputs and I have used that too.

regards, Jack

#### Ice-9

##### Re: FV-1: Pot as Faux Rotary Switch?
« Reply #11 on: April 27, 2017, 05:21:35 PM »
If you look up my FV-1 forum project you can use either a pot or a switch assembly, all this is based around Slackers PIC code so the pic is a little interface between the pot/switch and the FV-1. use either or, job done.
www.stanleyfx.co.uk

It's fairly straight forward, if you want to start it , press start. You can work out the rest of the controls for yourself !

#### slacker

##### Re: FV-1: Pot as Faux Rotary Switch?
« Reply #12 on: April 28, 2017, 01:19:19 PM »
Here's a way of doing it using a quad opamp and a few resistors http://www.diystompboxes.com/smfforum/index.php?topic=89977.msg778166#msg778166