Author Topic: RS-485 with Modbus  (Read 12166 times)

improtec

  • Newbie
  • Posts: 8
  • I'm a llama!
    • View Profile
RS-485 with Modbus
« on: June 26, 2012, 07:26:48 AM »
Hi,

Please, can you help me?

I have one F2424 working with  a RS-485 network with 6 ICPs Analogue inputs and 12 ABBs AC Drives and two LS AC Drives. With the ICPs modules all is ok, but the communication with the ABBs is too slow, about 25 seconds and cause the excecution time too slow. I use modbus RTU with the drives.

I think my problem is the way I did the dCusfu of the Modbus, I have to use for modbus commands for each drive, I mean are 12 x 4 = 48 modbus commands!

Wich is the the best way to arrange this commands? all in one dCusf?,one dCusf for each drive?, separate writemodbus of the readmodbus in different dCusf?

I'm using this now, one Cusf:

'Drive 1, direcci?n 09

relay[7]=READMODBUS (13,9,32)
IF TESTIO(Run_M7_1EF1)=1
THEN DM[212]=2             
ELSE DM[212]=1             
ENDIF

WRITEMODBUS 13,9,30,DM[212]
WRITEMODBUS 13,9,1,DM[213]
DM[214]=READMODBUS (13,9,102)

'Drive 2, direcci?n 10

relay[8]=READMODBUS (13,10,32)
IF TESTIO(Run_M8_RB)=1
THEN DM[216]=2             
ELSE DM[216]=1             
ENDIF

WRITEMODBUS 13,10,30,DM[216]
WRITEMODBUS 13,10,1,DM[217]
DM[218]=READMODBUS (13,10,102)

'Drive 3, direcci?n 11

relay[9]=READMODBUS (13,11,32)
IF TESTIO(Run_M6_1AD1)=1
THEN DM[222]=2             
ELSE DM[222]=1             
ENDIF

WRITEMODBUS 13,11,30,DM[222]
WRITEMODBUS 13,11,1,DM[223]

DM[224]=READMODBUS (13,11,102)

'Drive 4, direcci?n 12,

relay[10]=READMODBUS (13,12,32)
IF TESTIO(Run_M6_2AD2)=1
THEN DM[226]=2             
ELSE DM[226]=1             
ENDIF

WRITEMODBUS 13,12,30,DM[226]
WRITEMODBUS 13,12,1,DM[227]
DM[228]=READMODBUS (13,12,102)

'Drive 5, direcci?n 13

relay[11]=READMODBUS (13,13,32)
IF TESTIO(Run_M11_S_Z)=1
THEN DM[232]=2             
ELSE DM[232]=1             
ENDIF

WRITEMODBUS 13,13,30,DM[232]
WRITEMODBUS 13,13,1,DM[233]
'DM[234]=READMODBUS (13,13,102)

'Drive 6, direcci?n 14

relay[12]=READMODBUS (13,14,32)
IF TESTIO(Run_M4_1DCF1)=1
THEN DM[236]=2             
ELSE DM[236]=1             
ENDIF

WRITEMODBUS 13,14,30,DM[236]
WRITEMODBUS 13,14,1,DM[237]
DM[238]=READMODBUS (13,14,102)

'Drive 7, direcci?n 15

relay[13]=READMODBUS (13,15,32)
IF TESTIO(Run_M5_2DCF2)=1
THEN DM[242]=2             
ELSE DM[242]=1             
ENDIF

WRITEMODBUS 13,15,30,DM[242]
WRITEMODBUS 13,15,1,DM[243]
DM[244]=READMODBUS (13,15,102)

'Drive 8, direcci?n 16

relay[14]=READMODBUS (13,16,32)
IF TESTIO(Run_M4_2DCF1)=1
THEN DM[246]=2             
ELSE DM[246]=1             
ENDIF

WRITEMODBUS 13,16,30,DM[246]
WRITEMODBUS 13,16,1,DM[247]
DM[248]=READMODBUS (13,16,102)

'Drive 9, direcci?n 17

relay[15]=READMODBUS (13,17,32)
IF TESTIO(Run_M5_1DF2)=1
THEN DM[252]=2             
ELSE DM[252]=1             
ENDIF

WRITEMODBUS 13,17,30,DM[252]
WRITEMODBUS 13,17,1,DM[253]
DM[254]=READMODBUS (13,17,102)

'Drive 11, direcci?n 19

relay[17]=READMODBUS (13,19,32)
'IF TESTIO(Run_M3_SFCh)=1
'THEN DM[262]=2             
'ELSE DM[262]=1             
'ENDIF

WRITEMODBUS 13,19,30,DM[262]
WRITEMODBUS 13,19,1,DM[263]
DM[264]=READMODBUS (13,19,102)



support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:RS-485 with Modbus
« Reply #1 on: June 26, 2012, 10:49:42 AM »
It sounds like the ABB drives is either very slow in responding to the command or there may be comm error occuring. The PLC re-tries the comm a total of 3 times if the first attempt fail so you may not realize the errors that occured. You should connect the PC via an RS485 interface (e.g. U-485 adapter) and run a serial port monitoring software (e.g. the RealTerm software  http://realterm.sourceforge.net/ ) to monitor what's going on between the PLC and the ABB slave. This will give you a better idea if the ABB drive is just being slow or there is some problems during communication.

Note that your program seems to be sending back-to-back Modbus command that are addressing different slave IDs. Some Modbus slaves will ignore any consecutive Modbus commands if the last command it checked was not addressed to itself. This means that after you have talked to one slave attempt to immediately talk to the next slave may fail. This resulted in a timeout of the command and since the PLC re-tries, the timeout gives the newly addressed slave time to respond to the re-tried command but the PLC already wasted at least 0.15s in the first time out.

A trick that you can try is to add a small delay (e.g. run the statement DELAY 10) between two successive Modbus commands so that the slave has a chance to check if the new Modbus command is addressed to it.

If this does not address the problem and it is determined that the slow response is just part of the ABB drive characteristics and you have to live with it, then the only way not to affect the PLC program execution is to organize your {dCusF} to be triggered by a clock pulse periodically (e.g. 0.01s), and each time the custom function is called you only send the command to one slave and exit the function. A variable can be used to keep track of the ID of  the last slave that was addressed and the next time the same CusF is called a Modbus command is sent to the next slave until all the slave ABB drives have been addressed and the index can then be reset back to the first slave ID.
« Last Edit: June 26, 2012, 11:05:11 AM by support »
Email: support@triplc.com
Tel: 1-877-TRI-PLCS