搜档网
当前位置:搜档网 › 基于verilog hdl的电风扇设计

基于verilog hdl的电风扇设计

基于verilog hdl的电风扇设计
基于verilog hdl的电风扇设计

FPGA课程设计报告

项目名称电风扇的自动定时开关控制

专业班级

学生姓名

指导教师

2013年 6 月 4 日

摘要

如今的电风扇已一改人们印象中的传统形象,在外观和功能上都更追求个性化,而电脑控制、自然风、睡眠风、负离子功能等这些本属于空调器的功能,也被众多的电风扇厂家采用,并增加了照明、驱蚊等更多的实用功能。这些外观不拘一格并且功能多样的产品,预示了整个电风扇行业的发展趋势。

在追求个性时尚以及精致化的时代,消费者似乎对娇小可爱的家电产品情有独钟,于是扮相可爱、颜色亮丽、体积娇小的转页扇,各种便携式电风扇应运而生。这些电风扇的外壳和扇页都以塑料为原料,整体上极其轻巧,加上娇小的体积和靓丽的色彩和外观,一经推出便十分走俏。

电风扇增设了各种新功能,既彰显了个性,也在无形中提高了档次。如开发较早且比较实用的遥控功能,使操作摆脱了一定的空间限制,再加上液晶屏幕的动态显示,操作起来一目了然。随着消费者对健康的日益关注,厂家围绕着提高空气质量做起了文章,于是便增添了负离子、氧吧、紫外线杀菌等功能。

此外,驱蚊风扇可通过电加热使驱蚊物质挥发,并借助风力快速把驱蚊物质送到房间各个地方;带有“飘香”功能的小风扇在扇片中间的旋转轴内含有香片,随着扇片的转动,悠悠花香也随之飘出,并且香片可随意更换;带有照明功能的吊扇集照明与风扇功能于一体,他们都是凭借了某一项独特的功能而吸引了消费者的目光。

关键词:电脑控制;自然风;睡眠风;负离子功能

Abstract

The fanner nowadays has changed people's impression of the traditional image, in appearance and function are more the pursuit of individuality, and computer control, the natural wind, sleep wind, negative ion function these belong to the air conditioning function, also is the electric fan many manufacturers, and to increase the lighting, insect repellent and more the utility function. The appearance of these not to stick to one pattern and functional diversity of products, indicates the development trend of the whole electric fan industry.

In the pursuit of fashion and the era of sophisticated, consumers seem to have a special liking for the lovely home appliance products, so look lovely, bright color, SIZE PETITE fan, emerge as the times require various portable electric fan. The electric fan casing and fan pages are plastic as raw material, the whole is extremely light, color and appearance of small volume and beautiful plus, will be launched by the very popular.

Electric fan added new features, both her individuality, also improve the grade in virtually. If the remote control function developed earlier and more practical, the operation out of certain spatial constraints, dynamic coupled with LCD screen display, operate up stick out a mile. With consumers increasingly concerned about the health of the manufacturers to improve air quality, around the start of the article, then add to the negative ion, oxygen, ultraviolet sterilization function.

In addition, mosquito repellent fan by electric heating mosquito repellent substances volatile, and with the wind take the repellent substances to the room; a small fan with "fragrance" function in the axis of rotation of fan middle contains jasmine scented green tea, with rotating fan blades, long flower also floated out, and jasmine scented green tea can be replaced freely; fan with lighting function set lighting and fan functions, they are relying on a unique function and attract the attention of consumers.

Keywords: Computer control; Natural wind; Sleep wind; Negative ion function

摘要...........................................................................................................I Abstract ...................................................................................................... II 第1章FPGA课程设计报告提纲. (1)

1.1 任务 (1)

1.2 目的 (1)

1.3 使用环境(软件/硬件环境,设备等) (1)

第2章技术规范 (2)

2.1 功能定义 (2)

2.2 系统结构框图 (2)

2.3 应用范围 (3)

2.4 引脚描述 (3)

第3章设计方案 (5)

3.1 概述 (5)

3.2 顶层模块划分 (5)

第4章功能验证方案 (11)

4.1分频模块 (11)

课程设计的心得体会················································错误!未定义书签。

第1章 FPGA课程设计报告提纲

1.1 任务

运用FPGA用FPGA开发板的按键作为输入控制键,用数码管显示当前电风扇自动定时状态(包括:自动开/关,工作定时等)。

1.2 目的

运用verilog hdl描述设计,用Quartus II进行仿真波形

1.3使用环境 (软件/硬件环境,设备等)

Pc机Quartus II软件环境

第2章 技术规范

2.1 功能定义

(1),根据用户需求,通过按键切换来实现风扇定时和普通工作模式。

(2) 普通工作模式时,由手动开关控制电风扇的开关,即当开关打开时,风扇工作; 开关关闭时,风扇停止工作。

