1. Signal generator:
The signal source uses four signals: sine wave, triangle wave, sawtooth wave, and square wave generated by Arduino microcontroller. Since Arduino uno does not have easy-to-use DA conversion, a simple DA conversion unit can be generated through the R2R network to output the corresponding Voltage value. First generate digital signals of sine wave, triangle wave and other waveforms in Arduino , place the digital signal in the PORTD register ( D0~D7 ) in Arduino , and then output the converted signal through a simple DA converter built on the breadboard (i.e. analog signal) is input into the amplifier circuit as a signal source
Signal source Arduino program:
int wavedigital[255];
// Define graphics period
int cycle;
// Waveform mode switching button
const int button = 12;
// Waveform constant
volatile int wave = 0;
void setup()
{
Serial.begin(9600);
// Set interrupt program
//attachInterrupt(button, waveSelect, RISING);
// Output port 0-7
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
// Change the output signal frequency and it will take effect after adjusting the potentiometer and resetting it.
cycle=int(analogRead(A0)/10)+1;
// Default output is positive Xuan wave
wagegen();
}
void loop()
{
unsigned char date1[1]={0xFF};
unsigned char date2[1]={0xEE};
unsigned char date3[1]={0x0D};
unsigned char date4[1]={0x0A};
if(digitalRead(button)==0)
{
waveSelect();
}
// Adding this sentence will affect the quality of the waveform and cause distortion of the waveform.
//cycle=int(analogRead(A0)/10)+1;
for (int i=0;i<255;i++)
{
PORTD=wavedigital[i];
Serial.write(date1,1);
Serial.write(date3,1);
Serial.write(date4,1);
Serial.print(wavedigital[i]);
Serial.write(date2,1);
Serial.write(date3,1);
Serial.write(date4,1);
Serial.print(analogRead(A2));
// Debug the values of each waveform
// Serial.println( wavedigital[i]);
// Debug waveform cycle
delayMicroseconds(cycle);
// delayMicroseconds(10);
}
// The value of the debugging analog input has determined the waveform period
// Serial.println(cycle);
}
// Waveform selection program
void waveSelect() {
// Select the required waveform 0 -positive wave 1- triangular wave 2- sawtooth wave 3- rectangular wave
wave++;
if(wave == 4)
{
wave = 0;
}
wagegen();
delay(3000);
}
// Generate waveform values
void wagegen()
{
float x;
float y;
// The value of Zhengxuanbo
if(wave==0)
{
for(int i=0;i<255;i++)
{
x=(float)i;
y=sin((x/255)*2*PI);
wavedigital[i]=int(y*128)+128;
// Serial.print(wavedigital[i]);
}
}
// Value of triangle wave
if(wave==1)
{
for(int i=0;i<128;i++)
{
x=(float)i;
wavedigital[i]=int(2*x);
}
for(int i=128;i<255;i++)
{
x=(float)i;
wavedigital[i]=255-int((x-128)*2);
// Serial.print(wavedigital[i]);
}
}
// sawtooth wave
if(wave==2)
{
for(int i=0;i<255;i++)
{
x=(float)i;
wavedigital[i]=x;
// Serial.print(wavedigital[i]);
}
}
// Square wave worth generating
if(wave==3)
{
for(int i=0;i<128;i++)
{
wavedigital[i]=255;
}
for(int i=128;i<255;i++)
{
wavedigital[i]=0;
// Serial.print(wavedigital[i]);
}
}
Simple DA converter connection diagram equipped with Arduino :
Physical connection diagram:
2. Amplification circuit:
The amplification circuit uses the schematic diagram provided in the competition attachment of Lichuang Electronic Design Competition. The schematic diagram and PCB are drawn in Lichuang EDA , and the welding and debugging of the circuit are completed.
Schematic diagram: The schematic diagram uses the schematic diagram customized by Lichuang competition and is drawn on Lichuang EDA .
PCB : Use the recommended package in the schematic diagram to lay out, type and connect the components.
Actual picture after welding:
PCB for testing
Measurement display (LabVIEW as oscilloscope):
The measurement display part uses Labview as the waveform of the host computer to display the signal, and uses a simple state machine architecture to display the waveform sent by the host computer. The implementation method is to input the waveform into the differential amplification circuit, and the amplified waveform forms a data packet. The header is hexadecimal FF and the packet tail is hexadecimal EE . The data of the source signal is read through the Arduino microcontroller and sent through the serial port. Give Labview a host computer, unpack and display the data in the host computer part.
By unpacking the signals sent by the slave computer, two sets of LabVIEW programs were written, which were to display the simple DA -converted analog signals and amplified signals built on Arduino through the breadboard . After the LabVIEW programs were written , package the program as an exe file so that the program can still be used on a computer that does not have LabVIEW installed .
Sine wave:
Oscilloscope shows:
triangle wave
Oscilloscope display
sawtooth wave
Oscilloscope waveform:
Square wave:
Oscilloscope shows:
Sinusoidal signal
Triangular wave signal
sawtooth signal
Square wave signal:
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet