realolman said:
...Here's the deal : in the project organizer, your ladder logic MUST be in "programs"
I was following some tutorial and they put it in "user defined functions"...
realolman,
I must have missed this one originally and I'm sure by now you're a dab hand in CCW, but in the interest of "being more informed" with regard to the above...
You weren't to know, and I'm sure you were quite Green back then, but it should have been more obvious to Support that your "logic" was not running, at all. It took a savvy Support Engineer to twig that a fundamental mistake had been made.
But did they explain the difference?...
Why were you able to create logic under the User-Defined Function Block (UDFB) section, but we're not able to "Run" it?
CCW is quite simple in its project structure. A Program, whether it's written in Ladder Diagram (LD), Function Block Diagram (FBD) or Structured Text (ST), must indeed be created under the "Programs" section. Programs will only be executed from this section of the project.
So what is the purpose of creating a User-Defined Function Block (UDFB)?
Let's first look at what a Function Block does?
In software languages, a Function Block may contain input variables, output variables, pass-through variables, internal variables, and an internal behavioral description of the Function Block. Function Blocks are used primarily to specify the properties of a User Function which will then be instantiated in the program. Many software languages are based on Function Blocks.
So User-Defined Function Blocks allow a user to create a pre-defined logical operation for instantiation in their Programs.
UDFBs in CCW are very similar to Add On Instructions (AOI) used in Logix 5000 controllers. You create your pre-defined logic and variables (tags) and then the UDFB is made globally available for use in your Programs or even in other Projects. Again, this is similar to an Add On Instruction. There can be several instances of the same UDFB used in several Programs. A UDFB can be created, similar to Programs, using either LD, FBD or ST programming.
So the UDFBs are only defined under the UDFB section, and each instance is only executed in the Programs section. If a UDFB is defined, but not used in any Program, then it's pre-defined logic is not being executed anywhere while the controller is in Run Mode.
realolman said:
...I can build it with no errors, download it, and turn the PLC from rem run, to program, to rem run again... the software says I am connected but when I try to debug it, the debug doesn't show anything happening.. elements are supposed to be blue and turn red when true... mine's always black...
When you view the globally defined logic for a UDFB in a running controller, you will notice that the background is a distinctive Tan colour and the rungs will be Black, similar to when you are viewing a Program Offline. This is a "View Only" status. That is why you could not see the rung status for this logic changing.
The tutorial that you were following was obviously a using a UDFB and threw you off somehow. Perhaps it only showed the creation of the UDFB, but not its implementation in a Program? This made you think the tutorial had just shown you how to create a "User Program" and the rest is history.
Either way, that is what was happening.
To instantiate a UDFB in your Program, insert a Block instruction on the intended rung and the Block Selector window will open. Find your UDFB in the list; it should be of Type: IFB / Category: (User defined), and apply it. You will now have your UDFB instantiated as a Block instruction.
If you want to monitor the logical operation of an instance of a UDFB, while connected to the controller, then double-click on the instance itself, in the Program, and not the globally defined UDFB. This way the controller knows which instance you want to monitor and can correctly display its running status. You can also hover over a UDFB Block instruction and it will display a callout of all of its defined variables.
Regards,
George
This is a sample UDFB called "Pump Alternator"...