標(biāo)題: 單片機(jī)控制可控硅調(diào)光程序編好了,但是proteus仿真沒實現(xiàn) [打印本頁]

作者: MC311    時間: 2024-11-30 14:55
標(biāo)題: 單片機(jī)控制可控硅調(diào)光程序編好了,但是proteus仿真沒實現(xiàn)
程序編好了,但是proteus仿真沒實現(xiàn)

作者: man1234567    時間: 2024-12-2 08:54
深呼吸,然后刷新,然后就好了
作者: 2851143905    時間: 2024-12-2 10:06
沒圖沒程序不知知道你想要表達(dá)什么?
作者: MC311    時間: 2024-12-2 10:09
#include <REGX52.H> #include "Delay.h"         #include "INT0.h"         #include "Timer0.h"         #include "Key.h"         sbit    ChuFa= P1^0; unsigned char n; unsigned code LiangDu_tab[100]={100,200,300,400,500,600,700,800,900,1000,                                 1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,                                 2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,                                                                                  3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,                                 4100,4200,4300,4400,4500,4600,4700,4800,4900,5000,                                 5100,5200,5300,5400,5500,5600,5700,5800,5900,6000,                                 6100,6200,6300,6400,6500,6600,6700,6800,6900,7000,                                 7100,7200,7300,7400,7500,7600,7700,7800,7900,8000,                                                                                  8100,8200,8300,8400,8500,8600,8700,8800,8900,9000,                                 9100,9200,9300,9400,9500,9600,9700,9800,9900,10000,                                                                                                                  };   void main() {         Timer0Init();         Int0_Init();         ChuFa=0;         while(1)         {           //等待中斷         } }  void Int0_Routine(void) interrupt 0 {          ChuFa=1;         n=Key();         TL0 =65536-LiangDu_tab[n]%256;                //設(shè)置定時初值         TH0 =65536-LiangDu_tab[n]/256;                //設(shè)置定時初值         TR0=1; } void Timer0_Routine() interrupt 1 {         ChuFa=0;   Delay10us();         ChuFa=1;         TR0=0; }
作者: MC311    時間: 2024-12-2 10:12
#include <REGX52.H>
#include "Delay.h"       
#include "INT0.h"       
#include "Timer0.h"       
#include "Key.h"       
sbit    ChuFa= P1^0;
unsigned char n;
unsigned code LiangDu_tab[100]={100,200,300,400,500,600,700,800,900,1000,
                                1100,1200,1300,1400,1500,1600,1700,1800,1900,2000,
                                2100,2200,2300,2400,2500,2600,2700,2800,2900,3000,                                                
                                3100,3200,3300,3400,3500,3600,3700,3800,3900,4000,
                                4100,4200,4300,4400,4500,4600,4700,4800,4900,5000,
                                5100,5200,5300,5400,5500,5600,5700,5800,5900,6000,
                                6100,6200,6300,6400,6500,6600,6700,6800,6900,7000,
                                7100,7200,7300,7400,7500,7600,7700,7800,7900,8000,                                                
                                8100,8200,8300,8400,8500,8600,8700,8800,8900,9000,
                                9100,9200,9300,9400,9500,9600,9700,9800,9900,10000,                                
                                                                                 };  
void main()
{
        Timer0Init();
        Int0_Init();
        ChuFa=0;
        while(1)
        {
          //等待中斷
        }
}

void Int0_Routine(void) interrupt 0
{
        ChuFa=1;
        n=Key();
        TL0 =65536-LiangDu_tab[n]%256;                //設(shè)置定時初值
        TH0 =65536-LiangDu_tab[n]/256;                //設(shè)置定時初值
        TR0=1;
}
void Timer0_Routine() interrupt 1
{
        ChuFa=0;
  Delay10us();
        ChuFa=1;
        TR0=0;
}
key():
#include <REGX52.H>
#include "Delay.h"
#include <INTRINS.H>
sbit    KeyUp= P1^1;
sbit    KeyDown= P1^2;
unsigned char Key()
{
        unsigned char n=0;
        unsigned char x=0;
        unsigned char y=0;
        if(KeyUp==0)
{
        Delay(20);
        while(KeyUp==0)
        {
                n++;
                for(x=0;x<20;x++)
                {
                        if(n>=99)n=99;
                }
        }
        Delay(20);
        n=n+5;
        if(n>=99)n=99;
}
        if(KeyDown==0)
{
        Delay(20);
        while(KeyDown==0)
        {
                n--;
                for(y=0;y<20;y++)
                {
                        if(n<=0)n=0;
                }
        }
        Delay(20);
        n=n-5;
        if(n<=0)n=0;
}
return n;
}
程序這樣編的,外部中斷能進(jìn)去,定時器中斷好像沒作用,key.c我想寫的是,按下按鍵不松手就會一直n++亮度會遞增,按鍵松手就n+5亮度階梯增加,兩個功能一個是按下不松手亮度逐漸變化,一個是按下松手每按一下亮度變化一下
作者: WL0123    時間: 2024-12-2 11:11
仿真不能看出燈光亮度變化,可以用仿真軟件自帶的虛擬示波器看導(dǎo)通角波形以證實調(diào)光。




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1