Sign In

Project -microcontroller Based Solar Charger

gurpreet kaaur gurayagurpreet50@gmail.com India

Hardware: Pic16f877a,adc And Whole Components Like Resistor .capacitor And Diodes And Relays Software: C Using Keil With Embedded

i am working on this project ,,am making this project by myself..but in the programming on keil i am suffering from two errors..and noboady is here who can helo me..so please help me

Images

project -microcontroller based solar charger

Program

$mod51;  lcd  4-bit   mode   coonections
rs     equ    p1.7    ;lcd   register select line
en     equ    p1.6    ;lcd   enable line
db4    equ    p1.5    ;
db5    equ    p1.4    ; 
db6    equ    p1.3    ;
db7    equ    p1.2    ;adc0831 connections
cs     equ    p3.0
clk    equ    p3.1 
d0     equ    p3.2    ;input& output
dy1    equ    p3.4    ;soalr pannel voltage sensor
chg_rl equ    p3.5    ;charging control relay
ld_rl  equ    p3.7    ;load control relay dseg
 
org   0020h
val1:ds               1
val2:ds               1
val3:ds               1
adc_val:              ds1
buf: ds               1
cnt1:ds               1
cnt2:ds               1
img :ds               1
flags:ds              1
ocf  bit              flags.0;over charge flag
lbf  bit              flags.1;low batt flag
cseg 
org  0000h
jmp  main
org  000bh                    ;timer interrupt0
jmp  countdown
main: mov sp,#50h
mov   p3,#offh
mov   p1,#0ffh
clr   chg_rl
clr   chg_rl
lcall pwr_delay
lcall init
setb  clk
setb  d0
setb  dy1
mov   val1,#00h
mov   val2,#00h
mov   val3,#00h
mov   flags,#00h
 
 losdchar:  mov buf,#40h
 lcall cmd
 mov dptr,#rcharg
 rep:
 clr  a
 movc  A,@A+dptr
 jz screen
 mov  buf,a
 lcall dat
 inc  dptr
 sjmp rep
 screen1: mov buf,#80h
 mov  dptr,#msg1
 here:clr a
 movc A,@A+dptr
 jz next
 mov buf,a
 lcall dat
 inc dptr
 sjmp here
 next:mov buf,#ocoh
 lcall cmd
 mov dptr,#msg2
 here1:clr a
 movc a,@a+dptr
 jz over
 mov buf,a
 lcall dat
 inc dptr
 sjmp here1
 over: lcall one_sec_delay
 lcall one_sec_delay
 lcall clear
 mov buf,#0c0h
 lcall cmd
 mov dptr,#msg7
 here2: clr a
 movc A,@A+dptr
 jz  convert
 mov buf,a
 lcall dat
 inc dptr
 sjmp here2
 convert:lcall delay
 clr cs                ;initiate conversion
 setb clk              ;
 clr  clk              ;first clock
 setb clk 
 clr  clk              ;second clock
 mov  a,#00h           ;clear a
 mov  r5,#08h          ;8 clock pulses
 again:mov c ,do
 rlc a
 setb clk
 clr  clk
 djnz r5,again
 setb cs
 mov adc_val,a
 mov b,#79d
 mul ab              ;product in ab
 mov r1,b            ;product in b
 mov r2,a            ;low byte in a
 lcall hex2bcd
 mov val1,r7
 mov val2,r6
 mov val3,r5
 lcall sendval2lcd
 check:jnb lbf,check2   ;see if any flags are set
  
  jb dy1,convert
  check2:jnb ocf,proceed
  jb dy1,night
  sjmp convert
  proceed:jb dy1,night
  clr  ld_RL          ;off load
  clr  lbf            ;clear low batt flag
  mov a,val2          ;see if batt is full
  xrl a,#04h
  jz   fullchg
  clr  chg_rl         ;connect battery to pannel
  mov  dptr,#msg4     ;display charging msg
  mov img,#00h
  lcall sendstat2lcd
  ljmp  convert
  fullchg:setb ocf    ;set overcharge flag
  setb chg_rl         ;disconnect batt.from pannel
  mov th0,#03ch       ;start 5 min timer here
  mov tl0,#0boh       ;disconnect battery from pannel
  mov  cnt1,#200d 
  mov  cnt2,#30d
  setb  et0
  setb  tr0
  setb  ea
  mov  dptr,#msg5     ;displat batt.full msg
  mov img.#01h
  lcall sendstat2lcd
  ljmp  convert 
  night:clr       chg_rl ;reconnect batt to panel
  clr tr0               ;stop timer0 in case its running
  clr ocf               ;clear over charge flag
  setb ld_rl            ;connect load to batt
  mov a,val1
  xrl a,#00h
  jz   lowbat 
  mov  dptr,#msg3       ;display load on msg
  mov  img,#02h
  lcall sendstat2lcd
  ljmp convert
  low batt:                    setb lbf
  clr  ld_rl                ;disconnet load from battery
  mov dptr,#msg6            ;display load off msg
  mov img,#03h
  lcall secstat2lcd
  ljmp  convert
  sendval2lcd:               mov buf,#0c7h
  lcall cmd
  mov a,val 1
  orl a,#30h
  mov buf,a
  lcall dat
  mov a,val2
  orl a.#30h
  mov buf,a
  lcall dat
  mov buf,#'
  lcall dat  
  mov a,val3
  orl a,#30h
  mov buf,a
  lcall dat
  ret
  sendstat2lcd
  mov buf,#080h
  lcall cmd
  here3: clr a
  movc a,@a+dptr
  jz pict
  mov buf,a
  lcall dat
  inc dptr
  sjmp here3
  pict:mov buf,#oceh
  lcall cmd
  mov buf,img
  lcall dat
  back:
  ret
  ;
  timer0 isr
  ;
  countdown: clrtr0
  mov th0,#o3ch
  mov tl0,0b0h
  setb tr0
  djnz cnt1,back2
  mov  cnt1,#200d
  djnz cnt2,back2
  clr tr0        ;off 5 min timer
  clr et0
  clr ocf        ;clear over charge flag
  clr chg_rl     ;re-connect batt to panel
  back2:ret1
  hex2bcd:mov r3,#00d
  mov r4,#00d
  mov r5,#00d
  mov r6,#00d
  ret
  sendstat2lcd:
  mov buf,#080h
  lcall cmd
  here3: clr a
  movc a,@a+dptr
  jz   pict
  mov buf,a
  lcall dat
  inc dptr
  sjmp here3
  pict:mov buf,#0ceh
  lcall cmd
  mov buf,img 
  lcall dat
  back:
  ret
  ;
  ;
  ;
  countdown;clr tr0
  mov th0,#03ch
  mov tlo,#0b0h
  setb tr0
  djnz cnt1,back2
  mov  cnt1,#200d
  djnz cnt2,back2
  clr tr0         ;off 5 min timer
  clr et0
  clr ocf         ;clear over charge flag
  clr chg_rl      ;re-connect battery to pannel
  back2:ret1
  hex2bcd:mov r3#00d
  mov r4,#00d
  mov r5,#00d
  mov r6,#00d
  mov r7,#00d
  acall h2b
  ret
  h2b:mov b,#10d
  mov a,r2
  div ab
  mov r3,b         ;
  mov b,#10        ;r7,r6,r5,r4,r3
  div ab
  mov r4,b
  mov r5,a
  cjne r1,#00h,high_byte   ;check for high byte
  sjmp endd
  high_byte:mov a,#6
  add a,r3
  mov b,#10
  div ab
  mov r3,b
  add a,#5
  add A,r4
  mov b,#10
  div ab
  mov r4,b
  add a,#2
  add a,r5
  mov b,#10
  div ab
  mov r5,b
  cjne r6,#00d,add_it
  sjmp continue
  add_it:add a,r6
  continue:mov r6,a
  djnz r1,high_byte
  mov b,#10d
  mov a,r6
  div ab
  mov r6,b
  mov r7,a
  endd:ret
  one_sec_delay:mov r0,#10d    ;one second delay routine
  rz3:    mov r1, #100d
  rz1:    mov r2, #250d
  rz2:    nop
  nop
  djnz r2,rz2
  djnz r1,rz1
  djnz r0,rz3
  ret
  pwr_delay::15mse  dekay for lcd to intialize after power on
  mov r4,#100d
  h2: mov     r3,#250d
  h1: djnz    r3,h1
  djnz r4,h2
  ret; lcd
  cmd:push acc     ;save accumulator
  setb en
  clr rs           ;select send command
  mov a,buf        ;put data byte in acc
  mov c,acc.4      ;load high nibble data on data bus
  mov db4,c        ;one bit at a time using
  mov c,acc.5      ;bit move operations
  mov db5,c
  mov c,acc.6
  mov db6,c
  mov c,acc.7
  mov db7,c
  clr en
  nop
  setb en      ; pulse the enable line
  mov c,acc.0  ;similarly,load low nibble
  mov db4,c
  mov c,acc.1
  mov db5,c
  mov c,acc.2
  mov db6,c
  mov c,acc.3
  mov db7,c
  clr en
  nop
  setb en         ;pulse the enable line
  lcall ms delay
  pop acc
  ret; gurpreet
  dat:pusha acc    ;save accumulator
  setb  en 
  setb rs           ;select dens data
  mov a,buf         ;put data byte in acc
  mov c,acc.4       ;load high nibble on data bus
  mov db4,c         ;one bit at a time using
  mov c,     acc.5  ;bit move operations
  mov db5,c
  mov c.acc.6
  mov db6,c
  mov c,acc.7
  mov db6,c
  clr  en
  nop
  setb en           ;pulse the enable line
  mov c,acc.o       ;similarly,load low nibble
  mov db4,c
  mov c,acc.1
  mov db5,c
  mov c,acc.2
  mov db6,c
  mov c,acc.3
  mov db7,c
  clr en 
  nop
  setb en           ;pulse the enable line nop
  lcall msdelay
  pop acc
  ret; lcd suroutines
  clear: mov buf,#01h
  lcall cmd
  ret; gurpreet(lcd subroutines)
  delay:mov r5,#41d    ;41 ms delay
  qt2:mov r6,#50d
  qt1:mov r6,qt1
  djnz r5,qt2
  ret;qt22
  ret;lcd subroutines(gurpreet)
  init:mov buf,#30h     ;funtion set -data bits,lines,fonts
  lcall cmd
  acall delay
  mov buf,#30h
  lcall cmd
  acall delay
  mov buf ,#30h   
  lcall cmd
  acall delay
  mov buf,#28b
  lcall cmd
  mov buf,#0ch
  lcall cmd
  mov buf,#01h
  lcall cmd
  mov buf,#06h
  lcall cmd
  ret org 0320h
  msg1:     db'solar charge;00h
  msg2:     db'gurpreet guraya;00h
  msg3:     db'load on   ;00h
  msg4:     db'charging  ;00h
  msg5;     db'battery low load  off',00h
  msg6:     db'battery full',00h
  msg7:     db'volts',00h
  org 0400h
  rcharg:db 04d,31d,17d,31d,17d,31d,17d,31d  ;charging
  
  db o4d,31d,31d,31d,31d,31d,31d,31d  ;full
  db 31d,31d,14d,04d,04d,14d,31d,31d  ;load
  db 04d,31d,17d,17d,17d,17d,17d,31d  ;low batt
  db 31d,31d,31d,31d,31d,31d,31d,31d
  db 31d,31d,31d,31d,31d,31d,31d,31d
  db 31d,31d,31d,31d,31d,31d,31d,31d
  db 31d,31d,31d,31d,31d,31d,31d,31d,00h
  
 end
  
  
  
  

Replies

R Avinash
2016-07-11 12:41:09
from where you have got the program?
R Avinash Gupta
2016-07-13 05:29:47
we are waiting for your response ...

Post a reply to gurpreet kaaur

Think you can help gurpreet kaaur ? Then post your thoughts that might help gurpreet kaaur. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.