logo

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



Monitoring Battery Voltage With an Odyssey 2
Topic: Batteries   Posted:2004-05-02
Printer Friendly: Print

spacer
In this article I changed my PV controller so that the set point for turning off the load was lower. Of course, now that I have a solar powered Odyssey 2, what better use for it than to monitor the voltage of my battery? I wrote up how to input 8 bits into the Odyssey 2 in this article. I attached the 8 bits from the ADC0804 on my PV controller to the inputs on the 74LS244. Here is a picture of the system:



Here is where I hooked up to the ADC0804:



Note that this program is refined in this article, but some of the stuff I did here is interesting, still. Here is my first wack at the assembly language program running on the Odyssey 2 to measure the voltage:

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
startv  mov     a,#0ffh
movp    a,@a
add     a,#5ah
mov     r7,a
mov     r1,#10h
findc   inc     r1
inc     r1
inc     r1
djnz    r7,findc
mov     r5,#01h
call    03eah           ; print character BIOS routine
mov     a,r1            ;grab current pointer to string
jmp     disp
startd  call    0127h
mov     r7, #0ffh
lp1     jmp     0700h
lp2     djnz    r7, lp1
call    011ch           ; BIOS display off
jmp     start
org     04ffh           ; force the location of hello world
db      0a7h
org     0500h
disp    movp    a,@a            ; move mem at r1 to accumulator
mov     r5,a
call    03eah           ; print character BIOS routine
mov     r5,#27h
call    03eah           ; print character BIOS routine
inc     r1
mov     a,r1            ;grab current pointer to string 
movp    a,@a            ; move mem at r1 to accumulator
mov     r5,a
call    03eah           ; print character BIOS routine
inc     r1
mov     a,r1            ;grab current pointer to string 
movp    a,@a            ; move mem at r1 to accumulator
jmp     restvid
org     0513h
db      00h,00h,00h
db      00h,00h,06h
db      00h,01h,02h
db      00h,01h,08h
db      00h,02h,04h
db      00h,03h,00h
db      00h,03h,06h
db      00h,04h,02h
db      00h,04h,08h
db      00h,05h,04h
db      00h,06h,00h
db      00h,06h,06h
db      00h,07h,02h
db      00h,07h,08h
db      00h,08h,04h
db      00h,09h,00h
db      00h,09h,06h
db      01h,00h,02h
db      01h,00h,08h
db      01h,01h,04h
db      01h,02h,00h
db      01h,02h,06h
db      01h,03h,02h
db      01h,03h,08h
db      01h,04h,04h
db      01h,05h,00h
db      01h,05h,06h
db      01h,06h,02h
db      01h,06h,08h
db      01h,07h,04h
db      01h,08h,00h
db      01h,08h,06h
db      01h,09h,02h
db      01h,09h,08h
db      02h,00h,04h
db      02h,01h,00h
db      02h,01h,06h
db      02h,02h,02h
db      02h,02h,08h
db      02h,03h,04h
db      02h,04h,00h
db      02h,04h,06h
db      02h,05h,02h
db      02h,05h,08h
db      02h,06h,04h
db      02h,07h,00h
db      02h,07h,06h
db      02h,08h,02h
db      02h,08h,08h
db      02h,09h,04h
db      03h,00h,00h
db      03h,00h,06h
db      03h,01h,02h
db      03h,01h,08h
db      03h,02h,04h
db      03h,03h,00h
db      03h,03h,06h
db      03h,04h,02h
db      03h,04h,08h
db      03h,05h,04h
db      03h,06h,00h
db      03h,06h,06h
db      03h,07h,02h
db      03h,07h,08h
db      03h,08h,04h
db      03h,09h,00h
db      03h,09h,06h
db      04h,00h,02h
db      04h,00h,08h
db      04h,01h,04h
db      04h,02h,00h
db      04h,02h,06h
db      04h,03h,02h
db      04h,03h,08h
db      04h,04h,04h
db      04h,05h,00h
db      04h,05h,06h
db      04h,06h,02h
db      04h,06h,08h
org     0600h
restvid 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
jmp     startd
org     0700h
org     07f0h
jmp     lp2

There are 75 steps in .06 Volt increments from 10V to 14.5V. Instead of writing routines to convert the input, I created a table using a couple of perl scripts. gendat.pl:

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

asmgen.pl:

while(<>){
print "db       ";
print "0";
print (substr($_,1,1));
print "h,";
print "0";
print (substr($_,3,1));
print "h,";
print "0";
print (substr($_,4,1));
print "h\n";
}

To generate all of the db statements:

divine@trasho o2 $ perl gendat.pl | perl asmgen.pl

Note that this program is refined in this article. Here is what the program looks like running on the Odyssey 2:



Here is the voltage on my old analog meter:



Here is an image of the ROM.




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