The Chaos Device
Working from home with high levels of noise around my home office, I needed something like a radio studio 'on air' light to let passers-by know they should try to keep the volume down. I wanted something lightweight and portable, and there was nothing like this for sale at the time. Thus, I designed and built the Chaos Device, partly as a test of my prototyping capabilities.
The cases were designed in OpenSCAD and 3D-printed in PLA.
Here's a demo of it in action.
Transmitter
The electronics consist of:
- A preassembled 433MHz radio transmitter circuit (dangling out of the front of the case to avoid interfering with the other electronics).
- A push to make switch and activity LED.
- A preassembled boost converter circuit that takes the 1.5V from the single AA battery and produces 5V.
- A 555 timer chip with a resistor and capacitor configured to produce a 100Hz square wave.
The transmitter broadcasts the square wave generated by the 555 timer for as long as the switch is held down.
Interactive 3D print model
The STL viewer widget is borrowed with permission from mitxela.com.
Receiver
The electronics consist of:
- A preassembled 433MHz radio receiver circuit.
- An attiny85 processor.
- A speaker, LEDs mounted in the front of the case, and a power switch.
- Another preassembled boost converter circuit to supply 5V.
- A few other components, including a couple of transistors for amplification and a capacitor to stabilise the input voltage to the processor.
Case front
I made the printed sign on the front after a visit to Bletchley Park, a cryptography museum that was the former site of the British Government Code and Cypher School where the Enigma code was cracked during the Second World War. The museum features a number of mockups demonstrating how the buildings were used for codebreaking, and the walls are decorated with supposedly authentic posters and directives written in a tone that attempts to be simultaneously aloof and scientific, but also paternalistic, expecting the reader to do their best. "It's for your own good — just look at the data!" I attempted to replicate the tone on the sign here, fully-justifying the text in the era-appropriate manner.
The red glow from inside the case comes from an LED mounted on the boost converter circuit board.
The case has a slightly ramshackle appearance due to being glued together, as a slightly easier alternative to using screws in the screw sockets which are unused in this prototype.
Case rear
I printed the case to fit around some components I had to hand. The speaker, switch and battery contacts are recycled from old electronic toys.
Interactive 3D print model
Programming the attiny85 processor
The processor was programmed using avrdude by plugging it into a breadboard and using an Arduino Uno as a programming interface.
The code
The program running on the processor is conceptually pretty simple:
- Once the processor is turned on, it listens for the signal from the receiver (the 100Hz square wave).
- When the signal is detected, the activation sound is played and the case LEDs start flashing. The program waits for a second to give you a chance to take your thumb off the button, in order to avoid deactivating itself straight away.
- When the signal is detected again, the deactivation sound is played and the case LEDs stop flashing. The processor goes back to listening for the activation signal.
Practical considerations
Signal to noise ratio
The signal from the preassembled receiver is very noisy. Simply trying to read the radio receiver pin for a 5V high resulted in the Device activating and deactivating itself repeatedly as it continuously registered false positive signals. I tested a few approaches to make the signal clearer:
- Keeping the aerial away from sources of spurious electromagnetic radiation, including the inductor on the receiver's own boost converter circuit.
- Varying the frequency of the square wave. The maximum frequency the radio pair would transmit and receive was 1MHz.
- Low-pass filtering the signal with a capacitor.
Ultimately I had to resort to denoising the signal algorithmically. The processor uses a state machine to verify that the receiver pin performs two uninterrupted oscillations. In simpler terms, that means a signal is only registered when:
- The program detects the receiver pin is low for at least 500 consecutive loop iterations.
- Then, when the receiver pin goes high, it stays high for at least 500 consecutive loop iterations.
- Then, when the receiver pin goes low again, it stays low for at least 500 consecutive loop iterations.
- Then, when the receiver pin goes high again, it stays high for at least 500 consecutive loop iterations.
Voltage drop
A single AA battery does not have a very high impedance, and this is evident in the Chaos Device when, after days of use and with the battery beginning to go flat, the pitch of the activation and deactivation sounds starts to droop and squawk like a broken robot. This amusing malfunction occurs because:
- Activating the speaker increases the power draw.
- This causes the circuit voltage to drop.
- As a result, the processor's clock slows down.
- The rate at which the speaker output pin is cycled consequently falls.
- The perceived pitch of the sound from the speaker also falls.
In theory, a big enough capacitor wired in parallel with the power supply can smooth out any variations in the voltage, but I found that even a 10mF electrolytic capacitor (which is physically too large for the case as designed) made no noticable difference.
If possible, I prefer a device to require only a single cell: it reduces the size of the case and, more importantly, removes the need to find matching batteries. Using batteries with different levels of charge in the same device is dangerous, and a lot of batteries are thrown away because they end up partially charged, and can't be matched with another one. Even if you don't care about waste, nothing is more annoying than having a drawer full of odd batteries and not being able to use any of them!
I decided this defect was hilarious enough to live with. The only functional issue it presented was that the voltage drop eventually gets so severe that the processor actually turns off. It immediately turns back on again as power is no longer drawn and the voltage rises to 5V again, but it starts in inactive mode, which is obviously not the intended behaviour from pressing the button on the transmitter to activate it. My solution was to make the activation sound different to the deactivation sound, which is an audible reassurance that the receiver is in the correct mode.
The name
The Chaos Device was named after the item in the game Heretic, for MS DOS.
Using the item teleports you back to the start of the level. This feature will be implemented as budget constraints allow.