ARTE
BELLEZA Y BIENESTAR
ARTESANÍA
CULTURA E HISTORIA
ENTRETENIMIENTO
MEDIO AMBIENTE
COMIDA Y BEBIDAS
INGENIERÍA INVERSA
CIENCIAS
DEPORTES
TECNOLOGÍA
TECNOLOGÍA VESTIBLE
DDS Sine Generator: Arduino, Sine Table and R-2R Ladder (after Jackson, 1973)
Ed

Creado por

Ed

4. diciembre 2026FI
0
0
0
0
0

DDS Sine Generator: Arduino, Sine Table and R-2R Ladder (after Jackson, 1973)

A sine-wave generator from 1 Hz to 8 kHz, set in 1 Hz steps with a knob. It works the way Leland Jackson patented direct digital synthesis in 1973: a counter adds a frequency number every sample, its top bits pick a value from a sine table, a resistor ladder turns that into a voltage and a filter smooths the steps. Arduino Uno, 25 resistors, an OLED and an encoder.
Intermedio
About 3 hours

Instrucciones

1

Jackson's frequency synthesizer, 1973

US 3,735,269: an accumulator receives the wanted frequency and "successively" generates addresses in a store holding samples of the output wave; a digital-to-analog converter turns them into "a step-type waveform which is passed through a low pass filter". To shrink the store, "sign and quadrature symmetry" of the sine are used: only a quarter of the wave is kept.
Paso 1 - Image 1
2

Frequency word, steps and filter

Cargando el cuaderno de Jupyter…
3

Build the R-2R ladder

On a perfboard, use 10 kΩ 1 % resistors: "R" is one, "2R" two in series. Chain eight nodes with R between neighbours. From each node a 2R goes to one Arduino pin: D8 (bit 0) at the first node up to D7 (bit 7) at the last, in the order D8, D9, D2, D3, D4, D5, D6, D7. From the first node a ninth 2R goes to GND. The last node is the output. Put a 2.2 nF capacitor from the output to GND, and a 1 µF capacitor (+ to the output) in series to the BNC.

Materiales para este paso:

Placa perforada / placa de prototiposPlaca perforada / placa de prototipos1 pieza
ResistenciaResistencia25 piece (10 kΩ 1 %)
Kit de condensadores cerámicosKit de condensadores cerámicos1 piece (2.2 nF from the kit)
Condensador electrolíticoCondensador electrolítico1 piece (1 µF)
Juego de conectores coaxiales (BNC / SO-239)Juego de conectores coaxiales (BNC / SO-239)1 piece (BNC socket from the set)
Tira de pinesTira de pines1 strip
Cable de conexiónCable de conexión1 m
Alambre de soldaduraAlambre de soldadura1 m

Herramientas necesarias:

Soldador de estañoSoldador de estaño
PelacablesPelacables
MultímetroMultímetro
4

Add the display and knob

OLED: VCC 5V, GND, SDA to A4, SCL to A5. Encoder: A to A0, B to A1, button to A2, common pins to GND.

Materiales para este paso:

Pantalla OLEDPantalla OLED1 piece (128 x 64, I2C)
Codificador rotatorioCodificador rotatorio1 pieza
Cable de conexiónCable de conexión0.5 m

Herramientas necesarias:

Soldador de estañoSoldador de estaño
5

Upload the firmware

Board "Arduino Uno"; install Adafruit SSD1306 and Adafruit GFX in the library manager first.
dds_generator.inocpp
// Direct digital synthesis sine generator on an Arduino Uno, after L. B. Jackson, US 3,735,269 (1973):
// an accumulator adds a frequency word every sample, its top bits address a stored sine table (one quarter kept,
// the rest by quadrature symmetry), an 8-bit R-2R ladder is the DAC and an RC low-pass smooths the steps.
// DAC bits 0-1 on D8-D9, bits 2-7 on D2-D7 (D0/D1 stay free for USB). Encoder on A0/A1, its button on A2. OLED on A4/A5.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

const uint32_t FS = 31250;                 // samples per second: 16 MHz / 512
const uint32_t F_MIN = 1, F_MAX = 8000;    // Hz; above FS/4 the steps are too coarse for the filter
Adafruit_SSD1306 oled(128, 64, &Wire, -1);

