文档库 最新最全的文档下载
当前位置:文档库 › Designing Safe VHDL State Machines with Synplify

Designing Safe VHDL State Machines with Synplify

Designing Safe VHDL State Machines with Synplify
Designing Safe VHDL State Machines with Synplify

Designing Safe VHDL State Machines with Synplify

Introduction

One of the strengths of Synplify is the Finite State Machine compiler. This is a powerful feature that not only has the ability to automatically detect state machines in the source code, and implement them with either sequential, gray, or one-hot encoding.

But also perform a reachability analysis to determine all the states that could possibly be reached, and optimize away all states and transition logic that can not be reached. Thus, producing a highly optimal final implementation of the state machine.

In the vast majority of situations this behavior is desirable. There are occasions, however, when the removal of unreachable states is not acceptable. One clear example is when the final circuit will be subjected to a harsh operating environment, such as space applications where there may be high levels of radiation. In the presence of high levels of radiation, storage elements (flip-flops) have been known to change state due to alpha particle hits. If a single bit of a state register where to suddenly change value, the resulting state may be invalid. If the invalid states and transition logic had been removed, the circuit may never get back to a valid state.

By default Synplify will create state machines that are optimized for speed and area. This application note will use an example state machine design to show the default small & fast implementation. It will also demonstrate how to trade-off some of that speed & area to produce highly reliable state machines using Synplify.

Example 1:

Assume that the transition diagram in figure 1 is to be implemented as a one-hot FSM:

Figure 1.

One possible RTL implementation would be:

library ieee;

use ieee.std_logic_1164.all;

entity FSM1 is

port(clk, in1, rst: in std_logic;

out1: out std_logic_vector(2 downto 0));

end FSM1;

architecture RTL of FSM1 is

type state_values is (s0, s1, s2, s3, s4);

signal state, next_state: state_values;

attribute syn_encoding : string;

attribute syn_encoding of state : signal is "onehot"; begin

process (clk, rst)

begin

if rst = '1' then

state <= s0;

elsif rising_edge(clk) then

state <= next_state;

end if;

end process;

process (state, in1)

begin

case state is

when s0 =>

out1 <="000";

if in1 = '0' then

next_state <= s0;

else

next_state <= s1;

end if;

when s1 =>

out1 <="001";

if in1 = '0' then

next_state <= s1;

else

next_state <= s2;

end if;

when s2 =>

out1 <="010";

if in1 = '0' then

next_state <= s2;

else

next_state <= s3;

end if;

when s3 =>

out1 <="011";

if in1 = '0' then

next_state <= s3;

else

next_state <= s4;

end if;

when s4 =>

out1 <="100";

if in1 = '0' then

next_state <= s4;

else

next_state <= s0;

end if;

when others =>

out1 <= "000";

next_state <= s3;

end case;

end process;

end RTL;

Note:

1. The òsyn_encodingó attribute is used to specify that this state machine should be

encoded as one-hot.

2. There are 5 defined states (S0, S1, S2, S3, and S4), all of which are reachable.

3. Since the encoding style is one-hot, there are 27 undefined (and unreachable) states

that are covered by the òothersó branch of the case statement.

4. The state register resets to state S0.

5. The òothersó case specifies a transition to state S3. Keep in mind that this circuit will

never reach the òothersó branch without some external influence such as an alpha particle hit or a physical defect in the target part.

6. The syn_encoding attribute directs the FSM compiler to implement this design as a

one-hot state machine. The final circuit will have the state encodings: S0 = 00001, S1 = 00010, S2 = 00100, S3 = 01000, S4 = 10000.

7. The material covered in this application note applies to all supported encoding styles,

one-hot, sequential, and gray.

Default Implementation:

If Synplify is used to synthesize this design as is, the result is an optimized state machine with the transition logic for unreachable states removed. The final implementation is basically a shift register. Where the state register resets to the 00001 state (S0), and the output of state bit 4 is the input to state bit 3, the output of state bit 3 is the input to state bit 2, and so on. This is shown in figure 2 using the Technology View in HDL Analyst.

This is a very optimal result for both timing and area. In a normal operating environment this circuit will function perfectly. Suppose, however, that this circuit is to be placed in a hostile operating environment where a register could spontaneously change value due to an alpha particle hit, or some other reason. What would happen if this state machine ended up in the 00000 state? The next transition would shift all the state bits resulting in the state 00000. The result being that this FSM would effectively be stuck in the 00000 state.

òSafeó Implementation:

To handle this type of problem, the FSM compiler in Synplify has a special encoding directive, òsafeó, that will add logic such that if the state machine should ever reach an invalid state, it will be forced to the reset state. This behavior has the advantage of avoiding any possible òhangó conditions, where the state machine is unable to get back to a valid state, while having minimal impact on the timing of the circuit.

To enable this feature simply change the value of the syn_encoding attribute from:

attribute syn_encoding of state : signal is "onehot";

to:

attribute syn_encoding of state : signal is "safe,onehot";

Note: The syn_encoding attribute can also be applied in the SCOPE graphical constraint editor or directly in the constraint (.sdc) file. Using the following syntax:

define_attribute {state[*]} syn_encoding {safe,onehot}

Synthesizing this design will result in a circuit that has the state transition logic implemented exactly as shown in figure 2 above, with the addition of the circuitry in figure 3 added to the reset logic.

If an invalid state is detected, the state_illegalpipe1 register is set on the next rising clock edge. On the falling edge of the clock, the state_illegalpipe2 register is set. Instance

G_13 ORs the original reset signal òrstó with the new recovery logic. The output of instance G_13 drives the clear/preset pins of the state bits, forcing the circuit to the (valid) reset state. Once this valid state is reached, the next rising edge of the clock will clear the state_illegalpipe1 register, the next falling edge of the clock will clear the

state_illegalpipe2 register and normal operation will begin. Note that the result of this recovery logic, the output of state_illegalpipe2, is registered on the falling edge of the clock to prevent any harzardous conditions that could result from removing the reset signal too close to the active clock edge of the state registers.

The recovery logic discussed above is generated for the example circuit which happens to have an asynchronous reset. If the circuit had a synchronous reset instead, the logic implemented would be slightly different. Suppose the register definition was changed from:

process (clk, rst)

begin

if rst = '1' then

state <= s0;

elsif rising_edge(clk) then

state <= next_state;

end if;

end process;

to:

process (clk)

begin

if rising_edge(clk) then

if rst = '1' then

state <= s0;

else

state <= next_state;

end if;

end if;

end process;

For this synchronous reset implementation, the circuitry in figure 4 would be added to the reset logic:

If an invalid state is detected, the state_illegalpipe register is set on the next rising clock edge. Instance G_66 ORs the original reset signal òrstó with the new recovery logic. On the next positive clock edge, the state register will switch to the (valid) reset state. Once this valid state is reached, the next rising edge of the clock will clear the state_illegalpipe register, and normal operation will begin.

In both the asynchronous and synchronous reset case, if the circuit should ever reach an invalid state (state 00000 for example), the recovery logic will be activated reseting the state register back to the 00001 state (S0). Once the FSM is back to the valid state of 00001 (S0), normal operation of the state machine can resume. Notice that upon entering an invalid state this circuit will recover to the 00001 state (S0) not the 01000 state (S3) as described in the òothersó branch of the case statement.

This implementation eliminates the possibility of the state machine getting òstuckó in an invalid state and not returning to a valid state. This problem is handled with very minimal impact on the timing of the circuit. However, as pointed out above, the transition out of

an invalid state is not implemented exactly as described in the òothersó branch of the source code. This deviation from the defined òothersó branch behavior only occurs for invalid states. If the òothersó case contained any valid state transitions they would be implemented as described in the source code.

òExactó Implementation:

It is possible to get an implementation of the circuit that fully implements the òothersóbranch if it is necessary to do so. This requires disabling the reachability analysis of the state machine, which is done by turning off the FSM compiler, defining state codes as constants instead of enumerated types. This can have a significant affect on the area and timing of the circuit.

To get a full implementation of the òothersó case change the state register description from:

type state_values is (s0, s1, s2, s3, s4);

signal state, next_state: state_values;

attribute syn_encoding : string;

attribute syn_encoding of state : signal is "onehot";

to:

signal state, next_state: std_logic_vector(4 downto 0);

constant s0 : std_logic_vector(4 downto 0) := "00001";

constant s1 : std_logic_vector(4 downto 0) := "00010";

constant s2 : std_logic_vector(4 downto 0) := "00100";

constant s3 : std_logic_vector(4 downto 0) := "01000";

constant s4 : std_logic_vector(4 downto 0) := "10000";

attribute syn_preserve : boolean;

attribute syn_preserve of state : signal is true;

Note:

1. The state register is defined as a std_logic_vector rather than an enumerated type.

2. The state encodings have been defined as constants. In this case the states are

defined such that they implement a one-hot state machine. Any other encoding

would work just as well.

3. A syn_preserve attribute is applied to the state register to disable the FSM compiler.

4. The syn_encoding attribute is no longer needed because the FSM compiler disabled.

5. The rest of the code remains unchanged.

Figure 5 uses the RTL view of HDL Analyst to show that the òothersó case is fully implemented.

The instances next_state14, next_state13, next_state12, next_state11, and

next_state10 decode the current state (S4, S3, S2, S1, S0 respectively). The instances un13, un14, and un20 implement the next state logic for state S0 (bit 0 of the state register). The function is ((~In1 & S0) | (In1 & S4)). The function for state bits 1, 2, and 4 are very similar. Bit 3, however, has an extra term generated by instance un16. This term checks if the FSM is currently in a valid state. If so, the function ((~In1 & S3) | (In1 & S2)) is used. If not, bit 3 is forced high making the next state 01000 (S3) as described in the òothersó branch of the original source code.

Summary:

To summarize, Synplify contains a powerful FSM compiler which by default will produce state machine implementations that are highly optimial in regards to area and timing. If recovery from an invalid state is important the òsafeó feature can be used to force the state machine to the reset state if an invalid state is reached, with minimal impact on timing and area of the circuit. This implementation of transitioning out of an invalid state may differ from what is explicitly described in the source code. For most designs this is an acceptable deviation, since these transitions are by definition not valid. If these invalid state transitions must be handled exactly as described by the source code, the FSM compiler can be disabled. However, this may result in a substantial impact on timing and area.

To quantify the impact on timing and area, the three implementations of this state machine were synthesized targeting an Altera Flex10k part and a Xilinx Virtex part. The estimated timing and area results reported by Synplify are displayed in table 1 below.

Target Altera Flex10k D EPF10K10A-1Xilinx Virtex D XCV50-4 ns LCs Regs ns LUTs Regs Default 4.485 5.125 Safe 6.71477.267 Full

11.418512.7175 Others

Tab 1

8路温度巡回检测、报警系统

8路巡回检测、报警系统 一、摘要 随着电子技术的发展,家用电器和办公设备的智能化、系统化已成为发展趋势,而这些高性能几乎都要通过电子电路实现。同时,温度作为与我们生活息息相关的一个环境参数,对其的测量和研究也变得极为重要。本实验基于数字、模拟电子电路相关知识,实现了8路温度巡回检测、报警系统。此系统包括555时钟电路、计数与译码显示电路、拨码开关和数据选择电路、蜂鸣报警电路、电压比较电路、Pt100测温电路等模块。各模块焊接前均用Multisim软件对电路进行了仿真。8路通道中,有6路采用拨码开关实现对通道的工作状态模拟,1路采用滑动变阻器与窗口比较器实现通道的工作状态模拟,还有1路为热电阻Pt100的测温电路,且后两路通道均设置两个阈值,可检测系统工作状态是否处于正常范围之内。该系统能够对多个通道的工作状态(如温度)是否正常进行巡回检测。当某一通道出现故障(如超温)时,由巡回检测系统发出报警并显示故障的通道号,故障排除后,系统可继续进行巡回检测。

