LED数显太阳能充电控制器基本资料介绍.doc_第1页
LED数显太阳能充电控制器基本资料介绍.doc_第2页
LED数显太阳能充电控制器基本资料介绍.doc_第3页
LED数显太阳能充电控制器基本资料介绍.doc_第4页
LED数显太阳能充电控制器基本资料介绍.doc_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

led太阳能充电控制器原理图第一层原理图第二层原理图第三层原理图pcb版图拼版图(pcb)pcb打样仿真图仿真图(proteus)实物图实物图(1)实物图(2)实物图(3)源程序/*|=太阳能充电控制器=|使用芯片:atmega8a软件设计人:何涛工程开始时间:2012.06.12联系电话珠海)qq:562673469=|*/*74hc164.c*/#include app.hvoid show_164(unsigned char _showvalue) unsigned char count0; for(count0=0;count0=1; portd=portd&0xfd; /clk 0 /delay(1); portd=portd|0x02; /clk 1 /delay(10); portd=portd|0x02; /clk 1 /*74hc164.h*/void show_164(unsigned char _showvalue);/*ad.c*/#include app.h/*adc*/void adc_init(int8u channel) /*/ switch(channel)/aref2.56v adlar channelcase 0:admux=0xc0+0;break;case 1:admux=0xc0+1;break;case 2:admux=0xc0+2;break;case 3:admux=0xc0+3;break;case 4:admux=0xc0+4;break;case 5:admux=0xc0+5;break;case 6:admux=0xc0+6;break;case 7:admux=0xc0+7;break;default:break; adcsra=0x00;/ 16int16u adc_start(int8u channel) int8u temp_l; int8u temp_h;int16u ad_data;switch(channel)case 0:admux=0xc0+0;break;case 1:admux=0xc0+1;break;case 2:admux=0xc0+2;break;case 3:admux=0xc0+3;break;case 4:admux=0xc0+4;break;case 5:admux=0xc0+5;break;case 6:admux=0xc0+6;break;case 7:admux=0xc0+7;break;default:break; adcsra |=0xc0;/ad temp_l=adcl; temp_h=adch;ad_data=temp_h*256+temp_l;adcsra =0x80;/ad switch(channel)case 0:admux=0xc0+0;break;case 1:admux=0xc0+1;break;case 2:admux=0xc0+2;break;case 3:admux=0xc0+3;break;case 4:admux=0xc0+4;break;case 5:admux=0xc0+5;break;case 6:admux=0xc0+6;break;case 7:admux=0xc0+7;break;default:break; adcsra |=0xc0;/ad temp_l=adcl; temp_h=adch; ad_data=temp_h*256+temp_l;adcsra =0x80;/ad return(ad_data);void ad_select(int8u channel) switch(channel) case 0:led_num20=adc_start(6)/4;break;/uxx.x 10 case 1:led_num21=adc_start(7)/4;break;/axx.x case 2:led_num22=adc_start(0)/4;break;/bxx.x case 3:led_num23=adc_start(1)/4;break;/cxx.x /*ad.h*/void adc_init(unsigned char channel);unsigned int adc_start(unsigned char channel);void ad_select(unsigned char channel);/*app.h*/#include #include #include /#include kernel.h/#include task.h#include misc.h#include initial.h#include 74hc164.h#include delay.h#include led.h#include ad.h#include eeprom.h/*delay.h*/#include app.hunsigned int min = 0;/unsigned int sec = 0;/void delay(unsigned int a) unsigned int i,j; for(i=0;ia;i+) for(j=0;j59) sec = 0; min +; /*delay.h*/extern unsigned int min;/extern unsigned int sec;/extern unsigned int count,flag_count;/void delay(unsigned int a);void solarcount(void);/*eeprom.h*/#include app.hvoid eeprom_init(void) int8u i=0; flag_0 =eepromread(1); flag_3 =eepromread(4); flag_4 =eepromread(5); flag_5 =eepromread(6); flag_6 =eepromread(7); flag_7 =eepromread(8); flag_9 =eepromread(10); flag_10=eepromread(11);void eeprom_start(void) eepromwrite(1,flag_0); eepromwrite(4,flag_3); eepromwrite(5,flag_4); eepromwrite(6,flag_5); eepromwrite(7,flag_6); eepromwrite(8,flag_7);/125 eepromwrite(10,flag_9); eepromwrite(11,flag_10);void eeprom_recover(void) eepromwrite(1,6); eepromwrite(4,50); eepromwrite(5,108); eepromwrite(6,144); eepromwrite(7,0); eepromwrite(8,125); eepromwrite(10,0); eepromwrite(11,0); /*eeprom.c*/void eeprom_init(void);void eeprom_start(void);void eeprom_recover(void);/*initial.c*/#include app.hint16u time1=3;void gpio_init(void);void timer1_init(void);void timer2_init(void);void interrupt_init(void);void battery_init(void);void hardware_init(void) adc_init(6); eeprom_init(); gpio_init();timer1_init(); timer2_init(); interrupt_init();battery_init(); void battery_init(void) int16u i=4,j=5; while(time1)/6s if(flag_count=1) time1-;flag_count=0; display4(time1); while(i-) while(j-) display1(windows_1,120); portd=0xff; delay(1000); j=8; / delay(100); /*void gpio_init(void)ddrb = 0xdf; /pb5portb = 0x20; ddrc = 0x00;portc = 0xff; ddrd = 0xff; portd = 0xff; /timer1 initialize - prescale:1024/ wgm: 0) normal, top=0xffff/ desired value: 1hz/ actual value: 1.000hz (0.0%)void timer1_init(void) tccr1b = 0x00; /stop tcnt1h = 0xff; /setup tcnt1l = 0xb2; ocr1ah = 0x00; ocr1al = 0x4e; ocr1bh = 0x00; ocr1bl = 0x4e; icr1h = 0x00; icr1l = 0x4e; tccr1a = 0x00; tccr1b = 0x05; /start timer timsk |= 0x10;/avoid timer2_init(void) tccr2 = 0x00; /stop assr = 0x00; /set async mode tccr2 = 0x0f; /start tcnt2 = 0x00; /setup ocr2 = 0x4d; timsk|= 0x80; void interrupt_init(void)sreg |= 0x80; /enable global interrupt/*initial.h*/void hardware_init(void);/*interputl.c*/#include app.hunsigned int count=0,flag_count=0;/#pragma interrupt_handler timer1_interrupt:7void timer1_interrupt(void)/clear timer2 ocif flagtifr |= 0x10; tcnt2 = 0x00;#pragma interrupt_handler timer2_interrupt:4void timer2_interrupt(void)tifr |= 0x80;/clear timer2 ocif flag tcnt2 = 0x00;count+;if(count100) count=0; flag_count=1;/1s solarcount();/if(flag_timestart!=1)/min=0;/*lcd.c*/#include app.hint8u led_num=0x28,/*0*/ 0xeb,/*1*/ 0x32,/*2*/ 0xa2,/*3*/ 0xe1,/*4*/ 0xa4,/*5*/ 0x24,/*6*/ 0xea,/*7*/ 0x20,/*8*/ 0xa0,/*9*/ 0x60,/*a*/ 0x25,/*b*/ 0x3c,/*c*/ 0x74,/*f*/ 0x29,/*u*/ 0xff,/* 15*/;/int8u led_num1=0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,0x08,0x03,0x46,0x0e,0x41; /+int8u led_num1= 0x08,/*0*/ 0xcb,/*1*/ 0x12,/*2*/ 0x82,/*3*/ 0xc1,/*4*/ 0x84,/*5*/ 0x04,/*6*/ 0xca,/*7*/ 0x00,/*8*/ 0x80,/*9*/ 0x40,/*a*/ 0x05,/*b*/ 0x1c,/*c*/ 0x54,/*f*/ 0x09,/*u*/ 0xff,/* 15*/ ;int8u led_num2=0,1,2,3;int16u fixed_time=1,5,10,60,120,180,240,300,360,420,480,540,600,660,720;/14void display2(int8u value);void display3(int8u value);void display1(int8u windows,int8u value) int8u s=value; if(windows=0) /1 uxx.x show_164(led_num14); portd=0xd8; delay(10); if(windows=1) /2 axx.x b show_164(led_num10); portd=0xd8; delay(10); if(windows=2) /3 bxx.x a show_164(led_num11); portd=0xd8; delay(10); if(windows=3) /4 cxx.x show_164(led_num12); portd=0xd8; delay(10); show_164(led_nums/100); portd=0x78; delay(10); show_164(led_num1s%100/10); portd=0xb8; delay(10); show_164(led_nums%10); portd=0xe8; delay(10); void display2(int8u value) int8u s=value; show_164(led_num113); /f.xxx portd=0xd8; delay(10); show_164(led_num0); portd=0x78; delay(10); show_164(led_nums/10); portd=0xb8; delay(10); show_164(led_nums%10); portd=0xe8; delay(10); void display3(int8u value) int8u s=value; show_164(led_nums/100); portd=0xd8; delay(10); show_164(led_num1s%100/10); portd=0x78; delay(10); show_164(led_nums%10); portd=0xb8; delay(10); show_164(led_num14); /xx.xu portd=0xe8; delay(10); void display4(int16u value)/ xxxx int16u t=value; show_164(led_numt/1000); portd=0xd8; delay(10); show_164(led_numt%1000/100); portd=0x78; delay(10); show_164(led_numt%100/10); portd=0xb8; delay(10); show_164(led_numt%10); portd=0xe8; delay(10); void display5(int16u value) int16u t=value; /720min show_164(led_numt/100);/7 portd=0xd8; delay(10); show_164(led_numt%100/10);/2 portd=0x78; delay(10); show_164(led_numt%10);/0 portd=0xb8; delay(10); if(count50) show_164(0xdf);/ else if(count4)i=0; key_manage(); if(flag_timestart!=1)/ display(); else if(flag_timestart=1)/ display5(fixed_timeflag_0-min); judgement(); performance(); led_control(); /*misc.c*/#include app.h/*/*/ int8s flag_0=6;/10.8 int8u flag_4=108;/10.8 int8u flag_5=144;/14.4 int8u flag_7=125;/12.5 int8u flag_3=20; int8s flag_6=0; int8u flag_9=0; int8u flag_10=0; int8u flag_11=0; int8u flag_timestart=0;/ 1 int8u flag_light=0; / int8u flag_wait=0; /*/ int8u enter1=0; int8u enter2=0; int8u enter3=0;/*/ int8u windows_1=0;/ int8s windows_2=0;/11/*/ int8u flag_undervoltage=0;/ int8u flag_overvoltage =0;/*/ int16u time=4;/*/ int8u out_a=0,out_b=0,cha=0,chb=0;/local function(s) declarationint16u swget_key1(void);int16u swget_key2(void);int16u swget_key3(void);int16u swget_key4(void);/*int16u swget_key1(void)static int16u wkeystatus = 1;if(wkeystatus = 1)if(pinb & (1 key_r) = 0) /key pressedwkeystatus = 0;else if(wkeystatus = 0)if(pinb & (1 key_r) /key releasedwkeystatus = 1;return(true);return(false);/*int16u swget_key2(void)static int16u wkeystatus = 1;if(wkeystatus = 1)if(pinc & (1 key_s) = 0) /key pressedwkeystatus = 0;else if(wkeystatus = 0)if(pinc & (1 key_s) /key releasedwkeystatus = 1;return(true);return(false);/*int16u swget_key3(void)static int16u wkeystatus = 1;if(wkeystatus = 1)if(pinc & (1 key_a) = 0) /key pressedwkeystatus = 0;else if(wkeystatus = 0)if(pinc & (1 key_a) /key releasedwkeystatus = 1;return(true);return(false);/*int16u swget_key4(void)static int16u wkeystatus = 1;if(wkeystatus = 1)if(pinc & (1 key_b) = 0) /key pressedwkeystatus = 0;else if(wkeystatus = 0)if(pinc & (1 11)windows_2=0;break; if(enter2=1) switch(windows_2) case 0:flag_0+=1;if(flag_014)flag_0=0;break;/a case 1:break;/a case 2:break;/b case 3:flag_3+=1;if(flag_3100)flag_3=1;break;/ case 4:flag_4+=1;if(flag_4113)flag_4=106;break;/ case 5:flag_5+=1;if(flag_5164)flag_5=136;break;/ case 6:flag_6+=1;if(flag_62)flag_6=0;break;/ case 7:flag_7+=1;if(flag_7130)flag_7=120;break;/ case 8:break;/ case 9:flag_9=!flag_9;break;/ case 10:flag_10=!flag_10;break;/usb_5v case 11:flag_11=!flag_11;break;/ default:break; break; case b: if(!(enter1|enter2|enter3)out_b=!out_b;break; if(enter1=1)windows_2-;if(windows_20)windows_2=11;break; if(enter2=1) switch(windows_2) case 0:flag_0-=1;if(flag_00)flag_0=14;break;/a case 1:break;/a case 2:break;/b case 3:flag_3-;if(flag_30)flag_3=99;break;/ case 4:flag_4-=1;if(flag_4106)flag_4=112;break;/ case 5:flag_5-=1;if(flag_51

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论