Menu

modbus tcp single bit read and write

Help
2018-10-26
2018-10-29
  • Mike Cinquino

    Mike Cinquino - 2018-10-26

    Hello,

    I am looking to start simple and simply read a value from a rockwell micro850 plc. I have been able to do this with other applications.

    On the PLC side I have a few direct coils mapped. To start I would like to be able to read a boolean variable with the modbus address of 00002. I am new to this but I believe the modbus function is 01 write direct coil.

    So I have my TCP_UDPPort setup. I have a ModbusTCPDriver linked to that port and I have a single tag to do the write with.

    The memor address on the PLC side is 00002. If I try to assign the tag MemAddress to 00002 it converst it to 2? Not sure if that is the problem. My tag MemReadFuction is set to 1 (Read Single) and MemWriteFuntion is set to 5 (Write Single). Everything else is default.

    I have attached images of what I have.

    Any help would be greatly appreciated.

     
  • Fabio Luis Girardi

    Hi Mike!

    PascalSCADA don't use the Modbus Address format (0xxxxx, 1xxxxx, 2xxxxx, 3xxxx and 4xxxxx), so, the address typed in MemAddress is the absolute, starting from 0, address. The area of the data being read/write is choosed by MemReadFunction and MemWriteFunction, were Modbus function 01 is used to read coils (more than one on a single request) states and 05 is used to set a single coil. So, your tag in PascalSCADA should have:

    MemAddress=2
    MemReadFunction = 1
    MemWrieFunction = 5 (single coil) / 15 multiple coils

    As you have done. The unique thing that you did wrong is, as modbus functions 01, 02, 05 and 15 works/maps bits, you don't need the TTagBit, since your PLCTagNumber using these functions becomes a coil bit. Except if you changed the property TagType of your TPLCTagNumber from pttDefault (that in this case, with MB functions 01, 02, 05 and 15, means bit) to anything else. If you changed this property to anything different from pttDefault, you should use TTagBit.

    Another point, is that you don't need a button to show the tag value in Label/Edit. Use the controls THMIEdit/THMILabel and link the property PLCTag with desired tag. But if you need the access the PLCTag Value in your code, your code is correct at all.

    My notebook keyboard is broken. Please forgive-me if I typed something wrong.

    PS. If in CCW you have declared the coil address 00002, try change the PLCTagNumber.MemAddress to 1

     
  • Mike Cinquino

    Mike Cinquino - 2018-10-29

    Thank you for getting back to me so quickly.

    I was able to get things working with the info you provided and some other changes I found.

    It looks like the addressing on this combination of hardware is 1 less than the assigned value. I have attached a few screen shots of some other things I missed that may be helpful to others.

    On the image labeled active I missed that the default propoerty is false. It is a little tricky because it says false w/o a check mark. That made me think it was active.

    On the image labeled driver I missed 2 things. The ProtocolDriver needs to be selected and the PLCStation needed to be set as 1. I am assuming another PLC added to the network would be 2 and so on.

    on image on off I show the code I used to turn a bit on and off. 2 buttons one for on and one for off. In that example SCADA_1 is a TPLCTagNumber.

    I think that was it. Now I will try to move some data back and forth.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.