-
Notifications
You must be signed in to change notification settings - Fork 1
Home
This project is my latest attempt to create a wearable mask which can alert me when I'm dreaming and encourage lucid dreams. Unfortunately, I've been struggling with insomnia over the last few years, so this project is in an "almost but not quite" state. Recent changes seem to be getting it under control, and I hope to be able to pick up this project again some time soon.
To build this project, you'll need the following:
- An AVR programmer
- A FTDI USB-Serial interface
- The ability to cut, etch, and drill circuit boards (laser printer masks are sufficient)
- The ability to do simple surface-mount soldering (SOICs and 0804s)
- The ability to sew a fabric mask to hold everything in place
- Eagle
- avrdude
This is a work in progress as I find my old notes, and some of these components have probably been replaced by newer versions.
- AVR atmega328p
- 0804 resistors, capacitors, PTC, LEDs
- IR distance sensors
- CR2032 battery holder
- 32.768kHz crystal
- Pushbuttons
- Male and female headers
- Etch both circuit boards using the Eagle files (NB: I made these for home etching, so they have large tolerances and don't have the extra layers for professional fabbers to do solder masks and drilling)
- Using the Eagle files as a guide, solder on all the components (TODO: I need to add actual values to the resistors and capacitors)
- Using the air wires as a guide, connect the two boards together
- Create a programming header to map the pins from the AVR programmer and the FTDI adapter onto the pins on the board (TODO: create a schematic)
- Run "make fuses" (this only has to be done once per AVR chip)
- Run "make program" to build and upload the program
- Make a fabric mask (TODO: upload pictures of what I made)
To turn the mask on, insert the battery. Once you're in bed, press a button to turn on recording and REM detection logic. After a delay (TODO what is it?), the "dream alarm" will be enabled and will flash the LEDs (the morse code for "DREAM") when REM sleep is detected. In the morning, download the eye movement data for further analysis (or just clear it).
With the FTDI adapter attached and the battery in, run a standard serial emulator (e.g. minicom). Connect with 230400 / ? / ? / ? with no handshake. The following commands are available:
- SCAN - see how much of the flash memory is in use
- ERASE - erase the flash memory
- VOLT - perform a crude battery test
- MORSE - blink with Morse code
- ADC - turn on the sensors
- ADCVERB - start printing what the sensors "see"
- SUM - print a checksum of the current flash memory (may or may not work?) You can also initiate an XMODEM download to download the flash contents (no command required; just start an XMODEM download).
IR readings are 10-bit numbers. The data is downloaded as a binary blob. Each 256-byte "packet" has an 8-byte header followed by readings and other data. bytes 0-7: FF EE 0 byte 8,12,etc: