Read & write BOOL data via Modbus TCP between two Mico850 controllers

ahaanwar2

Member
Join Date
Jan 2020
Location
Sanaa
Posts
19
Dear all, glad to be here and I hope that we all can benefit from this great community.

I am trying to send and receive data between two Mico850 controllers, however my data types are different (Real, INT, and BOOL). Should I create more than Msg_modbus2, each for each type of data or one read and another write Msg_modbus2 are enough.

Moreover, the data carried in the msg_modbus2 are in WORD format, I can convert INT to WORD using the Convert function (any to word) and (any to int) directly, but how about converting the REAL and BOOL data types?

I can do without REAL as INT can be enough, but how to deal with BOOL data. Should I use some sort of arrays or what?

Please help me as I am frustrated.

Best,
Anwar
 
Welcome to the PLCTalk forum community !

You are correct that you should use arrays by "packing" the BOOL tags into bits of a WORD type tag, and sending one or more 16-bit WORDs of data using Modbus/TCP.

Your logic on the receiving side should then "unpack" that data into the desired BOOL tags.
 
Thanks a lot for your response, could you please give me an example how to pack and unpack the booleans into word. What function to be used, and how to use it?
 
No function necessary: look up bit addressing modes in the help file.





Micro850 source: pack bits B3:0/0 and B3:1/0 into N7:0; send N7:0



Code:
   B3:0/0     N7:0/0
----] [---------( )-------


   B3:1/0     N7:0/1
----] [---------( )-------


(send word N7:0 data via Modbus)
Micro850 destination: receive N7:1; unpack bits into B3:2/0 and B3:2:1:


Code:
(receive data into word N7:1 via Modbus)



    N7:1/0     B3:2/0
-----] [---------( )-----

    N7:1/1     B3:2/1
-----] [---------( )-----
You may even be able to send words B3:0 and receive into B3:2.
 
Last edited:
Thanks for the help.


Do I need to use two MSG_Modbus2 functions for read and two for write?
Because I am reading and writing INT and BOOL variables. I mean, with the conversion using bit addressing do I need to still use a separate MSG_Modbus2 for Boolean variables?


Regards
 
Last edited:

Similar Topics

Greetings. I have a 1769-L30ER that runs a new piece of equipment my company bought. I would like to read from and write to some tags on this PLC...
Replies
7
Views
1,436
Hi everyone, I am working on a project that needs to expose the SV (Set Value) of a temperature controller to a SCADA system. SCADA <-...
Replies
4
Views
164
Thank you for any and all responses/help. I have an RSLogix 5000 v20 and a Cognex In-Sight v5.9 spreadsheet (8502P). I can not figure out how to...
Replies
0
Views
137
Dear colleagues, I am reaching out for assistance with an issue I am having. I have a code that can successfully insert data from FactoryTalk...
Replies
6
Views
1,058
Back
Top Bottom