Mercurial > public > hwos_code
annotate src/calibrate.asm @ 577:bfb87b4cf2ca
Italian update
author | heinrichsweikamp |
---|---|
date | Sun, 18 Feb 2018 19:18:46 +0100 |
parents | 54346c651b6a |
children | b455b31ce022 |
rev | line source |
---|---|
113 | 1 ;============================================================================= |
2 ; | |
560 | 3 ; File calibration.asm REFACTORED VERSION V2.91 |
113 | 4 ; |
5 ; o2 sensor calibration subroutines | |
6 ; | |
7 ; Copyright (c) 2014, Heinrichs Weikamp, all right reserved. | |
8 ;============================================================================= | |
9 | |
448 | 10 #include "hwos.inc" |
11 #include "shared_definitions.h" ; Mailbox between c and asm | |
12 #include "math.inc" | |
113 | 13 #include "adc_lightsensor.inc" |
14 #include "eeprom_rs232.inc" | |
15 | |
16 calibrate CODE | |
17 | |
560 | 18 global check_sensors ; Check O2 sensor thresholds for fallback and voting logic |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
19 check_sensors: |
560 | 20 ; Check min_mv |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
21 movff o2_mv_sensor1+0, sub_a+0 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
22 movff o2_mv_sensor1+1, sub_a+1 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
23 movlw LOW min_mv |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
24 movwf sub_b+0 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
25 movlw HIGH min_mv |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
26 movwf sub_b+1 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
27 call sub16 ; sub_c = sub_a - sub_b |
192 | 28 bsf use_O2_sensor1 ;=1: Use this sensor for deco |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
29 btfsc neg_flag |
192 | 30 bcf use_O2_sensor1 ;=1: Use this sensor for deco |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
31 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
32 movff o2_mv_sensor2+0, sub_a+0 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
33 movff o2_mv_sensor2+1, sub_a+1 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
34 movlw LOW min_mv |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
35 movwf sub_b+0 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
36 movlw HIGH min_mv |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
37 movwf sub_b+1 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
38 call sub16 ; sub_c = sub_a - sub_b |
192 | 39 bsf use_O2_sensor2 ;=1: Use this sensor for deco |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
40 btfsc neg_flag |
192 | 41 bcf use_O2_sensor2 ;=1: Use this sensor for deco |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
42 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
43 movff o2_mv_sensor3+0, sub_a+0 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
44 movff o2_mv_sensor3+1, sub_a+1 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
45 movlw LOW min_mv |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
46 movwf sub_b+0 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
47 movlw HIGH min_mv |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
48 movwf sub_b+1 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
49 call sub16 ; sub_c = sub_a - sub_b |
192 | 50 bsf use_O2_sensor3 ;=1: Use this sensor for deco |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
51 btfsc neg_flag |
192 | 52 bcf use_O2_sensor3 ;=1: Use this sensor for deco |
560 | 53 |
54 ; Check max_mv | |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
55 movff o2_mv_sensor1+0, sub_a+0 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
56 movff o2_mv_sensor1+1, sub_a+1 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
57 movlw LOW max_mv |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
58 movwf sub_b+0 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
59 movlw HIGH max_mv |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
60 movwf sub_b+1 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
61 call sub16 ; sub_c = sub_a - sub_b |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
62 btfss neg_flag |
192 | 63 bcf use_O2_sensor1 ;=1: Use this sensor for deco |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
64 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
65 movff o2_mv_sensor2+0, sub_a+0 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
66 movff o2_mv_sensor2+1, sub_a+1 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
67 movlw LOW max_mv |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
68 movwf sub_b+0 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
69 movlw HIGH max_mv |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
70 movwf sub_b+1 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
71 call sub16 ; sub_c = sub_a - sub_b |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
72 btfss neg_flag |
192 | 73 bcf use_O2_sensor2 ;=1: Use this sensor for deco |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
74 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
75 movff o2_mv_sensor3+0, sub_a+0 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
76 movff o2_mv_sensor3+1, sub_a+1 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
77 movlw LOW max_mv |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
78 movwf sub_b+0 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
79 movlw HIGH max_mv |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
80 movwf sub_b+1 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
81 call sub16 ; sub_c = sub_a - sub_b |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
82 btfss neg_flag |
192 | 83 bcf use_O2_sensor3 ;=1: Use this sensor for deco |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
84 |
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
85 btfss hud_connection_ok ;=1: HUD connection ok |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
86 bra check_sensor2 ; No HUD/Digital data |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
87 |
147 | 88 ; Copy disable flags from digital input |
227
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
224
diff
changeset
|
89 btfss sensor1_active |
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
224
diff
changeset
|
90 bcf use_O2_sensor1 |
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
224
diff
changeset
|
91 btfss sensor2_active |
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
224
diff
changeset
|
92 bcf use_O2_sensor2 |
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
224
diff
changeset
|
93 btfss sensor3_active |
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
224
diff
changeset
|
94 bcf use_O2_sensor3 |
192 | 95 bra check_sensor3 ; Check for voting logic |
145
e3ac5b2021bc
NEW: Setpoint-Fallback option for external O2 sensor failure
heinrichsweikamp
parents:
113
diff
changeset
|
96 |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
97 check_sensor2: |
560 | 98 ; Copy disable flags from internal calibration routine |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
99 btfss sensor1_calibrated_ok |
192 | 100 bcf use_O2_sensor1 |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
101 btfss sensor2_calibrated_ok |
192 | 102 bcf use_O2_sensor2 |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
103 btfss sensor3_calibrated_ok |
192 | 104 bcf use_O2_sensor3 |
105 check_sensor3: ; Check for voting logic | |
560 | 106 ; bcf voting_logic_sensor3 ; Yes, ignore this sensor |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
107 return |
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
108 |
192 | 109 |
113 | 110 global calibrate_mix |
111 calibrate_mix: | |
112 ; calibrate S8 HUD | |
113 btfss s8_digital ; S8 Digital? | |
114 bra calibrate_mix2 ; No | |
115 | |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
116 ; Yes, calibrate any S8-connected HUD |
113 | 117 clrf temp1 ; Chksum |
118 movlw 0xAA ; Start Byte | |
119 addwf temp1,F | |
120 movff WREG,TXREG2 | |
121 call rs232_wait_tx2 | |
122 | |
123 movlw 0x31 ; Calibrate | |
124 addwf temp1,F | |
125 movff WREG,TXREG2 | |
126 call rs232_wait_tx2 | |
127 | |
560 | 128 movff opt_calibration_O2_ratio,WREG ; Calibration gas %O2 |
113 | 129 addwf temp1,F |
130 movff WREG,TXREG2 | |
131 call rs232_wait_tx2 | |
132 | |
560 | 133 movff amb_pressure+0,WREG ; Ambient pressure |
113 | 134 addwf temp1,F |
135 movff WREG,TXREG2 | |
136 call rs232_wait_tx2 | |
137 movff amb_pressure+1,WREG | |
138 addwf temp1,F | |
139 movff WREG,TXREG2 | |
140 call rs232_wait_tx2 | |
141 | |
560 | 142 movff temp1,TXREG2 ; Chksum |
113 | 143 call rs232_wait_tx2 |
144 | |
145 calibrate_mix2: | |
560 | 146 movff opt_calibration_O2_ratio,WREG ; Calibration gas %O2 |
113 | 147 mullw .100 |
148 movff PRODL,xA+0 | |
149 movff PRODH,xA+1 | |
560 | 150 ; (%O2*100)*[ambient,mbar]/100 -> xC |
113 | 151 movff amb_pressure+0,xB+0 |
152 movff amb_pressure+1,xB+1 | |
448 | 153 rcall calibrate_mix2_helper |
113 | 154 movff o2_mv_sensor1+0,xB+0 |
155 movff o2_mv_sensor1+1,xB+1 | |
156 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
157 ; xC= ppO2/mV | |
158 movff xC+0,opt_x_s1+0 | |
560 | 159 movff xC+1,opt_x_s1+1 ; Factor for Sensor1 |
113 | 160 |
560 | 161 movff opt_calibration_O2_ratio,WREG ; Calibration gas %O2 |
113 | 162 mullw .100 |
163 movff PRODL,xA+0 | |
164 movff PRODH,xA+1 | |
560 | 165 ; (%O2*100)*[ambient,mbar]/100 -> xC |
113 | 166 movff amb_pressure+0,xB+0 |
167 movff amb_pressure+1,xB+1 | |
448 | 168 rcall calibrate_mix2_helper |
113 | 169 movff o2_mv_sensor2+0,xB+0 |
170 movff o2_mv_sensor2+1,xB+1 | |
171 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
172 ; xC= ppO2/mV | |
173 movff xC+0,opt_x_s2+0 | |
560 | 174 movff xC+1,opt_x_s2+1 ; Factor for Sensor2 |
113 | 175 |
560 | 176 movff opt_calibration_O2_ratio,WREG ; Calibration gas %O2 |
113 | 177 mullw .100 |
178 movff PRODL,xA+0 | |
179 movff PRODH,xA+1 | |
560 | 180 ; (%O2*100)*[ambient,mbar]/100 -> xC |
113 | 181 movff amb_pressure+0,xB+0 |
182 movff amb_pressure+1,xB+1 | |
448 | 183 rcall calibrate_mix2_helper |
113 | 184 movff o2_mv_sensor3+0,xB+0 |
185 movff o2_mv_sensor3+1,xB+1 | |
186 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
187 ; xC= ppO2/mV | |
188 movff xC+0,opt_x_s3+0 | |
560 | 189 movff xC+1,opt_x_s3+1 ; Factor for Sensor3 |
113 | 190 |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
191 bsf sensor1_calibrated_ok |
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
192 bsf sensor2_calibrated_ok |
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
193 bsf sensor3_calibrated_ok ; Set flags prior check |
560 | 194 |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
195 rcall check_sensors ; Check O2 sensor thresholds min_mv and max_mv and set use_02_sensorX flags |
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
196 ; initialise internal calibration flags |
192 | 197 btfss use_O2_sensor1 ; Sensor out of range? |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
198 bcf sensor1_calibrated_ok ; Yes, disable this sensor |
192 | 199 btfss use_O2_sensor2 ; Sensor out of range? |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
200 bcf sensor2_calibrated_ok ; Yes, disable this sensor |
192 | 201 btfss use_O2_sensor3 ; Sensor out of range? |
189
e79bc535ef9e
ignore un-calibrated sensors even if they become valid
heinrichsweikamp
parents:
187
diff
changeset
|
202 bcf sensor3_calibrated_ok ; Yes, disable this sensor |
113 | 203 |
204 ; When no sensor is found, enable all three to show error state | |
192 | 205 btfsc use_O2_sensor1 |
113 | 206 return |
192 | 207 btfsc use_O2_sensor2 |
113 | 208 return |
192 | 209 btfsc use_O2_sensor3 |
113 | 210 return |
192 | 211 bsf use_O2_sensor1 |
212 bsf use_O2_sensor2 | |
213 bsf use_O2_sensor3 | |
113 | 214 ; Clear factors |
215 banksel opt_x_s1+0 | |
216 clrf opt_x_s1+0 | |
217 clrf opt_x_s1+1 | |
218 clrf opt_x_s2+0 | |
219 clrf opt_x_s2+1 | |
220 clrf opt_x_s3+0 | |
221 clrf opt_x_s3+1 | |
222 banksel common | |
223 return | |
224 | |
560 | 225 |
448 | 226 calibrate_mix2_helper: |
560 | 227 call mult16x16 ; xA*xB=xC |
448 | 228 movlw LOW .100 |
229 movwf xB+0 | |
230 movlw HIGH .100 | |
231 movwf xB+1 | |
560 | 232 goto div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder (And return) |
233 | |
448 | 234 |
560 | 235 global compute_mvolts_for_all_sensors |
113 | 236 compute_mvolts_for_all_sensors: ; Compute mV or all sensors (S8 Mode) |
237 ; compute AD results in 100µV steps (16bit/sensor) | |
238 ; 24bit AD result is in 244,1406541nV | |
239 ; Devide 24bit value through 409,5999512 -> 410 (0,01% error) | |
560 | 240 #DEFINE ad2mv_factor .410 |
241 ; Sensor 1 | |
242 clrf xC+3 | |
243 movff s8_rawdata_sensor1+2,xC+2 | |
244 movff s8_rawdata_sensor1+1,xC+1 | |
245 movff s8_rawdata_sensor1+0,xC+0 | |
246 movlw LOW ad2mv_factor | |
247 movwf xB+0 | |
248 movlw HIGH ad2mv_factor | |
249 movwf xB+1 | |
250 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
251 movff xC+1,o2_mv_sensor1+1 | |
252 movff xC+0,o2_mv_sensor1+0 ; in 100uV steps | |
253 ; Sensor 2 | |
254 clrf xC+3 | |
255 movff s8_rawdata_sensor2+2,xC+2 | |
256 movff s8_rawdata_sensor2+1,xC+1 | |
257 movff s8_rawdata_sensor2+0,xC+0 | |
258 movlw LOW ad2mv_factor | |
259 movwf xB+0 | |
260 movlw HIGH ad2mv_factor | |
261 movwf xB+1 | |
262 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
263 movff xC+1,o2_mv_sensor2+1 | |
264 movff xC+0,o2_mv_sensor2+0 ; in 100uV steps | |
265 ; Sensor 3 | |
266 clrf xC+3 | |
267 movff s8_rawdata_sensor3+2,xC+2 | |
268 movff s8_rawdata_sensor3+1,xC+1 | |
269 movff s8_rawdata_sensor3+0,xC+0 | |
270 movlw LOW ad2mv_factor | |
271 movwf xB+0 | |
272 movlw HIGH ad2mv_factor | |
273 movwf xB+1 | |
274 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder | |
275 movff xC+1,o2_mv_sensor3+1 | |
276 movff xC+0,o2_mv_sensor3+0 ; in 100uV steps | |
113 | 277 |
560 | 278 bcf new_s8_data_available ; Clear flag |
279 return ; Done. | |
113 | 280 |
560 | 281 |
282 | |
283 global transmit_setpoint ; Transmit current setpoint from WREG (in cbar) to external electronics | |
352
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
284 transmit_setpoint: |
448 | 285 return |
352
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
286 btfss s8_digital ; S8 Digital? |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
287 return ; No, ignore |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
288 |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
289 ; Yes, transmit setpoint from WREG |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
290 movwf temp2 ; Store setpoint |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
291 clrf temp1 ; Chksum |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
292 movlw 0xAA ; Start Byte |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
293 addwf temp1,F |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
294 movff WREG,TXREG2 |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
295 call rs232_wait_tx2 |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
296 |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
297 movlw 0x60 ; New SP |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
298 addwf temp1,F |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
299 movff WREG,TXREG2 |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
300 call rs232_wait_tx2 |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
301 |
560 | 302 movff temp2,WREG ; SP in cbar |
352
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
303 addwf temp1,F |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
304 movff WREG,TXREG2 |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
305 call rs232_wait_tx2 |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
306 |
560 | 307 movff temp1,TXREG2 ; Chksum |
352
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
308 call rs232_wait_tx2 |
5c6da9fa5cb0
add setpoint change to first sample in CCR mode
heinrichsweikamp
parents:
275
diff
changeset
|
309 return |
113 | 310 |
311 | |
312 END |