导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→发表看法:[wanglian13][求助]求教,抗干扰



No.31854
作者:wanglian13
邮件:yuqingwa@public1.sz.js.cn
ID:12487
登陆:2次
文章数:1篇
最后登陆IP:218.4.164.33
最后登陆:2003/6/18 4:10:56
注册:2003/5/24 18:43:18
财富:55
发帖时间:2003/5/24 18:45:12
发贴者IP:61.155.173.194
标题:wanglian13:[求助]求教,抗干扰
摘要:No.31854[求助]求教,抗干扰 求教,抗干扰
    1. 有一电路,见上传,FinglishiLed.sch,由CPU(pic16c73)控制继电器,继电器控制40W日光灯。
    2. 功能已实现,当人按开关,CPU接到开关命令后,打开日光灯,大概工作30--300次不等时,总发生死机,LED显示全无,且不接收任何命令。
    3. CPU内已开启看门狗,不起作用,但用示波器看晶振似乎跳动。

   // watdog is not timo


 #if defined(__PCM__)
#include   <16f73.h>  

#fuses XT,WDT,NOPROTECT    //NOWDT
#use delay(clock=4000000)

#define uchar unsigned char
#define uint unsigned int
//uint   time2s;time40s;

#byte port_b=6


#define jijinDec PIN_A0
//#define  PIN_A1
#define Light_Dec PIN_B7
#define Left PIN_C5
#define Right PIN_C2
#define spkrF PIN_A5

//#define  LightB   PIN_B0
#define DoorB  PIN_A4
//#define spkrA   PIN_B2
//#define LightA  PIN_B3
#define DoorA  PIN_A3
#define Fengji  PIN_C1
#define Light_Ce PIN_C0
//#define BellDoorc PIN_B7

//#define    LcdDat PIN_C0
//#define    LcdClk     PIN_C1
//#define    LOADPIN     PIN_C2
//#define    LcdCom      PIN_B7


//#define         PIN_C2
//#define         PIN_C3
//#define         PIN_C4

#define    detDoorB     PIN_A2
#define    detDoorA     PIN_A1
//#define    spkrB        PIN_C7

#define INTS_PER_SECOND 76     // (20000000/(4*256*256))


//#include   <input.c>  
#include   <24041.c>  

int16 seconds;      // A running seconds counter
byte int_count;    // Number of interrupts left before a second has elapsed
byte int_num1;
byte lightbiao;
byte DAfirst;
uchar  disdata[3];
byte waitnum,waitnum1;
//byte lcdcomBZ;
byte doorOpen;
byte ledon;
//int16 wdtNum;

void wait() {           // This function waits for either ~2ms or until a
  int countdown;        // event happens (in this case a rs232 character)

  countdown=200;
  while(--countdown!=0)
    delay_us(10);
}


void  wait_times(uint waitnum)  // about 1 s
{
  uint i,j;
  for (j=0; j  <waitnum;j++)
  {
   for (i=0; i  <97;i++)
   delay_ms(10);
   restart_wdt();                        // sets timer to interrupt in 200us
  }

}


void  wait_times_openA(uint waitnum)  // about 1 s
{
  uint i,j;
  for (j=0; j  <waitnum;j++)
  {
   for (i=0; i  <100;i++)
   delay_ms(6);
   if(input(detDoorA))
   {
    doorOpen=0;
    break;

   }
   restart_wdt();                        // sets timer to interrupt in 200us
  }

}


void  wait_times_openB(uint waitnum)  // about 1 s
{
  uint i,j;
  for (j=0; j  <waitnum;j++)
  {
   for (i=0; i  <100;i++)
   delay_ms(6);
   if(input(detDoorB))
   {
    doorOpen=0;
    break;

   }

   restart_wdt();                        // sets timer to interrupt in 200us
  }

}

/*

void LCD(uchar  ccdata)
{

    uchar i,j;

      i=8;
      output_high(LOADPIN);


        do
        {

         if((int1)(ccdata&0x01))
                  output_high(LcdDat);
         else
            output_low(LcdDat);
                   output_high(LcdClk);
    output_low(LcdClk);
          output_high(LcdClk);
    ccdata>  >  =1;
        }while(--i!=0);
  output_low(LOADPIN);
}
*/
/////////////0403b  6f 0c 76 3-5e 1d 5b 7b 0e 7f 9-5f


////   Ma-RB6,mb-rb5,mc-rb4,md-rb3,me-rb3,mf-rb1,mg-rb0, com yang


//byte  disdata[3];

static struct
{
  uchar ascii;
        uchar stroke;
} CONST led_stroke[27]=        {{'0',0x81},{'1',0xcf},{'2',0x92},{'3',0x86},{'4',0xcc},   {'5',0xa4},{'6',0xa0},{'7',0x8f},{'8',0x80},{'9',0x84},  {'E',0xb0},{'-',0x81},{'.',0x20},{0x00,0x00},{0xff,0xff},  };


uchar get_stroke(uchar c)
{
  uchar i=0;
  while(led_stroke[i].ascii != c) i++;

  return(led_stroke[i].stroke);
}

uchar kbscan(void)   /*  4key   */
{
   if (!input(detDoorA)||!input(detDoorB)||!input(jijinDec)||!input(Right)||!input(Left)||!input(Light_Dec))  //(detDoorA 1; detDoorB 2; jijinDec 3; Right 4; Left 5; Light_Dec 6;
    {
  delay_ms(10);

    {if (input(detDoorA)==0)

    {
     delay_ms(10);
      {if (input(detDoorA)==0)

       return(1);
      }
    }
   }


    {if(input(detDoorB)==0)
    {
     delay_ms(10);
     {if(input(detDoorB)==0)

      return(2);}
    }}


    {if(input(jijinDec)==0)
    {  delay_ms(10);
      {if(input(jijinDec)==0)

       return(3);}
    }}

    {if(input(Right)==0)
    {  delay_ms(10);
      {if(input(Right)==0)
            {output_low(spkrF);
       delay_ms(140);
       output_high(spkrF);
       return(4);}}
    }}

   {if(input(Left)==0)
    {  delay_ms(10);
      {if(input(Left)==0)
           { output_low(spkrF);
       delay_ms(140);
       output_high(spkrF);
       return(5);}}
    }}

    {if(input(Light_Dec)==0)
    {  delay_ms(10);
      {if(input(Light_Dec)==0)
             {output_low(spkrF);
       delay_ms(140);
       output_high(spkrF);
       return(6);}}
    }}


      }

 else  return(0);
}

void detDoorAF(void)  //before door open for doora
{

  output_low(DoorB);  //   high
  output_high(DoorA);
  //DAfirst=1;

}


void detDoorBF(void)
{
  output_low(DoorA);  //   low
  output_high(DoorB);
  //DBfirst=1;
}
/*
void jijinDecF(void)
{
// DAfirst=1;DBfirst=0;

 if (DAfirst==1)
 { DAfirst=0;
  output_high(Fengji);
  output_high(DoorB);  //
  output_high(DoorA);

  wait_times(waitnum);
  output_low(Fengji);
  output_low(DoorB);   //
  output_low(DoorA);
  //wait_times(waitnum);
 }

}

*/
//void RightF(void){output_high(spkrA);}
//void LeftF(void){output_high(spkrB);}

void Light_DecF(void)
{ if (lightbiao==1)
 {
  output_high(Light_Ce);   //high

  lightbiao=0;
 }
 else
 {
  output_low(Light_Ce);
  lightbiao=1;
 }
}


void key_chuli(uchar key)     //if (!detDoorA||!detDoorB||!jijinDec||!Right||!Left||!Light_Dec)  //(detDoorA 1; detDoorB 2; jijinDec 3; Right 4; Left 5; Light_Dec 6;
{
  // uchar key,speed_d_temp,JumpMark=1;
  // uint i;
  //uchar key;
 // key = kbscan();


      switch (key)

   {              //sw
    case 0:

    break;

    case 1:

    detDoorAF();
    seconds=0;
    doorOpen=1;
     while ((input(detDoorA)==0)&&(doorOpen==1))
      {
      //  if(input(jijinDec)==0)
        // {
       // delay_ms(10);
       // if(input(jijinDec)==0)
       // jijinDecF();
      // }

       restart_wdt();                        // sets timer to interrupt in 200us

        if (seconds>  1200)
         {
          if ((seconds>  1200)&&(seconds  <6600))
          {
           //restart_wdt();                        // sets timer to interrupt in 200us
          output_low(spkrF);
         // output_high(spkrB);
         // output_high(spkrA);
        //   output_low(LightB);
                //   output_low(LightA);

          delay_ms(110);  //140
          //  output_low(spkrA);   //sound off
                    //  output_low(spkrB);   //sound  off
                       output_high(spkrF);
       //   output_high(LightB);
                //   output_high(LightA);
         //restart_wdt();
         //wait_times(1);
         wait_times_openA(3);

                  }

          if (seconds>  6599)
              {
              output_high(DoorA);  //  low
              output_high(DoorB);
              output_low(spkrF);
          // output ......

>>返回讨论的主题



  发表回复
用户名   *您没有注册?
密码   *
验证码   * .
标题   *
心情
随便说说    我回答你    最新发现    得意的笑   
气死我了    真是没劲    坚决同意    表示反对   
大家过来    好奇怪哟    懒得理它    大家小心   
文件上传
内容


字体:      字体大小:    颜色:
粗体 斜体 下划线 居中 超级连接 Email连接 图片 Flash图片 Shockwave文件 realplay视频文件 Media Player视频文件 QuickTime视频文件 引用 飞行字 移动字 发光字 阴影字 查看更多的心情图标 背景音乐
点击加入表情
                         
选项
有回复时用短消息通知您?

   




老古网执行:47毫秒 最大:8312毫秒 查询6次