Shop OBEX P1 Docs P2 Docs Learn Events
Battery monitor — Parallax Forums

Battery monitor

RVRV Posts: 9
edited 2013-11-24 16:56 in BASIC Stamp
I am attempting to build a remote battery monitor using a BS2 and Xbee. The program works well for one battery but I would like to monitor two. I have attempted to change the code to read the output on pin 1 in addition to the existing pin 0 but am unable to get it to work properly and would like any suggestions and or code.

The program is as follows:

rct var word ' RCtime value
Vx var word ' voltage value calculated
' we want this to = applied voltage Vx
Cn1 con 48576 ' first constant, see below
Cn2 con 8 ' second constant, ditto
' circuit attached to P0
low 0
loop:
RCtime 0,0,rct
low 0
Vx=Cn1 / rct + Cn2
debug home,dec? rct,"Vx=",dec Vx/10,".",dec1 Vx
pause 500
goto loop


This is from emesystems.com and I did attempt to contact them for suggestions to no avail.

Thank you in advance for any help. I am a rank newbie....

Pete

P.S. The article is at www.emesystems.com/BS2rct.htm

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2013-11-23 15:20
    RV wrote: »
    The program works well for one battery but I would like to monitor two. I have attempted to change the code to read the output on pin 1 in addition to the existing pin 0 but am unable to get it to work properly and would like any suggestions and or code.

    Two batteries? In series or what?

    If it's a matter of two different batteries then you need two battery monitor circuits
    and this (?) re-hashing of your code using P0 and P1, I think:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    rct VAR Word ' RCtime value
    Vx VAR Word ' voltage value calculated
    Cn1 CON 48576 ' first constant, see below
    Cn2 CON 8 ' second constant, ditto
    
    low 0
    low 1
    
    DO
    
    RCtime 0,0,rct
    low 0
    Vx=Cn1 / rct + Cn2
    DEBUG HOME,DEC? rct,"1 Vx=",DEC Vx/10,".",DEC1 Vx  ' ***
    pause 500
    
    RCTIME 1,0,rct
    LOW 1
    Vx=Cn1 / rct + Cn2
    DEBUG HOME,DEC? rct,"2 Vx=",DEC Vx/10,".",DEC1 Vx  '  ***
    pause 500
    
    LOOP
    

    That could be made more compact, but I didn't want to complicate.
  • RVRV Posts: 9
    edited 2013-11-24 16:56
    Thanks PJ
    I am still playing with the hardware side and have just about worked it out.

    Pete
Sign In or Register to comment.