二、设计任务 2.1 设计选题 选题八:8路巡回检测、报警系统的设计与实现 2.2 设计任务要求 (1)基本要求:用十进制计数器、数据选择器、显示译码器和适当门电路设计一个8路循环检测报警器,循环检测周期不超过8秒。当某一路出现故障(如超温)时停止检测,并且发出报警和显示故障的通道号; (2)扩展要求1:电源电压模拟:要求采用滑动变阻器设计与实现2路电源电压输出的模拟。电压比较器可设定上、下限电压报警值; (3)扩展要求2:实现1路热电阻Pt100的测温电路。 三、方案设计与论证 接通电源后,555芯片在3口输出10Hz的时钟信号,在此信号的控制下,74ls160开始在0~7内循环计数,通过QA,QB,QC,QD输出BCD码到74ls47和74ls151的A,B,C端口。八路通道的电压输出值送入74LS151八路数据选择器的D0~D7端,74LS151的Y和~W互为反码形式输出,Y接74LS160的控制端ENT,~W接蜂鸣器。正常情况下,~W输出为低电平,无法驱动三极管,蜂鸣器不响。当有某一路或多路出现故障时,Y端输出为低电平,计数器74LS160停止计数,QA,QB,QC输出数据保持为出现故障时接受的二进制码,通过译码器在共阳数码管上显示的是一个不变的值,即故障通道号,~W端输出一个高电平,三极管导通,蜂鸣器响。系统方框图见图1: 图1 系统方框图 此系统全部使用硬件搭建,未使用单片机,无需编程,芯片采用了74系列,在

基于模拟路灯控制系统的设计毕业论文说明书

毕业论文声明 本人郑重声明: 1.此毕业论文是本人在指导教师指导下独立进行研究取得的成果。除了特别加以标注地方外,本文不包含他人或其它机构已经发表或撰写过的研究成果。对本文研究做出重要贡献的个人与集体均已在文中作了明确标明。本人完全意识到本声明的法律结果由本人承担。 2.本人完全了解学校、学院有关保留、使用学位论文的规定,同意学校与学院保留并向国家有关部门或机构送交此论文的复印件和电子版,允许此文被查阅和借阅。本人授权大学学院可以将此文的全部或部分内容编入有关数据库进行检索,可以采用影印、缩印或扫描等复制手段保存和汇编本文。 3.若在大学学院毕业论文审查小组复审中,发现本文有抄袭,一切后果均由本人承担,与毕业论文指导老师无关。 4.本人所呈交的毕业论文,是在指导老师的指导下独立进行研究所取得的成果。论文中凡引用他人已经发布或未发表的成果、数据、观点等,均已明确注明出处。论文中已经注明引用的内容外,不包含任何其他个人或集体已经发表或撰写过的研究成果。对本文的研究成果做出重要贡献的个人和集体,均已在论文中已明确的方式标明。 学位论文作者(签名): 年月

关于毕业论文使用授权的声明 本人在指导老师的指导下所完成的论文及相关的资料(包括图纸、实验记录、原始数据、实物照片、图片、录音带、设计手稿等),知识产权归属华北电力大学。本人完全了解大学有关保存,使用毕业论文的规定。同意学校保存或向国家有关部门或机构送交论文的纸质版或电子版,允许论文被查阅或借阅。本人授权大学可以将本毕业论文的全部或部分内容编入有关数据库进行检索,可以采用任何复制手段保存或编汇本毕业论文。如果发表相关成果,一定征得指导教师同意,且第一署名单位为大学。本人毕业后使用毕业论文或与该论文直接相关的学术论文或成果时,第一署名单位仍然为大学。本人完全了解大学关于收集、保存、使用学位论文的规定,同意如下各项内容: 按照学校要求提交学位论文的印刷本和电子版本;学校有权保存学位论文的印刷本和电子版,并采用影印、缩印、扫描、数字化或其它手段保存或汇编本学位论文;学校有权提供目录检索以及提供本学位论文全文或者部分的阅览服务;学校有权按有关规定向国家有关部门或者机构送交论文的复印件和电子版,允许论文被查阅和借阅。本人授权大学可以将本学位论文的全部或部分内容编入学校有关数据库和收录到《中国学位论文全文数据库》进行信息服务。在不以赢利为目的的前提下,学校可以适当复制论文的部分或全部内容用于学术活动。 论文作者签名:日期: 指导教师签名:日期: 摘要 随着城市建设和社会经济的迅速发展,城市道路照明作为城市文明与现代化程度的重要标志,已受到越来越多的关注,规模也在不断扩大。路灯是一个城市的照明系统不可分割更无可替代的一部分,现有的路灯管理的方式方法已远远不能满足城市路灯发展与管理的需要,必须依靠现代化的高科技管理手段。由于单片机具有集成度高,处理能力强,可靠性高,系统结构简单,价格低廉的优点,因此在路灯照明工程中被广泛应用。本系统采用MSC-51系列单片机AT89C51和相关的光电检测设备来设计智能光控路灯控制器,利用51系列单片机可编程控制八位逻辑I/O端口实现路灯的智能化,达到节能、自动控制的目的,单片机采集光敏电阻或光电开关的信号控制路灯的亮灭,具有自动检测故障报警等功能,同时根据实际情况,通过计时系统来对时间进行有效的控制,在本设计中,输入是开关按钮,进行时间控制,显示是六个数码管和LED二极管,时

