Abstract : This tester uses the STM32F 103 series microcontroller and the Arduino Uno microcontroller as the core control device. It uses the DDS module, amplifier and resistor divider circuit to generate a differential signal U id with adjustable amplitude and frequency . It builds a triode differential amplification according to the problem. circuit and debug it to work normally. By collecting the input voltage U i d and the current I i d flowing through the input resistor , the input resistance R i d is calculated ; by collecting the output voltage U od, the voltage amplification factor Avd is calculated ; and In order to measure the amplitude-frequency characteristics of the differential amplifier circuit, write a program to display it on the display screen.
The voltage amplification factor and input resistance of the amplifier were measured at 1KHz. From measurement and calculation, it was found that the amplification factor was approximately 32 times and the input resistance was approximately 50 ohms. This tester basically meets the requirements of the question.
Keywords : STM32F 103 ; AD985 1 ; Arduino Uno.
Option 1: Microcontroller + FPGA method. This solution uses the FPGA to output a differential mode signal with an amplitude adjustable in 0-100mV in 10mV steps, a frequency adjustable in 100Hz~1MHz in 100Hz steps, and a common mode signal adjustable in 0V~1V in 10mV steps. To generate signals for testing, use the microcontroller to control the signal source and control the FPGA. That is, the microcontroller performs top-level functions such as collection, processing, calculation, display, and human-computer interaction interface of the output signal, and the FPGA completes the signal output for testing.
Option 2: Use the STM32F103 series microcontroller based on the ARM Cortex™-M4 core and the Arduino UNO series microcontroller board based on the ATmega328P. Among them, the STM32F103 series of microcontrollers and the microcontroller board have high clock speeds, and the internal integrated FPU has strong computing power and can handle complex calculations and control. Arduino UNO series microcontroller boards are easy to program, have low power and are capable of performing simple operations.
After considering its feasibility and all available resources, option 2 was adopted as this design plan. 2. Differential signal source generation solution selection
Solution 1: Use the DAC of the STM32 microcontroller to generate differential signals. The DAC module of the STM32F407 is configured in 12-bit mode and used in conjunction with the DMA controller. However, frequency changes are required, and the high-frequency sine wave generated by a microcontroller is not accurate enough and takes up resources.
Option 2: Use ADI's most widely used DDS chip AD9851 to make a sine wave generator. This module can output a highly stable sine wave with a frequency range of up to 40MHz and an amplitude range of 80mV~2V. In addition, this chip uses a dedicated voltage stabilization reference chip. The power supply is more stable. Combined with the STM32 microcontroller DAC to output common mode signals, it is easier to write programs.
In summary, the second solution is adopted as this design solution.
figure 1
The overall block diagram of the system is shown in Figure 1. This system uses the STM32F103 microcontroller based on the ARM core and the software of the Arduino UNO series microcontroller board based on the ATmega328P to control the DDS module AD9851 to generate differential signals, which are input to the amplification circuit through the amplitude modulation module based on the amplifier principle. The STM32F103 microcontroller is used to measure the amplitude-frequency characteristics of the differential amplifier circuit and display it on the display.
figure 2
The circuit under test is shown in Figure 2 as a differential common-emitter amplifier circuit.
Through the simulation software, set the differential mode signal frequency to 1KHz, input the differential signal into the differential amplifier circuit, and connect the input signal and output signal to the oscilloscope. Observe, record and measure uid and uod, and calculate the theoretical voltage amplification factor by calculating Avd =uod/uid.
2. Calculation of theoretical input resistance
Through the simulation software, set the differential mode signal frequency to 1KHz, connect the differential signal to the oscilloscope, observe, record and measure uid on the premise that the waveform is not significantly distorted, and use a multimeter to measure the input current Iid, and apply the amplifier's input resistance formula Rid =uid/Iid, calculate the theoretical input resistance as.
3. Circuit and Programming
Apply an operational amplifier circuit and adjust the resistance of the relevant resistor to change its amplification factor to achieve amplitude modulation.
image 3
Use Arduino to control the DDS module so that the input differential signal frequency is 1KHz, input the differential signal into the differential amplifier circuit, and connect the input signal and output signal to the oscilloscope. When there is no obvious distortion in the waveform, observe, record and measure uid and uod. By calculating Avd =uod/uid, the actual voltage amplification factor is calculated to be 32 times.
应用Arduino控制DDS模块,设置差模信号频率为1KHz,将差分信号连接至示波器,在波形未明显失真的前提下,观察,记录并测量uid,并使用万用表测量输入电流Iid,应用放大器的输入电阻公式Rid =uid/Iid,计算实际输入电阻为50欧姆。
四、测试方案与测试结果
表1 测试仪器表
测试仪器列表 |
|
万用表 |
VICTOR VC890C+ |
电源 |
EAST WYK-303B2 |
示波器 |
RIGOL DG4102 |
信号源 |
RIGOL DP832A |
2.1、放大倍数测试
使差模信号频率稳定在1KHz下测量并计算放大器的电压放大倍数和输入电阻。
表2 放大倍数测试表
输出/输入电压 |
测量值 |
uod |
3.52V |
uid |
0.11V |
Avd |
32 |
根据电压放大倍数公式Avd =uod/uid,计算Avd=32。
2.2、输入电阻测试
表3 输入电阻测试表
Uid |
0.11V |
Iid |
2.2mA |
根据输入电阻公式Rid =uid/Iid ,计算得实际输入电阻Rid=50欧姆。
STM32代码
#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "lcd.h"
#include "usart.h"
#include "dac.h"
#include "adc.h"
#include "usmart.h"
/************************************************
ALIENTEK¾«Ó¢STM32¿ª·¢°åʵÑé20
DAC ʵÑé
¼¼ÊõÖ§³Ö£ºwww.openedv.com
ÌÔ±¦µêÆÌ£ºhttp://eboard.taobao.com
¹Ø×¢Î¢ÐŹ«ÖÚÆ½Ì¨Î¢Ðźţº"ÕýµãÔ×Ó"£¬Ãâ·Ñ»ñÈ¡STM32×ÊÁÏ¡£
¹ãÖÝÊÐÐÇÒíµç×ӿƼ¼ÓÐÏÞ¹«Ë¾
×÷ÕߣºÕýµãÔ×Ó @ALIENTEK
************************************************/
int main(void)
{
//u16 adcx;
//float temp;
u8 t=0;
u16 dacval=0;
u8 key;
delay_init(); //ÑÓʱº¯Êý³õʼ»¯
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//ÉèÖÃÖжÏÓÅÏȼ¶·Ö×éΪ×é2£º2λÇÀÕ¼ÓÅÏȼ¶£¬2λÏìÓ¦ÓÅÏȼ¶
uart_init(115200); //´®¿Ú³õʼ»¯Îª115200
KEY_Init(); //³õʼ»¯°´¼ü³ÌÐò
//LED_Init(); //LED¶Ë¿Ú³õʼ»¯
//LCD_Init(); //LCD³õʼ»¯
usmart_dev.init(72); //³õʼ»¯USMART
Adc_Init(); //ADC³õʼ»¯
Dac1_Init(); //DAC³õʼ»¯
//POINT_COLOR=RED;//ÉèÖÃ×ÖÌåΪºìÉ«
//LCD_ShowString(60,50,200,16,16,"Elite STM32");
//LCD_ShowString(60,70,200,16,16,"DAC TEST");
//LCD_ShowString(60,90,200,16,16,"ATOM@ALIENTEK");
//LCD_ShowString(60,110,200,16,16,"2015/3/8");
//LCD_ShowString(60,130,200,16,16,"WK_UP:+ KEY1:-");
//ÏÔʾÌáʾÐÅÏ¢
//POINT_COLOR=BLUE;//ÉèÖÃ×ÖÌåΪÀ¶É«
//LCD_ShowString(60,150,200,16,16,"DAC VAL:");
//LCD_ShowString(60,170,200,16,16,"DAC VOL:0.000V");
//LCD_ShowString(60,190,200,16,16,"ADC VOL:0.000V");
DAC_SetChannel1Data(DAC_Align_12b_R, 0);//³õʼֵΪ0
while(1)
{
t++;
key=KEY_Scan(0);
if(key==WKUP_PRES)
{
if(dacval<100)dacval+=10;
//DAC_SetChannel1Data(DAC_Align_12b_R, dacval);//ÉèÖÃDACÖµ
}else if(key==KEY1_PRES)
{
if(dacval>10)dacval-=10;
else dacval=0;
//DAC_SetChannel1Data(DAC_Align_12b_R, dacval);//ÉèÖÃDACÖµ
}
delay_ms(10);
Dac1_Set_Vol(dacval);
}
//void Dac1_Set_Vol(u16 vol)
//{
//float temp=vol;
//temp/=1000;
//temp=temp*4096/3.3;
//DAC_SetChannel1Data(DAC_Align_12b_R,temp);//12λÓÒ¶ÔÆëÊý¾Ý¸ñʽÉèÖÃDACÖµ
//}
}
Arduino代码
#define ad9851_w_clk 2 #define ad9851_fq_up 3 #define ad9851_rest 4 #define ad9851_bit_data 5 int a=1; void setup() { pinMode(ad9851_w_clk, OUTPUT); pinMode(ad9851_fq_up, OUTPUT); pinMode(ad9851_rest, OUTP UT); pinMode(ad9851_bit_data , OUTPUT); pinMode(13, OUTPUT); digitalWrite(ad9851_w_clk, 0); digitalWrite(ad9851_fq_up, 0); digitalWrite(ad9851_rest, 0); digitalWrite(ad9851_bit_data, 0); Serial.begin(9600); Serial.println( "init complete!"); } void loop() { ad9851_reset_serial(); ad9851_wr_serial(0x01, 500); //0x01 means six times the frequency is turned on //ad9851_wr_serial(0x00, 500); //0x00 means the six times the frequency is not turned on digitalWrite(13, 0); delay(500); digitalWrite(13, 1); delay(500); digitalWrite(13, 0); delay(500); digitalWrite(13, 1); delay(500); ad9851_reset_serial( ); ad9851_wr_serial(0x01, 2000); } //************************************** *************// // ad9851 reset (serial port mode) // //----------------------- ----------------------------// void ad9851_reset_serial() { digitalWrite(ad9851_w_clk, 0); digitalWrite(ad9851_fq_up, 0); / /rest signal digitalWrite(ad9851_rest, 0); digitalWrite(ad9851_rest, 1); digitalWrite(ad9851_rest, 0); //w_clk signal digitalWrite(ad9851_w_clk, 0); digitalWrite(ad9851_w_clk, 1); digitalWrite(ad9851_w_clk, 0); / /fq_up signal digitalWrite(ad9851_fq_up, 0); digitalWrite(ad9851_fq_up, 1); digitalWrite(ad9851_fq_up, 0); } //************************* ******************************// // Write commands and data to ad9851 (serial port) // //---- --------------------------------------------------// void ad9851_wr_serial(unsigned char w0, double frequency) { unsigned char i, w; long int y; double x; int bit_data; /ar inByte; String b=""; //Calculate the HEX value of frequency x = 4294967295 / 180; / /Suitable for 180m crystal oscillator/180 is the final clock frequency (or 30m six times frequency) //If the clock frequency is not 180MHz, modify the frequency value here, the unit is MHz frequence = frequence / 1000000; frequence = frequence * x; y = frequence ; //**********************************************/ / while (Serial.available() > 0) //Determine whether the serial port has data { b +=char(Serial.read()); //Read data, the serial port can only read 1 character at a time delay(10);
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