Делаю опрос частотника через бибку, вроде и опрос идет но значения все одинаковые, понимаю что где-то скосячил , но не вижу ошибку:
ComConn1(enable:=TRUE,PortNum:=3,PortBaudrate:=192 00,PortParity:=0,PortStopBits:=1,PortByteSize:=8,
Port_Mode:=2(*0-rs232*),Port_ModeOn:=FALSE,Port_CloseOn:=FALSE,Han dle=>id_port,Done=>port_ok,ErrCode=>er_com1);
CASE step OF
0://Опрос регистра статуса
MRhR(Enable:=port_ok,Mode:=MB_RTU,DevAddr:=48,Firs tAddr:=RegAddr1,
Quantity:=1,ComHandle:=id_port,TimeOut:=T#100MS,Bu ffer:=bufferATV,Complete=>ok_op,
Exception=>er_op,ByteCnt=>);
IF ok_op AND er_op=0 THEN
ptr_x:=ADR(status);
ptr_x^:=BufferATV[1];
ptr_x:=ptr_x+1;
ptr_x^:=BufferATV[0];
MRIR(Enable:=FALSE,Buffer:=buffer1);step:=1;
ELSE MRIR(Enable:=FALSE,Buffer:=buffer1);error_opr:=MRI R.Exception;step:=1;
END_IF
1://Опрос регистра тока
MRIR(Enable:=port_ok,Mode:=MB_RTU,DevAddr:=48,Firs tAddr:=RegAddr2,
Quantity:=1,ComHandle:=id_port,TimeOut:=T#100MS,Bu ffer:=bufferATV,Complete=>ok_op,
Exception=>er_op,ByteCnt=>);
IF ok_op AND er_op=0 THEN
Bytes_word1.mas_byte[1]:=BufferATV[0];
Bytes_word1.mas_byte[0]:=BufferATV[1];
tok:=Bytes_word1.var_word;
MRIR(Enable:=FALSE,Buffer:=buffer1);step:=2;
ELSE MRIR(Enable:=FALSE,Buffer:=buffer1);error_opr:=MRI R.Exception;step:=2;
END_IF
2://Опрос регистра напряжения
MRIR(Enable:=ComConn1.Done,Mode:=MB_RTU,DevAddr:=4 8,FirstAddr:=RegAddr3,
Quantity:=1,ComHandle:=id_port,TimeOut:=T#100MS,Bu ffer:=bufferATV,Complete=>ok_op,
Exception=>er_op,ByteCnt=>);
IF ok_op AND er_op=0 THEN
Bytes_word1.mas_byte[1]:=BufferATV[0];
Bytes_word1.mas_byte[0]:=BufferATV[1];
volt:=Bytes_word1.var_word;
MRIR(Enable:=FALSE,Buffer:=buffer1);step:=3;
ELSE MRIR(Enable:=FALSE,Buffer:=buffer1);error_opr:=MRI R.Exception;step:=3;
END_IF
3://Опрос регистра наработки
MRIR(Enable:=ComConn1.Done,Mode:=MB_RTU,DevAddr:=4 8,FirstAddr:=RegAddr4,
Quantity:=1,ComHandle:=id_port,TimeOut:=T#100MS,Bu ffer:=bufferATV,Complete=>ok_op,
Exception=>er_op,ByteCnt=>);
IF ok_op AND er_op=0 THEN
Bytes_word1.mas_byte[1]:=BufferATV[1];
Bytes_word1.mas_byte[0]:=BufferATV[0];
narabot:=Bytes_word1.var_word;
MRIR(Enable:=FALSE,Buffer:=buffer1);step:=4;
ELSE MRIR(Enable:=FALSE,Buffer:=buffer1);error_opr:=MRI R.Exception;step:=4;
END_IF
4://Запись в регистр частоты
write1:=fregensy;
MWSR(Enable:=ComConn1.Done,Mode:=MB_RTU,DevAddr:=8 ,RegAddr:=16#219A,
Value:=write1,ComHandle:=id_port,TimeOut:=T#100MS, Complete=>ok_wr,Exception=>);
IF ok_wr THEN
MWSR(Enable:=FALSE,value:=0);step:=5;
ELSE MWSR(Enable:=FALSE,value:=0);error_wr:=MWSR.Except ion;step:=5;
END_IF
5://Запись в регистр частоты
write1:=stat_in;
MWSR(Enable:=ComConn1.Done,Mode:=MB_RTU,DevAddr:=8 ,RegAddr:=16#2135,
Value:=write1,ComHandle:=id_port,TimeOut:=T#100MS, Complete=>ok_wr,Exception=>);
IF ok_wr THEN
MWSR(Enable:=FALSE,value:=0);step:=0;
ELSE MWSR(Enable:=FALSE,value:=0);error_wr:=MWSR.Except ion;step:=0;
END_IF
END_CASE