Mercurial > public > hwos_code
comparison src/adc_lightsensor.asm @ 37:0e1723f2761e
use four additional data points for the battery monitor
author | mh@mh-THINK.fritz.box |
---|---|
date | Thu, 15 Aug 2013 12:39:05 +0200 |
parents | 11d4fc797f74 |
children | 18fe4e668baa |
comparison
equal
deleted
inserted
replaced
36:527c35f17a66 | 37:0e1723f2761e |
---|---|
100 get_battery_voltage3: | 100 get_battery_voltage3: |
101 movlw .100 | 101 movlw .100 |
102 cpfslt lo | 102 cpfslt lo |
103 movwf lo | 103 movwf lo |
104 ; lo will be between 100 (Full) and 0 (empty) | 104 ; lo will be between 100 (Full) and 0 (empty) |
105 | |
106 ; use 3,6V battery sensing based on 50mA load | |
107 ; 75% | |
108 movff batt_voltage+0,sub_b+0 | |
109 movff batt_voltage+1,sub_b+1 | |
110 movlw LOW lithium_36v_75 | |
111 movwf sub_a+0 | |
112 movlw HIGH lithium_36v_75 | |
113 movwf sub_a+1 | |
114 call subU16 ; sub_c = sub_a - sub_b | |
115 btfsc neg_flag | |
116 bra get_battery_voltage3a | |
117 movlw .75 | |
118 movwf lo | |
119 get_battery_voltage3a: | |
120 ; 50% | |
121 movlw LOW lithium_36v_50 | |
122 movwf sub_a+0 | |
123 movlw HIGH lithium_36v_50 | |
124 movwf sub_a+1 | |
125 call subU16 ; sub_c = sub_a - sub_b | |
126 btfsc neg_flag | |
127 bra get_battery_voltage3b | |
128 movlw .50 | |
129 movwf lo | |
130 get_battery_voltage3b: | |
131 ; 25% | |
132 movlw LOW lithium_36v_25 | |
133 movwf sub_a+0 | |
134 movlw HIGH lithium_36v_25 | |
135 movwf sub_a+1 | |
136 call subU16 ; sub_c = sub_a - sub_b | |
137 btfsc neg_flag | |
138 bra get_battery_voltage3c | |
139 movlw .25 | |
140 movwf lo | |
141 get_battery_voltage3c: | |
142 ; 10% | |
143 movlw LOW lithium_36v_10 | |
144 movwf sub_a+0 | |
145 movlw HIGH lithium_36v_10 | |
146 movwf sub_a+1 | |
147 call subU16 ; sub_c = sub_a - sub_b | |
148 btfsc neg_flag | |
149 bra get_battery_voltage3d | |
150 movlw .10 | |
151 movwf lo | |
152 get_battery_voltage3d: | |
105 movf batt_percent,W | 153 movf batt_percent,W |
106 cpfsgt lo ; keep batt_percent on the lowest value found | 154 cpfsgt lo ; keep batt_percent on the lowest value found |
107 movff lo,batt_percent ; store value | 155 movff lo,batt_percent ; store value |
108 btfsc battery_is_36v ; but always use computed value for 3,6V battery | 156 ; btfsc battery_is_36v ; but always use computed value for 3,6V battery |
109 movff lo,batt_percent ; store value | 157 ; movff lo,batt_percent ; store value |
110 bcf adc_running ; =1: The ADC is in use | 158 bcf adc_running ; =1: The ADC is in use |
111 return | 159 return |
112 | 160 |
113 get_battery_voltage4: | 161 get_battery_voltage4: |
114 ; Use 1,5V battery voltage mode | 162 ; Use 1,5V battery voltage mode |