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; as 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; also two potentiometer control amplitude and frequency, therefore, 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 Code:

#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:

ComponentsValuesQuantity
Resistors2.2k 1
Potentiometer 10k2
CapacitorCeramic 100nF1
SemiconductorArduino Uno1

This circuit show how to make simple sine wave using Arduino and we can change sine wave frequency and amplitude very easily.

Arduino pin 11 give PWM signal out and then this PWM value keep changing like sine shape and this also make digital sine form.

Then R1 with capacitor C1 make low pass filter and then filter remove fast PWM and give smooth analog sine.

After that, potentiometer VR1 control amplitude going to A0 and potentiometer VR2 control frequency going to A1 and then finally, 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

Hence, 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:

To conclude, this Arduino Sine Wave Output Circuit with RC Filter is easy way to make smooth sine signal, as this signal is not perfect like real DAC but good for hobby and audio demo.

Also, two potentiometer knobs give easy control for amplitude and frequency; further, the circuit is easy to build and good for beginners.

Exit mobile version