Digital Lfo(2)

back to some digital. First what could be the schematic (idea shape) :
digi_lfo_jpg

I’ve implemented the random voltage via one PWM timer. Nothing fancy, just using the rand_r in the main() fonction seeded with a floating ADC pin. Maybe I’ll change that for a LFSR latter, but it works as it anyway. There’s also a trick (borrowed for the random thingy post earlier) made possible with a button. the random voltage can be “biased” in a way. It can go form its full amplitude,  only from 2.5V to 5V, or 0V to 5V. This is done before outputing the data to the PWM with simple bit manipulation.

       switch(noise_mode)                    //OFFSET NOISE
{

case 0:
OCR0B = noise_value;
break;

case 1:
OCR0B = noise_value | 0b10000000; //can only be 127 or higher (2.5V to 5V)
break;

case 2:
OCR0B =  noise_value >> 1; //divide by two !
break;
default:break;
}

The speed of the random voltage is determined by the use of an ADC reading used as an index into a look up table (noise_speed.h). Quite handy, the sampling rate is 8Khz at the moment. It can go from 1sec to 16hz (or something like this, don’t remember the maths) I must admit it works pretty well !

I gave up the original idea of reducing the sampling rate to achieve the lowest speed, otherwise the random voltage update will be reduced as well, and so will be its speed. instead I’m dividing the sampling rate into the 8Khz window with a timer to achieve the other sampling rates while still maintaining the sampling rate at 8khz for other outputs. That way, I can also output another independant LFO (wich I will). One can add as many DAC the hardware allows (depends on how many pins you’ll give away for the Chip Select).

minutes long LFOs are also possible, instead of 16bits accumulator a 32bits accumulator can be used !

The LFO is almost done, just have to find other waveforms to add. Note the “shaping” op amps at the end to put the waveform into “synth” format (10Vp-p and 0v bias)

some random things before leaving (otherwise people will think I’m living in WordPress servers…) :

-don’t try reading ADCH twice otherwise you may look dumb…it’s clear once read.
-bitwise operators are handy !
-use the flash memory to stock tables.
-Although Don’t try to stick 16bits or 32bits in flash memory otherwise you’ll, once again, look dumb as hell. (although you could stock the 16bit data into two 8bit location). Actually you can write your data but it is chopped in piece into 8bit registers !
-you’ve never have enough debug facilities !
-you should get a life instead of torturing those 8bit microcontroller !

I don’t know why, but if there’s any interest in the world wide web for this, the C code and .h files (in protomode) are here :
https://github.com/ThebigDickhead/AVR_PROG/tree/master/LFO

if this can be of any use to someone, it would have been worth sharing !

thanks for reading!

Advertisements

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s