简易数字钟的设计

中文摘要 数字钟已经成为人们日常生活中不可缺少的必需品,广发应用于家庭及办公室等公共场所,给人们的生活、学习、工作及娱乐带来了极大的方便。由于数字集成电路技术的发展和采用了先进的石英技术,使得数字钟具有走时准确、性能稳定、携带方便等优点,它还用于计时、自动报时及自动控制等各个领域。尽管目前市场上已有现成的数字钟集成电路芯片出售,价格便宜、使用方便,但鉴于单片机的定时器功能也可以完成数字钟的设计,因此进行数字的设计是必要的。在这里我们将已学过的比较零散的数字电路的知识有机的、系统的联系起来用于实际,来培养我们的综合分析和设计电路,写程序、调试电路的能力。 单片机具有体积小、功能强、可靠性高、价格低廉等一系列优点,不仅已成为工业测控领域普遍采用的智能化控制工具,而且已渗入到人们工作和生活的各个角落,有力地推动了各行各业的技术改造和产品的更新换代,应用前景广阔。 本次做的数字钟是以单片机(AT89C51)为核心,结合相关的元器件(共阴极LED 数码显示器等),再配以相应的软件,达到制作简易数字钟的目的。硬件部分采用了单片机原理实验室的实验箱进行合理接线调试;软件部分通过keil进行了C程序的修改编译,protues软件仿真等。最终在实验箱上实现了与仿真结果相同的实际效果。 关键词单片机定时功能、AT89C51、共阴LED、Keil、Protues软件。

Abstract Microelectronics and computer technology along with the rapid development and progress, making the design of electronic systems and applications have entered a new era. The traditional manual design process is being advanced electronic design automation technology to replace. And is currently supporting modern technology has become the universal platform for electronic design, and step by step to support the development of system-level design. Only to hardware description language and logic synthesis-based top-down design methodology to meet the increasingly complex needs of digital system design. The progressive development of the taxi industry, the taxi meter is getting higher and higher requirements, the user requires not only the performance of the stability of billing, billing and accurate anti-cheat functions; and as a result of the instability in oil prices, billing system the need for regular adjustment of the meter so that users can request not to change the hardware to facilitate the billing system modifications. The system is the use of language, it can make use of digital circuits and system description, simulation and automatic design, and software as a development platform designed billing system procedures taxi and carried out a simulation program. To the achievement of pre-billing and simulation, as well as car to start, stop, pause and other functions, and dynamic scan shows the number of fares. Key Words Microcontroller\、AT89C51、7SEG-MPX6-CC-RED 、Keil、Proteus

课程设计八路温度巡回检测系统

《单片机原理及应用》课程设计总结报告 题目: 八路温度巡回检测系统 设计人姓名: XXX 院系: XXXXX学院 专业: XXXXX 学号:X X X X X 指导教师:X X X 日期:201X-XX-XX

内容摘要 摘要:MCS-51是一种带8K字节闪烁可编程可檫除只读存储器的低电压,高性能COMOS8的微处理器,俗称单片机。利用单片机与AD转换器设计的八路温度巡回检测系统,可对某粮库或冷冻厂八点(八个冷冻室或八个粮仓)进行温度巡回检测。能够测量-30~+50o C的温度范围,检测精度不大于±1o C。并采用数码管显示测量值。 关键词:MCS-51、温度、巡回检测、

目录 1 设计任务 (3) 1.1引言 (3) 1.2设计题目 (3) 1.3设计目的 (3) 2 总体方案设计与论证 (3) 2.1总体方案设计与论证 (3) 2.2温度采集、计算方案设计与论证 (4) 3 硬件设计 (4) 3.1STC89C52简介 (4) 3.2DS18B20简介 (8) 3.3晶振 (9) 3.4LED显示电路电路及实物图 (9) 4 软件设计 (12) 4.1设计总框图 (12) 4.2自动巡检流程图 (13) 5 系统调试 (13) 6 总结和个人体会 (14) 附录一:设计电路图 (16) 附录二:元件清单 (16)

附录三:源程序 (17) 1、设计任务 1.1引言 温度测量与控制在工业、农业、国防等行业有着广泛的应用。利用单片机技术的温度测控仪有着体积小、可靠性高、价格便宜等优点而被广泛应用。 1.2设计题目 八路温度巡回检测装置 1.3设计目的 运用所学单片机原理知识,设计和调试小产品,从而了解产品设计开发的一些基本流程,并且加深对单片机知识的理解。 2、总体方案设计与论证 2.1总体方案设计与论证 本次课程设计的要求是8路温度巡显仪,要正常显示、进行参数设置等多个工作状态故系统工作的标志位是程序工作的主要的线索,每个功能模块在判断后系统的标志位再去执行相应的功能。见如下的框图所示。 1号键 为2 2号键 F0=1 为1 F0=0 图2.1 系统软件设计的整体思路框图 系统的标志位 判 断 按下了F 键 参数设定态 进入冻结态 正常巡显态 设置节拍 设置报警限值 显示温度态

vhdl课程设计(电子钟+闹铃)

