【强烈推荐】基于MSP430单片机的信号发生器设计_毕业论文设计

毕业论文

基于MSP430单片机的信号发生器设计

摘要

随着科技的发展和现代科研的需要,信号发生器已经成为了很多行业进行研究测试不可或缺的工具。信号发生器又称信号源或振荡器,在生产实践和科技领域中有着广泛的应用。各种波形曲线均可以用三角函数方程式来表示。能够产生多种波形,如三角波、锯齿波、矩形波(含方波)、正弦波的电路被称为函数信号发生器。函数信号发生器在电路实验和设备检测中具有十分广泛的用途。例如在通信、广播、电视系统中,都需要射频(高频)发射,这里的射频波就是载波,把音频(低频)、视频信号或脉冲信号运载出去,就需要能够产生高频的振荡器。在工业、农业、生物医学等领域内,如高频感应加热、熔炼、淬火、超声诊断、核磁共振成像等,都需要功率或大或小、频率或高或低的振荡器。

本系统采用MSP430F149单片机为控制核心,利用单片机内置的DA芯片,通过按键中断来逻辑选择要输出的波形(正弦波、方波、三角波、锯齿波),再设置其它键来控制

1

波形的幅值及频率,然后通过单片机控制显示到LCD1602上。

波形的产生是通过MSP430单片机执行某一波形发生程序,向DA转换器的输入端按一定的规律发生数据,从而在DA转换电路的输出端得到相应的电压波形。在MSP430学习板的键盘按键,通过软件编程来选择各种波形、幅值电压和频率,按不同按键产生不同波形的信号。此方案的有点是电路原理比较简单,实现起来比较容易。

关键字:MSP430,信号发生器,LCD1602

ABSTRACT

