300 likes | 502 Views
Programmable Music Box. Team 18 Abhinav Todi , Danqi Ye, Sharaf Nazaar TA: Michelle Ansai. Introduction: Traditional Music Box. Sound derived from plucking of comb. Protrusions on drum encode song. One melody per box. Objective. Programmable Music Box MIDI compatible with:
E N D
Programmable Music Box Team 18 AbhinavTodi, Danqi Ye, SharafNazaar TA: Michelle Ansai
Introduction: Traditional Music Box • Sound derived from plucking of comb. • Protrusions on drum encode song. • One melody per box
Objective • Programmable Music Box • MIDI compatible with: • Real time with keyboard • MIDI files on SD card • MIDI protocols from PC
WHY MIDI? • MIDI stands for Musical Instrument Digital Interface • MIDI is a technical standard • MIDI formatting is well documented • Files use up very little space • Versatility in manipulation and choice of instrument
High Level Block Diagram Power Supply Music Box Interface (Servos) External Memory (SD/Flash) Microcontroller Unit Peripheral Hardware (Keyboard/PC) Keypad for Mode Selection Liquid Crystal Display Legend: Power MIDI PWM Digital I/O
High Level Flow Diagram Decode note number Corresponding servo control moves servo Initialize serial communication Load MIDI callback function Yes Initialize Servo Controls, LCD, keypad No NoteOn? Mode? Load Music Callback Function Real Time Yes Event? Real Time Routine while() loop SD card routing No
Design Considerations • Power Supply: • Conversion between 5V and 3.3V • MIDI I/O: • 5 Pin DIN connector • Current loop isolated from circuit
Design Considerations • Microcontroller Unit: • Memory available • Baud synchronization with MIDI • I/O Pins available
Design Considerations • SD Card: • Variable length parsing • Meta-events/Channel Events • Servo: • Play chords • Size and Calibration (Our biggest headache)
MIDI Interface • UART communication protocol • Pin 12/13 for RX/TX pins (Pin conflict management) • Callback function for interrupt driven input Data 1 Data 2 Status 1000nnnn 0kkkkkkk 0vvvvvvv The ‘Note On’ channel event is what we are most concerned with.
Microcontroller Original Idea: Final Decision: + 74F675A Shift Reg
LCD and Keypad • LCD/Keypad Design Functions: • Keypad selects 2 modes of operation • LCD displays mode selected
SD Card Interface • SPI communication protocol (different from real-time MIDI interface) • Uses pins 50 – 53
SD Card Interface Flow-Diagram Open midi file Extract Information from Header Chunk Yes Infinite while loop eof? No Read next track chunk 00ff 2f00 Parse delta time Parse event info Decode note on/ Set Tempo Event Note on/ set tempo
SD Card Interface Functions • Extract relevant info from header/track chunk: • No. of tracks • Length of tracks • Time base • Tempo
Header Chunk MIDI File Format Track Chunk End of Track Chunk
SD Card Interface Functions • Read variable length delta-time • Recognize event of relevance:
MIDI File Delta Time Calculation • Delta time is stored as number of ticks • For default tempo of 120 bpm:
Servo Specs • Runs on 5V power supply • 20.2mm x 8.5mm x 20.2mm • Torque: 0.03 Nm (Fairly weak)
Software For Testing • For real time testing: • ‘ChucK’ is used to sequence melody. See http://chuck.cs.princeton.edu/ • Servos flick in sync with sound card output. • SD card requires larger memory for sequencing • MIDI events stored on temp file and played back
The Final Product • PCB of an Arduino Shield • Mechanical box consisting of 3 combs, 6 servos
Limitations • Mechanical Limitation: • Calibration • Servo torque strength (size vs. strength) Size Matters!
Future Improvements • Increased musical range • Recording Mode • USB interface • Decreased Cost with Uno and Shift Register • More precise mechanical design • That, or synthesize the sound.
Special Thanks • Professor Haken for lending equipment and advice on MIDI interface. • SkotWiedmann for advice and help on circuit design.