Site icon Circuit Ideas for You

Arduino Sine Wave Output Circuit with RC Filter

This project show how to make simple Arduino sine wave circuit with RC filter.

Arduino cannot give real analog output, but it only gives PWM signal.

So we use low pass RC filter to change PWM into smooth sine wave.

Two potentiometer control amplitude and frequency.

This circuit is very easy and good for small experiment.

Low Pass RC Filter Blocking High Frequency PWM:

Graph showing how RC filter removes high-frequency components:

Gain
1.0 |---------\
0.8 |          \
0.6 |           \
0.4 |            \_____
0.2 |                  \______
0.0 |_____________________________→ Frequency
                 fc

fc is cutoff frequency = 1 / (2 × pi × R × C)

Arduino Coding:

#include <Arduino.h>

int ampPin = A0;
int freqPin = A1;
int pwmPin = 11;

float angle = 0.0;

void setup() {
pinMode(pwmPin, OUTPUT);
}

void loop() {
int ampRead = analogRead(ampPin);
int freqRead = analogRead(freqPin);

float amplitude = map(ampRead, 0, 1023, 0, 255);
float frequency = map(freqRead, 0, 1023, 1, 50);

float sineValue = sin(angle) * amplitude + amplitude;
int pwmValue = constrain(sineValue, 0, 255);

analogWrite(pwmPin, pwmValue);

angle += 0.02 * frequency;
if (angle > 6.28) angle = 0;
}

Circuit Working:

Arduino Sine Wave Output Circuit Diagram with RC Filter

Parts List:

ComponentValue / TypeQuantity
Resistors2.2k 1
Potentiometer 10k2
CapacitorCeramic 100nF1
SemiconductorArduino Uno1

This circuit show how to make simple sine wave using Arduino.

We can change sine wave frequency and amplitude very easy.

Arduino pin 11 give PWM signal out.

PWM value keep changing like sine shape.

This make digital sine form.

Then R1 with capacitor C1 make low pass filter.

Filter remove fast PWM and give smooth analog sine.

Potentiometer VR1 control amplitude going to A0.

Potentiometer VR2 control frequency going to A1.

Arduino read both values and change the output signal.

Formula with Calculation:

Low pass filter cutoff frequency formula:

fc = 1 / (2 × pi × R × C)

here,

fc = 1 / (2 × 3.14 × 2200 × 0.0000001)
fc = 1 / (1.38 × 0.00022)
fc = 723 Hz

This is enough to smooth PWM around 31kHz of Arduino.

How to Build:

To build a Arduino Sine Wave Output Circuit with RC Filter following are the steps to follow:

Conclusion:

This Arduino Sine Wave Output Circuit with RC Filter is easy way to make smooth sine signal.

Signal is not perfect like real DAC but good for hobby and audio demo.

Two knobs give easy control for amplitude and frequency.

Easy to build and good for beginners.

References:

Creating sine waves with an Arduino

Exit mobile version