红水杯

Differential Signal Analyzer

 
Overview

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:

The output signal oscilloscope displays:

Sinusoidal signal

 

Triangular wave signal

 

 

sawtooth signal

 

 

Square wave signal:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-16 00:25:26
  • Please help me how to use Altium Designer15.0.7
  • [New version CH554 review DIY] Audio Tuner 4
  • Modern motor design could improve portable vacuum cleaners
  • DSP basic information
  • LED as a button, unlimited creativity. Similar to a touchpad
  • Newbie, Saber simulation error

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号