一款 Sauna 控制器控制器原理图

2020-01-13 18:39发布

<p> 闲话少说,上原理图。链接:https://pan.baidu.com/s/1VY-AQ1rRtxLioNI49VaMLQ&nbsp;</p><p>提取码:h667</p><p> 按钮的处理的办法很好,节约了很多IO口。</p><br> <br><p> 此处只给出数码管扫描、按键读取的函数,注意下某些IO口的模式变化。其它程序都是浮云~~~~</p><br><p> //1ms中断,用于数码管扫描、按键检测</p><br><p> void Timer0Interrupt(void) interrupt 1</p><br><p> {</p><br><p> &nbsp; &nbsp; TH0 = 0xFC;</p><br><p> &nbsp; &nbsp; TL0 = 0x18;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; //add your code here!</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; bit_con++; if(bit_con&gt;6) bit_con=0;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; ms_100_con++;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; ms_1_con++;</p><br> <br><p> &nbsp; &nbsp; &nbsp; &nbsp; //关闭所有数码管,消隐</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; LED1_A = 0;LED2_A = 0;LED3_A = 0;LED4_A = 0;LED5_A = 0;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; switch(bit_con)</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; {</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;case 0:&nbsp;&nbsp;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; //检测按钮</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;key_value = 0; cn_value = 0;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;for(key_tab_con=0;key_tab_con&lt;8;key_tab_con++)</p><br><!--8--><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;{</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;put_one_char(~KEY_TAB[key_tab_con]);&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;//依次输出按键扫描码A-H</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;if(!KEY_in) key_value = key_value + KEY_TAB[key_tab_con];</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;if(!CN_in)&nbsp;&nbsp;cn_value&nbsp;&nbsp;=&nbsp;&nbsp;cn_value + KEY_TAB[key_tab_con];</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;}</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;//if(key_value) key_flg = 1;&nbsp; &nbsp; &nbsp; &nbsp; </p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;//if(cn_value) cn_flg = 1;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; //检测按钮结束</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;break;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;case 1: //LED1</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;put_one_char(Led_show_buf[0]);</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;LED1_A = 1;LED2_A = 0;LED3_A = 0;LED4_A = 0;LED5_A = 0;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;break;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;case 2: //LED2</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;put_one_char(Led_show_buf[1]);</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; LED1_A = 0;LED2_A = 1;LED3_A = 0;LED4_A = 0;LED5_A = 0;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;break;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;case 3: //LED3</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;put_one_char(Led_show_buf[2]);</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; LED1_A = 0;LED2_A = 0;LED3_A = 1;LED4_A = 0;LED5_A = 0;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;break;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;case 4: //LED4</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;put_one_char(Led_show_buf[3]);</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; LED1_A = 0;LED2_A = 0;LED3_A = 0;LED4_A = 1;LED5_A = 0;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;break;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;case 5: //LED5</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;put_one_char(Led_show_buf[4]);</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; LED1_A = 0;LED2_A = 0;LED3_A = 0;LED4_A = 0;LED5_A = 1;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;break;</p><br> <br><p> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;default:</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; break;</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; }</p><br> &nbsp; &nbsp; &nbsp; &nbsp; <br><p> }</p><br><p> /*******************************/</p><br><p> /*&nbsp; &nbsp;*&nbsp;&nbsp;『 164写1个数码管 』 *&nbsp;&nbsp;*/</p><br><p> /*******************************/&nbsp;&nbsp;</p><br><p> void put_one_char(uchar data_char)</p><br><p> {</p><br><p> &nbsp;&nbsp;uchar temp; </p><br><p> &nbsp;&nbsp;temp=data_char;</p><br><p> &nbsp;&nbsp;P3M1 = 0x00; //P1强推挽输出</p><br><p> &nbsp;&nbsp;P3M0 = 0xbf;</p><br><p> &nbsp;&nbsp;for (i=0;i&lt;8;i++)&nbsp;&nbsp;</p><br><!--8--><p> &nbsp;&nbsp;{ </p><br><p> &nbsp; &nbsp; CLK_164 = 0;//拉低74HC164时钟 &nbsp; &nbsp; &nbsp; &nbsp; </p><br><p> &nbsp; &nbsp; if(temp&amp;0x80)</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;DAT_164 = 1;</p><br><p> &nbsp; &nbsp; else</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;DAT_164 = 0; </p><br><p> &nbsp; &nbsp; temp=temp&lt;&lt;1;//左移一位数据,先发高位&nbsp; &nbsp; &nbsp; &nbsp; </p><br><!--1--><p> &nbsp; &nbsp; CLK_164 = 1;//拉高74HC164时钟 </p><br><p> &nbsp;&nbsp;}&nbsp;&nbsp;</p><br><p> &nbsp;&nbsp;DAT_164 = 1;</p><br><p> &nbsp;&nbsp;CLK_164 = 0; </p><br> &nbsp; &nbsp;<br><p> &nbsp;&nbsp;P3M1 = 0x20; //P34、P35输入、其余强推挽输出</p><br><p> &nbsp;&nbsp;P3M0 = 0x8f; </p><br><p> &nbsp;&nbsp;_nop_();_nop_();_nop_();_nop_();</p><br><p> }</p><br> <br><p> 为了布线方便(仔细看图纸),数码管的接线也是不一般的,所以字符表也就不一般了。</p><br><p> code unsigned char SMG_1_3_5_TAB[]= {</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0xC0,/*0*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0xFC,/*1*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x4A,/*2*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x68,/*3*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x74,/*4*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x61,/*5*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x41,/*6*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0xF8,/*7*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x40,/*8*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x60,/*9*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x7f,/*-*/ //0x50,/*A*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0xbf,/* */ //0x45,/*b*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0xC3,/*C*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x4C,/*d*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x43,/*E*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x53,/*F*/</p><br><p> };</p><br><p> code unsigned char SMG_2_4_TAB[]= {</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x21,/*0*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x6F,/*1*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x34,/*2*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x64,/*3*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x6A,/*4*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0xE0,/*5*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0xA0,/*6*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x67,/*7*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x20,/*8*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x60,/*9*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0xfe,/*-*/ //0x22,/*A*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0xff,/*b*/ //0xA8,/*b*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0xB1,/*C*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x2C,/*d*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0xB0,/*E*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0xB2,/*F*/</p><br><p> };</p><br><p> //扫描按键用的</p><br><p> code unsigned char KEY_TAB[8]={</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x01,/*A*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x02,/*B*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x04,/*C*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x08,/*D*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x10,/*E*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x20,/*F*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x40,/*G*/</p><br><p> &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;0x80 /*H*/</p><br><p> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; };</p><br> <br><p> ----------------------分割线下面才是我的目的----------------------------------</p><br><p> 找人(招聘),前一段时间,有个女孩子到我们公司面试(铜山新区,润泽电气),当时你说要把目前手头的工作完成才可以~~。不巧的事,人事部门主管后来离职了,你的资料我找不到了,所以借此找找你,我的邮箱64785674在163点公司。谢谢。</p><br> <br><p> 招聘硬件设计工程师,要求:徐州人,有工作经验,工作经验要求硬件设计&gt;2年(含非常爱恋电子设计的新手)。 </p><p><br></p>
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
23条回答
outt60777
2020-01-14 22:14
非常谢谢。这个说明非常详细。

有一个问题:
//关闭所有数码管,消隐
        LED1_A = 0;LED2_A = 0;LED3_A = 0;LED4_A = 0;LED5_A = 0;

你的数码管都是共阳。三极管是pnp。如果拉底,那就是vdd通电。

通电,怎么是关led呢?
·················································
是我看错了。其实是NPN,而不是pnp。9013

一周热门 更多>