太阳能充电控制器项目Word格式.docx
- 文档编号:17718498
- 上传时间:2022-12-08
- 格式:DOCX
- 页数:25
- 大小:334.08KB
太阳能充电控制器项目Word格式.docx
《太阳能充电控制器项目Word格式.docx》由会员分享,可在线阅读,更多相关《太阳能充电控制器项目Word格式.docx(25页珍藏版)》请在冰豆网上搜索。
0XFE;
//0DATA
_ShowValue>
>
=1;
PORTD=PORTD&
0XFD;
//CLK0
//delay
(1);
PORTD=PORTD|0X02;
//CLK1
//delay(10);
}
PORTD=PORTD|0X02;
}
/****************************74HC164.H******************************/
voidShow_164(unsignedchar_ShowValue);
/****************************AD.C***********************************/
/*Æ
¬
Ä
Ú
ADC³
õ
Ê
¼
»
¯
*/
voidADC_Init(INT8Uchannel)
{/*¹
¤
×
÷
Ó
µ
¥
´
Î
ª
£
½
Ï
Â
switch(channel)//Ä
²
¿
AREFµ
ç
Ñ
¹
2.56VADLAR×
á
û
Ò
¶
Ô
Æ
ë
Ê
ä
È
Í
¨
À
channel
{
case0:
ADMUX=0xc0+0;
break;
case1:
ADMUX=0xc0+1;
case2:
ADMUX=0xc0+2;
case3:
ADMUX=0xc0+3;
case4:
ADMUX=0xc0+4;
case5:
ADMUX=0xc0+5;
case6:
ADMUX=0xc0+6;
case7:
ADMUX=0xc0+7;
default:
}
ADCSRA=0x00;
//Æ
ô
µ
16·
Ö
INT16UADC_Start(INT8Uchannel)
INT8UTemp_L;
INT8UTemp_H;
INT16UAD_Data;
switch(channel)
{
default:
}
ADCSRA|=0xC0;
AD×
Temp_L=ADCL;
Temp_H=ADCH;
AD_Data=Temp_H*256+Temp_L;
ADCSRA=0x80;
//¹
Ø
±
Õ
return(AD_Data);
voidAD_select(INT8Uchannel)
LED_NUM2[0]=ADC_Start(6)/4;
//UXX.X³
Ë
10±
±
ã
¾
LED_NUM2[1]=ADC_Start(7)/4;
//AXX.X
LED_NUM2[2]=ADC_Start(0)/4;
//bXX.X
LED_NUM2[3]=ADC_Start
(1)/4;
//CXX.X
}
/****************************AD.H***********************************/
voidADC_Init(unsignedcharchannel);
unsignedintADC_Start(unsignedcharchannel);
voidAD_select(unsignedcharchannel);
/***************************APP.H***********************************/
#include<
iom8v.h>
macros.h>
eeprom.h>
//#include"
Kernel.h"
task.h"
misc.h"
initial.h"
74HC164.h"
delay.h"
LED.h"
AD.h"
EEPROM.h"
/***************************DELAY.H*********************************/
unsignedintMin=0;
//·
unsignedintSec=0;
//Ã
voiddelay(unsignedinta)
unsignedinti,j;
for(i=0;
i<
a;
i++)
for(j=0;
j<
500;
j++);
voidSolarCount(void)//¼
¸
Sec++;
if(Sec>
59)
Sec=0;
Min++;
externunsignedintMin;
externunsignedintSec;
externunsignedintCount,flag_count;
//¼
ý
voiddelay(unsignedinta);
voidSolarCount(void);
/***************************EEPROM.H********************************/
voidEEPROM_Init(void)
INT8Ui=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);
voidEEPROM_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);
voidEEPROM_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********************************/
voidEEPROM_Init(void);
voidEEPROM_Start(void);
voidEEPROM_Recover(void);
/***************************INITIAL.C*******************************/
INT16UTime1=3;
voidGpio_Init(void);
voidTimer1_Init(void);
voidTimer2_Init(void);
voidInterrupt_Init(void);
voidBattery_Init(void);
voidHardware_Init(void)
ADC_Init(6);
EEPROM_Init();
Gpio_Init();
Timer1_Init();
Timer2_Init();
Interrupt_Init();
Battery_Init();
voidBattery_Init(void)
INT16Ui=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);
//***************************************************************
voidGpio_Init(void)
DDRB=0xDF;
//PB5×
ö
°
ü
PORTB=0x20;
DDRC=0x00;
PORTC=0xFF;
DDRD=0xFF;
PORTD=0xFF;
//TIMER1initialize-prescale:
1024
//WGM:
0)Normal,TOP=0xFFFF
//desiredvalue:
1Hz
//actualvalue:
1.000Hz(0.0%)
voidTimer1_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;
//startTimer
TIMSK|=0x10;
//Ê
³
AÆ
Å
Ð
Ü
voidTimer2_Init(void)
TCCR2=0x00;
//stop
ASSR=0x00;
//setasyncmode
TCCR2=0x0F;
//start
TCNT2=0x00;
OCR2=0x4D;
TIMSK|=0x80;
voidInterrupt_Init(void)
SREG|=0x80;
//EnableGlobalInterrupt
/***************************INITIAL.H*******************************/
voidHardware_Init(void);
/***************************INTERPUTL.C*****************************/
unsignedintCount=0,flag_count=0;
#pragmainterrupt_handlerTimer1_Interrupt:
7
voidTimer1_Interrupt(void)
//ClearTimer2OCIFFlag
TIFR|=0x10;
#pragmainterrupt_handlerTimer2_Interrupt:
4
voidTimer2_Interrupt(void)
TIFR|=0x80;
//ClearTimer2OCIFFlag
Count++;
if(Count>
100)
Count=0;
flag_count=1;
//µ
1S±
ê
SolarCount();
if(flag_timestart!
=1)//¼
Ç
å
Á
Min=0;
//Ó
Ã
·
/***************************LCD.C***********************************/
INT8ULED_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*/
};
//INT8ULED_NUM1[]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10,0x08,0x03,0x46,0x0E,0x41};
//¹
+Ð
¡
INT8ULED_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*/
INT8ULED_NUM2[]={0,1,2,3};
INT16UFixed_Time[]={1,5,10,60,120,180,240,300,360,420,480,540,600,660,720};
//14
voidDisplay2(INT8Uvalue);
voidDisplay3(INT8Uvalue);
voidDisplay1(INT8Uwindows,INT8Uvalue)
INT8Us=value;
if(windows==0)//½
æ
1UXX.XÐ
î
Show_164(LED_NUM[14]);
PORTD=0XD8;
delay(10);
if(windows==1)//½
2AXX.XBÂ
Show_164(LED_NUM[10]);
if(windows==2)//½
3bXX.XAÂ
Show_164(LED_NUM[11]);
if(windows==3)//½
4CXX.X³
Show_164(LED_NUM[12]);
}
Show_164(LED_NUM[s/100]);
PORTD=0X78;
Show_164(LED_NUM1[s%100/10]);
PORTD=0XB8;
Show_164(LED_NUM[s%10]);
PORTD=0XE8;
voidDisplay2(INT8Uvalue)
Show_164(LED_NUM1[13]);
//F.XXX
Show_164(LED_NUM[0]);
Show_164(LED_NUM[s/10]);
voidDisplay3(INT8Uvalue)
//XX.XU
voidDisplay4(INT16Uvalue)//Ï
XXXX
{
INT16Ut=value;
Show_164(LED_NUM[t/1000]);
Show_164(LED_NUM[t%1000/100]);
Show_164(LED_NUM[t%100/10]);
Show_164(LED_NUM[t%10]);
voidDisplay5(INT16Uvalue)
//720min
Show_164(LED_NUM[t/100]);
//7
//2
//0
50)
Show_164(0XDF);
//Ï
elseif(Count<
51)
Show_164(0XFF);
PORTD=0
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 太阳能 充电 控制器 项目
![提示](https://static.bdocx.com/images/bang_tan.gif)