数字钟的设计 一、系统功能概述 (一)、系统实现的功能: 1、具有“时”、“分”、“秒”的十进制数字显示(小时从00 ~ 23)。 2、具有手动校时、校分、校秒的功能。 3、有定时和闹钟功能,能够在设定的时间发出闹铃声。 4、能进行整点报时。从59分50秒起,每隔2秒发一次低音“嘟”的信号,连续5次, 最后一次为高音“嘀”的信号。 (二)、各项设计指标: 1、显示部分采用的6个LED显示器,从高位至低位分别显示时、分、秒。 2、有一个设置调闹钟定时时间、正常时间的按钮,选择调的对象。 3、有三个按钮分别调时、分、秒的时间。 4、有一个按钮用作开启/关闭闹铃。 5、另外需要两个时钟信号来给系统提供脉冲信号,使时钟和闹钟正常工作,分别为1Hz、 1kHz的脉冲。 二、系统组成以及系统各部分的设计 1、系统结构描述//要求:系统(或顶层文件)结构描述,各个模块(或子程序)的功能描述;(一)系统的顶层文件: 1、顶层文件图:(见下页) 2、各模块的解释: (1)、7个输入量clk_1khz、clk_1hz、key_slt、key_alarm、sec_set、min_set、hour_set:其中clk_1khz为闹铃模块提供时钟,处理后能产生“嘟”、“嘀”和变化的闹铃声音;clk_1hz为计时模块提供时钟信号,每秒计数一次;key_slt选择设置对象:定时或正常时间;key_alarm能够开启和关闭闹铃;sec_set、min_set、hour_set用于设置时间或定时,与key_slt相关联。各按键输出为脉冲信号。 (2)、CNT60_A_SEC模块: 这个模块式将clk_1hz这个时钟信号进行60进制计数,并产生一个分钟的触发信号。该模块能将当前计数值实时按BCD码的格式输出。将该输出接到两位LED数码后能时时显示秒的状态。通过alarm_clk可以选择设置对象为时间还是定时值。在设置时间模式上,key上的一个输入脉冲可以将clk的输入信号加一。在设置定时模式上,key 上的脉冲只修改定时值,不影响时间脉冲clk的状态。 同时该模块具有两个输出口out_do、out_di来触发整点报时的“嘟”、“嘀”声音。 (3)、CNT60_A_MIN模块: 这个模块式将CNT60_A_SEC的输出信号进行60进制计数,并产生一个时位的触发信号。该模块能将当前计数值实时按BCD码的格式输出。将该输出接到两位LED数码后能时时显示分的状态。通过alarm_clk可以选择设置对象为时间还是定时值。在设置时间模式上,key上的一个输入脉冲可以将clk的输入信号加一。在设置定时模式上,key上的脉冲只修改定时值,不影响时间脉冲clk的状态。 同时该模块具有三个输出口out_do、out_di、out_alarm来触发整点报时的“嘟”、“嘀”、闹铃声音。

模拟路灯控制系统附硬件图及c程序

摘要 本文介绍了一个模拟路灯控制系统的应用方案,用以实现模拟路灯的智能控制。本方案以宏晶公司的MCU芯片STC12C5410AD为核心,加以简单的外围电路,实现了模拟路灯控制系统所要求的全部技术内容。STC单片机在最近几年应用越来越广泛,因其抗干扰能力强、稳定性好,性价比高,因此是低成本路灯控制解决方案的首选。该控制系统除了选用廉价的单片机芯片,还采用了廉价的红外对射传感器,大大降低了系统成本。整个系统的电路简单,结构紧凑,电源驱动仅采用变压器与三端稳压器相结合,附加少许滤波电容便实现了稳定的电源输出。经过多次测试,证实该系统能长时间稳定工作,完全满足设计要求指标。 关键词:模拟控制;LED照明;单片机

ABSTRACT This paper introduces a simulation control system application scheme street, to simulate the street lamp of intelligent control. This plan to macro crystal company MCU, STC12C5410AD as the core, to chip the periphery of the simple circuit, realize the simulation street lamp control system all of the requested technology content. STC SCM in recent years more and more wide application, because of its strong anti-interference ability, good stability, high performance/price ratio, and so is the low cost street lamp control solutions of choice. The control system in addition to choose cheap single-chip microcomputer chip, also adopted the cheap infrared mutual illuminate sensor, and greatly reduce the cost of system. The whole system of the circuit is simple, compact structure, power drive only used three transformer and the regulators, and the combination of a few additional filter capacitance will realize the stable power output. After many test, and confirm that the system can work stably for a long time, fully meet the design requirements index. Keywords: Simulate controlling; LED lighting; Single-chip microcomputer

数字时钟设计原理

数字时钟设计——原理图一.实验目的 设计一个多功能数字中电路,基本功能为:①准确计时,以数字形式显示分、秒的时间;②分和秒的计时要求为60进位;③校正时间。 二.设计框图和工作原理 由振荡器产生高稳定的高频脉冲信号,作为数字钟的时间基准(系统时钟),再经分频器输出标准秒脉冲信号。秒计数器计满60后向分计数器进位,分计数器计满60后重新开始计时。计数器的输出经译码器送显示器。计时出现误差时可以用校时电路进行校分。 三.设计方案

1.振荡器的设计 振荡器是数字钟的核心。振荡器的稳定度及频率的精确度决定了数字钟计时的准确程度,通常选用石英晶体构成振荡器电路。一般来说,振荡器的频率越高,计时精度越高。 在这里我们选用由集成电路定时器555与RC组成的多谐振荡器。这里选用555构成的多谐振荡器,输出振荡频率v0=1KHz的脉冲,电路参数如下图所示。 2.分频器的设计 选用3片中规模集成电路计数器74LS90可以完成分频功能。因为每片为1/10分频,3片级联则可获得所需要的频率信号,即第1片的Q3端输出频率为100HZ,第2片的Q3端输出为10Hz,第3片的Q3端输出为1Hz。分频电路如下图所示:

3.分秒计数器的设计 分和秒计数器都是模M=60的计数器,其计数规律为:00-01-… -58-59-00…选74LS92作十位计数器,74LS90作个位计数器。再将它们级联组成模数M=60的计数器。分秒计数电路如下: 74LS90的原理图如下: 74LS92的原理图如下: 4.校时电路的设计 当数字钟接通电源或者计时出现误差时,需要校正时间(或称校时)。校时是数字钟应具备的基本功能。一般电子手表都具有时、分、秒等校时功能。为使