(3) 定时模式时,根据设定定时时间来选择电风扇工作时间,比如10 分钟、 20分钟、 30分钟等,并且同步显示剩余工作时间,但是此时用户仍可以通过开关控制提前关掉电扇。

(4) LED 上显示当前工作状态:风扇工作亮,停止工作灭。数码管显示总的设定的时间(小时,分钟)和剩余工作时间。

2.2 系统结构框图

分频模块

自动定时倒计时模块

模式选择控制模块

显示模块

Clk

In

opt

key

En

On

Out_H

Out_L

C_out

总体设计可以分为以上几个模块,各模块的功能简要介绍:

(1)分频模块:模块的功能是把50MHz 的系统时钟转换为1Hz 的时钟,和2Hz 的时钟。1Hz的时钟供计数模块的使用。2Hz的时钟供输入定时数值的使用。

(2)模式选择控制模块:选择需要的工作模式。包括两个模式:定时、普通。

(3)自动定时倒计时模块:选择定时模式后,根据键盘的输入值来设定工作时间,在定时时间以内则风扇工作,倒计时结束或开关关闭时风扇自动关闭。

(4)显示模块:LED 上显示当前工作状态:风扇工作亮,停止工作灭。数码管显示总的设定的时间和剩余工作时间。

2.3 应用范围

可以用于控制电扇手动控制电风扇工作或停止,也可以按照设定的时间自动工作或停止。

2.4 引脚描述

顶层模块管脚描述

(1)输入开关管脚

位宽信号名称功能描述输入输

Clk 系统时钟,频率为50MHz input 1

input 1 Op 模式选择信号,为1时为定

时模式;为0时为普通模式。

In 输入设定时间信号input 4

Key 设定时间后开始计时信号Input 1

Clr 清零信号input 1

Fz 复制信号Input 1

En 开始计时信号Input 1

(2)输出显示管脚

位宽信号名称功能描述输入输

Output 1 Out 风扇工作信号,为1是风扇

工作,为0时风扇停止工作

Out_3 时间高位数码管输出端,为output 7

时钟的十位

Out_2 时间低位数码管输出端,为

output 7 时钟的个位

output 7 Out_1 时间高位数码管输出端,为

分钟的十位

output 7 Out_0 时间高位数码管输出端,为

分钟的十位

第3章设计方案

3.1 概述

此自动定时控制器,可以实现定时模式和普通模式的切换,一共有六个模块。

(1)分频模块:模块的功能是把50MHz 的系统时钟转换为1Hz 的时钟,和2Hz 的时钟。1Hz的时钟供计数模块的使用。2Hz的时钟供输入定时数值的使用。

(2)模式选择控制模块:模式选择控制模块:选择需要的工作模式。包括两个模式:定时、普通。

(3)自动定时倒计时模块:选择定时模式后,根据键盘的输入值来设定工作时间,在定时时间以内则风扇工作,倒计时结束或开关关闭时风扇自动关闭。

(4)显示模块:LED 上显示当前工作状态:风扇工作亮,停止工作

灭。数码管显示总的设定的时间和剩余工作时间。

(5)信号处理模块:该模块的主要作用是在定时没有结束的时候用火仍可以通过开关来控制电扇的关闭。

(6)数据输入模块:当赋值信号(fz)有效后可以通过键盘输入定时的时间,确定输入无误后按下启动键(en),风扇开始倒计时。

3.2 顶层模块划分

(1)分频模块:这个模块的功能是把频率为50MHz的时钟转换为1Hz的时钟,供计时模块的使用。

引脚分配:

信号

名称

功能描述方向宽度

Clk 输入

50MHz的时钟

信号

input 1

Inclk

输出经过

分频以后的

1Hz的时钟信

output 1

Nclk 输出经过Output 1

分频后的2hz 的时钟信号

电路设计:

(2)模式选择控制模块:选择需要的工作模式。包括两个模式:自动、手动,op 为1时是定时模式,opl 为0时是普通模式。若为定时模式风在设定的时间内自动工作,当计时结束时风扇自动停止工作,即计时反馈信号out 为0时,风扇自动关闭。若选为手动模式,则在有手动开关key 来控制风扇的开关,key 为1时风扇工作,为0时停止工作。

引脚分配

信号名称

功能描述

方向 宽度 op

模式选择信号,为1时为自动开关模式;为0时为手动开关模

input

1

式。

key 开关信号

input 1 out 风扇工作状态信号 output 1 clk 主时钟 Input 1 Clr 清零信号

Input 1 A_1 Op 为1时a_1为1 Output 1 A_0 Op 为0时a_0为1 Output 1 Key_1

Key 和a_0都为1时可key_1为1,否则为0。

Output

1

电路设计

(3)自动定时倒计时模块:选择定时模式后,根据键盘的输入值来设定工作时间,在定时时间以内则风扇工作,倒计时结束时风扇自动关闭。

