|
|
View previous topic :: View next topic |
Author |
Message |
kocakaya Guest
|
Need Advice Urgent |
Posted: Sat Feb 10, 2007 6:15 am |
|
|
I made a 100 A car battery charger .There is 2x20 LCD and AN0 is Current Value Input AN1 is Voltage input. I want to write 24LC512 RAM and send to pc with Int_rda charging results. when battery voltage higher I am showing it with leds . My code is below Do you think is there a wrong in code When voltage is higher lcd showing speed gets faster because of led delays .Timers hold the amper hour .what can you advice ?
Code: |
void besli() {
OUTPUT_HIGH(PIN_D4);
delay_ms(300);
OUTPUT_LOW(PIN_D4);
delay_ms(300);
OUTPUT_HIGH(PIN_C5);
delay_ms(300);
OUTPUT_LOW(PIN_C5);
delay_ms(300);
OUTPUT_HIGH(PIN_D3);
delay_ms(300);
OUTPUT_LOW(PIN_D3);
delay_ms(300);
OUTPUT_HIGH(PIN_D2);
delay_ms(300);
OUTPUT_LOW(PIN_D2);
delay_ms(300);
OUTPUT_HIGH(PIN_C2);
delay_ms(300);
OUTPUT_LOW(PIN_C2);
delay_ms(300);
}
void dortlu() {
OUTPUT_HIGH(PIN_C5);
delay_ms(300);
OUTPUT_LOW(PIN_C5);
delay_ms(300);
OUTPUT_HIGH(PIN_D3);
delay_ms(300);
OUTPUT_LOW(PIN_D3);
delay_ms(300);
OUTPUT_HIGH(PIN_D2);
delay_ms(300);
OUTPUT_LOW(PIN_D2);
delay_ms(300);
OUTPUT_HIGH(PIN_C2);
delay_ms(300);
OUTPUT_LOW(PIN_C2);
delay_ms(300);
}
void uclu() {
OUTPUT_HIGH(PIN_D3);
delay_ms(300);
OUTPUT_LOW(PIN_D3);
delay_ms(300);
OUTPUT_HIGH(PIN_D2);
delay_ms(300);
OUTPUT_LOW(PIN_D2);
delay_ms(300);
OUTPUT_HIGH(PIN_C2);
delay_ms(300);
OUTPUT_LOW(PIN_C2);
delay_ms(300);
}
void ikili() {
OUTPUT_HIGH(PIN_D2);
delay_ms(300);
OUTPUT_LOW(PIN_D2);
delay_ms(300);
OUTPUT_HIGH(PIN_C2);
delay_ms(300);
OUTPUT_LOW(PIN_C2);
delay_ms(300);
}
void tekli()
{
OUTPUT_HIGH(PIN_C2);
delay_ms(300);
OUTPUT_LOW(PIN_C2);
delay_ms(300);
}
#use delay(clock=4000000)
void akimgerilim()
{
int adcdeger;
set_adc_channel( 1 );
delay_us(1);
value = Read_ADC();
deger=value/51;
value=value/51;
delay_us(1);
set_adc_channel( 0 );
delay_us(1);
adcdeger=Read_ADC();
max=adcdeger*1.5;
delay_us(1);
}
#INT_RDA
void yaz()
{
}
#INT_RTCC
void clock_isr() {
high_count -= 1;
akimgerilim();
if(high_count==0)
{
++seconds;
high_count=high_start;
ahtoplam=ahtoplam+(max/3600);
}
if(seconds>=60)
{
dakika++;
seconds=0;
}
if(dakika>=60)
{
saat++;
dakika=0;
}
}
#int_TIMER1
void clock_isr2()
{
high_count2 -= 1;
if(high_count2==0)
{
++seconds2;
high_count2=high_start;
if(input(PIN_C1)==1)
{
dakika2=dakika2+10;
seconds2=0;
}
}
if( input(PIN_C1)!=1 )
{
if(seconds2>=60)
{
dakika2++;
seconds2=0;
}
}
if(dakika2>=60)
{
saat2++;
dakika2=0;
}
}
void main()
{
lcd_init();
init_ext_eeprom();
setup_adc_ports(AN0_TO_AN1|VSS_VDD);
setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_0);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256|RTCC_8_bit);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
enable_interrupts(INT_RTCC);
enable_interrupts(INT_TIMER1);
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
set_timer0(0);
do {
lcd_putc("\f");
delay_ms(1);
lcd_gotoxy(1,1);
lcd_putc(" M K P Micro ");
lcd_gotoxy(1,2);
lcd_putc(" Akuyu Baglayiniz");
delay_ms(200);
do {
output_high(PIN_D7);
delay_ms(250);
output_low(PIN_D7);
delay_ms(250);
}while (deger<1);
OUTPUT_HIGH(PIN_D7);
lcd_putc("\f");
delay_ms(1);
lcd_gotoxy(1,1);
lcd_putc(" Aku Baglandi\n");
lcd_gotoxy(1,2);
lcd_putc(" Bekleyiniz");
for(a=0;a<3;a++)
{
OUTPUT_D(0x9F);
OUTPUT_HIGH(PIN_C5);
OUTPUT_HIGH(PIN_C2);
delay_ms(450);
OUTPUT_D(0x00);
OUTPUT_LOW(PIN_C5);
OUTPUT_LOW(PIN_C2);
delay_ms(450);
}
lcd_putc("\f");
delay_ms(500);
if(deger<1>2.40)
{
ariza=3;
goto ariza10;
}
OUTPUT_HIGH(PIN_D7);
OUTPUT_HIGH(PIN_D5);
delay_ms(2000);
system_start=1;
set_timer1(0);
delay_ms(500);
asama=1;
dakika=0;
saat=0;
seconds=0;
ahtoplam=0;
ilk=0;
kademe=0;
lcd_putc("\f");
delay_ms(1);
do {
ariza=0;
if(ilk==0)
{
ilk=1;
if(max<2)
{
ariza=5;
break;
}
}
if(max<2)
{
islemtamam=0;
a1=0;
ariza=4;
break;
}
lcd_gotoxy(1,1);
printf(lcd_putc,"V:%01.2f ", value);
lcd_gotoxy(12,1);
printf(lcd_putc,"Ah:%2f.1",ahtoplam);
lcd_gotoxy(1,2);
printf(lcd_putc,"I:%03.1f ",max);
lcd_gotoxy(13,2);
printf(lcd_putc,"T:%02u:%02u",saat,dakika);
if(value<2>=2.10 && value<2>=2.20 && value<2>=2.30 && value<2.40 && kademe==0)
{
OUTPUT_HIGH(PIN_D4);
OUTPUT_HIGH(PIN_C5);
OUTPUT_HIGH(PIN_D3);
ikili();
}
if(asama==4 || asama==5 || asama==6 || asama==7 || asama==8 || asama==9)
{
OUTPUT_HIGH(PIN_D4);
OUTPUT_HIGH(PIN_C5);
OUTPUT_HIGH(PIN_D3);
OUTPUT_HIGH(PIN_D2);
tekli();
}
//////////////////////////////////////////////////////////////////////////
if(saat2==10 && value<2>=2.30) && asama==1))
{
asama=2;
saat2=0;
dakika2=0;
seconds2=0;
}
if(((saat2==2 && dakika2==30) && value<2>=2.35) && asama==2)
{
asama=3;
saat2=0;
dakika2=0;
seconds2=0;
}
if(((saat2==1 && dakika2==30) && value<2>=2.40) && asama==3)
{
asama=4;
kademe=1;
saat2=0;
dakika2=0;
seconds2=0;
}
if(((saat2==1 && dakika2==30) && value<2>=2.45) && asama==4)
{
asama=5;
saat2=0;
dakika2=0;
seconds2=0;
}
if(((saat2==1 && dakika2==30) && value<2>=2.50) && asama==5)
{
asama=6;
zaman=0;
saat2=0;
dakika2=0;
seconds2=0;
}
if(((saat2==1 && dakika2==30) && value<2>=2.55) && asama==6)
{
asama=7;
saat2=0;
dakika2=0;
seconds2=0;
}
if(((saat2==1 && dakika2==30) && value<2>=2.6) && asama==7)
{
asama=8;
saat2=0;
dakika2=0;
seconds2=0;
}
if(((saat2==1 && dakika2==30) && value<2>=2.65) && asama==8)
{
asama=9;
saat2=0;
dakika2=0;
seconds2=0;
}
if(saat2==1 && asama==9)
{
islemtamam=1;
ariza=6;
break;
}
if(saat==14 && value<2>2.40)
{
islemtamam=1;
ariza=6;
break;
}
}while (TRUE);
|
Thanks for help |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|