uint8_t quarter[64];                       // sin over 0-90 degrees at half-step offsets, 0..127
volatile uint32_t acc = 0, inc = 0;
uint32_t freq = 1000; uint32_t step = 100;
const uint32_t STEPS[] = {1, 10, 100, 1000};

ISR(TIMER1_COMPA_vect) {
  acc += inc;
  uint8_t p = acc >> 24, i = p & 63, q = (p & 64) ? quarter[63 - i] : quarter[i];
  uint8_t v = (p & 128) ? 128 - q : 128 + q;
  PORTD = (PORTD & 0x03) | (v & 0xFC);
  PORTB = (PORTB & 0xFC) | (v & 0x03);
}

void setFreq(uint32_t f) {
  uint32_t w = (uint32_t)(((uint64_t)f << 32) / FS);
  noInterrupts(); inc = w; interrupts();
}

void show() {
  oled.clearDisplay(); oled.setTextColor(SSD1306_WHITE);
  oled.setTextSize(2); oled.setCursor(0, 8); oled.print(freq); oled.print(" Hz");
  oled.setTextSize(1); oled.setCursor(0, 44); oled.print("step "); oled.print(step); oled.print(" Hz  (press)");
  oled.display();
}

void setup() {
  for (uint8_t i = 0; i < 64; i++) quarter[i] = (uint8_t)(127.0 * sin((i + 0.5) * PI / 128.0) + 0.5);
  DDRD |= 0xFC; DDRB |= 0x03;
  pinMode(A0, INPUT_PULLUP); pinMode(A1, INPUT_PULLUP); pinMode(A2, INPUT_PULLUP);
  oled.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  setFreq(freq); show();
  TCCR1A = 0; TCCR1B = _BV(WGM12) | _BV(CS10);   // CTC, no prescaler
  OCR1A = 16000000UL / FS - 1;
  TIMSK1 = _BV(OCIE1A);
}

uint8_t lastAB = 3; int8_t sub = 0; bool lastBtn = true; uint32_t shownAt = 0; bool dirty = false;
const int8_t TABLE[16] = {0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0};

void loop() {
  uint8_t ab = (digitalRead(A0) << 1) | digitalRead(A1);
  sub += TABLE[(lastAB << 2) | ab]; lastAB = ab;
  if (sub >= 4 || sub <= -4) {                       // one detent = four quadrature changes
    int32_t f = (int32_t)freq + (sub > 0 ? 1 : -1) * (int32_t)step; sub = 0;
    if (f < (int32_t)F_MIN) f = F_MIN; if (f > (int32_t)F_MAX) f = F_MAX;
    freq = f; setFreq(freq); dirty = true;
  }
  bool b = digitalRead(A2);
  if (!b && lastBtn) { uint8_t k = 0; while (STEPS[k] != step) k++; step = STEPS[(k + 1) % 4]; dirty = true; delay(20); }
  lastBtn = b;
  if (dirty && millis() - shownAt > 150) { show(); shownAt = millis(); dirty = false; }
}

Materiales para este paso:

Arduino Uno R3Arduino Uno R31 pieza

Herramientas necesarias:

Ordenador con el IDE de ArduinoOrdenador con el IDE de Arduino
Cable USB-BCable USB-B
6

Use and check it

Turn the knob slowly to change the frequency; press it to change the step (1, 10, 100, 1000 Hz). On a scope the output is about 5 V peak to peak, centred on 0 after the capacitor. It drives high-impedance inputs (scopes, amplifiers), not speakers. Up to a few kHz it is a clean sine; towards 8 kHz the steps show, and a second 10 kΩ + 2.2 nF stage smooths them more.

Herramientas necesarias:

OsciloscopioOsciloscopio

Materiales

11

Herramientas requeridas

6
  • 2 vendors sell this, none ship to you yet
    Marcador de posición
  • Marcador de posición
  • Marcador de posición
  • Marcador de posición
  • 1 vendor sell this, none ship to you yet
    Marcador de posición
  • Marcador de posición

CC0 Dominio público

Este Plano se publica bajo CC0. Eres libre de copiar, modificar, distribuir y usar este trabajo para cualquier propósito, sin pedir permiso.

Apoya al Maker comprando productos a través de su Plano, donde gana una Comisión del Maker establecida por los vendedores, o crea una nueva iteración de este Plano e inclúyela como conexión en tu propio Plano para compartir ingresos.

Discusión

(0)

Iniciar sesión para unirte a la discusión

Cargando comentarios...