191 views|0 replies

12

Posts

0

Resources
The OP
 

[Follow me Season 2 Episode 2] Basic tasks: Generate a sine wave with a DAC; Amplify the DAC signal with an OPAMP [Copy link]

 This post was last edited by zarkx on 2024-10-16 14:19

I've been so busy lately that I almost forgot

Generating a Sine Wave with a DAC

Refer to the DAC example on the official website to generate a sine wave.

Use the sample code directly

You can see that the A0 pin is used in the code.

#include "analogWave.h"
#include <OPAMP.h>

analogWave wave(DAC);
int freq = 100;

void setup() {
	// put your setup code here, to run once:
	Serial.begin(250000);
	analogReadResolution(8);

	wave.sine(freq);
	wave.amplitude(0.5);

	OPAMP.begin(OPAMP_SPEED_HIGHSPEED);
}

void loop() {
	// put your main code here, to run repeatedly:
	int value = analogRead(A3);
	Serial.println(value);
	delay(1);
}

Amplifying a Sine Wave Signal Using an Operational Amplifier

Refer to the circuit diagram of OPAMP on the official website and draw a simple circuit diagram. There is an amplifier inside ardiuno.

As shown in the picture, I used two 10K resistors. In fact, other resistance values can also be used. The resistance is the same.

The wiring is as shown in the figure, GND to A2 connects to a resistor, A2 to A3 connects to a resistor, and don't forget to connect the A1 and A0 contacts.

The code is as follows

#include "analogWave.h"
#include <OPAMP.h>

analogWave wave(DAC);
int freq = 100;

void setup() {
	// put your setup code here, to run once:
	Serial.begin(250000);
	analogReadResolution(8);

	wave.sine(freq);
	wave.amplitude(0.5);

	OPAMP.begin(OPAMP_SPEED_HIGHSPEED);
}

void loop() {
	// put your main code here, to run repeatedly:
	int dacvalue = analogRead(A0);
	int opampvalue = analogRead(A3);

	Serial.print(dacvalue);
	Serial.print(" ");
	Serial.println(opampvalue);
	delay(1);
}

The effect diagram is as follows

The following is the final video. In the simulated graph, you can clearly see that the floating difference between the two waveforms is twice as much. When I measured with a simple oscilloscope, I found that the peaks of waveforms A0 and A3 were similar, but A0 was wider. It should be because the screen was too small and was scaled. Overall, the difference is about half.



This post is from DigiKey Technology Zone
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list