adccommunitymod (AutomationDirect) asked a question.

Linux C programming with libmodbus

Created Date: January 22,2020

Created By: rpettigr

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

I am writing code to read select coils on a Click PLC in C on a raspberry pi. The intent is a cheap monitor to send out an email if an alarm condition appears. I have been successful at reading data from SD019 to SD023 5 registers from Modbus addrress 61459 (The real time clock). What I am having trouble with is finding the addresses of C1, C2 and C3. The data points I am reading do not show the BITs being flipped for these coils. I tried reading at Modbus address 3074 and at modbus address 16385. I do not know if anyone else ventures into this kind of programming but I am looking for at least a pointer to where I could be going wrong for Modbus addresses. The solution is out there somewhere..... Thank you for your time. Ron


  • adccommunitymod (AutomationDirect)

    Created Date: January 22,2020

    Created by: rpettigr

    I am writing code to read select coils on a Click PLC in C on a raspberry pi. The intent is a cheap monitor to send out an email if an alarm condition appears. I have been successful at reading data from SD019 to SD023 5 registers from Modbus addrress 61459 (The real time clock). What I am having trouble with is finding the addresses of C1, C2 and C3. The data points I am reading do not show the BITs being flipped for these coils. I tried reading at Modbus address 3074 and at modbus address 16385. I do not know if anyone else ventures into this kind of programming but I am looking for at least a pointer to where I could be going wrong for Modbus addresses. The solution is out there somewhere.....

    Thank you for your time.

    Ron

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: January 23,2020

    Created by: RBPLC

    Have you tried verifying the address with something other than the Pi? For example I can pick up that address (16385) using the QModMaster program and a BRX plc but I can't pick it up with the ModbusTCPMaster Program. It could be an implementation of a specific library that is being used in the Pi.

  • adccommunitymod (AutomationDirect)

    Created Date: January 23,2020

    Created by: Adisharr

    Have you tried verifying the address with something other than the Pi? For example I can pick up that address (16385) using the QModMaster program and a BRX plc but I can't pick it up with the ModbusTCPMaster Program. It could be an implementation of a specific library that is being used in the Pi.

    Do you find one Modbus simulator to be more 'compliant ' than others?

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: January 23,2020

    Created by: Tinker

    What functions are you using? registers and bits need different functions, I'd guess that C bits would need modbus_read_bits() since the CLICK address picker says to use MODBUS function 01 .

    modbus_read_input_registers() uses function 04 and would probably work for SD registers.

    One experiment I would try is, since you have been able to read an integer from SD registers, I'd try packing some C bits into DH register an see if I could read that. However, the address picker shows modbus function 03 as being appropriate for DH which I guess would be modbus_read_registers() so one wouldn't exactly be trying something that already worked, but still it might provide some clues

    Expand Post