基于单片机的多点温度监测系统设计

基于单片机的多点温度监测系统设计 摘要:DS18B20是一种可组网的高精度数字式温度传感器,由于其具有单总线的独特优点,可以使用户轻松地组建起传感器网络,并可使多点温度测量电路变得简单、可靠。PL2303是Prolific公司生产的一种高度集成的RS232-USB接口转换器,可提供一个RS232全双工异步窜行通信装置与USB功能接口便利连接的解决方案。 该系统由上位机和下位机两大部分组成。下位机实现温度的检测并提供标准RS232通信接口,芯片使用了A TMEL公司的AT89S52单片机和DALLAS公司的DS18B20数字温度传感器。上位机部分使用了通用PC。该系统可应用于仓库测温、楼宇空调控制和生产过程监控等领域。 关键字:温度测量;单总线;数字温度传感器;单片机;转换器 Based on SCM more temperature monitoring system design Abstract:DS18B20 is a network of high precision digital temperature sensor, since it has the unique advantages single bus, users can easily set up sensor network, and can make more temperature measurement circuit become simple and reliable. PL2303 Prolific company is the production of a highly integrated RS232-USB interface converter, can provide a RS232 full-duplex asynchronous channeling line of communication equipment and the USB interface convenient connection function of the solution. The system consists of PC and a machine under two main components. A machine to implement the temperature detection and provide standard RS232 communication interface, ATMEL company used chip AT89S52 SCM and DALLAS company DS18B20 digital temperature sensor. PC parts used the general PC. This system can be used in storage temperature measurement, building the air conditioning control and production process monitoring, etc。 Key words:temperature measurement; Single bus; Digital temperature sensors; Single chip microcomputer; converter

vhdl数字时钟设计

数字时钟设计 一、题目分析 1、功能介绍 1)具有时、分、秒计数显示功能,以24小时循环计时。 2)时钟计数显示时有LED灯的花样显示。 3)具有调节小时、分钟及清零的功能。 4)具有整点报时功能。 2、总体方框图 3、性能指标及功能设计 1)时钟计数:完成时、分、秒的正确计时并且显示所计的数字;对秒、分——60进制计数,即从0到59循环计数,时钟——24进制计数,即从0到23循环计数,并且在数码管上显示数值。 2)时间设置:手动调节分钟、小时,可以对所设计的时钟任意调时间,这样使数字钟真正具有使用功能。我们可以通过实验板上的键7和键4进行任意的调整,因为我们用的时钟信号均是1HZ的,所以每LED灯变化一次就来

一个脉冲,即计数一次。 3)清零功能:reset为复位键,低电平时实现清零功能,高电平时正常计数。可以根据我们自己任意时间的复位。 4)蜂鸣器在整点时有报时信号产生,蜂鸣器报警。产生“滴答.滴答”的报警声音。 5)LED灯在时钟显示时有花样显示信号产生。即根据进位情况,LED不停的闪烁,从而产生“花样”信号。 二、选择方案 1、方案选择 方案一:根据总体方框图及各部分分配的功能可知,本系统可以由秒计数器、分钟计数器、小时计数器、整点报时、分的调整以及小时的调整和一个顶层文件构成。采用自顶向下的设计方法,子模块利用VHDL语言设计,顶层文件用原理图的设计方法。显示:小时采用24进制,而分钟均是采用6进制和10进制的组合。 方案二:根据总体方框图及各部分分配的功能可知,本系统可以由秒计数器、分钟计数器、小时计数器、整点报时、分的调整以及小时的调整和一个顶层文件构成。采用自顶向下的设计方法,子模块利用VHDL语言设计,顶层文件用原理图的设计方法。显示:小时采用24进制,而分钟和秒均60进制。 终上所述,考虑到试验时的简单性,故我选择了方案二。 三、细化框图 根据自顶向下的方法以及各功能模块的的功能实现上述设计方案应系统细化框图:

基于51单片机的路灯控制系统设计开题报告

一、本课题的内容及研究意义 1、论文研究的目的和意义 如今,照明电路的数量越来越多,使得城市街道、小区内的路灯的用电量占城市用电量的比重越来越大,在用电高峰期时,电网超负荷运行,电网电压都低于额定值,在用电低谷期供电电压又高于额定值,当电压高时不但影响照明设备的使用寿命,而且耗电量也大幅增加,当低谷时,照明设备有不能正常工作。 所以,对城市的路灯的设计已经成为了当务之急,特别是午夜之后车流量急剧减少时,应该适当的关闭路灯,节约用电。但是我国的既节能又能延长路灯寿命的技术相比国外却是落后了,因此智能节能路灯控制系统的设计对于城市的发展至关重要。本论文旨在设计一套对外界光线和电压信号的采集来控制路灯的自动启停以及智能调压的控 制系统,它能对路灯进行稳压、调压、自启动并延长路灯寿命的作用。 2、论文研究内容 本设计可以通过对外界光线和电压信号的采集来控制路灯的自动启停以及智能调压从而减少城市路灯照明耗电量,又对输入电压进行稳压调节来提高用电效率。要求独立选择芯片、设计电路、编制程序、调试、完成整个系统功能。 主要内容如下: (1) 根据控制技术的特点,进行路灯系统设计的整体研究与设计。 (2) 针对光线和电压信号的采集,采用数据采集技术。 (3) 通过按键可对相关的参数值进行设置,从而实现对不同时间进行不同的开灯模式。 (4) 当电压符合额定电压时,系统自动进行稳压。 (5) 在午夜之后降低电压以调节路灯亮度,实现调压。 二、本课题的研究现状和发展趋势 目前,路灯系统一般采用钠灯、水银灯、金卤灯等灯具。这类灯具有发光效率高、光色好、安装简易等优点,被广泛使用,但同时也存在着诸如:功率因子低、对电压要求严格、耗电量大等缺点。 我国目前大部分城市都采用全夜灯的方式进行照明,普遍存在的问题有两点:一方面因为后半夜行人稀少,采用全夜灯的方式浪费太大,因此,有的地方采取前半夜全亮,后半夜全灭的照明方式;有的地方在后半夜采用亮一隔一或亮一隔二的节能措施,此种方式虽然节约了电费支出,却带来了社会治安和交通安全问题,不利于城市安全问题。 另一方面,在后半夜因行人稀少,而应该降低路灯的亮度,以避免光源污染,影响居民的晚间的休息。但由于后半夜是用电低谷期,电力系统电压升高,路灯反而比白天更亮了。这不仅造成了能源浪费,还大大影响了设备和灯具的使用寿命。目前,路灯照明广泛采用高压钠灯,其设计寿命在12000小时以上,在正常情况下至少可用3年,但是由于超压使用,现在路灯的使用寿命仅仅只有1年左右,有的甚至只有几个月,造成

