Noise Generator

In this exercise you will use the embedded programming and sampling techniques and presented in previous classes to build a simple noise generator using a DAC coupled with audio speakers. The basic idea is to generate a sinusoidal signal of a controlled frequency and output it into the DAC, this principle is known as Numerically Controlled Oscillator (NCO).

ATMega328 Microcontroller Family

For this exercise, we will use the AVR MCU found in the Arduino Uno board: the ATmega328.

DAC Peripheral

The ATmega328 doesn't have a DAC so an external DAC was built using the R-2R resistor ladder network. The schematic and wiring of the Arduino and the DAC with the audio speakers is shown below. Don't worry, it will, probably, be wired by the teaching assistant ;).

ADC and speakers schematic

ADC and speakers wiring

WARNING: Both the Arduino and the speakers must be connected to the same ground! That means that if you're using a USB speaker, plug it in the same PC or laptop that you plugged the Arduino.

ADC and DAC Operation

You will implement an application that generates a sine wave with a given frequency using a look-up table. The sine wave frequency will be controlled by the voltage value read by the ADC. In order to do this, you will configure the MCU's ADC through it's registers. You can use your source code from the Digital Voltmeter exercise. The generated sine samples must be sent to the 8-bit DAC through the MCU's Port B. Understanding and implementing these operations is up to you, but the supplied documentation might help you a lot.

Expected results

  1. Working demonstration: When connecting your Arduino to the DAC, the audio speaker's frequency must be set proportionally to the potentiometer value from 1 Hz to 1000 Hz
  2. Well documented, C++, interrupt-driven working code
  3. Report presenting the design of the implemented hardware and software systems, including software diagrams and operational characteristics (sampling rate, precision, etc.)

Useful docs