Measuring battery voltage with Bs1 and ADC0831
icepuck
Posts: 466
I started off with ad_conv.bas form the bs1appnotes in chapter 2 along with that same circuit. I have it all working on a breadboard.The problem I'm having is with converting the bs2 code from BAADv1.3.pdf to give a voltage.
I started to convert the following code..
I think it may have something to do with the "()" for rounding.
Trying to rewrite that segment of code is were I'm getting confused.
I included the original working code and the non working code
-dan.
I started to convert the following code..
Calc_Volts: v = 16 * adcBits / 255 r = 16 * adcBits // 255 v2 = 100 * r / 255 v3 = 100 * r // 255 v3 = 10 * v3 / 255 IF (v3 >= 16) THEN v2 = v2 + 1 '<-- syntax check makes it this far when it expects IF (v2 >= 100) THEN ' a variable v = v + 1 v2 = 0 ENDIF RETURN
I think it may have something to do with the "()" for rounding.
IF (v3 >= 16) THEN v2 = v2 + 1 IF (v2 >= 100) THEN v = v + 1 v2 = 0 ENDIF
Trying to rewrite that segment of code is were I'm getting confused.
I included the original working code and the non working code
-dan.
Comments
IF v3 < 16 THEN label1
v2 = v2 + 1
label1:
IF v2 < 100 THEN label2
v = v + 1
v2 = 0
label2:
-dan