就是说在测量28V时,vin=adc_rms/100是对的么?
那请问在主程序while,刷新测量电压的代码中,以下通过串口返回测量电压值的代码怎样理解呢?谢谢!
Uart1_TxByte( adc_rms/1000+'0');
Uart1_TxByte((adc_rms%1000)/100+'0');
Uart1_TxByte('.');
Uart1_TxByte((adc_rms%100)/10+'0');
Uart1_TxByte((adc_rms%10)+'0');
- if(res_cnt == 0) //测量8次显示一次, 8*40=320ms, 大约刷新3次一秒
- {
- for(RMS_Sum=0, i=0; i<8; i++) RMS_Sum += rms_tmp[i]; //8次测量累加和
- adc_rms = sqrt(RMS_Sum / (ADC_NUM/4)); // 计算均方值, 2倍采样
-
- UART1_PrintString("7SEGS"); //7段数码管命令头
- Uart1_TxByte(0x00);
- Uart1_TxByte(0x00);
- Uart1_TxByte(0x00);
-
- if(adc_rms > 4000) //溢出
- {
- UART1_PrintString("EEEE"); //溢出显示 EEEE
- }
- else //电压正常
- {
- adc_rms = (u16)((float)adc_rms * 1.0f); //校准, 根据具体电路参数确定
- Uart1_TxByte( adc_rms/1000+'0');
- Uart1_TxByte((adc_rms%1000)/100+'0');
- Uart1_TxByte('.');
- Uart1_TxByte((adc_rms%100)/10+'0');
- Uart1_TxByte((adc_rms%10)+'0');
- }
复制代码
|