简易数字钟设计(已仿真)

简易数字钟设计 摘 要 本文针对简易数字钟的设计要求,提出了两种整体设计方案,在比较两个方案的优缺点后,选择了其中较优的一个方案,进行由上而下层次化的设计,先定义和规定各个模块的结构,再对模块内部进行详细设计。详细设计的时候又根据可采用的芯片,分析各芯片是否适合本次设计,选择较合适的芯片进行设计, 最后将设计好的模块组合调试,并最终在EWB 下仿真通过。 关键词 数字钟,EWB ,74LS160,总线,三态门,子电路 一、引言:所谓数字钟,是指利用电子电路构成的计时器。相对机械钟而言,数字钟能达到准确计时,并显示小时、分、秒,同时能对该钟进行调整。在此基础上,还能够实现整点报时,定时报闹等功能。 设计过程采用系统设计的方法,先分析任务,得到系统要求,然后进行总体设计,划分子系统,然后进行详细设计,决定各个功能子系统中的内部电路,最后进行测试。 二、任务分析:能按时钟功能进行小时、分钟、秒计时,并显示时间及调整时间,能整点报时,定点报时,使用4个数码管,能切换显示。 总体设计 本阶段的任务是根据任务要求进行模块划分,提出方案,并进行比较分析,最终找到较优的方案。 方案一、采用异步电路,数据选择器 将时钟信号输给秒模块,秒模块的进位输给分模块,分模块进位输入给时模块,切换的时候使用2选1数据选择器进行切换,电路框图如下: 该方案的优点是模块内部简单,基本不需要额外的电路,但缺点也很明显,该方案结构不清晰,模块间关系混乱,模块外还需使用较多门电路,不利于功能扩充,且使用了异步电路,计数在59的时候,高一级马上进位,故本次设计不采用此方案。 方案二、采用同步电路,总线结构 时钟信号分别加到各个模块,各个模块功能相对独立,框图如下: 显示 切换 秒钟 分钟 小时 控制 1Hz 脉冲信号 闹钟

八路温度巡回检测系统

单片机专业技能设计报告 题目: 八路温度巡回检测系统 设计人姓名: 胡振宇 院系: 物理与电子信息学院 专业: 09电信本 班级学号:090802075 指导教师:刘小燕 日期:2011-12-25

目录 1 设计任务 (3) 1.1引言 (3) 1.2设计题目 (3) 1.3设计目的 (3) 2 总体方案设计与论证 (3) 2.1总体方案设计与论证 (3) 2.2温度采集、计算方案设计与论证 (4) 3 硬件设计 (4) 3.1STC89C52简介 (4) 3.2DS18B20简介 (8) 3.3晶振 (9) 3.4L E D显示电路电路 (9) 4 软件设计 (12) 4.1设计总框图 (12) 4.2自动巡检流程图 (13) 5 系统调试 (13) 6 总结和个人体会 (14) 附录一:设计电路图 (16) 附录二:源程序 (16)

1、设计任务 1.1引言 温度测量与控制在工业、农业、国防等行业有着广泛的应用。利用单片机技术的温度测控仪有着体积小、可靠性高、价格便宜等优点而被广泛应用。 1.2设计题目 八路温度巡回检测装置 1.3设计目的 运用所学单片机原理知识,设计和调试小产品,从而了解产品设计开发的一些基本流程,并且加深对单片机知识的理解。 2、总体方案设计与论证 2.1总体方案设计与论证 本次课程设计的要求是8路温度巡显仪,要正常显示、进行参数设置等多个工作状态故系统工作的标志位是程序工作的主要的线索,每个功能模块在判断后系统的标志位再去执行相应的功能。见如下的框图所示。 1号键 为2 2号键 F0=1 为1 F0=0 图2.1 系统软件设计的整体思路框图 系统的标志位 判 断 按下了F 键 参数设定态 进入冻结态 正常巡显态 设置节拍 设置报警限值 显示温度态

VHDL数字钟设计报告

VHDL数字钟设计报告 一. 数字钟总体设计方案: 1.1设计目的 ①正确显示时、分、秒; ②可手动校时,能分别进行时、分的校正; ③整点报时功能; 1.2设计思路 数字钟的设计模块包括:分频器、去抖动电路、校时电路、“时、分、秒”计数器、校时闪烁电路、 整点报时和译码显示电路。 每一个功能模块作为一个实体单独进行设计,最后再用VHDL的例化语句将各个模块进行整合,生成 顶层实体top。 该数字钟可以实现3个功能:计时功能、设置时间功能和报时功能。 二.数字钟模块细节 2.1 分频器(fenpin) 本系统共需3种频率时钟信号(1024Hz、512Hz、1Hz)。为减少输入引脚,本系统采用分频模块,只需由外部提供1024Hz基准时钟信号,其余三种频率时钟信号由分频模块得到。 分频原理:为以1024Hz基准时钟经1024分频得到512Hz,1Hz频率时钟信号。 分频器管脚 代码:

