Recommended Posts

I have a problem about speed of sending data to PLC. I set 62 registers at same time. When I run the sequence below, it takes a long time. How can I optimize timing and offset of channels. I use ModbusTCP.

   RasyonNo1_Out = private.UretimID
   SILO1F_Out = result.hm1mk
   SILO2F_Out = result.hm2mk
   SILO3F_Out = result.hm3mk
   SILO4F_Out = result.hm4mk
   SILO5F_Out = result.hm5mk
   SILO6F_Out = result.hm6mk
   SILO7F_Out = result.hm7mk
   SILO8F_Out = result.hm8mk
   SILO9F_Out = result.hm9mk

   SILO10F_Out = result.hm10mk
   SILO11F_Out = result.hm11mk
   SILO12F_Out = result.hm12mk      
   PRESIRA1F_Out = result.pr1mk * 100
   PRESIRA2F_Out = result.pr2mk * 100
   PRESIRA3F_Out = result.pr3mk * 100    
   PRESIRA4F_Out = result.pr4mk * 100
   PRESIRA5F_Out = result.pr5mk * 100
   PRESIRA6F_Out = result.pr6mk * 100    
   PRESIRA7F_Out = result.pr7mk * 100
   PRESIRA8F_Out = result.pr8mk * 100
   PRESIRA9F_Out = result.pr9mk * 100    
   PRESIRA10F_Out = result.pr10mk * 100
   PRESIRA11F_Out = result.pr11mk * 100
   PRESIRA12F_Out = result.pr12mk * 100    
   PRESIRA13F_Out = result.pr13mk * 100
   PRESIRA14F_Out = result.pr14mk * 100
   PRESIRA15F_Out = result.pr15mk * 100    
   PRESIRA16F_Out = result.pr16mk * 100
   PRESIRA17F_Out = result.pr17mk * 100
   PRESIRA18F_Out = result.pr18mk * 100   
   SIVI1F_OUT = var.formulL1[0]   
   S1_ID_OUT[0] = result.hm1ic
   S2_ID_OUT[0] = result.hm2ic
   S3_ID_OUT[0] = result.hm3ic    
   S4_ID_OUT[0] = result.hm4ic
   S5_ID_OUT[0] = result.hm5ic
   S6_ID_OUT[0] = result.hm6ic    
   S7_ID_OUT[0] = result.hm7ic
   S8_ID_OUT[0] = result.hm8ic
   S9_ID_OUT[0] = result.hm9ic    
   S10_ID_OUT[0] = result.hm10ic
   S11_ID_OUT[0] = result.hm11ic
   S12_ID_OUT[0] = result.hm12ic

   PS1_ID_OUT[0] = result.pr1ic
   PS2_ID_OUT[0] = result.pr2ic
   PS3_ID_OUT[0] = result.pr3ic    
   PS4_ID_OUT[0] = result.pr4ic
   PS5_ID_OUT[0] = result.pr5ic
   PS6_ID_OUT[0] = result.pr6ic    
   PS7_ID_OUT[0] = result.pr7ic
   PS8_ID_OUT[0] = result.pr8ic
   PS9_ID_OUT[0] = result.pr9ic    
   PS10_ID_OUT[0] = result.pr10ic
   PS11_ID_OUT[0] = result.pr11ic
   PS12_ID_OUT[0] = result.pr12ic    
   PS13_ID_OUT[0] = result.pr13ic
   PS14_ID_OUT[0] = result.pr14ic
   PS15_ID_OUT[0] = result.pr15ic    
   PS16_ID_OUT[0] = result.pr16ic
   PS17_ID_OUT[0] = result.pr17ic
   PS18_ID_OUT[0] = result.pr18ic

Share this post

Link to post
Share on other sites

Timing doesn't affect output channels so that is not your issue. The issue is that every time you do:

myChannel = someValue

it has to send the Modbus query. So if you have 62 outputs, it will take 62 separate queries, which will be pretty slow.  To set multiple outputs at once, you'll have to bypass channels and use a function call instead.  To do this, create an array with the consecutive values:

private out
out[0] = firstRegistryValue
out[1] = secondRegistryValue
out[2] = thirdRegistryValue
// etc.

then call the function to send it:

device.myDevice.setRegisterS16(id, firstAddress, out)

There are other setRegister() functions depending on data type.

Share this post

Link to post
Share on other sites

Is there an unsigned set register function? When reading I use ReadHoldingU16() but there doesn't appear to be a corresponding SetRegisterU16()?

Share this post

Link to post
Share on other sites

No, there doesn't need to be.  The Modbus packet is the same.  It is up to your device to properly interpret the value.  For a read, however, DAQFactory has to know which type your data is as it can't tell from the packet (again, because it is the same).

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now