管脚分配

信号名称 功能描述

输入输出

位宽 Clk 主时钟

Input 1 nclk 计时时钟,频率为1Hz input 1 en 开始倒计时信号 input 1 H 小时数据输入 input 8 m 分钟数据输入 Input 8 Sign 时间计数为零反馈信号

output

1

电路设计

(4)显示模块:LED 上显示当前工作状态:风扇工作亮,停止工作灭。数码管显示总的设定的时间和剩余工作时间。

管脚分配

信号名称

功能描述

输入输出

位宽 Data_3 时间高位输出端,为小时的十位

input 4 Data_2 时间低位输出端,为小时的个位

input 4 Data_1

时间高位输出端,为分钟的十位

input

4

Data_0 时间低位输出端,为分钟的个位

input 4 Out_3 时间高位数码管输出端,为小时的十位

output 7 Out_2 时间低位数码管输出端,为小时的个位

output 7 Out_1 时间高位数码管输出端,为分钟的十位

Output 7 Out_0 时间低位数码管输出端,为分钟的个位

Output 7 Clk 主时钟 Input 1 clr 清零信号 Input 1 sign 计时信号

Input

1

电路设计

(5)信号处理模块:该模块主要是用来在定时还没有结束时,用户仍可以通过开关关闭电扇。

信号名称 功能描述

输入输出

位宽 Key

电扇开关

Input

1

Key_1 电扇在普通模式下产生的工

作信号

Input 1 Sign 倒计时信号 Input 1 Out 电扇工作信号

Output

1

(6)数据输入模块:该模块用于用户输入定时时间。

信号名称 功能描述

输入输

位宽

Clk 2hz 时钟,用于防抖 Input 1 clr 清零信号 Input 1 Fz 赋值信号 Input 1 H_0 小时低位输入端 Input 1 H_1 小时高位输入端 Input 1 M_0 分钟低位输入端 Input 1 M_1 分钟高位输入端 Input 1 H 小时输入数值 Output 8 M 分钟输入数值

Output

8

第4章功能验证方案4.1分频模块

module fenpin(clk,clr,nclk,inclk);

input clk,clr;

output nclk,inclk;

reg nclk,inclk;

reg [50:0] nadd,inadd;

always @ (posedge clk)

begin

if(!clr)

begin

nclk=0;

nadd=0;

end

else

begin

if(nadd==24999999)

begin

nclk=!nclk;

nadd=0;

end

else

nadd=nadd+1;

end

end

always @ (posedge clk)

begin

if(!clr)

begin

inclk=0;

inadd=0;

end

else

begin

if(inadd==12999999)

begin

inclk=!inclk;

inadd=0;

end

else

inadd=inadd+1;

end

end

endmodule

倒计时模块

module hour(a,en,sign,data,clk,b_h,bcd_h,bcd_l);

input a,clk,en,sign;

input [7:0] data;

wire [7:0] data;

output b_h;

reg b_h;

output [3:0] bcd_h,bcd_l;

reg [3:0] bcd_h,bcd_l;

reg [7:0] count;

reg e;

always @ (posedge clk)

begin

if(!en)

e=1;

end

always @ (posedge a or negedge en)

if(!en)

begin

count=data;

b_h=0;

end

else

begin

if(a)

begin

if(count[3:0]==0)

begin

if(count[7:4]==0)

begin

b_h=1;

end

else

begin

count[7:4]=count[7:4]-1;

count[3:0]=4'b1001;

b_h=0;

end

end

else

begin

count[3:0]=count[3:0]-1;

b_h=0;

end

end

end

always @ (posedge clk or posedge e)

begin

if(e)

begin

bcd_h=count[7:4];

bcd_l=count[3:0];

end

end

Endmodule

module clock(en,a_1,sign,data,sclk,clk,b_m,bcd_h,bcd_l);

input en,sign,clk,sclk,a_1;

input [7:0] data;

wire [7:0] data;

output b_m;

reg b_m;

output [3:0] bcd_h,bcd_l;

reg [3:0] bcd_h,bcd_l;

reg [7:0] count;

wire as;

reg e;

assign as=e&sign&a_1;

always @ (posedge clk)

begin

if(!en)

e=1;

End

always @ (posedge sclk or negedge en)

if(!en)

begin

count=data;

b_m=0;

end

else

begin

if(as)

begin

if(count[3:0]==0)

begin

if(count[7:4]==0)

begin

count[7:4]=4'b0101;

count[3:0]=4'b1001;

b_m=1;

end

else

begin

count[7:4]=count[7:4]-1;

count[3:0]=4'b1001;

b_m=0;

end

end

else

begin

count[3:0]=count[3:0]-1;

b_m=0;

end

end

end

always @ (posedge clk or posedge e)

begin

if(e)

begin

bcd_h=count[7:4];

bcd_l=count[3:0];

end

end

endmodule

相关主题