muna
hi , 
can we change the setpoint remotely (without need to change it directly from ladder logic program)?! If yes, what is its address with openplc mega, please?! 

Regards,
Reply 0 0
thiagoralves
The address depends on where your setpoint variable is located. Just use Modbus to remotely write to the variable. Just keep in mind that only output variables can be written using Modbus (holding registers). The correlation between variable addresses and modbus addresses can be found here: http://www.openplcproject.com/scada
Reply 0 0
muna
setpoint is set as input , in the same side with sensor value then I used condition (greater than) then coil. I want to switch  the coil on if the sensor value greater than setpoint, that means should be in input side.  does this  mean I cannot change the setpoint in this case?
Reply 0 0
thiagoralves
Input of a block is not the same thing as a variable-defined input. When I mean input, I'm talking about the PLC input (variables defined in the range %IX0.0, %IW0, etc). These variables hold the values read by the PLC input pins. Therefore, variables defined in those locations cannot be written by Modbus commands. In the other hand, variables like %QX0.0, %QW0, etc are output variables, since the content of these variables are transferred to PLC output pins. These variables can be read and written by Modbus commands. Ideally you should actually use memory variables (%MW0) to store your setpoint. Memory can also be read and written by Modbus.
Reply 0 0
muna
Ok. Thank you 
I will try it 
Reply 0 0
muna
Hi, 

I have question about coil, could you answer it, please? 
I have tried for many days to write command to switch coil on or off, but it didn't work. I can only read its values. 
Through my searching, I found this in Forum 

"We figured it out about the same time your responded.  Just for the benefit of anyone that's reading this, the problem is fixed if you place holding contacts in series with the coils.  For instance, if you have a coil named LAMP (%QX0.0) be sure to put a contact named LAMP (%IX0.0) in series with the coil.  In this manner, the coil will indeed turn off when a write command is issued to the coil through MODBUS." 

I tried to add normal contact before the lamp in different places(here I am not sure how is it?  as I am not familiar with ladder logic).  I can't generate the program in any of these cases. I have only sensor and set-point connect as input for function block, then there is coil and power rail. could you help me to figure out it? How can I write command to switch on/off coil remotely. 

Reply 0 0
thiagoralves
I believe that the statement you quoted is false. It doesn't make any sense to me. What you need to keep in mind while writing to coils and registers using Modbus commands is that ladder logic takes precedence over Modbus commands. This means that if you have a rung that says your coil must be 0, your coil will remain 0 even if you send Modbus commands writing 1 to it. Therefore, in your setpoint example, instead of trying to write directly to the coil at the end of the rung (which will never work for the reason I mentioned), write to your setpoint variable using Modbus, and let the ladder logic do the rest. For example, if you have a GE block comparing your setpoint with the number 30, and the output of the GE block connected to your coil, every time you write a number bigger than 30 on your setpoint variable using Modbus, your coild will be turned on. If you write something smaller than 30, your coil will be turned off.
Reply 0 0
muna
Thanks for your response 
This sentence I found it here in discussion and question about writing to coil. 
Anyway, I compare sensor value with setpoint(this setpoint, I can change it remotely), if the sensor value greater than setpoint, the coil is on otherwise it is off.
So, your talk means I can't write on coil at all, it is impossible using ladder-logic, and even  SCADABR can't control the coil directly via this PLC . 
I can only control the coil through the setpoint, changing its value to switch on/off the coil. 
Reply 0 0
thiagoralves
No, what I said is that you can write to a coil as long as it is not being used as output coil by ladder logic. If ladder logic is writing to the coil, it will take precedence over Modbus. If all you want is to purely turn on/off a coil using Modbus, you can create a simple rung with a contact and a coil like this:
button = QX0.0
lamp = QX0.1

      button                  lamp
|------|   |------------------(  ) -------|

Therefore, when you use modbus to write 1 to "button" (QX0.0 - modbus coil address 0), ladder logic will toggle the "lamp" (QX0.1 - modbus coil address 1)
Reply 1 0
muna
Yes, I know this scenario. 
Thanks a lot for your helping . 
Reply 0 0
Reply