With the development of science and technology and modern scientific research needs, signal generator production practice and science and technology widely used in the field. Various waveform curve all can by trigonometric function equation. Can produce various waveform, such as triangle wave, sawtooth wave, rectangle wave (including square wave), the circuit is called sine wave function signal generator. Function signal generator in circuit experiment and test equipment in a very wide range of purposes. For example in communication, radio, and television systems, all need rf ( industry, agriculture, biomedical in fields, all need power or big or small, frequency or DA chip, through the keys to logical choice to interrupt the output waveform (sine wave and square-wave, triangle wave, sawtooth wave), then Settings other key to control the amplitude and frequency wave,

3

then through the single-chip microcomputer control on display to LCD1602.

Waveform was developed through MSP430 microcontroller performs A waveform procedures to the DA converter input according to certain rules, which occurred in data transform circuit DA of the output voltage waveform obtained the corresponding. In learning board keypad MSP430 through software programming to select different waveform, amplitude voltage and frequency produces different according to different keys, the signal waveform. This scheme of P1DIR &= ~BIT0 SDA改成输入模式

#define SDA_out P1DIR |= BIT0 SDA变回输出模式

#define SDA_val P1IN&BIT0 SDA的位值

#define TRUE 1

#define FALSE 0

#define pai 3.14

***************按键模块全局变量*************** uchar key_Pressed; 按键是否被按下:1--是,0--否uchar key_val; 存放键值

uchar key_Flag; 按键是否已放开:1--是,0--否

设置键盘逻辑键值与程序计算键值的映射

uchar key_Map[] = uchar s1[] = {"zhengxian:"}; uchar s2[] = {"fangbo:"};

uchar s3[] = {"juchi:"};

uchar s4[] = {"sanjiao:"};

***************调节模块全局变量*************** uchar fuzhi;

uchar pinlv;

unsigned int time; 定时

int vcc; da上加的电压

uchar boxing;

double bianliang;

uchar biaozhi;

int pianyi;

int shuchu;

***************总体定义模块***************

void xianshi(void);

5

void DispNChar(uchar x,uchar y, uchar n,uchar *ptr); void LocateXY(uchar x,uchar y) ;

void Disp1Char(uchar x,uchar y,uchar data);

void LcdReset(void) ;

void LcdWriteCommand(uchar cmd,uchar chk) ;

void LcdWriteData( uchar data );

void WaitForEnable(void);

void Set_IO(void);

void start(void);

void stop(void);

uchar check(void);

void write1(void);

void write0(void);

void write1byte(uchar wdata);

uchar Write_DAC(uchar wdata);

void Init_Keypad(void);

void Check_Key(void);

void Key_Event(void);

void zhengxian(void);

void chansheng1(void);

void fangbo(void);

void chansheng2(void);

void juchi(void);

void chansheng3(void);

void sanjiao(void);

void chansheng4(void);

void zengfu(void);

void jiaofu(void);

void zengpin(void);

void jianpin(void);

void delay100us(void);

void delay5ms(void);

void delay15ms(void);

***************总体显示模块***************

*********************************************** 函数名称:xianshi

功能:让液晶显示程序中液晶显示的主框架

参数:

7

返回值:

***********************************************

void xianshi(void)

{

}

*******************************************

函数名称:DispNchar

功能:让液晶从某个位置起连续显示N个字符

参数:x--位置的列坐标

y--位置的行坐标

n--字符个数

ptr--指向字符存放位置的指针

返回值:无

********************************************

void DispNChar(uchar x,uchar y, uchar n,uchar *ptr) {

}

*******************************************

函数名称:LocateXY

功能:向液晶输入显示字符位置的坐标信息

参数:x--位置的列坐标

y--位置的行坐标

返回值:无

******************************************** void LocateXY(uchar x,uchar y)

{

}

******************************************* 函数名称:Disp1Char

功能:在某个位置显示一个字符

参数:x--位置的列坐标

y--位置的行坐标

data--显示的字符数据

返回值:无

******************************************** void Disp1Char(uchar x,uchar y,uchar data)

9

{

}

*******************************************

函数名称:LcdReset

功能:对1602液晶模块进行复位操作

参数:无

返回值:无

******************************************** void LcdReset(void)

{

}

*******************************************

函数名称:LcdWriteCommand

功能:向液晶模块写入命令

参数:cmd--命令,

chk--是否判忙的标志,1:判忙,0:不判返回值:无

******************************************** void LcdWriteCommand(uchar cmd,uchar chk) {

}

******************************************* 函数名称:LcdWriteData

功能:向液晶显示的当前地址写入显示数据

参数:data--显示字符数据

返回值:无

******************************************** void LcdWriteData( uchar data )

{

}

******************************************* 函数名称:WaitForEnable

功能:等待1602液晶完成内部操作

11

参数:无

返回值:无

******************************************** void WaitForEnable(void)

{

}

***************总体DA转换模块*************** *******************************************

函数名称:Set_IO

功能:设置IIC对应IO为输出方向并输出高电平参数:无

返回值:无

******************************************** void Set_IO(void)

{

}

******************************************* 函数名称:start

功能:完成IIC的起始条件操作

参数:无

返回值:无

******************************************** void start(void)

{

}

******************************************* 函数名称:stop

功能:完成IIC的终止条件操作

参数:无

返回值:无

******************************************** void stop(void)

{

13

******************************************* 函数名称:check

功能:检查从机的应答操作

参数:无

返回值:从机是否有应答:1--有,0--无

******************************************** uchar check(void)

{

}

******************************************* 函数名称:write1

功能:向IIC总线发送一个1

参数:无

返回值:无

******************************************** void write1(void)

{

}

******************************************* 函数名称:write0

功能:向IIC总线发送一个0

参数:无

返回值:无

******************************************** void write0(void)

{

}

******************************************* 函数名称:write1byte

功能:向IIC总线发送一个字节的数据

参数:wdata--发送的数据

返回值:无

******************************************** void write1byte(uchar wdata)

15

}

******************************************* 函数名称:Write_DAC

功能:向DAC中写入输出电压数据

参数:无

返回值:写入结果:1--成功,0--失败

******************************************** uchar Write_DAC(uchar wdata)

{

}

***************总体按键模块*************** ******************************************* 函数名称:Init_Keypad

功能:初始化扫描键盘的IO端口

参数:无

返回值:无

******************************************** void Init_Keypad(void)

{

}

******************************************* 函数名称:Check_Key

功能:扫描键盘的IO端口,获得键值

参数:无

返回值:无

******************************************** void Check_Key(void)

{

}

******************************************* 函数名称:Key_Event

功能:检测按键,并获取键值

参数:无

17

返回值:无

******************************************** void Key_Event(void)

{

}

***************总体波形及显示模块*************** *******************************************

函数名称:zhengxian

功能:输出正弦波

参数:无

返回值:无

******************************************** void zhengxian(void)

{

}

*******************************************

函数名称:chansheng1

功能:输出正弦波

参数:无

返回值:无

********************************************

void chansheng1(void)

{

写入DAC

}

*******************************************

函数名称:fangbo

功能:输出显示

参数:无

返回值:无

********************************************

void fangbo(void)

{

}

*******************************************

19

函数名称:chansheng2

功能:输出方波

参数:无

返回值:无

******************************************** void chansheng2(void)

{

}

******************************************* 函数名称:juchi

功能:输出显示

参数:无

返回值:无

******************************************** void juchi(void)

{

}

*******************************************

相关文档
最新文档