From c4b463fc244b03cf0681829193c6879d91a1b871 Mon Sep 17 00:00:00 2001 From: Jay Robson Date: Wed, 2 Oct 2024 23:50:43 +1000 Subject: [PATCH] improve readme --- README.md | 49 +++++++------------------------------------------ 1 file changed, 7 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index df887cb..db00825 100644 --- a/README.md +++ b/README.md @@ -18,49 +18,14 @@ This uses an AVR microcontroller (ATMega328P-PU). | A0-A3 | Serial: DTR, TXD, RXD, CTS | | A4-A5 | I2C: SDA, SCL | -# Pin Description - -| Pin(s) | Purpose | -|--------|----------------------------------| -| 0-7 | 8-bit DAC (for audio) | -| 8 | Next button | -| 9-10 | LEDs | -| 11-13 | ISP Programmer, otherwise unused | -| A0-A3 | Serial: DTR, TXD, RXD, CTS | -| A4-A5 | I2C: SDA, SCL | - -# 8 bit DAC - -this is a resistor ladder. one major advantage i get for using all of pins 0-7, is i can set all of them very efficiently, and simultaneously if i write to them directly (setting to `PORTD` instead of using `digitalWrite` in a loop). unfortunately this means i have to use software serial, but the performance compromise was worth it, because setting pins via registers directly is extremely fast in the right circumstances. - -# I2C - -this is to communicate with EEPROM. there is 256 KB installed. songs are read from here. i am actually using my own implementation here of software i2c, because i needed to write entire 128 byte pages to EEPROM in a single go. my implementation is master only, and it doesn't require any buffers or interrupts. it is not limited in the amount of bytes a single transaction or response may have. - -# Serial - -via serial, EEPROM can be flashed, or songs can be streamed directly. - -# Tone generating, mixing, and playback - -this is the most performance critical part, and is done entirely in software. there are 32 channels for tones to play in, meaning up to 32 tones can play at one time. all of this is done using integer math. - -# Amplifiers - -there are 2 dual opamps, using 3 opamps in total. 1 is to drive some transistors to create a raised ground at 2.5V. this is the speaker ground. downside of this is that in order for this to connect to an audio system (such as a speaker, headphones, or mic input), both systems must be isolated from each other. - -one opamp follows the signal from the 8 bit DAC, but with gain from the potentiometer to prevent clipping. the output of this is followed by another opamp, which drives some transistors to increase the current. - # Instruction Set -for streaming from eeprom and serial, i need a representation that is as compact as possible. there are a total of 7 instructions (but 6 in use here). - -| ID | Name | Size (bytes) | Provides | +| ID | Name | Size | Layout | |-|-|-|-| -| 0 | stop | 1 | halts execution | -| 1 | setup | 8 | provides important information for the song, such as volume, microseconds per tick, and where to jump on song skip | -| 2 | set | 3 | assigns a frequency to a channel | -| 3 | set-ts | 5 | same as set, but waits until given ticks have passed | -| 4 | clear | 1 | stops a channel from playing | -| 5 | clear-ts | 4 | same as clear, but waits until given ticks have passed | +| 0 | stop | 1 | - | +| 1 | setup | 8 | us_per_tick (29), amplitude (8), size (24) | +| 2 | set | 3 | index (5), frequency (12) | +| 3 | set-ts | 5 | index (5), ticks (20), frequency (12) | +| 4 | clear | 1 | index (5) | +| 5 | clear-ts | 4 | index (5), ticks (20) |