📄 main.lst
字号:
1176 {
1177 k=Calculate_Line_k(492,400,647,600);
1178 b=Calculate_Line_b(492,400,647,600);
1179 Pre=(k*input+b);
1180 }
1181
1182 if(input>646 && input<772)
1183 {
1184 k=Calculate_Line_k(646,600,772,800);
1185 b=Calculate_Line_b(646,600,772,800);
1186 Pre=(k*input+b);
1187 }
1188 if(input>771 && input<886)
1189 {
1190 k=Calculate_Line_k(772,800,886,1000);
1191 b=Calculate_Line_b(772,800,886,1000);
1192 Pre=(k*input+b);
1193 }
1194 if(input>885)
1195 {
1196 Pre=1000;
1197 }
1198 // return( (unsigned int)( ((float)Para_Pre_Oil_Zoom_k/100)*Pre+((float)Para_Pre_Oil_Shift_b) ) );
1199 return Pre;
1200 }
1201 */
1202 unsigned int Calculate_Pre(unsigned int input)
1203 {
1204 1 //unsigned int Pre1;
1205 1 float Pre;
1206 1 float k,b;
1207 1 if( (input>0 && input<63) || input==0)
1208 1 {
1209 2 Pre=0;
1210 2 }
1211 1 if(input>62 && input<283)
1212 1 {
1213 2 // Calculate_Line(17,0,77,500,*k,*b);
1214 2
1215 2 k=Calculate_Line_k(63,0,283,200);
1216 2 b=Calculate_Line_b(63,0,283,200);
1217 2 Pre=(k*input+b);
1218 2 // Pre=(int) ( (float)500/60*input+(-((float)500/60*17)) );
1219 2 }
1220 1 if(input>282&& input<478)
1221 1 {
1222 2 k=Calculate_Line_k(283,200,478,400);
1223 2 b=Calculate_Line_b(283,200,478,400);
1224 2 Pre=(k*input+b);
1225 2 //Pre=(int) ((float)500/46*input+(500-77*((float)500/46)));
1226 2 }
1227 1
1228 1 if(input>477 && input<563)
1229 1 {
1230 2 k=Calculate_Line_k(478,400,563,500);
1231 2 b=Calculate_Line_b(478,400,563,500);
C51 COMPILER V7.50 MAIN 07/28/2008 18:17:59 PAGE 21
1232 2 Pre=(k*input+b);
1233 2 }
1234 1
1235 1 ///////////////////////////
1236 1 if(input>562 && input<634)
1237 1 {
1238 2 k=Calculate_Line_k(563,500,634,600);
1239 2 b=Calculate_Line_b(563,500,634,600);
1240 2 Pre=(k*input+b);
1241 2 }
1242 1 if(input>633 && input<710)
1243 1 {
1244 2 k=Calculate_Line_k(634,600,710,700);
1245 2 b=Calculate_Line_b(634,600,710,700);
1246 2 Pre=(k*input+b);
1247 2 }
1248 1 //////////////////////////////////////
1249 1 if(input>709 && input<759)
1250 1 {
1251 2 k=Calculate_Line_k(710,700,759,800);
1252 2 b=Calculate_Line_b(710,700,759,800);
1253 2 Pre=(k*input+b);
1254 2 }
1255 1 if(input>758 && input<868)
1256 1 {
1257 2 k=Calculate_Line_k(759,800,868,1000);
1258 2 b=Calculate_Line_b(759,800,868,1000);
1259 2 Pre=(k*input+b);
1260 2 }
1261 1 if(input>867)
1262 1 {
1263 2 Pre=1000;
1264 2 }
1265 1 // return( (unsigned int)( ((float)Para_Pre_Oil_Zoom_k/100)*Pre+((float)Para_Pre_Oil_Shift_b) ) );
1266 1 return Pre;
1267 1 }
1268
1269 //Calculate_Volate()
1270 char Sign_Byte=0x00;////check byte
1271 char Sign_Temp=0x00;//temp store
1272 unsigned char Get_Value=0;
1273 bit Up_Get_Value=0;
1274
1275 unsigned char Sign_Temp1;//for receive para
1276 bit Sign_Para=0;
1277 /////////////////////////////////////////////up get Para from E2prom
1278 unsigned char Byte_Up_Get_Para=0;
1279 bit Bit_Up_Get_Para=0;
1280 unsigned char Count_Up_Get_Para=0;
1281 unsigned char Check_Up_Get_Para=0;
1282
1283 //////////////////////////
1284
1285 unsigned char Send_Count=0;
1286 unsigned char Receive_Count=0;
1287 //unsigned char Send_Sign=0;
1288 /*
1289 void INT_UART_Tx_Rx() interrupt 4 using 3// serious interrupt
1290 {
1291 unsigned char xx=0x00;
1292 ES = 0;
1293
C51 COMPILER V7.50 MAIN 07/28/2008 18:17:59 PAGE 22
1294 if(RI)
1295 {
1296 // P1_6=0;
1297 RI=0;
1298 TI=0;
1299 xx=SBUF;
1300 // Receive_Count=SBUF;
1301 if(!Recieve_Para_Start)
1302 {
1303 ///////////////////////////////////////////////////////////////
1304 if(xx==0xbb)/////up receiving measure order
1305 {
1306 Get_Value=xx;
1307
1308 P1_6=0;
1309 }
1310 else
1311 if(Get_Value==0xbb)
1312 {
1313
1314 Get_Value=0;
1315 if( xx==CPU_NO)
1316 {
1317 // XBYTE[0x8004]=0xc0;
1318 Up_Get_Value=1;
1319
1320 }
1321 else
1322 Up_Get_Value=0;
1323 }
1324 if(Up_Get_Value)
1325
1326 {
1327 // Send_Sign=1;
1328 // TI=1;
1329 // Send_Count=0;
1330 Up_Get_Value=0;
1331 Send_Count=0;
1332 P1_6=1;
1333 TI=0;
1334
1335 SBUF=0xaa;
1336
1337 // Send_Count=0;
1338
1339 // SBUF=0xaa;
1340 // while(TI!=1);
1341 }
1342
1343 /////////////////////////////////////////////////////////////////
1344 if(xx==0x66)///////para adjust from up
1345 {
1346 Recieve_Para_Start=1;
1347 Receive_Count=0;
1348 P1_6=0;
1349
1350 }
1351
1352
1353 ////////////////////////////////////////////////////////////
1354 if(xx==0xdd)/////up receiving measure order
1355 {
C51 COMPILER V7.50 MAIN 07/28/2008 18:17:59 PAGE 23
1356 Byte_Up_Get_Para=0xdd;
1357 P1_6=0;
1358 }
1359 else
1360 if(Byte_Up_Get_Para==0xdd)
1361 {
1362 Byte_Up_Get_Para=0;
1363 if( xx==CPU_NO)
1364 {
1365 // XBYTE[0x8004]=0xc0;
1366 Bit_Up_Get_Para=1;
1367
1368 }
1369 else
1370 Byte_Up_Get_Para=0;
1371 }
1372 if(Bit_Up_Get_Para)
1373
1374 {
1375 // Send_Sign=1;
1376 // TI=1;
1377 // Send_Count=0;
1378 Byte_Up_Get_Para=0;
1379 Count_Up_Get_Para=0;
1380 P1_6=1;
1381 TI=0;
1382
1383 SBUF=0xee;
1384
1385 // Send_Count=0;
1386
1387 // SBUF=0xaa;
1388 // while(TI!=1);
1389 }
1390
1391
1392
1393 }
1394
1395 ///////////////////////////////////////////////////
1396 else
1397 if(Recieve_Para_Start)////para adjust from up
1398 {
1399 P1_6=0;
1400 // TI=0;
1401 // RI=0;
1402 switch(Receive_Count)
1403 {
1404 case 0:
1405 CPU_NO1=xx;
1406 Sign_Byte=xx;
1407
1408
1409 break;
1410 case 1:
1411 Para_Tem_Oil1=xx;
1412 Sign_Byte=Sign_Byte^xx;
1413 break;
1414 case 2:
1415 Para_Tem_water1=xx;
1416 Sign_Byte=Sign_Byte^xx;
1417 break;
C51 COMPILER V7.50 MAIN 07/28/2008 18:17:59 PAGE 24
1418 case 3:
1419 Para_Speed_Divide1=xx;
1420 Sign_Byte=Sign_Byte^xx;
1421 break;
1422 case 4:
1423 Para_Speed_Alarm_Percent1=xx;//alarm percent
1424 Sign_Byte=Sign_Byte^xx;
1425 break;
1426 case 5:
1427 // Para_Speed_Alarm_Percent1=xx;
1428 Sign_Temp1=xx;
1429 Sign_Byte=Sign_Byte^xx;
1430 break;
1431 case 6:
1432 Para_Speed_Standard1=((unsigned int)(Sign_Temp1))*256+(unsigned int)xx;
1433 Sign_Byte=Sign_Byte^xx;
1434 break;
1435 case 7:
1436 Para_Speed_Percent1=xx;
1437 Sign_Byte=Sign_Byte^xx;
1438 break;
1439 case 8:
1440 Sign_Temp1=xx;
1441 Sign_Byte=Sign_Byte^xx;
1442 break;
1443
1444 case 9:
1445 Para_Pre_Oil1=((unsigned int)(Sign_Temp1))*256+(unsigned int)xx;
1446 Sign_Byte=Sign_Byte^xx;
1447
1448 break;
1449 /////////
1450 case 10:
1451 Para_Pre_Oil_Zoom_k1=xx;
1452 Sign_Byte=Sign_Byte^xx;
1453
1454 break;
1455
1456 case 11:
1457 Para_Pre_Oil_Shift_b1=(char)xx;
1458 Sign_Byte=Sign_Byte^xx;
1459
1460 break;
1461 //////////////////////
1462 /////////Para_Pre_Oil_Zoom_k
1463 case 12:
1464 {
1465
1466
1467 Recieve_Para_Stop=1;
1468 Recieve_Para_Start=0;
1469 if(Sign_Byte==xx)
1470 {
1471 P1_6=1;
1472
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -