WXing 发表于 2009-8-21 18:21:24

发个proteus仿真16*64点阵,595级联实现。想调节整屏的灰度,该如何实现?

这两天在proteus上弄了个16*64点阵,8个595级联实现。现在想调节整屏的灰度,实现8级或16级灰度,论坛里有人说是控制595的OE使能端,但我还是不明白具体怎么个控制法,希望高手能指点下,感激不尽!Keil工程文件和Proteus电路图已放在压缩包里。
原理图:
http://cache.amobbs.com/bbs_upload782111/files_17/ourdev_473291.JPG
(原文件名:全图.JPG)

点击此处下载 ourdev_473292.rar(文件大小:69K) (原文件名:16×64LED.rar)
源代码如下:
/*************************************************/
#include<reg51.h>
/*************************************************/
#define uchar unsigned char
sbit hc595_ds=P2^0;                     //管脚定义
sbit hc595_shcp=P2^1;
sbit hc595_stcp=P2^2;
sbit hc595_oe=P2^3;
/*************************************************/
uchar code table1[]={0x08,0x00,0x08,0x08,0x1F,0xFC,0x11,0x00,
                                        0x21,0x00,0x41,0x10,0x1F,0xF8,0x11,0x00,
                                        0x11,0x00,0x11,0x04,0xFF,0xFE,0x01,0x00,   
                                        0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00}; //年
uchar code table2[]={0x01,0x00,0x01,0x00,0x01,0x00,0x09,0x20,
                                        0x09,0x10,0x11,0x0C,0x11,0x04,0x21,0x10,
                                        0x41,0x10,0x01,0x20,0x01,0x40,0x00,0x80,
                                        0x01,0x00,0x02,0x00,0x0C,0x00,0x70,0x00}; //少
uchar code table3[]={0x00,0x08,0x3F,0xFC,0x20,0x00,0x28,0x08,
                                        0x24,0x18,0x22,0x20,0x21,0x40,0x20,0x80,
                                        0x21,0x40,0x22,0x30,0x24,0x18,0x28,0x08,
                                        0x20,0x00,0x20,0x04,0x3F,0xFE,0x00,0x00}; //区
uchar code table4[]={0x04,0x80,0x04,0x80,0x04,0x88,0x04,0x98,
                                        0x04,0xA0,0x7C,0xC0,0x04,0x80,0x04,0x80,
                                        0x04,0x80,0x04,0x80,0x04,0x80,0x04,0x80,
                                        0x1C,0x82,0xE4,0x82,0x44,0x7E,0x00,0x00}; //北
/*************************************************/
void hc595_write_data(uchar data_ds);       //数据移位到595移位寄存器
void hc595_display();                                       //数据锁存到595存储寄存器,并送到8位并口输出
void delay(int n);                                               //延时
/*************************************************/
void main()
{       
        uchar i;
        hc595_oe=0;
        while(1)
        {       
                for(i=0;i<16;i++)
                {                            
                          hc595_write_data(table1);            //写数据到595移位寄存器,一共8个595
                          hc595_write_data(table1);       
                       hc595_write_data(table2);       
                       hc595_write_data(table2);
                        hc595_write_data(table3);        
                        hc595_write_data(table3);       
                          hc595_write_data(table4);       
                          hc595_write_data(table4);
                        //hc595_oe=1;                                           //关显示
                        P1=i;P3=i;                                                  //选择要扫描的行
                        hc595_display();                                     //数据锁存到595存储寄存器,并送到8位并口输出
                          //hc595_oe=0;                                          //输出允许,开显示
                     delay(100);                                
                }       
        }
}
/*************************************************/
void hc595_write_data(uchar data_ds)
{
      uchar n_bit;
      for(n_bit=0;n_bit<8;n_bit++)
      {
                       hc595_shcp=0;
             hc595_ds=data_ds&(1<<n_bit);
             hc595_shcp=1;

      }
}
/*************************************************/
void hc595_display()
{
    hc595_stcp=0;
        delay(1);
    hc595_stcp=1;
}
/*************************************************/
void delay(int n)
{
        while(n--);
}
/*************************************************/

millwood0 发表于 2009-8-21 20:29:07

rather than putting the OE pin either high or low, alternate them between high and low and the duty cycle will change the brightness.

naipeng 发表于 2009-8-21 20:47:54

好像仿真不出来灰度。就像仿真发光管时,亮度只有两个等级,在实际中时,发光管可以用PWM来调亮度,在proteus里面,仿真不出来那样的效果。个人认为是不是154控制的列显示时,消隐时间改变可以变灰度。以前做点阵时,好像是延时时间变化的话,闪烁/
这个还是做出实物来好。仿真看看是不是显示字,显示字的动态效果还是可以的。但灰度这种人眼感觉的东西,难说。

WXing 发表于 2009-8-22 12:49:33

一楼的高手能说的更详细点吗?对这个程序来说是要改变开显示后的delay时间吗?我试过,改变delay的时间,发现亮度没有什么变化,时间太长是闪烁,太短则不亮。2楼的naipeng说的有道理,也许仿真不出灰度的感觉,其实我只是想具体知道灰度怎么实现,并不是说一定要在Proteus里仿真实现,板子上实现也可以,希望有知道的大虾能再指点一下,静候佳音。

txr999 发表于 2010-1-2 23:21:06

下载学学

liubin198745 发表于 2011-4-28 09:14:29

可否左右移动

keshipt 发表于 2012-8-24 23:10:19

16*64点阵

Zigbee2012 发表于 2013-4-20 23:11:08

首先谢谢楼主!! 顺便提醒下初学者楼主有个“笔误”吧从左到右从上到下第14个 网络标号R45应改成R35
页: [1]
查看完整版本: 发个proteus仿真16*64点阵,595级联实现。想调节整屏的灰度,该如何实现?