Unity Pro - Modbus Management

ndelucca

Member
Join Date
Jul 2013
Location
Rosario
Posts
28
Hi everyone, i wanted to ask about Modbus configuration with Unity PRo. I have a Modicon M340 (modbus master), and 3 modbus devices (slaves) wich i want to communicate. Im using the Read/Write_VAR functions. The thing is, when i try to read the 3 devices, i get timeout errors (i have set the timeouts properly), and i cant read/write any of them, but when i have only one device configured, i have no problems. The read/write request i need to do are cyclical. Is there any function or option that takes care of all the communications secuence, or do i have to write the code from scratch?. Any advice would be appreciated. Thanks.
 
You have to manage the coms yourself. If you get response from first device then only poll to next device
 
Which modbus protocol are you using? Is it modbus tcp/ip, modbus RTU, Modbus ASCII, modbus Plus ??? Depending on which one you are using certain settings have to be taken into consideration
 
I have another problem, now focused on a single slave writing. The WRITE_VAR allows me to write a '%MW' value pretty easily. Now, it also says that you can write bits ('%M'), and this is what i cant do. I cant figure out the sintax i have to use, for example, i need to write the bit nº 4, in register 400, (ussually would be 400:X4), but it shows error. I've tryed many variants for the sintax and still doesnt work. Also, the parameters to write are in format of "ARRAY [n..m] of INT", and what im trying to write would be a BOOL or DIGITAL. If anyone could tell me how to do this, i would really apreciate it.
 
you might have to use BIT_TO_WORD block to send your bits across as words, and then WORD_TO_BIT on the other end. That is probably the easiest way.

otherwise I guess try use BOOL_TO_INT and map each bit to an integer, and then write this array of integers which are all either 0 or 1.

in M340 individuals bits in words are accessed as %MW400.4
 
the problem with the BIT_TO_WORD solution is that i can only program the master, on the slave side i cant touch anything but the bit itself. The slave is a soft starter Altistart 48 from Schneider. What i cant figure out is how to direct to the bit,ie: 400.3. (note that i can write the hole register 400 with an int, but i dont want to change any bits in exception of the nº3, cause many of those other bits are reserved for ATS48 system, and i could mess something up.
 
Oh I didn't understand that you need to write to a specific bit within a word on the remote end.

read the value of the word, change the bit you want, write the whole word back.

If the other bits in that word are reserved, you may find the register is read-only anyway and writing to it has no effect.

or as you say if the other bits in the word change in between the time you read it and write it back you might messing something up. Sounds like you might not be taking the right approach to this system, I like to hard-wire writes whenever I can, What is the signal you are trying to send (start/stop/reset?)
 

Similar Topics

Hello i want to implement a Read_var / Write_var functions to communicate with a modbus tcp device at the moment i use the unity simulator at the...
Replies
4
Views
1,970
Does anyone have a good doc that explains the addressing for modbus with unity. I am having issues setting up the addressing when trying to...
Replies
7
Views
4,005
Hello, P.S: I am new to this Forum, please excuse me if i ma writing in the wrong section or if i used something that isn't accepted within this...
Replies
11
Views
4,405
I have a confusion regarding modbus addressing that it looks like in unity PLC we can only access 1x (%Mx) and 4x (%MWx) registers and we have to...
Replies
3
Views
4,780
OK Gang, I'm setting up a M340 system using Wonderware as the HMI and I really want my DASMB server to match the addressing in the PLC and not be...
Replies
0
Views
2,205
Back
Top Bottom