Go to file
Jay Robson 9a75323691 update readme, remove instruction, improve port.hpp 2024-10-02 23:33:45 +10:00
.gitignore add forced inlines 2024-10-01 13:39:28 +10:00
Project.jpg add README 2024-10-01 01:54:17 +10:00
README.md update readme, remove instruction, improve port.hpp 2024-10-02 23:33:45 +10:00
buttons.cpp improvements 2024-09-30 23:25:16 +10:00
buttons.hpp added song skipping 2024-09-29 18:07:58 +10:00
dac.hpp can now interface with eeprom; improved computer communication 2024-08-28 13:10:57 +10:00
data.cpp added song skipping 2024-09-29 18:07:58 +10:00
data.hpp added song skipping 2024-09-29 18:07:58 +10:00
eeprom.cpp optimise I2C 2024-10-01 16:19:43 +10:00
eeprom.hpp optimise I2C 2024-10-01 16:19:43 +10:00
entry.hpp improvements 2024-09-30 23:25:16 +10:00
indicator.cpp optimisations 2024-08-31 16:31:19 +10:00
indicator.hpp can now interface with eeprom; improved computer communication 2024-08-28 13:10:57 +10:00
port.hpp update readme, remove instruction, improve port.hpp 2024-10-02 23:33:45 +10:00
scheduler.cpp update readme, remove instruction, improve port.hpp 2024-10-02 23:33:45 +10:00
scheduler.hpp added track skipping 2024-09-27 22:46:51 +10:00
serial.cpp can now interface with eeprom; improved computer communication 2024-08-28 13:10:57 +10:00
serial.hpp added bufferless i2c implementation 2024-08-31 01:53:25 +10:00
soft_twi.cpp optimise I2C 2024-10-01 16:19:43 +10:00
soft_twi.hpp optimise I2C 2024-10-01 16:19:43 +10:00
timing.hpp initial commit 2024-08-19 22:43:24 +10:00
tone-generator.ino optimise I2C 2024-10-01 16:19:43 +10:00
tone.cpp use integer math only for tone generation 2024-08-26 13:02:17 +10:00
tone.hpp add forced inlines 2024-10-01 13:39:28 +10:00
tones.cpp optimisations 2024-08-31 16:31:19 +10:00
tones.hpp optimisations 2024-08-31 16:31:19 +10:00
util.hpp add forced inlines 2024-10-01 13:39:28 +10:00

README.md

Overview

This uses an AVR microcontroller (ATMega328P-PU).

Project

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

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
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