照片上的液晶屏是我的信号发生器的显示,显示信号的真有效值和频率。
数据采样后输出到PC上显示的图形很精确,包括MAX038产生的正弦波上部的小尖峰也很清楚,STM32的ADC精度很稳定性相当好,对于音频范围的低频信号来说,1Msps的采样也基本够用了。只要采集足够的点送给measurementsudio提供的函数来分析,可以达到非常精确的程度,12BIT的分辨率相当于数字表的3位半的效果,用来测试信号的频率、真有效值、峰值、峰峰值等等非常方便和精确,和我用硬件实现的频率计和真有效值的读数相同(这也说明了我做的信号发生器的硬件是准确的,哈哈,之前跟数字表总对不上,看来是数字表准确度差),实现完全可以当作低频示波器来用,再加上个模拟前端电路,完全可以实用化了
上位机的程序还处在对于measuremenStudio的摸索当中,只是初步了解到了几个函数,用它来实现数据处理实在是方便,look
public void DataReceived_Proc() //UDP数据接收、数据处理、数据显示函数
{
try
{
while (bStates)
{
myudpcomm.Receive(ref CommReceiveBuffer);
Received_Command = Bytes2Struct(ref CommReceiveBuffer);
//textBox3.Text = Received_Command.SampleRate.ToString() + (acEstimate++).ToString();
dADC1_Result = new double[Received_Command.SampleDepth];
dADC2_Result = new double[Received_Command.SampleDepth];
//数据处理,将通讯接收区中的ADC数据传入绘图用数组中
for (int i = 0; i < (int)(Received_Command.SampleDepth); i++)
{
dADC1_Result = (BitConverter.ToUInt16(CommReceiveBuffer, 40 + 4 * (i + 0))) * (3.3 / 4096.0);
dADC2_Result = (BitConverter.ToUInt16(CommReceiveBuffer, 40 + 4 * (i + 0) + 2)) * (3.3 / 4096.0);
}
str = "通道A(绿色)\r\n";
//测试真有效值
Measurements.ACDCEstimator(dADC1_Result, out acEstimate, out dcEstimate);//交流(AC方式相当于信号通过一个电容隔直后进行测量)和直流(DC直通方式进行测量)真有效值测量
str += "AC方式有效值:" + ((int)(acEstimate * 1000)).ToString() + "mV " + "DC方式有效值" + ((int)(dcEstimate * 1000)).ToString() + "mV\r\n";
//测试信号频率、振幅Vp
mySingleToneInformationADC1 = new SingleToneInformation(dADC1_Result, Received_Command.SampleRate);
str += "频率:" + ((int)(acEstimate * 1000)==0 ? 0int )mySingleToneInformationADC1.Frequency).ToString() + "Hz " + "振幅Vp:" + ((int )mySingleToneInformationADC1.Amplitude*1000).ToString() + "mV\r\n";
str += "\r\n通道B(红色)\r\n";
//测试真有效值
Measurements.ACDCEstimator(dADC2_Result, out acEstimate, out dcEstimate);//交流(AC方式相当于信号通过一个电容隔直后进行测量)和直流(DC直通方式进行测量)真有效值测量
str += "AC方式有效值:" + ((int)(acEstimate * 1000)).ToString() + "mV " + "DC方式有效值" + ((int)(dcEstimate * 1000)).ToString() + "mV\r\n";
//测试信号频率、振幅Vp
mySingleToneInformationADC2 = new SingleToneInformation(dADC2_Result, Received_Command.SampleRate);
str += "频率:" + ((int)(acEstimate * 1000) == 0 ? 0 : (int)mySingleToneInformationADC1.Frequency).ToString() + "Hz " + "振幅Vp:" + ((int)mySingleToneInformationADC1.Amplitude * 1000).ToString() + "mV\r\n";
textBox3.Text = str;
//ThresholdPeakDetector.Analyze用来找出从波谷到波峰上升沿顶点的数组序号
//可以用于固定显示波形从上升沿的某固定点开始,相当与硬件的同步触发电路功能
//b = ThresholdPeakDetector.Analyze(dADC2_Result, 2, 10);
//foreach (int k in b)
//{
// textBox3.Text += k.ToString() + " ";
//}
//for (int i = 0; i < Received_Command.SampleDepth - b[1]; i++)
{
//dADC1_Result = dADC2_Result[i + b[1]];
}
//textBox3.Text += b[b.Length - 1].ToString();
//bIsUdpDataReceived = true; //表示接收到了UDP数据,允许进行再次发送
bIsDataReadyForPlot = true;
myGraphPlotProc(); //绘图输出*/
//myD1 = new myMethodDelegate(h);
//myD1(1);
}
}
catch (Exception e1)
{
timer1.Enabled = false;
MessageBox.Show(e1.ToString());
}
finally
{
timer1.Enabled = false;
}
}
/************************************************************************************
* 绘图输出过程函数供,mygGraphPlotThread进程调用
* 始终循环检测bIsDataReadyForPlot,一旦为真则进行绘图,绘图完成后置标志为false
* **********************************************************************************/
public void myGraphPlotProc() //绘图输出函数
{
//while (true )
{
if(bIsDataReadyForPlot)
{
waveformPlot1.PlotY(dADC1_Result);
waveformPlot2.PlotY(dADC2_Result);
bIsDataReadyForPlot = false;
}
}
}
保护版权哈
http://www.ouravr.com/bbs/bbs_content.jsp?bbs_sn=862510&bbs_page_no=1&search_mode=1&search_text=示波器&bbs_id=9999
用户377235 2014-3-12 20:17
用户377235 2014-3-12 20:14
用户377235 2012-11-24 14:10
很好。楼主可否发我一份程序?ztj18130@163.com
jizzll_617398179 2008-5-21 22:16
用户149535 2008-5-20 00:21
jizzll_617398179 2008-5-18 23:52
用户394922 2008-5-17 20:55
用户137602 2008-5-13 18:28