FUNCTION FC4 : void
VAR
ge1:INT;
shi1:int;
bai1:int;
qian1:int;
wan1:int;
shiwan1:int;
baiwan1:int;
qianwan1:int;
yi1:int;
shiyi1:int;
END_VAR
VAR_INPUT
in:dWORD;
END_VAR
var_output
out:dint;
ge:dINT;
shi:dINT;
bai:dINT;
qian:dINT;
wan:DINT;
shiwan:DINT;
baiwan:DINT;
qianwan:DINT;
yi:DINT;
shiyi:DINT;
led_ge:BYTE;
led_shi:BYTE;
led_bai:BYTE;
led_qian:BYTE;
led_wan:BYTE;
led_shiwan:BYTE;
led_baiwan:BYTE;
led_qianwan:BYTE;
led_yi:BYTE;
led_shiyi:BYTE;
END_VAR
BEGIN
out:=DWORD_TO_DINT (in);
ge:=out MOD 10;
shi:=(out-ge)/10 MOD 10;
bai:=(out-ge-shi*10)/100 MOD 10;
qian:=(out-ge-shi*10-bai*100)/1000 MOD 10;
wan:=(out-ge-shi*10-bai*100-qian*1000)/10000 MOD 10;
shiwan:=(out-ge-shi*10-bai*100-qian*1000-wan*10000)/100000 MOD 10;
baiwan:=(out-ge-shi*10-bai*100-qian*1000-wan*10000-shiwan*100000)/1000000 MOD 10;
qianwan:=(out-ge-shi*10-bai*100-qian*1000-wan*10000-shiwan*100000-baiwan*1000000)/10000000 MOD 10;
yi:=(out-ge-shi*10-bai*100-qian*1000-wan*10000-shiwan*100000-baiwan*1000000-qianwan*10000000)/100000000 MOD 10;
shiyi:=(out-ge-shi*10-bai*100-qian*1000-wan*10000-shiwan*100000-baiwan*1000000-qianwan*10000000-yi*100000000)/1000000000 MOD 10;
ge1:=DINT_TO_INT(ge);
shi1:=DINT_TO_INT(shi);
bai1:=DINT_TO_INT(bai);
qian1:=DINT_TO_INT(qian);
wan1:=DINT_TO_INT(wan);
shiwan1:=DINT_TO_INT(shiwan);
baiwan1:=DINT_TO_INT(baiwan);
qianwan1:=DINT_TO_INT(qianwan);
yi1:=DINT_TO_INT(yi);
shiyi1:=DINT_TO_INT(shiyi);
fc5 (led_in:=ge1,led_out:=led_ge);
fc5 (led_in:=shi1,led_out:=led_shi);
fc5 (led_in:=bai1,led_out:=led_bai);
fc5 (led_in:=qian1,led_out:=led_qian);
fc5 (led_in:=wan1,led_out:=led_wan);
fc5 (led_in:=shiwan1,led_out:=led_shiwan);
fc5 (led_in:=baiwan1,led_out:=led_baiwan);
fc5 (led_in:=qianwan1,led_out:=led_qianwan);
fc5 (led_in:=yi1,led_out:=led_yi);
fc5 (led_in:=shiyi1,led_out:=led_shiyi);
END_FUNCTION
数据转换和位分离程序