The ATtiny85 receives three analog controls:
SPEED on PB3 / ADC3
DEPTH on PB4 / ADC2
CHAOS on PB2 / ADC1
Each potentiometer provides a voltage between 0 and 5V.
The Tiny85 converts this voltage with its ADC to a value between 0 and 1023.
The three parameters then have different roles:
SPEED determines the speed of the LFO.
DEPTH determines the modulation amplitude.
CHAOS adds a pseudo-random component.
The Tiny85 can thus produce several LFO shapes: triangle, sawtooth, square, random, triangle + random, and sample & hold.
The added benefit of this circuit is that the Tiny85 produces two completely different signals.
PB0 -> frequency variation
PB1 -> rhythmic slicing of the sound
The NE555 generates the audio signal.
The Tiny85 varies its frequency via PB0 to the 555's CV.
However, in parallel, a switch (and/or pushbutton in parallel) allows you to enable or disable "Blink Sound."
PB1 periodically acts on the 555's TRIG input, resulting in two superimposed modulations: the sound becomes "stuttering."
--------------------
The Timer0 operates in Fast PWM mode, with a frequency of 31.25 kHz.
The PWM duty cycle is modified by the LFO.
The output then consists of:
PB0 RC filter 1 kΩ -> 10 µF -> NE555 CV
The RC network transforms the PWM into a much slower average voltage.
In other words, the Tiny85 doesn't directly transmit its PWM signal to the 555 as an audio signal; it uses the PWM to generate an analog control voltage.
This voltage is applied to the CV input of the NE555 and varies its oscillation frequency.
The Tiny therefore acts as a small digital LFO generator that drives the frequency of the 555.
--------------------
The Digital LFO
The program uses a 16-bit phase accumulator:
`volatile uint16_t phase = 0;`
At each Timer1 interrupt:
`phase += phaseStep;`
Timer1 triggers this interrupt 256 times per second.
The ratio between `phaseStep` and this frequency therefore determines the LFO frequency.
For example:
`phaseStep = 256 → 1 Hz`
`phaseStep = 512 → 2 Hz`
`phaseStep = 1280 → 5 Hz`
The 8 most significant bits of the accumulator are then used to obtain a phase position between 0 and 255:
`uint8_t p = phase >> 8;`
This value is used to calculate the LFO's shape.
--------------------
The DEPTH
Once the waveform is calculated, the program applies the depth:
modulation = (wave * depth) / 127;
Then it centers the result around 128:
output = 128 + modulation;
128 corresponds to the middle of the PWM range 0–255.
The DEPTH potentiometer therefore acts as a true depth control: at zero, the LFO no longer affects the variable capacitor; at maximum, the modulation is at its maximum.
--------------------
The CHAOS
The CHAOS parameter is involved in the random waveforms.
The program uses a small pseudo-random number generator based on an LFSR:
uint16_t lfsr = 0xACE1;
The principle is classic in the embedded world: rather than calculating a complex random number, a shift register is modified with a few XOR operations.
This results in a lightweight pseudo-random sequence, perfectly suited for a small AVR.
The chaos can then be added to the triangle or used on its own.
The result is particularly interesting in "Triangle + Random" mode: the overall movement remains that of the triangle, but it is disrupted by a random component.
--------------------
The BLINK SOUND
This is where the Tiny's second signal comes into play.
PB1 is explicitly defined in the program as:
#define BLINK_PIN PB1
Timer1 also handles this output.
On each interrupt:
if (++blinkCounter >= blinkDivision){
blinkCounter = 0;
PORTB ^= (1 << BLINK_PIN);
}
With:
blinkDivision = 31 and Timer1 at 256 Hz, PB1 changes
A state signal is sent every 31 interrupts.
This results in approximately 4.13 Hz for the complete signal.
PB1 therefore produces a slow square wave, which is sent through a 1N4148 diode to the NE555 trigger.
The button enables or disables this function.
The Blink rate is independent of the shape of the audio LFO.
Therefore, for example, a slow and regular frequency variation can be achieved while simultaneously making the sound appear and disappear several times per second.
Refer to the schematic:
Schema_nb_Tiny555_SoundBox.pdf (or color)
Code: Tiny555_SoundBox_V01.ino
Arduino47
brUNO Clerc
It's free and open source: Enjoy!
Discussion (0 comments)