ngch
深圳工控小匠
級(jí)別: 網(wǎng)絡(luò)英雄

精華主題: 0
發(fā)帖數(shù)量: 775 個(gè)
工控威望: 8895 點(diǎn)
下載積分: 1689 分
在線時(shí)間: 969(小時(shí))
注冊(cè)時(shí)間: 2009-09-30
最后登錄: 2024-11-06
查看ngch的 主題 / 回貼
樓主  發(fā)表于: 2012-08-07 20:23
圖片:
請(qǐng)教!
omron串行通信接收數(shù)據(jù)如何轉(zhuǎn)換成浮點(diǎn)數(shù)
ASCII碼:302E+3344=D300+D301=0.34
程序如何進(jìn)行換算得到0.34
深圳工控小匠:
工業(yè)非標(biāo)設(shè)備電氣自動(dòng)化控制
(深圳光明區(qū)、寶安區(qū)、龍華區(qū)、東莞長(zhǎng)安)
QQ:357405496
jx_einstein
級(jí)別: 論壇先鋒
精華主題: 0
發(fā)帖數(shù)量: 868 個(gè)
工控威望: 1047 點(diǎn)
下載積分: 2421 分
在線時(shí)間: 860(小時(shí))
注冊(cè)時(shí)間: 2010-01-09
最后登錄: 2024-08-05
查看jx_einstein的 主題 / 回貼
1樓  發(fā)表于: 2012-08-10 17:39
寫(xiě)個(gè)塊:
IF S_INT1<58 AND S_INT1>47 THEN
    S_INT1R:= INT_TO_REAL(S_INT1)-48.0;
    ELSE
    ;
END_IF;
IF S_INT1=46 THEN
    ZeroPoint:=1;
ELSE
    ;
END_IF;

IF S_INT2<58 AND S_INT2>47 THEN
    S_INT2R:= INT_TO_REAL(S_INT2)-48.0;
ELSIF S_INT2=46 THEN
    ZeroPoint:=2;
ELSE
    ;
END_IF;

IF S_INT3<58 AND S_INT3>47 THEN
    S_INT3R:= INT_TO_REAL(S_INT3)-48.0;
ELSIF S_INT3=46 THEN
    ZeroPoint:=3;
ELSE
    ;
END_IF;

IF S_INT4<58 AND S_INT4>47 THEN
    S_INT4R:= INT_TO_REAL(S_INT4)-48.0;
ELSIF S_INT4=46 THEN
    ZeroPoint:=4;
ELSE
    ZeroPoint:=14;
END_IF;

IF S_INT5<58 AND S_INT5>47 THEN
    S_INT5R:= INT_TO_REAL(S_INT5)-48.0;
ELSIF S_INT5=46 THEN
    ZeroPoint:=5;
ELSE
    ;
END_IF;

IF S_INT6<58 AND S_INT6>47 THEN
    S_INT6R:= INT_TO_REAL(S_INT6)-48.0;
ELSIF S_INT6=46 THEN
    ZeroPoint:=6;
ELSE
    ;
END_IF;

CASE ZeroPoint OF
    1:
     Value:=(S_INT2R*0.1+S_INT3R*0.01+S_INT4R*0.001+S_INT5R*0.0001+S_INT6R*0.00001)*1000.0;
     2:
     Value:=(S_INT1R*1.0+S_INT3R*0.1+S_INT4R*0.01+S_INT5R*0.001+S_INT6R*0.0001)*1000.0;
     3:
     Value:=(S_INT1R*10.0+S_INT2R+S_INT4R*0.1+S_INT5R*0.01+S_INT6R*0.001)*1000.0;
     4:
     Value:=(S_INT1R*100.0+S_INT2R*10.0+S_INT3R+S_INT5R*0.1+S_INT6R*0.01)*1000.0;
     5:
     Value:=(S_INT1R*1000.0+S_INT2R*100.0+S_INT3R*10.0+S_INT4R+S_INT6R*0.1)*1000.0;
     6:
      Value:=(S_INT1R*10000.0+S_INT2R*1000.0+S_INT3R*100.0+S_INT4R*10.0+S_INT5R)*1000.0;
ELSE
;
END_CASE;