A small question for anybody using GX IEC and local variables (something i would ultimately like to know for GX Works 2 but the logic should be the same).
Local variables are assigned to devices (M, D,...) at compilation time but the assigned device can be different from compilation to compilation. For example, if i use a local variable "test" (a bit) and use M's in the assign pool, at compilation, "test" can be coupled to M8000 and the next compilation it could be coupled to M8001 and so on. The same goes for word devices,... and even more importantly timers.
My question: to me, it seems quite dangerous to transfer programs online while the plc is running, using local variables. For example, timers that are running or that have reached their endvalue, could be assigned to different timers at compilation and then transferred online while the plc is running. Words could be given different addresses,... How do you handle online program transfers in that situation?
Also, what does Mitsubishi actually mean with local variables? In pc programming languages, local variables are usually variables that loose their value when you exit the function, program block,... Converting this logic to plc, this would mean that each local variable looses it's value when leaving the POU and therefor needs to be initiated again the next plc scan. That contradicts the ability to use timers as local variables. Assume that i have a local variable "testw" (word) assigned to a device D (for example, compiler picks D20). Let's say that i put the value 50 into it in the POU. Next plc scan, should i assume that 50 is still in my local variable "testw" or should i assume that i can't really know the value of "testw".
Hope that makes sense. In summary:
- can i count on the fact that my local variables keep their value/state/... when leaving the POU and entering the POU again the next plc scan
- how do you deal with online program transfer with re-assignment of devices to local variables
phew :)
On a last note, gx works manuals mention that you should reset your plc after transferring a compiled program. That would make sense since every local variable would get it's initial value after reset (unlatched D => value 0, timers => 0, bits false,...) but there are definately times when you can't stop the plc and need to make an adjustment while in run.
