|
拜 FATZEROS大的指導和提供材料&資料,終於把電路板給 "洗"了出來,距離上次氯化鐵洗PCB的時間應該有30年吧!!
使用 DIP TRACE 把 32PIN MCU弄出來, 使用 雷射印表機印出 相反(MIRROR) 的圖案,然後再一次印到"轉印紙"上面,這個階段最容易"脫落",使用3M膠帶把轉印紙固定到一般紙上面,這樣成功率會高一些!!
接下來把 轉印紙的圖案 用電熨斗 熱轉印到 空白電路板上面, 條件 溫度設定在 毛與棉之間,時間2分鐘!
轉印後若有遺漏可以使用油性簽字筆補強(效果會打折扣)
蝕刻的時間約 90分鐘~ 2小時(靜置方式) 蝕刻液體的濃度有關!!
蝕刻完畢用清水沖洗,水分去除後,使用 松香+松香水的溶液把碳粉圖案去除並有"助焊"功能
鑽孔接PIN腳使用 1.0mm 一般零件使用 0.8mm 鑽頭
第一版 錯誤很多 最大的錯誤是 SWIN RESET VCC GND 下載接點忘了放上去,要把 MCU的PIN 接出來真的很辛苦!!
第二版有考慮到 負載效應放了一些 DUMMY PAD
為了怕碳粉附著性不好,蝕刻會因為 UNDER CUT 造成斷線,刻意把線加粗,把鑽孔點取消,結果鑽洞會亂跑...
作了一個溫度計時鐘(AD轉換+TIMER) 時間一天慢三分..
第三版把連接線變細(0.03 >>0.02) 鑽孔點也露出,還是漏了幾條線和一個電容器
這次作的是 DHT11 的溫溼度計
使用 MCU有一個好處就是,LAYOUT 時因為 零件的配置需要,可以變更 MCU的腳位,只要在程式上面定義改一下就能配合,當然這也不是萬能的!!
- //for bread board setting
- /*
- #include "stm8s.h"
- #include "stm8s_clk.h"
- #include "stm8s_tim4.h"
- #define DHT_Port GPIOD
- #define DHT_data GPIO_PIN_2
- #define LEDPORT GPIOA
- #define DIN GPIO_PIN_1 //
- #define STB GPIO_PIN_2 //3
- #define Clk GPIO_PIN_3 //2
- #define LED2PORT GPIOD
- #define STB2 GPIO_PIN_4
- */
- //for PCB layout setting
- #include "stm8s.h"
- #include "stm8s_clk.h"
- #include "stm8s_tim4.h"
- #define DHT_Port GPIOF
- #define DHT_data GPIO_PIN_4
- #define LEDPORT GPIOC
- #define DIN GPIO_PIN_4 //
- #define STB GPIO_PIN_2 //3
- #define Clk GPIO_PIN_3 //2
- #define LED2PORT GPIOC
- #define STB2 GPIO_PIN_1
- u8 a,b,tg,th;
- u8 count80,count81;//計數時間
- u8 DHT_get;
- u8 DHT[5];
- display_2table[20]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,0x87,0xff,0xef};
- u16 display_time;
- u16 DHTI1,DHTBuf1;//avg humidity
- u16 DHTI2,DHTBuf2;//avg temperature
- u8 display_flag;
- u8 avg_count;
- void Delayus(u16 ust)//
- {
- while(ust !=0)
- {
- ust--;
- }
- }
- void DelayMs(u16 mst)
- {
- while( mst !=0)
- {
- Delayus(1315);//164
- mst--;
- }
- }
- void GPIOinit(void)
- {
- GPIO_Init(LEDPORT,DIN|STB|Clk|STB2,GPIO_MODE_OUT_PP_HIGH_FAST);//for LCM driver
- GPIO_Init(LED2PORT,STB2,GPIO_MODE_OUT_PP_HIGH_FAST);//for LCM driver-------------STB independence
- }
-
- /*
- 20141116 send Databyte
- */
- void Send6961_Data(u8 Dat)
- {
- u8 i;
- GPIO_WriteLow(LEDPORT,STB);
-
- for (i=0;i<8;i++)
- {
- if((Dat & 0x01)!=0)// SER=Dat & 0x80;
- {
- GPIO_WriteHigh(LEDPORT,DIN);
- }
- else
- {
- GPIO_WriteLow(LEDPORT,DIN);
- }
- Dat>>=1;
- GPIO_WriteLow(LEDPORT,Clk);// GPIO_WriteLow(LEDPORT,Clk);
- GPIO_WriteHigh(LEDPORT,Clk);
- }
- GPIO_WriteLow(LEDPORT,STB);
- }
- /*
- 20141116 send command byte
- */
- void Send6961_Cmd(u8 Dat)
- {
- u8 i;
- GPIO_WriteHigh(LEDPORT,STB);
- GPIO_WriteLow(LEDPORT,STB);
-
- for (i=0;i<8;i++)
- {
- if((Dat & 0x01)!=0)// SER=Dat & 0x80;
- {
- GPIO_WriteHigh(LEDPORT,DIN);
- }
- else
- {
- GPIO_WriteLow(LEDPORT,DIN);
- }
- Dat>>=1;
- GPIO_WriteLow(LEDPORT,Clk);// Clk=0;
- GPIO_WriteHigh(LEDPORT,Clk);
- }
- GPIO_WriteHigh(LEDPORT,STB);
- }
- //LED2
- void Send6961_Cmd2(u8 Dat)
- {
- u8 i;
- GPIO_WriteHigh(LED2PORT,STB2);
- GPIO_WriteLow(LED2PORT,STB2);
-
- for (i=0;i<8;i++)
- {
- if((Dat & 0x01)!=0)// SER=Dat & 0x80;
- {
- GPIO_WriteHigh(LEDPORT,DIN);
- }
- else
- {
- GPIO_WriteLow(LEDPORT,DIN);
- }
- Dat>>=1;
- GPIO_WriteLow(LEDPORT,Clk);// Clk=0;
- GPIO_WriteHigh(LEDPORT,Clk);
- }
- GPIO_WriteHigh(LED2PORT,STB2);
- }
- void Send6961_Data2(u8 Dat)
- {
- u8 i;
- GPIO_WriteLow(LED2PORT,STB2);
- GPIO_WriteLow(LED2PORT,STB2);
-
- for (i=0;i<8;i++)
- {
- if((Dat & 0x01)!=0)// SER=Dat & 0x80;
- {
- GPIO_WriteHigh(LEDPORT,DIN);
- }
- else
- {
- GPIO_WriteLow(LEDPORT,DIN);
- }
- Dat>>=1;
- GPIO_WriteLow(LEDPORT,Clk);// Clk=0;
- GPIO_WriteHigh(LEDPORT,Clk);
- }
- GPIO_WriteLow(LED2PORT,STB2);
- }
- void PT6961_Init(void) // 8bit mode
- {
- DelayMs(200);
- Send6961_Cmd(0x40);//CMD 2 fix address normal mode
- Send6961_Cmd(0xc0);//CMD 3 address=0
- Send6961_Data(0x0);
- Send6961_Data(0x00);
- Send6961_Data(0x00);
- Send6961_Data(0x00);
- Send6961_Cmd(0x02);//CMD 1 6digit 12segment
- Send6961_Cmd(0x89);//CMD 4 display control bright 14/16
- DelayMs(1);
-
- // DelayMs(200);
- Send6961_Cmd2(0x40);//CMD 2 fix address normal mode
- Send6961_Cmd2(0xc0);//CMD 3 address=0
- Send6961_Data2(0x0);
- Send6961_Data2(0x00);
- Send6961_Data2(0x00);
- Send6961_Data2(0x00);
- Send6961_Cmd2(0x02);//CMD 1 6digit 12segment
- Send6961_Cmd2(0x89);//CMD 4 display control bright 14/16
- DelayMs(1);
- }
- void DEMO_display(void)
- {//display humidity
- Send6961_Cmd(0x40);//CMD 2 fix address normal mode
- Send6961_Cmd(0xc0);//CMD 3 address=0
- Send6961_Data(0xf0);//空白
- Send6961_Data(display_2table[a]);//5
- Send6961_Data(0xf0);//空白
- Send6961_Data(display_2table[b]);//5
- Send6961_Data(0xf0);//空白
- Send6961_Data(0x50);//r
- Send6961_Data(0xf0);//空白
- Send6961_Data(0x76);//H
- Send6961_Cmd(0x02);//CMD 1 6digit 12segment
- Send6961_Cmd(0x89);//CMD 4 display control bright 14/16
- DelayMs(1);
- }
- void DEMO_display1(void)
- {
- //display temperature
- Send6961_Cmd2(0x40);//CMD 2 fix address normal mode
- Send6961_Cmd2(0xc0);//CMD 3 address=0
- Send6961_Data2(0xf0);//空白
- Send6961_Data2(display_2table[tg]);//5
- Send6961_Data2(0xf0);//空白
- Send6961_Data2(display_2table[th]);//5
- Send6961_Data2(0xf0);//空?
- Send6961_Data2(0x63);//5?
- Send6961_Data2(0xf0);//空白
- Send6961_Data2(0x39);//C
- Send6961_Cmd2(0x02);//CMD 1 6digit 12segment
- Send6961_Cmd2(0x89);//CMD 4 display control bright 14/16
- DelayMs(1);
- }
- void TransData(void)
- {
- DHTI1/= 6;
- DHTI2/= 6;
- a=DHTI1/10;
- b=DHTI1%10;
- tg=DHTI2/10;
- th=DHTI2%10;
- DHTI1=0;
- DHTI2=0;
- }
- void DHT_Start(void)
- {
- GPIO_Init(DHT_Port,DHT_data,GPIO_MODE_OUT_PP_HIGH_FAST);
- GPIO_WriteLow(DHT_Port,DHT_data);
- DelayMs(18);//18.17ms
- GPIO_WriteHigh(DHT_Port,DHT_data);//10us
- Delayus(20);
- }
- u8 DHT_Read(void)
- {
- u8 i, j,pulse,k;
- pulse=0;
- count81=0;
- while(!GPIO_ReadInputPin(DHT_Port,DHT_data));
- while(GPIO_ReadInputPin(DHT_Port,DHT_data));
- for(i=0;i<5;i++)
- {
- for (j=0;j<8;j++)
- {
- while(!GPIO_ReadInputPin(DHT_Port,DHT_data));
- while(GPIO_ReadInputPin(DHT_Port,DHT_data))
- {
- count81++;
- }
- pulse<<=1;
- if(count81>20)
- pulse +=1;
- else
- pulse +=0;
- count81=0;
- }
- DHT[i]=pulse;
- pulse=0;
- }
- }
- void tim4init(void)
- {
- TIM4_TimeBaseInit(TIM4_PRESCALER_128,250);//16m/128/250=500=2ms
- TIM4_SetCounter(250);
- TIM4_ITConfig(TIM4_IT_UPDATE,ENABLE);//2Mhz/8/250
- TIM4_Cmd(ENABLE);
- }
- void tim4svc(void)
- {
- display_time++;
- if(display_time==200)//10us
- {
- DHT_Start();//送出讀取的指令
- GPIO_Init(DHT_Port,DHT_data,GPIO_MODE_IN_PU_NO_IT);//此一 設定大大會影響 時間所以要獨立出來
- DHT_Read();
- DelayMs(1);
- avg_count++;
- DHTBuf1 += (u16)DHT[0];
- DHTBuf2 += (u16)DHT[2];
- display_time=0;
- if(avg_count>5)
- {
- DHTI1=DHTBuf1;
- DHTI2=DHTBuf2;
- display_flag=1;
- avg_count=0;
- DHTBuf1=0;
- DHTBuf2=0;
- }
- }
- TIM4_ClearITPendingBit(TIM4_IT_UPDATE);
- }
- main()
- {
- GPIOinit();//顯示用
- PT6961_Init();
- tim4init();
- rim();
-
- CLK_HSIPrescalerConfig(CLK_PRESCALER_HSIDIV1);//以16m速度 進行
- GPIO_Init(DHT_Port,DHT_data,GPIO_MODE_OUT_PP_HIGH_FAST);
- while (1)
- {
- if(display_flag==1)
- {
- TransData();
- DEMO_display1();
- DEMO_display();
- display_flag=0;
- }
- }
-
- }
- /*
- @far @interrupt void TIM1_OVF_IRQ(void)
- {
- tim1svc();
- }
- */
- @far @interrupt void TIM4_OVF_IRQ(void)
- {
- tim4svc();
- }
- #ifdef USE_FULL_ASSERT
- /**
- * @brief Reports the name of the source file and the source line number
- * where the assert_param error has occurred.
- * @param file: pointer to the source file name
- * @param line: assert_param error line source number
- * @retval : None
- */
- void assert_failed(u8* file, u32 line)
- {
- /* User can add his own implementation to report the file name and line number,
- ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
- /* Infinite loop */
- while (1)
- {
- }
- }
- #endif
- /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
複製代碼
|
評分
-
20
查看全部評分
-
|