Random Voltage generator

Started by Ryder17, February 06, 2016, 06:12:13 PM

Previous topic - Next topic

Ryder17

Hi all!

Im trying to build a pedal with a filter that fluctuates slightly every time you turn it on. To do this, I need to find a simple circuit that can change a resistance value randomly. Do any of you have an idea of how this can be achieved? I'm thinking a circuit that can send out a random voltage to an optocoupler would do it, im having a hard time finding a circuit to give out random voltages. Can anyone point me in the right direction?

Cheers

mth5044

Do you need continuous random voltage, or a random voltage every time you do something? The TAPLFO has a random voltage LFO, if you are looking for the former.

Ryder17

A random voltage every time i engage the filter would be ideal, a continuous random voltage would do though as long as its not too fast

R.G.

"Random" is not simple. The entire encryption industry relies on mat to convert highly non-random signal into what seems to be random, but is actually calculable if and only if you have the magic sequence of bits that unravels the randomness. So your first problem is finding a source of randomness to tell your voltage or resistor to be.

It is fairly easy to make a pseudorandom voltage. I programmed a microcontroller with a set of code that generated a pseudorandom sequence that approximates truly random, only repeating once every 32 thousand years. It is for all intents and purposes a random voltage, except that it generates the *same* set of random bits every time it is started.

This could be converted into a random startup device by having it save its 64-byte "state" to EE memory every so often, and the next time it comes up, start there. Since power-down times are random, what you would get would be a random start in a very long random sequence. Ought to work.

The next problem is how you're going to map a random binary sequence (or a random analog voltage; same problem) to your filter frequency or resistor. This includes the range of min to max on the voltage/resistor and whether it fluctuates while you use it or not.

There are solutions, but none as simple as "hey, give me some of that random".
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

PRR

I started gibbering before R.G., but fell asleep; I suspect overlap.

The classic random voltage is a diode; often the E-B junction of a BJT reverse-biased to breakdown.

This has output to MHz. For "low freq noise" you low-pass it.

For a "once in a while", you use a Sample/Hold to grab a random value.

All of this is a far corner of analog abuse. Today you could consider a teensy computer. It could even work CMOS switches to directly connect resistors, avoid the opto-resistor.

True random in deterministic computers is hard; If a computer follows a fixed "randomization" program it will arrive at the same result every time. Random algorithms often take a "seed", which they then process in complicated ways, to not get the same result each run. With real-time clocks in CPUs you have two probably-unrelated times: time since turn-on and current time. (However if the CPU is re-started each day on a precision clock, it becomes deterministic again...) Newer PC CPUs have a dedicated circuit, and some researchers say this is not random-enough for cryptography.

A real simple trick used on older unix was just a quasi-random sequence. But the current state was stored at each shut-down, so it would not repeat the same part of the sequence anytime soon. This seems to be how car and garage radio-keys work: the codes are in a say sequence of 64,000, both authorized sides know the sequence, a lurker who overhears the latest code can not work-out the next code (I bet NSA/KGB can). With any little CPU you can just store a table and a pointer to the next entry to be used.

OTOH if you don't need perfectly-unpredictable numbers, you can do well by starting a fast counter then reading it at some NON-deterministic time, such as user key-press. (The old trick for CMOS "dice" is a fast counter and a pushbutton.)

If you have a battery, DAC the battery. Map the range from 10V to 5V in 0.001V steps repeating say every 16. Insignificant droop of battery will cycle through 16 values "unpredictably".

Put a microphone on and extract some value of sound at the instant of turn-on. Unless you turn-on in dead-silence, you won't have the same instantaneous sound pressure each time. (If that is a problem, turn-up, there's always random hiss down there somewhere.)

The curse of mechanical switches is contact bounce. They stutter before settling to a fixed state. If you toggle a basic flip-flop with a switch, it may get 4 or 13 or 28 pulses, you don't know if it will change or change/change-back for no-change. But if you use raw bounce to step a counter or a pseudo-random sequence you will probably arrive at an unknown state every time.
  • SUPPORTER

Transmogrifox

#5
My guess is what the OP wants is something that is perceptually unpredictable.  Guitar FX units aren't usually designed for encrypting hidden messages into your music -- although that may be an interesting trick for communicating top secret messages to the illuminati over the popular rock station.

If you're triggering this by stomping a switch or some kind of non-periodic, not predictable event, then just sample/hold a moderately fast ramp oscillator.

