在本课中,我们要用一个按键来实现跑马灯的 10 级调速。这又会涉及到键的去抖的问 题。 本课的试验结果是,每按一次按键,跑马速度就降低一级,共 10 级。 这里我们又增加了一个变量 speedlever,来保存当前的速度档次。 在按键里的处理中,多了当前档次的延时值的设置。 请看程序: ―――――――――――――――― #define uchar unsigned char //定义一下方便使用 #define uint unsigned int #define ulong unsigned long #include <reg52.h> //包括一个 52 标准内核的头文件 sbit P10 = P1^0; //头文件中没有定义的 IO 就要自己来定义了 sbit P11 = P1^1; sbit P12 = P1^2; sbit P13 = P1^3; sbit K1= P3^2; bit ldelay=0; //长定时溢出标记,预置是 0 uchar speed=10; //设置一个变量保存默认的跑马灯的移动速度 uchar speedlever=0; //保存当前的速度档次 char code dx516[3] _at_ 0x003b;//这是为了仿真设置的 //一个按键控制的 10 级变速跑马灯试验 void main(void) // 主程序 { uchar code ledp[4]={0xfe,0xfd,0xfb,0xf7};//预定的写入 P1 的值 uchar ledi; //用来指示显示顺序 uint n; RCAP2H =0x10; //赋 T2 的预置值 0x1000,溢出 30 次就是 1 秒钟 RCAP2L =0x00; TR2=1; //启动定时器 ET2=1; //打开定时器 2 中断 EA=1; //打开总中断 while(1) //主程序循环 { if(ldelay) //发现有时间溢出标记,进入处理 { ldelay=0; //清除标记 P1=ledp[ledi]; //读出一个值送到 P1 口 ledi++; //指向下一个 if(ledi==4) { ledi=0; //到了最后一个灯就换到第一个 } } if(!K1) //如果读到 K1 为 0 { for(n=0;n<1000;n++); //等待按键稳定 while(!K1); //等待按键松开 for(n=0;n<1000;n++); //等待按键稳定松开 speedlever++; if(speedlever==10)speedlever=0; speed=speedlever*3; //档次和延时之间的预算法则,也可以用查表方法,做出 不规则的法则 } } } //定时器 2 中断 timer2() interrupt 5 { static uchar t; TF2=0; t++; if((t==speed)||(t>30)) //比较一个变化的数值,以实现变化的时间溢出,同时限制了最慢速 度为 1 秒 { t=0; ldelay=1;//每次长时间的溢出,就置一个标记,以便主程序处理 } } ―――――――――――――――――――――― 请打开 lesson11 目录的工程,编译,运行,看结果: 按 K1,速度则降低一次,总共 10 个档次。
上传时间: 2017-11-06
上传用户:szcyclone
LED 一般是恒流操作的,如何改变 LED 的亮度呢?答案就是 PWM 控制。在一定的 频率的方波中,调整高电平和低电平的占空比,即可实现。比如我们用低电平点亮一个 LED 灯,我们假设把一个频率周期分为 10 个时间等份,如果方波中的高低电平占空比是 9:1, 这是就是一个比较暗的亮度,如果方波中高低电平占空比是 10:0,这时,全部是高电平, 灯是灭的。如果占空比是 5:5,就是一个中间亮度,如果高低比是 1:9,是一个比较亮的 亮度,如果高低是 0:10,这时全部是低电平,就是最亮的。 实际上应用中,电视屏幕墙中的几十百万 LED 象素都是这样控制的,而且每一个象素 都有红绿蓝 3 个 LED,每个 LED 可以变化的亮度是几百到几万或者更多的级别,以实现真 彩色的显示。还有在您的手机中,背光灯的亮度如果是可以变化的,也应该是这种工作方式。 目前的城市彩灯也有很多都使用了 LED,需要控制亮度是也是 PWM 控制。 下面来分析我们的例程,在这个例程中,我们将定时器 2 溢出定为 1/1200 秒。每 10 次脉冲输出一个 120HZ 频率。这每 10 次脉冲再用来控制高低电平的 10 个比值。这样,在 每个 1/120 秒的方波周期中,我们都可以改变方波的输出占空比,从而控制 LED 灯的 10 个 级别的亮度。 为什么输出方波的频率要 120HZ 这么高?因为如果频率太低,人眼就会看到闪烁感 觉。一般起码要在 60HZ 以上才感觉好点,120HZ 就基本上看不到闪烁,只能看到亮度的变 化了。 下面请看程序,程序中有比较多的注释: ――――――――――――――――――――――― #define uchar unsigned char //定义一下方便使用 #define uint unsigned int #define ulong unsigned long #include <reg52.h> //包括一个 52 标准内核的头文件 sbit P10 = P1^0; //要控制的 LED 灯 sbit K1= P3^2; //按键 K1 uchar scale;//用于保存占空比的输出 0 的时间份额,总共 10 份 char code dx516[3] _at_ 0x003b;//这是为了仿真设置的 //模拟 PWM 输出控制灯的 10 个亮度级别 void main(void) // 主程序 { uint n; RCAP2H =0xF3; //赋 T2 的预置值,溢出 1 次是 1/1200 秒钟 RCAP2L =0x98; TR2=1; //启动定时器 ET2=1; //打开定时器 2 中断 EA=1; //打开总中断 while(1) //程序循环 { ;//主程序在这里就不断自循环,实际应用中,这里是做主要工作 for(n=0;n<50000;n++); //每过一会儿就自动加一个档次的亮度 scale++; if(scale==10)scale=0; } } //1/1200 秒定时器 2 中断 timer2() interrupt 5 { static uchar tt; //tt 用来保存当前时间在一秒中的比例位置 TF2=0; tt++; if(tt==10) //每 1/120 秒整开始输出低电平 { tt=0; if(scale!=0) //这里加这一句是为了消除灭灯状态产生的鬼影 P10=0; } if(scale==tt) //按照当前占空比切换输出高电平 P10=1; } ―――――――――――――――――― 在主程序中,每延时一段时间,就自动换一个占空比,以使亮度自动变化,方便观察。 编译,运行,看结果。 可以看到,LED 的亮度以每种亮度 1 秒左右不断变化,共有 10 个级别。
上传时间: 2017-11-06
上传用户:szcyclone
Received: from mail.creditcard.cmbc.com.cn (unknown [111.205.122.39]) by newmx82.qq.com (NewMx) with SMTP id for <714620454@QQ.COM>; Fri, 20 Oct 2017 03:56:09 +0800 X-QQ-FEAT: nHaaMjwLeTyzuDp5C5V++RVfPHSVEqOujK0vwZroSro= X-QQ-MAILINFO: MjJD59SVx+LnQ1oU2sDuZ8tZJyZAOGTJaybWFAYRjurknrZoc6gjmnU06 o+pkiTJsdtxgA5CmtpN2ggrWb/T2GoG07QFXqgJtIk+5X1iaz4UykQ9M2a782+Fdn83doxC 4Ej1t99JoZcj8dDkeM5dzZTSR8uZGwHEnIK9Uim+NcaroB2EUWgclSmSzIxUHIbJ1nTLA8G B4/wa X-QQ-mid: mx82t1508442969ti70kc84u X-QQ-ORGSender: master@creditcard.cmbc.com.cn Received: from sedm([195.203.59.13]) by mail.creditcard.cmbc.com.cn(1.0) with SMTP id sedm587; Thu, 19 Oct 2017 17:48:11 +0800 Date:Thu, 19 Oct 2017 17:48:11 +0800 (CST) Message-ID:<0305-euid-31911508406491578> To:=?gbk?B?zsTS1SDFrsq/?=<714620454@QQ.COM> From:master<master@creditcard.cmbc.com.cn> Subject: =?gbk?B?w/HJ+tDF08O/qDIwMTfE6jEw1MK159fTttTVy7Wl?= X-Priority: 3 X-MSMail-Priority: Normal MIME-Version: 1.0 Content-Type: multipart/related; boundary="****MAIN_BOUNDARY****2727BD00F7949069C75FEDD44F1F2988" This is a multi-part message in MIME format. --****MAIN_BOUNDARY****2727BD00F7949069C75FEDD44F1F2988 Content-Type: multipart/alternative; boundary="****SUB_BOUNDARY****2727BD00F7949069C75FEDD44F1F2988" --****SUB_BOUNDARY****2727BD00F7949069C75FEDD44F1F2988 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: base64
标签: 源代码
上传时间: 2017-11-17
上传用户:wendingchang
Reconstruction- and example-based super-resolution (SR) methods are promising for restoring a high-resolution (HR) image from low-resolution (LR) image(s). Under large magnification, reconstruction-based methods usually fail to hallucinate visual details while example-based methods sometimes introduce unexpected details. Given a generic LR image, to reconstruct a photo-realistic SR image and to suppress artifacts in the reconstructed SR image, we introduce a multi-scale dictionary to a novel SR method that simultaneously integrates local and non-local priors. The local prior suppresses artifacts by using steering kernel regression to predict the target pixel from a small local area. The non-local prior enriches visual details by taking a weighted average of a large neighborhood as an estimate of the target pixel. Essentially, these two priors are complementary to each other. Experimental results demonstrate that the proposed method can produce high quality SR recovery both quantitatively and perceptually.
标签: Super-resolution Multi-scale Dictionary Single Image for
上传时间: 2019-03-28
上传用户:fullout
C#远控源代码 * TCP network stream (IPv4 & IPv6 support) * Fast network serialization (NetSerializer) * Compressed (QuickLZ) & Encrypted (AES-128) communication * Multi-Threaded * UPnP Support * No-Ip.com Support * Visit Website (hidden & visible) * Show Messagebox * Task Manager * File Manager * Startup Manager * Remote Desktop * Remote Webcam * Remote Shell * Download & Execute * Upload & Execute * System Information * Computer Commands (Restart, Shutdown, Standby) * Keylogger (Unicode Support) * Reverse Proxy (SOCKS5) * Password Recovery (Common Browsers and FTP Clients) * Registry Editor
标签: QuasarRAT
上传时间: 2019-04-21
上传用户:netangels
在微电网调度过程中综合考虑经济、环境、蓄电池的 循环电量,建立多目标优化数学模型。针对传统多目标粒子 群算法(multi-objective particle swarm optimization,MOPSO) 的不足,提出引入模糊聚类分析的多目标粒子群算法 (multi-objective particle swarm optimization algorithm based on fuzzy clustering,FCMOPSO),在迭代过程中引入模糊聚 类分析来寻找每代的集群最优解。与 MOPSO 相比, FCMOPSO 增强了算法的稳定性与全局搜索能力,同时使优 化结果中 Pareto 前沿分布更均匀。在求得 Pareto 最优解集 后,再根据各目标的重要程度,用模糊模型识别从最优解集 中找出不同情况下的最优方案。最后以一欧洲典型微电网为 例,验证算法的有效性和可行性。
上传时间: 2019-11-11
上传用户:Dr.赵劲帅
New applications such as video conferencing, video on demand, multi- media transcoders, Voice-over-IP (VoIP), intrusion detection, distributed collaboration, and intranet security require advanced functionality from networks beyond simple forwarding congestion control techniques.
标签: Programmable Networks Active and
上传时间: 2020-05-26
上传用户:shancjb
Emerging technologies such as WiFi and WiMAX are profoundly changing the landscape of wireless broadband. As we evolve into future generation wireless networks, a primary challenge is the support of high data rate, integrated multi- media type traffic over a unified platform. Due to its inherent advantages in high-speed communication, orthogonal frequency division multiplexing (OFDM) has become the modem of choice for a number of high profile wireless systems (e.g., DVB-T, WiFi, WiMAX, Ultra-wideband).
标签: Broadband Wireless Networks
上传时间: 2020-05-26
上传用户:shancjb
Employing multiple transmit and receive antennas, namely using multi-input multi-output (MIMO) systems, has proven to be a major breakthrough in providing reliable wireless communication links. Since their invention in the mid-1990s, transmit diversity, achieved through space-time coding, and spatial multiplexing schemes have been the focus of much research in the area of wireless communications.
标签: Communication Systems Coding MIMO for
上传时间: 2020-05-26
上传用户:shancjb
Today’s wireless services have come a long way since the roll out of the conventional voice-centric cellular systems. The demand for wireless access in voice and high rate data multi-media applications has been increasing. New generation wireless communication systems are aimed at accommodating this demand through better resource management and improved transmission technologies.
标签: Radio Cognitive Software Defined
上传时间: 2020-05-26
上传用户:shancjb