Solar Power and Energy

SignalQ Sites:
NetAdminTools - Coprolite - NoNIC - SpotBridge - NAW - RoboCoop - AreWeDown - SolarPower - SysAdminTools - Xfig - Gold Loaf - GeekPapa - FixGMC - MCJ - FixRambler

Categories:
Batteries | Homebrew | Low Power Loads | Photovoltaic | Wind Power | Ocean Power | Solar Power Community | Other Solar Power Topics

Last 30 Days | Last 60 Days | Last 90 Days | RSS | All Articles/Links


Categories:
·Batteries
·Homebrew
·Low Power Loads
·Photovoltaic
·Wind Power
·Ocean Power
·Solar Power Community
·Other Solar Power Topics
·All Categories
·Other SignalQ Websites



SpotBridge



Refining the Odyssey 2 Battery Monitor Program
Topic: Batteries   Posted:2004-05-09
Printer Friendly: Print

spacerspacer
In this article I wrote a voltage monitor for the battery hooked up to my PV system that runs on an Odyssey 2 computer. Well, it was not the most efficient; however it did work fine. Here is a modification of the program:

cpu     8048            ; asl needs this to know how to assemble
org     0410h           ; start of ROM, but bypass interrupts, etc.
start   call    00f1h           ; BIOS reset
call    011ch           ; BIOS display off
mov     r0,#10h         ; starting character pointer for VDC 
mov     r2,#01h         ; 02 characters
mov     r3,#28h         ; x position
mov     r4,#70h         ; y position
mov     r6,#03h         ; color start with grey
mov     r1,#00h
mov     a,#0ffh         ; location of memory mapped input
movp    a,@a
add     a,#58h          ; a is 0 at 10.06 volts 
mov     r7,a   
inc     r7              ; r7 will dec once before loop  
clr     a               ; start a at 0
clr     c               ; start with no carry set
vstep   add     a,#06h
da      a
jc      wrap
vstepi  djnz    r7,vstep
jmp     disp
wrap    inc     r1
jmp     vstepi
disp    mov     r7,a
mov     r5,#01h         ; always tens place =1
call    03eah           ; print character BIOS routine
mov     a,r1
mov     r5,a
call    03eah           ; print character BIOS routine
mov     r5,#27h
call    03eah           ; print character BIOS routine
mov     a,r7
swap    a
anl     a,#0fh
mov     r5,a
call    03eah           ; print character BIOS routine
mov     a,r7
anl     a,#0fh
mov     r5,a
call    03eah           ; print character BIOS routine
mov     r5,#0ch
call    03eah           ; print character BIOS routine
mov     r5,#24h
call    03eah           ; print character BIOS routine
mov     r5,#17h
call    03eah           ; print character BIOS routine
mov     r5,#0Eh
call    03eah           ; print character BIOS routine
mov     r5,#14h
call    03eah           ; print character BIOS routine
mov     r5,#19h
call    03eah           ; print character BIOS routine
call    0127h
mov     r1,#0ffh
lpo     mov     r7,#0ffh
lpi     djnz    r7,lpi
djnz    r1,lpo
call    011ch           ; BIOS display off
jmp     start
org     04ffh           ; these are not read when live 
db      0a8h            ; 10.06 they are just used when
;       db      0b7h            ; 10.96 using the emulator to 
;       db      0b8h            ; 11.02 test
;       db      0d9h            ; 13.00

I used the Decimal Adjust Accumulator command to do some BCD math. To test some of the values, I modified the gendat.pl code:

$i=10;
$c=167;
while($i<14.6){
printf "%i %2.2f\n",$c,$i;
$i=$i+.06;
$c++;
}

This will list the decimal values for various voltages on my PV system:

divine@trasho o2 $ perl gendatm.pl
167 10.00
168 10.06
169 10.12
170 10.18
171 10.24
172 10.30
.
.
.
240 14.38
241 14.44
242 14.50
243 14.56
divine@trasho o2 $ 

Here is the binary for the ROM image. I hope you enjoy this new version as much as I did. I would like to say that one important point about technology reuse is that the mental concentration needed to make code efficient on an old microcontroller like this is like nothing else. You really have to think clearly to make this stuff work. Nothing is hidden. I remember working on my homebrew computer back in 1990 and realizing this as well. At the time, this was programming binary into a front panel to get the homebrew to talk to my laptop via the parallel port. It was exhilarating. I felt like I was cranking through a single roll of paper, pure, screaming, bits on, bits off, flashing, looping, buzzing through the ALU of the Z-80. :-)

-Agatha




Please read our Terms of Use
All logos and trademarks in this site are property of their respective owner. Copyright 1998-2008 SolarPower.org

Created by:
MCJ
MCJ CMS