Mercurial > public > hwos_code
comparison src/calibrate.asm @ 189:e79bc535ef9e
ignore un-calibrated sensors even if they become valid
author | heinrichsweikamp |
---|---|
date | Wed, 29 Oct 2014 12:53:01 +0100 |
parents | 669b5d00706d |
children | a0f9ec25852e |
comparison
equal
deleted
inserted
replaced
188:ebc28381f17d | 189:e79bc535ef9e |
---|---|
80 call sub16 ; sub_c = sub_a - sub_b | 80 call sub16 ; sub_c = sub_a - sub_b |
81 btfss neg_flag | 81 btfss neg_flag |
82 bcf use_02_sensor3 ;=1: Use this sensor for deco | 82 bcf use_02_sensor3 ;=1: Use this sensor for deco |
83 | 83 |
84 btfss hud_connection_ok ;=1: HUD connection ok | 84 btfss hud_connection_ok ;=1: HUD connection ok |
85 return ; No HUD/Digital data | 85 bra check_sensor2 ; No HUD/Digital data |
86 | 86 |
87 ; Copy disable flags from digital input | 87 ; Copy disable flags from digital input |
88 btfss sensor1_active | 88 btfss sensor1_active |
89 bcf use_02_sensor1 | 89 bcf use_02_sensor1 |
90 btfss sensor2_active | 90 btfss sensor2_active |
91 bcf use_02_sensor2 | 91 bcf use_02_sensor2 |
92 btfss sensor3_active | 92 btfss sensor3_active |
93 bcf use_02_sensor3 | 93 bcf use_02_sensor3 |
94 return | 94 return |
95 | 95 |
96 check_sensor2: | |
97 ; Copy disable flags from internal calibration routine | |
98 btfss sensor1_calibrated_ok | |
99 bcf use_02_sensor1 | |
100 btfss sensor2_calibrated_ok | |
101 bcf use_02_sensor2 | |
102 btfss sensor3_calibrated_ok | |
103 bcf use_02_sensor3 | |
104 return | |
105 | |
96 global calibrate_mix | 106 global calibrate_mix |
97 calibrate_mix: | 107 calibrate_mix: |
98 ; calibrate S8 HUD | 108 ; calibrate S8 HUD |
99 btfss s8_digital ; S8 Digital? | 109 btfss s8_digital ; S8 Digital? |
100 bra calibrate_mix2 ; No | 110 bra calibrate_mix2 ; No |
101 | 111 |
112 ; Yes, calibrate any S8-connected HUD | |
102 clrf temp1 ; Chksum | 113 clrf temp1 ; Chksum |
103 movlw 0xAA ; Start Byte | 114 movlw 0xAA ; Start Byte |
104 addwf temp1,F | 115 addwf temp1,F |
105 movff WREG,TXREG2 | 116 movff WREG,TXREG2 |
106 call rs232_wait_tx2 | 117 call rs232_wait_tx2 |
186 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | 197 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder |
187 ; xC= ppO2/mV | 198 ; xC= ppO2/mV |
188 movff xC+0,opt_x_s3+0 | 199 movff xC+0,opt_x_s3+0 |
189 movff xC+1,opt_x_s3+1 ; Factor for Sensor3 | 200 movff xC+1,opt_x_s3+1 ; Factor for Sensor3 |
190 | 201 |
191 ; Result is in 100µV | 202 bsf sensor1_calibrated_ok |
192 movff o2_mv_sensor1+0, sub_a+0 | 203 bsf sensor2_calibrated_ok |
193 movff o2_mv_sensor1+1, sub_a+1 | 204 bsf sensor3_calibrated_ok ; Set flags prior check |
194 movlw LOW min_mv | 205 rcall check_sensors ; Check O2 sensor thresholds min_mv and max_mv and set use_02_sensorX flags |
195 movwf sub_b+0 | 206 ; initialise internal calibration flags |
196 movlw HIGH min_mv | 207 btfss use_02_sensor1 ; Sensor out of range? |
197 movwf sub_b+1 | 208 bcf sensor1_calibrated_ok ; Yes, disable this sensor |
198 call sub16 ; sub_c = sub_a - sub_b | 209 btfss use_02_sensor2 ; Sensor out of range? |
199 bsf use_02_sensor1 ; Sensor active! | 210 bcf sensor2_calibrated_ok ; Yes, disable this sensor |
200 btfsc neg_flag | 211 btfss use_02_sensor3 ; Sensor out of range? |
201 bcf use_02_sensor1 | 212 bcf sensor3_calibrated_ok ; Yes, disable this sensor |
202 | |
203 ; Result is in 100µV | |
204 movff o2_mv_sensor2+0, sub_a+0 | |
205 movff o2_mv_sensor2+1, sub_a+1 | |
206 movlw LOW min_mv | |
207 movwf sub_b+0 | |
208 movlw HIGH min_mv | |
209 movwf sub_b+1 | |
210 call sub16 ; sub_c = sub_a - sub_b | |
211 bsf use_02_sensor2 ; Sensor active! | |
212 btfsc neg_flag | |
213 bcf use_02_sensor2 | |
214 | |
215 ; Result is in 100µV | |
216 movff o2_mv_sensor3+0, sub_a+0 | |
217 movff o2_mv_sensor3+1, sub_a+1 | |
218 movlw LOW min_mv | |
219 movwf sub_b+0 | |
220 movlw HIGH min_mv | |
221 movwf sub_b+1 | |
222 call sub16 ; sub_c = sub_a - sub_b | |
223 bsf use_02_sensor3 ; Sensor active! | |
224 btfsc neg_flag | |
225 bcf use_02_sensor3 | |
226 | 213 |
227 ; When no sensor is found, enable all three to show error state | 214 ; When no sensor is found, enable all three to show error state |
228 btfsc use_02_sensor1 | 215 btfsc use_02_sensor1 |
229 return | 216 return |
230 btfsc use_02_sensor2 | 217 btfsc use_02_sensor2 |