用C#做一个模拟示波器的使用单机程序,横坐标为时间t,要求按照t的变化以及X0、m、n的值画出对应的速度

05-1502-1602-1602-1602-1602-1602-1602-1602-1602-16最新范文01-0101-0101-0101-0101-0101-0101-0101-0101-0101-0101-0101-0101-0101-0101-01您所在位置: &
&nbsp&&nbsp&nbsp&&nbsp
基于DA转换的信号发生器(c#)技术文件.doc 50页
本文档一共被下载:
次 ,您可全文免费在线阅读后下载本文档。
下载提示
1.本站不保证该用户上传的文档完整性,不预览、不比对内容而直接下载产生的反悔问题本站不予受理。
2.该文档所得收入(下载+内容+预览三)归上传者、原创者。
3.登录后可充值,立即自动返金币,充值渠道很便利
你可能关注的文档:
··········
··········
本次D/A转换器设计以单片机AT89S52为主控制器,实现了波形的产生,频率的选择以及波形的选择等功能。本设计的主要功能是用单片机产生三角波,正弦波等波形,然后通过开关按键选择不同的频率和波形输出。本设计采用常用的D/A转换器件DAC0832来使单片机输出的数字信号转换为模拟信号,然后再通过运算放大器把D/A输出的电流信号转换为电压信号输出,这样以便用示波器对波形信号进行测量。这样就完成了D/A转换器的核心部分的设计。
关 键 词:
This design of D/A converter by single chip microcomputer AT89S52 as
primarily controller, has realized the wave production, frequency choice as well as wave function and so on choice. This design main function is has the triangle wave
Sine wave with the single chip microcomputer, then through switch pressed key choice different frequency and wave output ,and through digital tube show current transfer wave frequency value. This design uses commonly D/A transformation component DAC0832 tocause the digital signal which the single chip microcomputer to transform into the simulated signal, then transforms again through the operational amplifier the D/A output
electric current signal into the voltage signal output, like this facilitates uses the oscilloscope to the wave signal survey. It likes this completed the D/A Converter design primary designs.
Key words : Single chip microcomputer
Triangle wave
Sine wave 目录
第一章 引言 1
1.1系统背景介绍 1
1.2 D/A转换器的工作原理 2
1.3 本文研究的目的和意义 2
第二章 系统概述 3
2.1单片机的选择 3
2.1.1 单片机的发展特点 3
2.1.2 S52系列单片机简介 5
2.2 D/A的选择 15
2.2.1 D/A转换技术指标 15
2.2.2 DAC0832简介 16
硬件设计 21
3.1电路总框图 21
3.2各部分电路设计 21
3.2.1单片机最小系统的设计 21
3.2.2波形信号产生部分电路设计 22
软件设计 25
4.1 软件功能 25
4.2 系统流程图 25
4.2.1D/A转换器总流程图 25
4.2.2定时器T0中断服务子程序流程图 26
4.2.3定时器T1中断服务子程序流程图 26
4.2.4正弦波键处理子程序流程图 27
4.2.5三角波键处理子程序流程图 27
系统调试 29
5.1静态调试 29
5.2动态调试 30
第六章 总结与结束语 33
6.1实验结果 33
6.2设计历程 34
6.3 系统存在的问题和改进方案 36
6.4展望和体会 36
参考文献 39
附录………………………………….…………………………………………………41
第一章 引言
1.1系统背景介绍
D/A转换器,作为实验用的模拟信号源,是现今各种电子电路实验设计应用中必不可少的仪器设备之一。目前,市场上常见的D/A转换器多为纯硬件的搭接而成,且波形种类有限,多为锯齿、正弦、方波、三角等波形。
当今是科学技术及仪器设备高度智能化飞速发展的信息社会,电子技术的进步,给人们带来了根本性的转变。现代电子领域中,单片机的应用正在不断的走向深入,这必将导致传统控制与检测技术的日益革新。单片机构成的仪器具有高可靠性、高性能价格比,在智能仪表系统和办公自动化等
正在加载中,请稍后...C# 串口波形显示
时间: 19:05:48
&&&& 阅读:3061
&&&& 评论:
&&&& 收藏:0
标签:C#做的串口示波器,可以实现动态波形显示的效果。
using System.Collections.G
using System.ComponentM
using System.D
using System.D
using System.L
using System.T
using System.Windows.F
using System.IO.P
using System.Text.RegularE
namespace serial1
public partial class Form1 : Form
int maxR //最大比例
private bool listening = false;
private bool closing = false;
Point lastPoint,nowP
List&double& l = new List&double&(); //存储串口接收的值
Graphics //生成图形
Pen drawPen=new Pen(Color.Red,1);
private StringBuilder builder = new StringBuilder();
private SerialPort comm = new SerialPort();
public Form1()
InitializeComponent();
private void pictureBox1_Paint(object sender, PaintEventArgs e)
pictureBox1.Width = l.Count();
g.DrawLine(new Pen(Color.Black, 1), new Point(0, pictureBox1.Height / 2), new Point(pictureBox1.Width, pictureBox1.Height / 2));
lastPoint = new Point(0,pictureBox1.Height/2);
//如果发生值大于最大值,则画笔变为黄色
for (int i = 1; i & this.pictureBox1.W i++)
if (l[i] & maxRate/2)
drawPen.Color = Color.Y
l[i] = maxRate/2;
drawPen.Color = Color.R
nowPoint.X =
double tmpY = l[i] / maxR
tmpY =Math.Abs( (tmpY * pictureBox1.Height)-(pictureBox1.Height/2));
nowPoint.Y =Convert.ToInt32( tmpY);
//nowPoint.Y = Math.Abs(l[i] / maxRate * pictureBox1.Height - pictureBox1.Height);
g.DrawLine(drawPen, lastPoint, nowPoint);
lastPoint = nowP
private void Form1_Load(object sender, EventArgs e)
void comm_dataReceived(object sender, SerialDataReceivedEventArgs e)
if (closing) return; //防止关闭时锁死
string tmpS = comm.ReadLine();
builder.Append(tmpS);
string s = builder.ToString();
builder.Clear();//清除字符串构造器
string[] arr = s.Split(‘\n‘, ‘\r‘).Where(t =& t.Trim() != "").ToArray();
////因为要访问ui资源,所以需要使用invoke方式同步ui。
this.Invoke((EventHandler)(delegate
int tmpC=0;
listening = true;
for (int i = 0; i & arr.L i++)
int c = Convert.ToInt32(arr[i]);
if (Math.Abs(tmpC - c) & 100) Console.Out.WriteLine("错误");
textBox1.AppendText(Convert.ToString(c)+‘\n‘);
listening = false;
pictureBox1.Width = l.Count();
private void button1_Click(object sender, EventArgs e)
comm.PortName = comboBox1.SelectedItem.ToString();
comm.BaudRate =Convert.ToInt32( comboBox2.SelectedItem.ToString());
maxRate =Convert.ToInt32( textBox2.Text);
comm.Open();
comm.DataReceived += comm_dataR
private void button2_Click(object sender, EventArgs e)
closing = true;
while (listening) Application.DoEvents();
MessageBox.Show("ok");
comm.Close();
closing = false;
private void button4_Click(object sender, EventArgs e)
//16进制发送
if (checkBoxHexSend.Checked)
//我们不管规则了。如果写错了一些,我们允许的,只用正则得到有效的十六进制数
MatchCollection mc = Regex.Matches(txSend.Text, @"(?i)[/da-f]{2}");
List&byte& buf = new List&byte&();//填充到这个临时列表中
//依次添加到列表中
foreach (Match m in mc)
buf.Add(byte.Parse(m.Value));
//转换列表为数组后发送
comm.Write(buf.ToArray(), 0, buf.Count);
else//ascii编码直接发送
//包含换行符
if (checkBoxNewlineSend.Checked)
comm.WriteLine(txSend.Text);
else//不包含换行符
comm.Write(txSend.Text);
标签:原文地址:http://www.cnblogs.com/bankyh/p/4330275.html
&&国之画&&&& &&&&chrome插件
版权所有 京ICP备号-2
迷上了代码!C#与matlab混合编程中,如何使用fit函数结果 - Matlab论坛 -
中国电子技术论坛 -
最好最受欢迎电子论坛!
后使用快捷导航没有帐号?
林超文手把手教你学!
教你1000种电路设计思路
张飞硬件电路之PFC全集
参与免费送VIP+原创视频
运放、ADC、电磁兼容
C#与matlab混合编程中,如何使用fit函数结果
00:12:26  
本人在matlab下做了一个简单的正态分布拟合函数,根据输入的x,y序列得到mu和sigma的估计值,以及y序列的正态分布曲线拟合序列y1,matlab程序如下:
function [muhat,sigmahat,muci,sigmaci,y1]=normal_fit(x,y)
& &[muhat,sigmahat,muci,sigmaci]=normfit(y);
& &f=fit(x.',y.','gauss1');
& &y1 = f(x);
& &% y1 = f.a1 * exp(-((x-f.b1)/f.c1).*((x-f.b1)/f.c1));
& &%% a1=f.a1;
& &%% b1=f.b1;
& &%% c1=f.c1;
& &%% y1 = a1*exp(-((x-b1)/c1).*((x-b1)/c1));& &%%% y1 = feval(f,x)';
将上述函数normal_fit(x,y)编入名为NormalFitClass的类中,生成.Net的dll,NormalFitClass.dll
C#调用如下:
using NormalFitC
private void do()
& & double[] x = new double[12] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
& & double[] y = new double[12] {2, 6, 7, 9, 18, 33, 29, 16, 8, 5, 3, 1};
& & NormalFitClass.NormalFitClass nfc = new NormalFitClass.NormalFitClass();
& & MWNumericArray mx = (MWNumericArray)x;
& & MWNumericArray my = (MWNumericArray)y;
& & MWArray[] f = nfc.normal_fit(5, (MWArray)mx, (MWArray)my);&&
问题是C#调用的最后一句normal_fit()总是报错,
对于matlab函数中的y1,提示使用cfit错误;
对于matlab函数中%注释的y1,提示使用cfit错误;
对于matlab函数中%%注释的y1,提示使用subsref错误;
对于matlab函数中%%%注释的y1,也提示错误。
我只是想通过fit(x,y,'gauss1')返回一个拟合的高斯曲线,如何可以实现?
附:如果使用muhat和sigmahat值,用1/sqrt(2*pi)/sigmahat*exp(-((x-muhat).*(x-muhat)/2/sigmahat/sigmahat))来计算,所得高斯曲线不能与原y分布一致。
已退回1积分
13:49:53  
VS2008与Matlab混合编程之动态链接库&&
Matlab混合编程方法很多,在此不一一列举,而我直接能想到的就是采用动态链接库的方式。根据网上相关的资料,经过一天的实验,成功在VS环境下调用matlab生成的动态库,实现混合编程。在此简单介绍下过程。
1、配置Matlab。要将Matlab的.m文件生成动态库(DLL),需要对Matlab进行配置,主要有两个命令。
mex -setup
mbuild -setup
两个命令的运行过程基本相似,只要根据提示,选择用户需要的编译器环境即可。例如我机器上安装的是VS2008 SP1,则:
Select a compiler:
[1] Microsoft Visual C++ 2008 SP1 in E:\Program Files (x86)\Microsoft Visual Studio 9.0
选择[1]确定后,即可完成配置。
2、完成自己的.m文件(一般为函数),并将.m文件生成为动态链接库。
在Matlab中完成一个函数文件,命名为add.m,代码如下:
function c = add(a, b)
然后将add.m文件编译成C++动态库文件,命令如下:
mcc -C -W cpplib:libAdd -T link:lib add.m
其中,libAdd为输出的动态库文件名,add.m为用户代码文件。代码运行完毕后,会生成多个文件,而我们需要的文件只有四个:libAdd.dll libAdd.ctf libAdd.lib libAdd.h。(libAdd.h和libAdd.lib在编译时使用, libAdd.ctf和libAdd.dll在运行时调用 )
3、配置VS环境。主要是配置Matlab的include files和libraries路径。打开菜单Tools/Options,选择Projects and Solutions/VC++ directories标签页面,根据自己的平台选择Win32/x64, 在show directories for 中选择include files,添加matlab的头文件目录——&matlab安装目录/extern/include&。然后在show directories for 中再选择Library files,添加lib文件的目录——& matlab安装目录/extern/lib/win64/microsoft&(根据自己需要编译程序的平台选择)
4、在VS下建立工程调用生成的动态库。首先为配置工程的依赖项,右击工程选择Properties,选择Linker/Input标签页,在Additional Dependencies中添加所需要的lib库, mclmcrrt.lib,libmx.lb,libmat.lib,libeng.lib这四个为Matlab自带的库,另外将步骤2生成的 libAdd.h和libAdd.lib 拷贝至当前代码目录中,并在 Additional Dependencies中添加 libAdd.lib。
然后在C++代码文件中调用libTest库。在main函数中调用:
#include &libAdd.h&
int main(int argc, char *argv[])
if(!mclInitializeApplication(NULL, 0))& &&&
&&printf(&Can not initialize application!\n&);&&
&&return 0;
if (!libAddInitialize()) //该函数是生成库的名字+Initialize():libAddInitialize()
&&printf(&Cann not initialize the library!\n&);&&
&&return 0;
//定义两个matlab矩阵,矩阵类为mwArray& && && && && &
mwArray m1(10, 10, mxDOUBLE_CLASS);
mwArray m2(10, 10, mxDOUBLE_CLASS);&&
for (int i=1; i&=10; i++)&&
&&for (int j=1; j&=10;j++)& &
& &m1(j, i) = 10;& &
& &m2(j, i) = -10;& &
}& && && && && &&&
//调用函数进行加法运算& && && && && &
mwArray m3;& && && && && &
Add(1, m3, m1, m2); //1表示输出参数个数,这里为1个,且输出参数为m3, m1和m2分别表示两个输入矩阵
for (int i=1; i&=10; i++)&&
&&printf(&\n&);
&&for (int j=1; j&=10;j++)& &
& &printf(&%d &, m3(i,j));&&
完成编译后,运行程序会发现找不到相关的DLL,将步骤2生成libTest.dll libTest.ctf拷贝至工作路径下(EXE目录),并在环境变量上设置matlab的bin路径:E:\Program\Files\MATLAB\R2009a\E:\Program\Files\MATLAB\R2009a\bin\win64。(根据自己的需要设置),设置完毕后,关闭VS,重新打开后便可。该方法只能在安装有Matlab的机器上调用dll,如果在没有安装matlab的机器上使用时,需要首先安装MCRInstaller方可使用。
林超文手把手教你学!
教你1000种电路设计思路
张飞硬件电路之PFC全集
参与免费送VIP+原创视频
运放、ADC、电磁兼容
Powered by
供应链服务
版权所有 (C) 深圳华强聚丰电子科技有限公司【图文】模拟示波器的使用_百度文库
您的浏览器Javascript被禁用,需开启后体验完整功能,
享专业文档下载特权
&赠共享文档下载特权
&10W篇文档免费专享
&每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
模拟示波器的使用
阅读已结束,下载本文到电脑
想免费下载本文?
登录百度文库,专享文档复制特权,积分每天免费拿!
你可能喜欢}

我要回帖

更多关于 excel做折线图横坐标 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信