重庆交通大学电子设计竞赛魔幻棒.docx
- 文档编号:6013676
- 上传时间:2023-01-03
- 格式:DOCX
- 页数:14
- 大小:293.14KB
重庆交通大学电子设计竞赛魔幻棒.docx
《重庆交通大学电子设计竞赛魔幻棒.docx》由会员分享,可在线阅读,更多相关《重庆交通大学电子设计竞赛魔幻棒.docx(14页珍藏版)》请在冰豆网上搜索。
重庆交通大学电子设计竞赛魔幻棒
重庆交通大学电子设计竞赛设计报告
题目:
魔幻棒
院系:
机电学院
专业:
机械电子工程
姓名:
学号:
08490215
指导老师:
2011年5月
一、选题背景
随着科技的发展,人们的生活也在随之而变。
LED技术的应用和普及使LED在照明、显示等方面被广泛应用。
一般的LED显示是用多个LED组成阵列,通过点亮不同的LED来组成所显示图案、字符。
这样所需LED较多,且体积较大。
LED魔幻棒是利用人眼视觉暂留效应,通过摆动LED阵列,在不同位置点亮特定的LED来组成所显示图案、字符。
本设计以STC89C52单片机为主控,采用单排蓝色高亮度LED做显示媒介,极具观赏性和趣味性,可广泛用于娱乐活动。
二、设计方案
首先要考虑的是整个棒体的制作,考虑到电路简单和成本控制的问题,我们没有采用PCB板,而采用万能洞洞板代替。
经过考察后发现市场上没有足够尺寸的万能洞洞板,所以我们将一块普通的万能洞洞板切分成三块拼接成所需电路板。
接下来要考虑的是如何供电的问题。
开始我们想到了纽扣电池,因为可以减小体积。
但我们所用的是16个高亮度LED,考虑到电池供电时间及电压匹配的问题,我们将钮扣电池更换为三节五号干电池。
这样一来将电路板夹在电池盒中间,顺便可以将电池盒部分作为手持部分,改善了手持舒适度。
其次就是LED的驱动问题。
由于单片机的I/O口输出电流有限,经实验后发现如果直接用单片机I/O口输出电流驱动LED,LED发光非常微弱,显示效果不佳。
考虑到电路简单所以我们采用9014三极管当非门使用作为LED的驱动。
最后考虑的是LED显示的问题。
由于棒体通过往复摆动来显示字符、图案,所以必须准确的在棒体每次开始摆动的瞬间让单片机运行程序。
基于这样的考虑毫无疑问的选择了单片机的外部0中断方式,所要运行的程序作为中断服务程序出现。
但随之出现的问题是如何能快速、准确的让单片机产生中断即如何让P3.2/INT0引脚的电平适时跳变。
我们想到了微动开关,但经实验可靠性不高且灵敏度较差。
最后我们选择了水银开关作为触发开关。
经实验,LED显示正常且稳定性较好。
为了能控制显示不同的字符、图案,我们特地增加了一个按钮开关,这样一来操作者就可自行切换所显示字符、图案,增强了作品的可玩性。
三、作品原理
1.作品原理
人眼在观察景物时,光信号传入大脑神经,需经过一段短暂的时间,光的作用结束后,视觉形象并不立即消失,这种残留的视觉称“后像”,视觉的这一现象则被称为“视觉暂留”。
实验证明当物体在快速运动时,当人眼所看到的影像消失后,人眼仍能继续保留其影像0.1-0.4秒左右的图像,只要物体出现在同一位置的间隔时间小于0.1-0.4秒左右,人的大脑就无法分辨物体的运动。
本设计以STC89C52单片机为主控芯片,通过人手持棒体往复摇摆,LED阵列在空间扫过一定的扇形面。
只要在适当的位置点亮特定的LED就可形成显示屏的效果。
其结构及原理图如图1、2所示。
图1图2
此次设计主要技术问题有:
单片机控制、LED驱动、外部中断的产生等。
(1)单片机控制部分:
由于整个程序作为中断服务程序出现,所以主程序很简单,其所需要做的就是将所用到的特殊功能寄存器置到所需状态并查询切换按键是否按下。
中断服务程序的任务就是在中断发生后按所设定的方式在棒体扫过扇形面的同时连续的点亮特定的LED即可。
代码如下:
#include
#include"mohuanbang.h"
voidmain(void)
{
IT0=1;//低电平跳变中断
EX0=1;
EA=1;
BZD=0;
P0=0xFF;
while
(1)
{P1=0x00;//确保熄灭
P2=0x00;//
if(P0==0x7F)//按键检测
{
Delay(10000);
if(P0==0x7F);
AJ++;
}
if(AJ>4)AJ=0;
}
}
#ifndef_MOHUANBANG_H
#define_MOHUANBANG_H
typedefunsignedcharuint8;
typedefunsignedintuint16;
uint8BZD,YS,AJ=0,BZDS=0;//半数中断、页数、按键、中断数
uint8codejdxq[]={
0x08,0x80,0x88,0x80,0xC8,0xC0,0x78,0x41,0x38,0x63,0x29,0x36,0x0F,0x1C,0x0E,0x1C,
0x0C,0x1E,0x98,0x37,0xB8,0x63,0x68,0xE1,0x68,0xC0,0x48,0x40,0x08,0x00,0x00,0x00,
0x20,0x00,0x20,0x80,0x20,0xC0,0x20,0x60,0x20,0x30,0x20,0x1C,0xA0,0x0F,0xFF,0x03,
0xFF,0x01,0xA0,0x07,0x20,0x0E,0x20,0x38,0x20,0x70,0x20,0xE0,0x20,0xC0,0x20,0x40,
0x00,0x00,0x08,0x02,0x88,0x03,0xE8,0x01,0xFF,0xFF,0xFF,0xFF,0x68,0x80,0xC8,0xC2,
0x88,0xE3,0xE8,0x67,0x69,0x3E,0x0F,0x18,0x0E,0x3E,0xA8,0x67,0xE8,0xE1,0xC8,0xC0,
0x88,0x40,0x00,0x00,0x00,0x80,0x00,0xE0,0xF8,0x7F,0xF8,0x9F,0x88,0xC0,0x88,0x60,
0x88,0x38,0x8A,0x1F,0xFE,0x07,0xFC,0x03,0x88,0x0F,0x88,0x3C,0x88,0x70,0x88,0xE0,};//交大校庆
uint8codejd1951[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x4A,0x20,0x4B,0xB0,0x6D,0xD8,0x36,
0x4C,0x1B,0x3E,0x0E,0x4C,0x1B,0xD8,0x36,0xB0,0x6D,0x20,0x4B,0x20,0x4A,0x00,0x00,
0x10,0x60,0xF8,0x7F,0xE8,0x7F,0x00,0x60,0x00,0x00,0x00,0x00,0xF8,0x63,0xF8,0x63,
0x18,0x63,0x18,0x63,0x18,0x63,0xF8,0x7F,0xF8,0x7F,0x00,0x00,0x00,0x00,0xF8,0x63,
0xF8,0x63,0x18,0x63,0x18,0x63,0x18,0x63,0x18,0x7F,0x18,0x7F,0x00,0x00,0x00,0x00,
0x10,0x60,0xF8,0x7F,0xF8,0x7F,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};//交大1951
uint8codeanz[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xC4,0x0F,0xEE,0x1F,0xC4,0x0F,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xFC,0x0F,0xFE,0x1F,0xFC,0x0F,0x00,0x00,0x00,0x00,0xF0,0xC7,
0xF8,0xCF,0xFC,0x1F,0x1C,0xDC,0x1C,0xDC,0xFC,0x1F,0xF8,0xCF,0xF0,0xC7,0x00,0x00,
0x00,0x00,0xF8,0x01,0xFC,0x03,0xF8,0x07,0x00,0x0F,0x00,0x1E,0x00,0x0F,0xF8,0x07,
0xFC,0x03,0xF8,0x01,0x00,0x00,0x00,0x00,0xF0,0x07,0xF8,0x0F,0xFC,0x1F,0xDC,0x1D,
0x8C,0x19,0xDC,0x19,0xFC,0x1D,0xF8,0x0D,0xF0,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,};//爱念族
uint8codetank[]={
0x00,0x00,0x00,0x00,0x80,0x00,0x80,0x00,0xE0,0x1F,0xE0,0x3F,0x80,0x20,0x80,0x20,
0x00,0x19,0x80,0x3D,0x80,0x26,0x80,0x22,0x80,0x22,0x80,0x3F,0x00,0x3F,0x80,0x20,
0x80,0x3F,0x80,0x3F,0x80,0x21,0x80,0x00,0x80,0x20,0x80,0x3F,0x00,0x3F,0x08,0x20,
0xF8,0x3F,0xF8,0x3F,0x00,0x26,0x80,0x2F,0x80,0x3D,0x80,0x30,0x80,0x20,0x00,0x00,
0x80,0x80,0x80,0x81,0x80,0x8F,0x80,0xFE,0x00,0x78,0x80,0x1E,0x80,0x07,0x80,0x01,
0x80,0x00,0x00,0x1F,0x80,0x3F,0x80,0x20,0x80,0x20,0x80,0x20,0x80,0x3F,0x00,0x1F,
0x80,0x00,0x80,0x1F,0x80,0x3F,0x00,0x20,0x00,0x20,0x80,0x30,0x80,0x3F,0x80,0x3F,
0x00,0x20,0x00,0x00,0xF0,0x07,0xF8,0xDF,0xF8,0xDF,0xF0,0x07,0x00,0x00,0x00,0x00,};//tankyou!
uint8codehanzi[]={
0x08,0x40,0x08,0x48,0xEA,0x4B,0xEA,0x4B,0xAA,0x4A,0xAA,0x4A,0xFF,0x7F,0xFF,0x7F,
0xA9,0x4A,0xA9,0x4A,0xE9,0x4B,0xE9,0x4B,0x08,0x48,0x08,0x40,0x08,0x40,0x00,0x00,
0x00,0x40,0x00,0x70,0xFC,0x3F,0xFC,0x4F,0x44,0x60,0x44,0x30,0x44,0x1C,0xC5,0x0F,
0xFF,0x03,0xFE,0x01,0xC4,0x07,0x44,0x1E,0x44,0x38,0x44,0x70,0x44,0x60,0x44,0x20,
0x00,0x00,0x04,0x40,0x44,0x40,0x64,0x60,0xBC,0x20,0x9C,0x31,0x14,0x1B,0x07,0x0E,
0x07,0x0E,0x06,0x0F,0xCC,0x1B,0xDC,0x31,0xB4,0x70,0x34,0x60,0x24,0x20,0x04,0x00,
0x00,0x00,0x20,0x40,0x21,0x60,0xE7,0x3F,0xE6,0x3F,0x00,0x60,0xF9,0x5F,0xF9,0x5F,
0x49,0x42,0x4B,0x42,0xFF,0x5F,0xFD,0x5F,0x4D,0x42,0x4F,0x4A,0xFB,0x5F,0xF9,0x5F,
//重庆交通
0x20,0x00,0x20,0x80,0x20,0xC0,0x20,0x60,0x20,0x30,0x20,0x1C,0xA0,0x0F,0xFF,0x03,
0xFF,0x01,0xA0,0x07,0x20,0x0E,0x20,0x38,0x20,0x70,0x20,0xC0,0x20,0xC0,0x20,0x40,
0x00,0x00,0x40,0x00,0x70,0x02,0x30,0x02,0x12,0x02,0x5E,0x02,0x5C,0x02,0x54,0x42,
0x51,0xC2,0x5F,0xFF,0xDE,0x7F,0xD4,0x02,0x58,0x02,0x5F,0x02,0x17,0x02,0x72,0x02,
0x30,0x02,0x10,0x02,0x00,0x00,0xF8,0x0F,0xF8,0x0F,0x88,0x04,0x88,0x04,0x88,0x04,
0xFF,0x7E,0xFF,0xFF,0x88,0xC4,0x88,0xC4,0x88,0xC4,0xF8,0xCF,0xF8,0xCF,0x00,0xE0,
0x00,0xC0,0x00,0x80,0x80,0x00,0x80,0x00,0x82,0x00,0x82,0x00,0x82,0x40,0x82,0xC0,
0xE2,0xFF,0xF2,0x7F,0x9A,0x00,0x8E,0x00,0x86,0x00,0xC2,0x00,0xC0,0x00,0x80,0x00,
//大学电子
0x40,0x00,0x41,0x00,0xCF,0x7F,0xCE,0x7F,0x04,0xB0,0x80,0x90,0xC0,0xC0,0xFE,0x43,
0xBE,0x6F,0x82,0x3C,0x82,0x10,0xBE,0x3C,0xFE,0x6F,0xC0,0xC3,0x40,0xC0,0x40,0x40,
0x00,0x00,0x20,0x00,0x21,0x00,0x2F,0x00,0xEE,0x7F,0xE4,0x7F,0x00,0x30,0x20,0x18,
0x20,0x08,0x20,0x00,0x20,0x00,0xFF,0xFF,0xFF,0xFF,0x20,0x00,0x20,0x00,0x20,0x00,
0x20,0x00,0x00,0x00,0x20,0x80,0x24,0x80,0x24,0xC0,0xA4,0x47,0xAC,0x67,0xBD,0x3C,
0xB7,0x1C,0xA6,0x04,0xB4,0x7C,0xBC,0xFC,0xAC,0x87,0xA4,0x87,0x24,0xE0,0x24,0xE0,
0x20,0x00,0x08,0x04,0x8E,0x04,0xAE,0x86,0xAA,0x82,0xAA,0xDF,0xFE,0x5F,0xFE,0x62,
0xAB,0x3E,0xAB,0x3E,0xFE,0x62,0xFE,0xDF,0xAA,0xDF,0xAE,0x43,0x86,0x06,0x02,0x06,
//设计竞赛
0x08,0x08,0x08,0x0F,0xC8,0x03,0xFF,0xFF,0xFF,0xFF,0xC8,0x01,0x08,0x83,0x08,0xE0,
0x00,0x78,0xF8,0x1F,0xF8,0x07,0x18,0x00,0x18,0x00,0xF8,0x7F,0xF8,0xFF,0x00,0xC0,
0x00,0xE0,0x00,0xC0,0xF8,0x8F,0xF8,0x0F,0x48,0x04,0x48,0x04,0x48,0x04,0xFF,0x7F,
0xFF,0xFF,0x48,0xC4,0x48,0xC4,0x48,0xC4,0xF8,0xCF,0xF8,0xCF,0x00,0xE0,0x40,0xC0,
0x70,0x82,0x30,0x02,0x12,0x02,0x5E,0x02,0x5C,0x02,0x54,0x02,0x51,0x42,0x5F,0xFF,
0xDE,0x7F,0xD4,0x02,0x58,0x02,0x5F,0x02,0x77,0x02,0x32,0x02,0x10,0x02,0x00,0x00,
0xFE,0xFF,0xFE,0xFF,0x32,0x02,0x7A,0x06,0xCE,0x87,0x8E,0xC3,0x2C,0x71,0x24,0x3F,
0x25,0x0F,0x27,0x01,0x26,0x01,0x24,0x7F,0x24,0xFF,0x2C,0xC1,0x0C,0xC1,0x04,0xE0,
//机电学院
0x08,0x08,0x08,0x0F,0xC8,0x03,0xFF,0xFF,0xFF,0xFF,0xC8,0x01,0x88,0x83,0x08,0xE0,
0x00,0x78,0xF8,0x1F,0xF8,0x07,0x08,0x00,0x08,0x00,0xF8,0x7F,0xF8,0xFF,0x00,0xC0,
0x00,0xE0,0x00,0xC0,0x10,0x8C,0xD0,0x07,0xFF,0xFF,0xFF,0xFF,0xD0,0x20,0x90,0x39,
0xE8,0x1F,0xE8,0x07,0xE8,0x5F,0xE8,0x7F,0xFF,0x33,0xFF,0x1F,0x0A,0x3F,0xCE,0x73,
0xCC,0xC0,0x08,0xE0,0x00,0xC0,0xF8,0x8F,0xF8,0x0F,0xC8,0x04,0xC8,0x04,0xC8,0x04,
0xFF,0x7F,0xFF,0xFF,0xC8,0xC4,0xC8,0xC4,0xC8,0xC4,0xF8,0xCF,0xF8,0xCF,0x00,0xE0,
0x00,0xC0,0x80,0x80,0x80,0x00,0x82,0x00,0x82,0x00,0x82,0x00,0x82,0x00,0x82,0x40,
0xE2,0xFF,0xF2,0xFF,0x9A,0x00,0x8E,0x00,0x86,0x00,0xC2,0x00,0xC0,0x00,0x80,0x00,
//机械电子
0x20,0x04,0x20,0x04,0x22,0x46,0x22,0xC2,0xFE,0xFF,0xFF,0x7F,0x21,0x01,0x21,0x11,
0x20,0x10,0xFF,0x18,0xFF,0x0F,0x22,0x1F,0xAE,0x3B,0xAC,0x61,0x20,0xC0,0x20,0xE0,
0x00,0x80,0x08,0x08,0x08,0x08,0x08,0x0C,0x08,0x06,0x88,0x07,0xC8,0x05,0xF8,0x04,
0xFF,0xFF,0xFF,0xFF,0x78,0x04,0xE8,0x04,0x88,0x07,0x08,0x07,0x08,0x0E,0x08,0x0C,
0x08,0x04,0x00,0x00,0x00,0x10,0x22,0x10,0x3E,0x18,0x3E,0x0C,0x22,0x27,0xA2,0x63,
0xFE,0x7F,0xFE,0x3F,0x22,0x00,0xFE,0xFF,0xFE,0xFF,0x22,0x04,0x7A,0x0C,0xDE,0x08,
0x86,0x0F,0x02,0x07,0x00,0x20,0x08,0x39,0x1A,0x39,0x72,0x3D,0x62,0x7D,0xFE,0x61,
0xFE,0x65,0x02,0x6D,0x02,0x69,0xFE,0x61,0xFE,0x75,0x62,0x6D,0x3A,0x59,0x18,0x31,
//我本邪恶
};
voiddisplay1(void);
voiddisplay2(void);
voiddisplay3(void);
voiddisplay4(void);
voiddisplay5(void);
voidDelay(uint16N)
{
uint16x;
for(x=0;x<=N;x++);
}
voiddisplay1(void)
{
uint8i;
if(BZDS>4){YS++;BZDS=0;}
if(YS>5)YS=0;
Delay(5200);
for(i=0;i<64;i++)
{
P1=hanzi[YS*128+i*2];
P2=hanzi[YS*128+i*2+1];
Delay(100);
}
}
voiddisplay2(void)
{
uint8i;
Delay(4000);
for(i=0;i<64;i++)
{
P1=jdxq[i*2];
P2=jdxq[i*2+1];
Delay(120);
}
}
voiddisplay3(void)
{
uint8i;
Delay(4000);
for(i=0;i<64;i++)
{
P1=jd1951[i*2];
P2=jd1951[i*2+1];
Delay(120);
}
}
voiddisplay4(void)
{
uint8i;
Delay(4000);
for(i=0;i<64;i++)
{
P1=anz[i*2];
P2=anz[i*2+1];
Delay(120);
}
}
voiddisplay5(void)
{
uint8i;
Delay(4000);
for(i=0;i<64;i++)
{
P1=tank[i*2];
P2=tank[i*2+1];
Delay(120);
}
}
voidE0in()interrupt0
{
BZD=~BZD;
if(BZD==0)
{
BZDS++;
switch(AJ)
{
case0:
{display1();}break;
case1:
{display2();}break;
case2:
{display3();}break;
case3:
{display4();}break;
case4:
{display5();}break;
default:
{display1();}
}
}
}
#endif
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 重庆 交通大学 电子设计 竞赛 魔幻