In this tutorial we will start exploring the built-in functionality of the PD_7664 proces component. We will build a temperature regulator with the same basic specification as in tutorial 1, but now we want the regulation algorithm to run whenever the temperature changes. Therefore we will use the supervisor/servant notification model.
What you need to build -control logic:
The task of the component (shown in light green in the illustration) is to regulate a temperature to a temperature specified in a Setpoint, by controlling an output connected to a heating element. The temperature is measured by a 4-20 mA temperature transmitter. The regulating principle is a simple on/off with a temperature hysteresis. The regulation must run every time the input temperature changes.
Important note on naming. Whenever you need to name a new type, the tutorial will indicate the name like this "XX_Temperature_regulator_notification". Please select two letters that make sense to you like your initials (JD for John Doe) and put instead of the XX -i.e. "JD_Temperature_regulator_notification".
The below illustration shows what you will build in this tutorial. The red dots indicate tutorial steps.
Notification - proxy model
The previous tutorial uses the traditional “polling” model, where input values are read at an interval, governed by the timer subcomponent.
The COPP supervisor/servant notification model pushes values only when they have changed.
One component is Servant for another supervisor component. The supervisor sends orders (Required) to its servant(s). The servant(s) inform their supervisor, by sending their Actual state/value and condition whenever it has changed or as response to an order from the supervisor.
Two special sub-components (connectors), called Servant-proxy and Supervisor-proxy implement this functionality.
Required, used to instruct the Servant.
Actual, the actual state/value and condition of the Servant.
The data type of Required and Actual is adapted to the application.
When the supervisor wants to send a command to the servant it writes to Required in the Servant proxy Register. This will automatically copy the data to Required in the Supervisor proxy Register and activate the Supervisor proxy method: Required_changed within the servant.
When the servant wants to inform the Supervisor that something has changed, it writes to Actual in the Supervisor proxy Register which will automatically copy the data to Actual in the Servant proxy Register and activate the Servant proxy method: Actual_changed in the Supervisor. The system will keep the data in the 2 registers identical. After disconnections on the P-NET, Servant power up, Supervisor power up, or power up on both, the system will automatically make the data in the registers identical.
So what we want to build is this:
And what we built in tutorial 1 is this:
So now that we know the principles of supervisor/servant, let us go ahead and build our component.
Step 1: Create a new control component with one variable exposed in a register.
Open PD_7664 Process_component, by selecting the type in the open type menu. This component is used as ancestor to a new Process_component.
Right click on the blue icon with a ‘C’ and select “Create new type”. A new tab will open and you change its name to XX_Temperature_regulator_notification.
Add a non-volatile variable, Float32, (set_point_value) and a corresponding register Set_point, set Quantity (absolute temperature) and default value = 25 degrees celcius. Make sure that "get" and "set" is enabled for all user types (this tells the visualisation that this variable must be editable). Set maximum value to 40 and minimum to 20 (same values for alarm max and alarm min).
Step 2: Add proxy subcomponents.
In the subcomponent section:
Add a "servant-proxy-for" of type PD_2854 Temperature_input_base and rename it to Temperature.
Step 3: Write your regulation code.
Open method Calculate_actual in the Temperature regulator component and read the documentation. This method is called whenever there is a change reported from a servant (ie Actual_Changed), so there is no need for a timer.
The task of the regulator is to calculate when the output should be on. If the temperature is lower than the set point, then activate the output, in all other cases close the output.
This is what your code should look like
Step 4: Create an assembly
Next step is to create an assembly for the temperature regulator:
- Select ‘Create new type’ on the main button menu and select ‘Assembly’.
- Rename to XX_Temperature_regulator_notification_assembly
- Right click to add your control component
- Right click to add a temperature input transmitter interface PD_2855 - Temperature_input_4_to_20_mA
- Right click to add the output interface PD_2823 - Digital_1A_DC_output
- Now click on your control component and right click on the Temperature servant proxy and connect it to the just added temperature input transmitter supervisor proxy.
- Connect Output servant proxy in the same way to digital DC output.
As stated in the specifications (top of the page) it must be possible to view and change the set-point and to view the current temperature. We will also add the name of the (instance of the) assembly.
Save your view.
Open your graphical editor (press the sun icon). You now see your visualisation. It is empty for now.
Right click on view list and select "add"- "view for control instance" Click on the plus sign beside " XX_temperature_regulator_notification". Select register "setpoint". Select view PD_2159 - Number_name_value_unit.
On your visualisation you now see the element and you can drag it to a suitable position on the screen.
Your visualisation should look something like this:
Step 6: Create a main assembly
- Create new type - Assembly - rename it to XX_Temperature_regulator_notification_main
- Add the assembly PD_15858- Download_assembly_for_tutorial. The assembly includes a COPP PC device(used as downloader of customware) and a PD 610 COPP device (used to establish ethernet connection)
- Add your assembly: XX_Temperature_regulator_notification_assembly.
- Add a PD 850 device - connect it to the net. This is the device that will hold your components
- Add a PD 6350 COPP PC with display - and connect it to the net. This is the device that will run your visualisation.
Step 7: Locate the control components.
Now you need to locate your software components in suitable hardware. For this tutorial we will use a PD 850 Multifunction module that contain both analogue and digital I/O as well as a processor, so all your components can reside in the one device.
Click on the PD 850 device. Double click on the components in the "Not located elements" and they will move to the "Located elements".
Step 8: Create a project.
You will now need a project.
- Select "create new type" and select project.
- Rename the project to: XX_Temperature_regulator_notification_project
- Right click and set Color theme
- Right click and set "Quantity Local unit relation table
- Right click and set "Editor for view type table".
- Add your new main assembly "XX_Temperature_regulator_notification_main".
- Add your visualisation "Window_for_XX_Temperature_regulator_notification_assembly" as guest view on the COPP PC with display".
- Find the "Project Downloader device" in the "download" assembly and set it as downloader.
Step 9: Finalising your project, downloading your code and testing your regulator.
You will reuse the already established test bed from tutorial 2 with the same wiring.
Save and build
Make sure that the COPP PC is started, the power is on on the modules and that the test bed is connected to the PC via D-link connector.
Press the "Start project downloader" button.
Now a system window opens and you press "config all modules". Wait for the program to finish. Check that there are no failed modules. Now your code is loaded into the modules.
You can now see your visualisation on the COPP PC module.