plc - Panasonic FPWINPro Structured Text For Modbus - Stack Overflow

I've got a FP-X C60R Panasonic PLC with a AFPX-COM5 module.I have code that increments by 1 every

I've got a FP-X C60R Panasonic PLC with a AFPX-COM5 module. I have code that increments by 1 every second and it is working. I'm trying to figure out how to send counter value to a modbus holding register within the PLC. I'm trying to use port 2 of the COM5 module so modbus RTU Manual pg. 169/278 has a table but not sure how to implement.

// Monitor and increment the counter every second
timer_1s(IN := NOT timer_1s.Q, PT := T#1s); // The timer input is activated until it reaches Q

// The counter increments from 1 to 20, incrementing 1 time/second
IF timer_1s.Q THEN
    // Check if the counter has reached 4, if so, reset to 1
    IF counter >= 20 THEN
        counter := 1;   // Reset the counter to 1
    ELSE
        counter := counter + 1;   // Increment the counter by 1
    END_IF;
    
    // Store the counter value in Holding Register 0 (DT0)
    DT0 := counter;  // Store the counter in the first element
    
    // Trigger the Modbus communication to send the counter value to Holding Register 1
    modbus_request := TRUE;
END_IF;

When i compile, the compiler comes back with "DT0 is an explicit user address" so its like DT0 was never defined- i never defined it because i assumed by switching port 2 on the COM5 module to ModbusRTU would auto create the DT registers.

I've also tried looking here and adding

FP_MODBUS_MASTER(Port := SYS_COM2_PORT, SlaveAddress := 1, FunctionCode := SYS_MODBUS_16_PRESET_REGISTERS, StartRegister := 2, 
                 NumberOfRegisters := 1, MasterData := counter);
FP_MODBUS_MASTER(Port := SYS_COM2_PORT, SlaveAddress := 1, FunctionCode := SYS_MODBUS_03_READ_HOLDING_REGISTERS, StartRegister :=2, 
                 NumberOfRegisters := 1, MasterData := modbusRead);

with no luck (it compiles but will not stay in run mode)- essentially trying to write to the PLC holding register and then read from it. modbusRead returning 16#0000

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744869779a4598190.html

相关推荐

  • plc - Panasonic FPWINPro Structured Text For Modbus - Stack Overflow

    I've got a FP-X C60R Panasonic PLC with a AFPX-COM5 module.I have code that increments by 1 every

    1天前
    60

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信