If you have a ramp going at say, 1 kHz, then chances are you you will never produce a sequence you could predict, even if stomping it to a metronome (for one, the oscillator won't stay stable enough to sync predictably to an external timing source).  When you make that external timing unpredictable, then that is your source of randomness already.

A ramp or triangle oscillator is easy enough to make, and ways of doing Sample/Hold with a JFET abound.

These hold charge in a capacitor, normally buffered by a high impedance device like a FET but it will start to slowly drift over long periods of time.

If you need it to hold steady for long stints, then some kind of a digital circuit in which fixed resistor values and logic gates hold the same number indefinitely.

This would in hardware be a square oscillator driving a digital counter IC that just keeps counting and rolling over (digital ramp).  Then your switch drives the clock input of a bank of latches.  Every time you engage the switch it latches whatever number happens to be on the counter.
trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.

R.G.

Yep, perceptually unpredictable. That's what the microcontroller was for. It's an eight-pin, $0.70 device. The 'save where you stopped for the next start' makes repeated uses create perceptually unpredictable voltage for centuries of use.

Oh, wait! Centuries of FUN.  :icon_biggrin:
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Ryder17

Thank you all for your input. I think maybe too much emphasis has went into the word 'random'....as Transmogrifox mentioned, it just needs to be perceptually unpredictable, so when switching the filter on, its ever so slightly different each time.

Im going to try and do it with a logic IC, namely a CD4071. If I just have 10 different resistors in series with a LED/LDR and use the footswitch to trigger the cycle, it should give me roughly what im going for in the simplest way possible.

Cheers.

Ryder17

....And may I add..... Great forum this is guys. I've lurked for a little while but this is my first (of many im sure) post.

Mark Hammer

Y'know a pair, or  a trio, of LFOs running at different speeds can yield some pretty unpredictable results.

Ken Stone's Psycho-LFO is a nice example: http://www.cgs.synth.net/

merlinb

#10
Quote from: Ryder17 on February 07, 2016, 05:34:08 PM
Im going to try and do it with a logic IC, namely a CD4071. If I just have 10 different resistors in series with a LED/LDR and use the footswitch to trigger the cycle, it should give me roughly what im going for in the simplest way possible.
That's a good idea. It sounds like what you want is basically a version of the 'electronic die' that was a staple of beginner's electronics magazines for years. You have a simple oscillator (astable), driving a counter. Every time you press the button it kills the oscillator and the counter stops, and you have no idea where it will stop because the oscillator runs too fast for a human to keep track! In your case the counter would be driving different resistors to the LDR. Not sure what you want the CD4071 for, it's just a quad OR gate? If you use a binary counter like the CD4040 driving a resistor ladder then you could have dozens or even hundreds of possible outcomes.... The CD4060 can even be arranged to self-oscillate!

Transmogrifox

Yeah, the CD4060 looks like the ticket.  Add a momentary normally-open switch in series with one of the RC oscillator resistors (see page 3):
https://www.fairchildsemi.com/datasheets/CD/CD4060BC.pdf

The only point on which merlinb post I didn't follow was on STOPPING the oscillator when you push the switch.  You want the opposite action.

The oscillator runs while the switch is depressed and stops when you let off. That way the counter is stopped at a constant value instead of free-running.  In either case I agree that start/stopping the oscillator is far simpler than extra IC's to latch the counter.

If the oscillator is fast enough it will be very unpredictable where it stops.  This chip can run up to 8 MHz at 10V in.  If you set the oscillator to run at 4 MHz (reasonable for an RC oscillator) the counter will roll over about 240 times per second.  Combined with unpredictable switch bounce time, duration of switch pushing and unpredictable start state this will be pretty hard to generate a repeatable pattern.
trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.

merlinb

Quote from: Transmogrifox on February 08, 2016, 01:07:01 PM
The only point on which merlinb post I didn't follow was on STOPPING the oscillator when you push the switch.  You want the opposite action.
I was thinking the oscillator would run continually while the effect was bypassed, then stop when you hit the stomp switch, but I like your suggestion better.

Ryder17

Thats interesting, ill check that chip out.

When I said cd4071, I actually meant cd4017....... Ooops

From what I understand, this will give me 10 steps that can be cycled through when the switch is engaged? I could even use a 555 as an oscillator to do what your saying the 4060 can do right? It might actually be cool to do it this way, then I could have a switch to set stepping through the sequence and engage the oscillator to run it, it'll be kinda like a seekwah! I could use trims instead of resistors so the sequence could be adjusted  :)

Transmogrifox

The idea would work fine with the CD4017 too, but then you only have 1 of 10 distinctly different states you can land on.  The clocking scheme described above still works for making it unpredictable which state you land on next, so if that's what you want then it will work very well, I think.

With a true binary counter like a CD4040 or the CD4060 with 10 pins connected you have 2^10 = 1024 distinctly different values you can land on.  Basically you connect the resistors to the LED in a 2^x pattern --
Resistor 0 = 1k
Resistor 1 = 2k
Resistor 2 = 4k
Resistor 4 = 8k
.
.
.

However with the CD4017, you really can do a seek-wah type of effect because having 10 distinct steps makes it so you can individually tune each state with a pot.  Then all you are doing is making it unpredictable which of those 10 steps you choose next.  If each of the 10 steps is independently set with a pot then you can sort of "hand-pick" which states actually sound good.

Using something like a CD4060 you end up with truly random states and it may or may not sound good.

In the end the choice between a fine-grained adjustment like a CD4060 and a coarse step size like the CD4017 is a matter of whether you want it to be less predictable or more predictable.

And yes, a 555 timer would be just fine for clocking the CD4017.  The nice thing about the CD4017 is it has the clock enable pin, so you can connect the switch to this pin to start and stop the clock.

Then if you want a predictable repeating 10-step sequence you slow down the clock to an LFO rate, like 2 Hz or something and you have a second switch to hard-enable the clock.

Jeez this would be so easy to do with a microcontroller -- but you have to already know how to program them in order for it to be easy.  For cost and simplicity, RG is right on that point, but for the average DIY hardware hacker microcontrollers are a scary thing.

trans·mog·ri·fy
tr.v. trans·mog·ri·fied, trans·mog·ri·fy·ing, trans·mog·ri·fies To change into a different shape or form, especially one that is fantastic or bizarre.