comparison src/calibrate.asm @ 564:54346c651b6a

bring digital S8 HUD back to life...
author heinrichsweikamp
date Mon, 05 Feb 2018 17:59:55 +0100
parents b7eb98dbd800
children b455b31ce022
comparison
equal deleted inserted replaced
563:f4faff954816 564:54346c651b6a
101 btfss sensor2_calibrated_ok 101 btfss sensor2_calibrated_ok
102 bcf use_O2_sensor2 102 bcf use_O2_sensor2
103 btfss sensor3_calibrated_ok 103 btfss sensor3_calibrated_ok
104 bcf use_O2_sensor3 104 bcf use_O2_sensor3
105 check_sensor3: ; Check for voting logic 105 check_sensor3: ; Check for voting logic
106 ; DELETE - voting is done in calc_deko_divemode_sensor ## voting logic
107 ; bsf voting_logic_sensor1
108 ; movff o2_ppo2_sensor1,temp1
109 ; rcall check_sensor_voting_common
110 ; incfsz WREG ; Was Wreg=255?
111 ; bcf voting_logic_sensor1 ; Yes, ignore this sensor
112 ; bsf voting_logic_sensor2
113 ; movff o2_ppo2_sensor2,temp1
114 ; rcall check_sensor_voting_common
115 ; incfsz WREG ; Was Wreg=255?
116 ; bcf voting_logic_sensor2 ; Yes, ignore this sensor
117 ; bsf voting_logic_sensor3
118 ; movff o2_ppo2_sensor3,temp1
119 ; ;rcall check_sensor_voting_common
120 ; incfsz WREG ; Was Wreg=255?
121 ; bcf voting_logic_sensor3 ; Yes, ignore this sensor 106 ; bcf voting_logic_sensor3 ; Yes, ignore this sensor
122 return 107 return
123 108
124 ; DELETE COMPLETE FUNTION, PARTS OF THE CODE HAVE MIGRATED TO calc_deko_divemode_sensor ## voting logic
125 ; check_sensor_voting_common:
126 ; movf temp1,W
127 ; cpfsgt sensor_setpoint
128 ; bra check_sensor_voting_common2 ; temp1<sensor_setpoint
129 ; ; temp1>sensor_setpoint
130 ; movf temp1,W
131 ; subwf sensor_setpoint,W
132 ; movwf temp1
133 ; check_sensor_voting_common1:
134 ; movlw sensor_voting_logic_threshold ; Threshold in 0.01bar
135 ; cpfsgt temp1
136 ; retlw .255 ; Within range
137 ; retlw .0 ; Out of range
138 ; check_sensor_voting_common2:
139 ; ; temp1<sensor_setpoint
140 ; movf sensor_setpoint,W
141 ; subwf temp1,F
142 ; bra check_sensor_voting_common1
143 109
144 global calibrate_mix 110 global calibrate_mix
145 calibrate_mix: 111 calibrate_mix:
146 ; calibrate S8 HUD 112 ; calibrate S8 HUD
147 btfss s8_digital ; S8 Digital? 113 btfss s8_digital ; S8 Digital?
262 movlw LOW .100 228 movlw LOW .100
263 movwf xB+0 229 movwf xB+0
264 movlw HIGH .100 230 movlw HIGH .100
265 movwf xB+1 231 movwf xB+1
266 goto div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder (And return) 232 goto div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder (And return)
267
268
269 ; DELETE COMPLETE FUNTION, PARTS OF THE CODE HAVE MIGRATED TO calc_deko_divemode_sensor ## voting logic
270 ; compute_ppo2_analog:
271 ; call get_analog_inputs
272 ; bra compute_ppo2_common
273
274 ; global compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays
275 ; compute_ppo2:
276 ; btfss analog_o2_input ; cR hardware?
277 ; return ; No
278
279 ; btfss s8_digital ; =1: Digital I/O
280 ; bra compute_ppo2_analog ; use analog
281
282 ; ; use digital
283 ; btfss new_s8_data_available ; =1: New data frame recieved
284 ; return
285 ; rcall compute_mvolts_for_all_sensors
286
287 ; compute_ppo2_common:
288 ; ; o2_mv_sensor1:2 * opt_x_s1:2 = o2_ppo2_sensor1/10000
289 ; movff o2_mv_sensor1+0,xA+0
290 ; movff o2_mv_sensor1+1,xA+1
291 ; movff opt_x_s1+0,xB+0
292 ; movff opt_x_s1+1,xB+1
293 ; rcall compute_ppo2_common_helper
294 ; movff xC+0,o2_ppo2_sensor1 ; result in 0.01bar
295 ; ; ; Set to zero if sensor is not active!
296 ; ; btfss use_O2_sensor1
297 ; ; clrf o2_ppo2_sensor1
298
299 ; ; o2_mv_sensor2:2 * opt_x_s1:2 = o2_ppo2_sensor2/10000
300 ; movff o2_mv_sensor2+0,xA+0
301 ; movff o2_mv_sensor2+1,xA+1
302 ; movff opt_x_s2+0,xB+0
303 ; movff opt_x_s2+1,xB+1
304 ; rcall compute_ppo2_common_helper
305 ; movff xC+0,o2_ppo2_sensor2 ; result in 0.01bar
306 ; ; ; Set to zero if sensor is not active!
307 ; ; btfss use_O2_sensor2
308 ; ; clrf o2_ppo2_sensor2
309
310 ; ; o2_mv_sensor3:2 * opt_x_s1:2 = o2_ppo2_sensor3/10000
311 ; movff o2_mv_sensor3+0,xA+0
312 ; movff o2_mv_sensor3+1,xA+1
313 ; movff opt_x_s3+0,xB+0
314 ; movff opt_x_s3+1,xB+1
315 ; rcall compute_ppo2_common_helper
316 ; movff xC+0,o2_ppo2_sensor3 ; result in 0.01bar
317 ; ; ; Set to zero if sensor is not active!
318 ; ; btfss use_O2_sensor3
319 ; ; clrf o2_ppo2_sensor3
320 ; return ; Done.
321
322 ; compute_ppo2_common_helper:
323 ; call mult16x16 ;xA:2*xB:2=xC:4
324 ; movlw LOW .1000
325 ; movwf xB+0
326 ; movlw HIGH .1000
327 ; movwf xB+1
328 ; call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
329 ; movlw d'1'
330 ; addwf xC+0,F
331 ; movlw d'0'
332 ; addwfc xC+1,F
333 ; tstfsz xC+1 ; ppO2 is higher then 2.55bar?
334 ; setf xC+0 ; Yes.
335 ; return
336 233
337 234
338 global compute_mvolts_for_all_sensors 235 global compute_mvolts_for_all_sensors
339 compute_mvolts_for_all_sensors: ; Compute mV or all sensors (S8 Mode) 236 compute_mvolts_for_all_sensors: ; Compute mV or all sensors (S8 Mode)
340 ; compute AD results in 100µV steps (16bit/sensor) 237 ; compute AD results in 100µV steps (16bit/sensor)