library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity fenpin is port(clk1024:in std_logic; clk1,clk512:out std_logic ); end fenpin ; architecture cml of fenpin is begin process (clk1024) variable count1: integer range 0 to 512; variable q1: std_logic; begin if clk1024' event and clk1024='1' then if count1=512 then q1:=not q1; count1:=0; else count1:=count1+1; end if; end if; clk1<=q1; end process; process(clk1024) variable count512: integer range 0 to 1; variable q512: std_logic; begin if clk1024' event and clk1024='1' then if count512=1 then q512:=not q512; count512:=0; else count512:=count512+1; end if; end if; clk512<=q512; end process; end cml; 2.2 校时电路(jiaoshi)

VHDL硬件描述语言实验报告

硬件描述语言实验附录 姓名:xxx 学号:xxx 指导教师:xxx 目录 硬件描述语言实验附录 (1) 实验1.三输入与门电路实验 (2) 实验2. 三—八译码器实验 (3) 实验3. D触发器实验 (4) 实验4. 分频器实验 (5) 实验5. 状态机实验 (8)

实验1.三输入与门电路实验 --三输入与门电路threeinput --姓名:王定 --学号:1306034248 --中北大学 LIBRARY IEEE; --调用库 USE IEEE.STD_LOGIC_1164.ALL;--库文件 -------------------------------------------------------------- ENTITY threeinput IS --定义实体名,其名称必须与VHDL文本文件名称相同PORT( A: IN STD_LOGIC; --输入端口,时钟输入 B: IN STD_LOGIC; --输入端口,个位写入使能 C: IN STD_LOGIC; --输入端口,十位写入使能 CO: OUT STD_LOGIC); --输出端口,溢出标志 END ENTITY threeinput; --结束端口定义 -------------------------------------------------------------- ARCHITECTURE RTL OF threeinput IS--定义结构体 BEGIN PROCESS(A,B,C) IS --开始,必须带上 BEGIN CO<=A AND B AND C ; END PROCESS; END ARCHITECTURE RTL; --结束结构体 表1. 三输入与门电路VHDL实验代码 图1. 三输入与门电路仿真波形图,A,B,C输入,CO输出

模拟路灯控制系统的设计

摘要 路灯照明对人们的日常生活有着很重要的作用,路灯照明系统的好坏直接影响到人们夜晚出行的安全。中国的路灯控制系统老旧,效率低,浪费能源过多。路灯系统控制方式落后,无法远程控制开关灯时间,缺乏设备故障检测和报警系统。急需升级改善。单片机拥有卓越的控制能力,已经广泛应用在很多领域。基于单片机的智能路灯控制系统可以改变中国路灯现状,使得路灯的管理变得简单、可靠,能节约更多的电能,能使人们更加安全的出行,减少因路灯控制系统不完善而引起的交通事故。因此,设计一款智能路灯控制系统具有非常重要的意义。 文章介绍了模拟路灯控制系统的两大组成部分,即硬件系统和软件系统。硬件系统以AT89S52单片机为主控芯片,由实时时钟芯片DS1302产生实时系统时间,由LCD1602液晶显示屏显示菜单、提示和实时时间等信息,使用独立式键盘调整切换功能菜单、设置开关灯时间等,采用光敏电阻检测环境的明暗情况,使用反射型红外光电传感器检测交通情况,配合蜂鸣器和LED灯实现故障报警。软件系统包含系统监控程序模块、显示程序模块、键盘程序模块、实时时钟程序模块,环境检测程序模块、报警程序模块、交通检测程序模块,设定路灯开关时间程序模块等。 通过在proteus软件中模拟仿真调试,实现了课题规定的功能和性能指标要求,设计成果具有一定的推广应用价值。 关键词:路灯控制;AT89S52;DS1302;LCD1602

ABSTRACT Street lighting has a quite significant impact on people's daily life, the quality of the street lamp lighting system directly affects the safety of people at night. In china,street lamp control system is old-style, low efficiency and waste too much energy.The mode of streetlight control system is backward, it can’t remotely control switch lights in time, and lack equipment in fault detection and alarm system, which is badly in need of upgrading. MCU has excellent control ability, which has been widely used in many fields. Based on MCU intelligent lighting control system can change the status of Chinese street lighting, the street lamp management becomes simple and reliable, which can save more energy, make people more safe travel and reduce traffic accidents caused by defective street lamp control system . Therefore, it is great crucial to design a intelligent street lamp control system. This paper introduces the two components of the analog street lamp control system, namely the hardware system and the software system. The main control chip of hardware system is the AT89S52 microcontroller , real-time system time is produced by the real-time clock chip DS1302 , the information of menu,prompt and real time is displayed on the LCD1602 , hardware system use a separate keyboard to adjust or switch function menu and set the time switch lights, photosensitive resistance to measure the brightness of environment, and the reflection type infrared photoelectric sensor to detect traffic situation, with the buzzer and LED lamp realizes fault alarm. Software system includes system monitor module, display module, keyboard module, real-time clock module, environment detection program module, alarm module program, traffic detection program module, set the street lamp switch time program module and so on. By simulating and debugging in Proteus Software, the function and performance requirement of the project are achieved, and the design result has certain application value. Key words: street lamp control; at89s52; ds1302; lcd1602

相关文档
相关文档 最新文档