File:Audio generator (Arduino Mini clone, R-2R matrix).png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (1,963 × 930 pixels, file size: 175 KB, MIME type: image/png)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description

An audio sine/ramp/pulse instrument generator using a noname clone of Sparkfun ProMicro (itself a clone of Arduino Mini) or a similar compact Arduino-compatible - and an R-2R parallel DAC. 8-bit high, 8-bit long sinewave is stored in program memory and copied to SRAM at power-on.

  • Boards of this size don't provide access to any complete 8-bit port - which would be very convenient for parallel 8-bit output. At best, there's six bits from one port (PORTD for the Sparkfun Promicro), and the two other bits must be taken from another port (here, PORTB). An eight-bit parallel output thus needs two write-to-port instructions, causing transition glitches.
  • To minimize them (a) minimize the lag between two write-to-port instructions, to make the spikes shorter (b) allocate "two other bits" to most significant bits of the wavetable, to minimize the number of spikes. The remaining short and rare spikes are culled by capacitor C1.
  • Minimal port update from LUT takes around 40 clock cycles, or 2.5 microseconds at 16 MHz clock. 400000 updates per second = 50 kHz "clean" sinewave (8 points per period) or 100 kHz "not so clean" sinewave (4 points per period).
  • A complete generator also needs some time to poll switches and ADC. With 128-clock-cycle timer interrupt period, the above upper frequency limits decrease to 16 kHz and 32 kHz.
  • Hook up timer interrupt subroutine to either timer0 or timer2. All other timers must be disabled. This means loss of micros/millis/delay/tone functions.
  • Do not use stock analogRead() and digitalRead / digitalWrite etc. - these are too slow for the job. Use direct access to ports and direct control of the DAC via ADCSRA register.
  • As shown, the circuit uses only two resistor values, 75 Ohms and 10 kOhms. Resistors for the R-2R array can be of any value from 1K to around 20 KOhm. Use 1% resistors from one production lot. Don't worry about nonlinearity, with 8 bits and 1% resistors it's a non-issue.
  • Using a simple emitter follower buffer as shown means that you need more than 5V power supply. Two lithium batteries, providing 7...8 V, or a single 9V (aka PP3 or 6LR61) battery will fit well.
Date
Source Own work
Author Retired electrician

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current23:41, 10 December 2020Thumbnail for version as of 23:41, 10 December 20201,963 × 930 (175 KB)Retired electrician (talk | contribs){{Information |Description=An audio sine/ramp/pulse instrument generator using a clone of Sparkfun ProMicro (itself a clone of Arduino Mini) or a similar compact Arduino-compatible - and an R-2R parallel DAC. 8-bit high, 8-bit long sinewave is stored in program memory and copied to SRAM at power-on. * Boards of this size don't provide access to complete 8-bit port - which would be very convenient for parallel 8-bit output. At best, there's six bits from one port, so the two other bits must b...

There are no pages that use this file.

Metadata