112 unsigned short lookupMainTable(
unsigned short realRPM,
unsigned short realLoad,
unsigned short locationID){
123 unsigned char oldRPage =
RPAGE;
127 unsigned char lowRPMIndex = 0;
128 unsigned char highRPMIndex = Table->
RPMLength - 1;
130 unsigned short lowRPMValue = Table->
RPM[0];
131 unsigned short highRPMValue = Table->
RPM[Table->
RPMLength -1];
133 unsigned char RPMIndex;
134 for(RPMIndex=0;RPMIndex<Table->RPMLength;RPMIndex++){
135 if(Table->
RPM[RPMIndex] < realRPM){
136 lowRPMValue = Table->
RPM[RPMIndex];
137 lowRPMIndex = RPMIndex;
138 }
else if(Table->
RPM[RPMIndex] > realRPM){
139 highRPMValue = Table->
RPM[RPMIndex];
140 highRPMIndex = RPMIndex;
142 }
else if(Table->
RPM[RPMIndex] == realRPM){
143 lowRPMValue = Table->
RPM[RPMIndex];
144 highRPMValue = Table->
RPM[RPMIndex];
145 lowRPMIndex = RPMIndex;
146 highRPMIndex = RPMIndex;
152 unsigned char lowLoadIndex = 0;
153 unsigned char highLoadIndex = Table->
LoadLength -1;
155 unsigned short lowLoadValue = Table->
Load[0];
158 unsigned char LoadIndex;
159 for(LoadIndex=0;LoadIndex<Table->
LoadLength;LoadIndex++){
160 if(Table->
Load[LoadIndex] < realLoad){
161 lowLoadValue = Table->
Load[LoadIndex];
162 lowLoadIndex = LoadIndex;
163 }
else if(Table->
Load[LoadIndex] > realLoad){
164 highLoadValue = Table->
Load[LoadIndex];
165 highLoadIndex = LoadIndex;
167 }
else if(Table->
Load[LoadIndex] == realLoad){
168 lowLoadValue = Table->
Load[LoadIndex];
169 highLoadValue = Table->
Load[LoadIndex];
170 lowLoadIndex = LoadIndex;
171 highLoadIndex = LoadIndex;
177 unsigned short lowRPMLowLoad = Table->
Table[(Table->
RPMLength * lowLoadIndex) + lowRPMIndex];
178 unsigned short lowRPMHighLoad = Table->
Table[(Table->
RPMLength * highLoadIndex) + lowRPMIndex];
179 unsigned short highRPMLowLoad = Table->
Table[(Table->
RPMLength * lowLoadIndex) + highRPMIndex];
180 unsigned short highRPMHighLoad = Table->
Table[(Table->
RPMLength * highLoadIndex) + highRPMIndex];
186 unsigned short lowRPMIntLoad = lowRPMLowLoad + (((
signed long)((
signed long)lowRPMHighLoad - lowRPMLowLoad) * (realLoad - lowLoadValue))/ (highLoadValue - lowLoadValue));
187 unsigned short highRPMIntLoad = highRPMLowLoad + (((
signed long)((
signed long)highRPMHighLoad - highRPMLowLoad) * (realLoad - lowLoadValue))/ (highLoadValue - lowLoadValue));
190 return lowRPMIntLoad + (((
signed long)((
signed long)highRPMIntLoad - lowRPMIntLoad) * (realRPM - lowRPMValue))/ (highRPMValue - lowRPMValue));
206 unsigned short lowAxisValue = Table->
Axis[0];
207 unsigned short highAxisValue = Table->
Axis[15];
208 unsigned short lowLookupValue = Table->
Values[0];
209 unsigned short highLookupValue = Table->
Values[15];
213 for(Index=0;Index<16;Index++){
214 if(Table->
Axis[Index] < Value){
215 lowAxisValue = Table->
Axis[Index];
216 lowLookupValue = Table->
Values[Index];
217 }
else if(Table->
Axis[Index] > Value){
218 highAxisValue = Table->
Axis[Index];
219 highLookupValue = Table->
Values[Index];
221 }
else if(Table->
Axis[Index] == Value){
222 return Table->
Values[Index];
227 return lowLookupValue + (((
signed long)((
signed long)highLookupValue - lowLookupValue) * (Value - lowAxisValue))/ (highAxisValue - lowAxisValue));
254 if(Table->
RPM[i] >= Table->
RPM[i+1]){
261 if(Table->
Load[j] >= Table->
Load[j+1]){
284 if(Table->
Axis[i] >= Table->
Axis[i+1]){