source: buchla-68k/orig/doc/Thunder/THSCAN.TXT@ b8080f6

Last change on this file since b8080f6 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 5.2 KB
Line 
1Thunder main scan algorithm Rev 1 1988-12-15
2--------------------------- ------------------
3
4* Global variables:
5
6 s22stat switch 22 status
7 s24stat switch 24 status
8 s25stat switch 25 status
9
10 s22pres switch 22 pressure
11 s24pres switch 24 pressure
12 s25pres switch 25 pressure
13
14 pedal1 foot pedal 1 value
15 pedal2 foot pedal 2 value
16
17* Global variable tables:
18
19 eltab[] raw element value table 64 entries
20 (A/D input, may not need to be a table)
21
22 osube[] element offset value table 64 entries
23 ksube[] element pressure table 64 entries
24
25 switch[] switch status table 20 entries
26 (10 edit and 10 performance switches)
27
28 potstat[] pot status table 13 entries
29 potpres[] pot pressure table 13 entries
30 potvals[] pot value table 13 entries
31
32* Constant tables:
33
34 caplin[] element linearization table 255 entries
35 ovrnm02[] 2 element pot value multiplier table 512 entries
36 ovrnm08[] 8 element pot value multiplier table 512 entries
37 potamap[] pot index to sensor element A map 12 entries
38 potbmap[] pot index to sensor element B map 12 entries
39 swmap[] switch index to sensor element map 20 entries
40
41
42
43* Process raw sensor element readings into element pressures
44
45Note that this is shown as a background loop, but could be done on interrupt
46by setting the element index, e, to the element number input from the scanner,
47and replacing references to eltab[] with the element value from the scanner.
48
49 register short e, j, jsube, oldk;
50
51 for (e = 0; e < 64; e++) { /* for each element ... */
52
53 if ((e EQ FOOT1) OR (e EQ FOOT2)) { /* pedal inputs ? */
54
55 ksube[e] = eltab[e]; /* pass pedals thru intact */
56
57 } else { /* elements ? */
58
59 j = 255 - eltab[e]; /* invert A/D input */
60
61 j = j - osube[e]; /* subtract offset */
62
63 if (j < 0) /* limit at 0 */
64 j = 0;
65
66 jsube = caplin[j]; /* linearize the value */
67
68 oldk = ksube[e]; /* get old pressure */
69
70 if (jsube > oldk + HYST) /* apply hysteresis */
71 ksube[e] = jsube - HYST;
72 else if (jsube < oldk)
73 ksube[e] = jsube;
74 }
75 }
76
77 pedal1 = ksube[FOOT1]; /* update pedal 1 value */
78 pedal2 = ksube[FOOT2]; /* update pedal 2 value */
79
80
81* Process 1-element switch pressures into switch closures and releases
82
83 register short sw, elval;
84
85 for (sw = 0; sw < 20; sw++) { /* for each switch ... */
86
87 elval = ksube[swmap[sw]]; /* get current value */
88
89 if (elval > ONTHR) /* determine switch status */
90 switch[sw] = TRUE;
91 else if (elval > OFFTHR)
92 switch[sw] = FALSE;
93 }
94
95* Process the 4-element switch (switch #22)
96
97 register short sum;
98
99 /* sum the elements */
100
101 sum = ksube[SW22A] +
102 ksube[SW22B] +
103 ksube[SW22C] +
104 ksube[SW22D];
105
106 if (sum > 255) /* determine switch pressure */
107 s22pres = 255;
108 else
109 s22pres = sum;
110
111 if (s22pres > ONTHR) /* determine switch status */
112 s22stat = TRUE;
113 else if (s22pres < OFFTHR)
114 s22stat = FALSE;
115
116
117* Process the 3-element switches (switch #24 and switch #25)
118
119 register short sum;
120
121 /* sum the elements for switch #24 */
122
123 sum = ksube[SW24A] +
124 ksube[SW24B] +
125 ksube[SW24C];
126
127 if (sum > 255) /* determine pressure */
128 s24pres = 255;
129 else
130 s24pres = sum;
131
132 if (s24pres > ONTHR) /* determine switch status */
133 s24stat = TRUE;
134 else if (sw24pres < OFFTHR)
135 s24stat = FALSE;
136
137 /* sum the elements for switch #25 */
138
139 sum = ksube[SW25A] +
140 ksube[SW25B] +
141 ksube[SW25C];
142
143 if (sum > 255) /* determine pressure */
144 s25pres = 255
145 else
146 s25pres = sum;
147
148 if (s25pres > ONTHR) /* determine switch status */
149 s25stat = TRUE;
150 else if (s25pres < OFFTHR)
151 s25stat = FALSE;
152
153
154
155* Process Pot 1 (8 elements)
156
157 register short pres, sum;
158 register long temp;
159
160 sum = ksube[POT1A] + /* sum the elements */
161 ksube[POT1B] +
162 ksube[POT1C] +
163 ksube[POT1D] +
164 ksube[POT1E] +
165 ksube[POT1F] +
166 ksube[POT1G] +
167 ksube[POT1H];
168
169 if (sum > 255) /* determine pot pressure */
170 pres = 255;
171 else
172 pres = sum;
173
174 if (pres > ONTHR) /* determine pot status */
175 potstat[0] = TRUE;
176 else if (pres < OFFTHR)
177 potstat[0] = FALSE;
178
179 if (potstat[0]) { /* if active, calculate pot value */
180
181 temp = pot1b + /* pot1b * 1 */
182 (pot1c << 1) + /* pot1c * 2 */
183 (pot1d << 1) + /* pot1d * 3 */
184 pot1d +
185 (pot1e << 2) + /* pot1e * 4 */
186 (pot1f << 2) + /* pot1f * 5 */
187 pot1f +
188 (pot1g << 2) + /* pot1g * 6 */
189 (pot1g << 1) +
190 (pot1h << 2) + /* pot1h * 7 */
191 (pot1h << 1) +
192 pot1h;
193
194 if (sum > 511) /* limt sum to table range */
195 sum = 511;
196
197 potvals[0] = ovrnm08[sum] * temp;
198 }
199
200
201* Process Pots 2..13 (2 elements each)
202
203 register short elemb, pot, pres, sum;
204
205 for (pot = 1; pot < 13; pot++) { /* for each pot ... */
206
207 /* sum the elements */
208
209 elemb = ksube[potbmap[pot]];
210
211 sum = ksube[potamap[pot]] + elemb;
212
213 if (sum > 255) /* determine pressure */
214 pres = 255
215 else
216 pres = sum;
217
218 potpres[pot] = pres;
219
220 if (pres > ONTHR) /* determine status */
221 potstat[pot] = TRUE;
222 else if (pres < OFFTHR)
223 potstat[pot] = FALSE;
224
225 /* if pot is active, calculate pot value */
226
227 if (potstat[pot]) {
228
229 if (sum > 511) /* limit sum to table range */
230 sum = 511;
231
232 potvals[pot] = ovrnm02[sum] * elemb;
233 }
234 }
Note: See TracBrowser for help on using the repository browser.