FV-1: Pot as Faux Rotary Switch?

Started by thehallofshields, April 24, 2017, 05:37:21 PM

Previous topic - Next topic

thehallofshields

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

Quote from: thehallofshields 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) ?

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

#2
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 [edit]. 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.

ElectricDruid

Quote from: robthequiet 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.

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

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

Quote from: robthequiet 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
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

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

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

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.

My bad. Carry on.

Tom

robthequiet

No worries, Tom, for a second I thought we had a bit of alchemy going. Many ways to skin a cat  :icon_cool:

amz-fx

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

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

Sanity: doing the same thing over and over again and expecting the same result. Mick Taylor

Please at least have 1 forum post before sending me a PM demanding something.

slacker