In this tutorial, we will explore the PD_7664 process component. We will build a temperature regulator like in tutorial 1, but now we want the control code to run when the temperature changes. As a result, we will use the notification model.
1. You need to build the light green component in the picture to the left.
a. You set a setpoint.
b. When the temperature is below the setpoint, the component should turn on an output that you connect to a heating element.
c. On the other hand, when the temperature is above the setpoint, the output should turn off.
2. You "measure" the temperature with a 4-20 mA temperature transmitter.
3. The regulation is a simple on/off controller with a temperature hysteresis. It must run every time the input temperature changes.
The diagram below shows what you will build in this tutorial. The red dots show tutorial steps.
The last tutorial uses the classic “polling” model, where input values are read at an interval with the help of a timer.
The COPP notification model pushes values only when data change.
One component is a servant for a supervisor component. The supervisor sends orders through "Required" to its servants. The servants inform their supervisor, by sending their Actual state or value, and condition when it changes or as a response to an order from the supervisor.
Required, used to instruct the servant.
Actual, the actual state or value, and condition of the servant.
You fit the data type of Required and Actual 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 copy the data to Required in the supervisor proxy register and call the supervisor proxy method - Required_changed - within the servant.
When the servant wants to tell the supervisor that data has changed, it writes to Actual in the supervisor proxy register. It will copy the data to Actual in the servant proxy register and call the servant proxy method: Actual_changed in the supervisor. The system will keep the data in the two registers the same. After a node disconnects from the P-NET, servant power-up, supervisor power-up, or power-up on both, the system will make the data in the registers the same.
So what we want to build is this:
And what we built in tutorial 1 is this:
So now that we know the model, let's build our component.
1. Create the component
a. Open PD_7664 Process_component. Select the type in the open type menu. You use this component as ancestor to a new Process_component.
b. Right-click on the component and select “Create new type”.
d. A new tab will open, and you change its name to XX_Temperature_regulator_notification.
2. Add Setpoint_value
a. Add a non-volatile variable, Float32 and call it Setpoint_value.
b. Set Quantity to absolute temperature.
c. Set default value = 25 degrees celcius
3. Add the register Setpoint
b. Enable "get" and "set" for all user types.
c. Set max value to 40 and min to 20.
d. Do the same for alarm max and alarm min.
1. Open method Calculate_actual in the Temperature regulator component and read the documentation. This method is called when there is a change reported from a servant (Actual_Changed), so there is no need for a timer.
The task of the regulator is to figure when the output should be on. If the temperature is lower than the setpoint, then turn on the output, in all other cases close the output.
This is what your code should look like:
Next step is to create an assembly for the temperature regulator:
1. Select ‘Create new type’ on the main button menu and select ‘Assembly’.
2. Rename to XX_Temperature_regulator_notification_assembly.
3. First, right-click to add your control component.
a. Then, right-click to add a temperature input transmitter interface PD_2855 - Temperature_input_4_to_20_mA.
b. Rename to "Temperature_input".
a. Last, right-click to add the output interface PD_2823 - Digital_1A_DC_output.
b. Rename to "DC_Output".
a. Now click on your control component.
b. Right-click on the Temperature servant proxy.
c. Connect it to the just added temperature input transmitter supervisor proxy.
7. Connect Output servant proxy in the same way to digital DC output.
3. Rename to "Window_for_XX_Temperature_regulator_notification_assembly".
5. Save your view.
6. Add view to viewlist
b. Click on the plus sign beside " XX_temperature_regulator_notification".
c. Select register "Setpoint".
d. Select view PD_2159 - Number_name_value_unit.
7. On your view, you now see the element and you can drag it to where you want on the screen.
b. Double-click on "XX_temperature_regulator_notification".
c. Select PD_2292 - Name.
Your view should look like this:
a. Create new type - Assembly
b. Rename it to XX_Temperature_regulator_notification_main
2. First, add the assembly PD_15858- Download_assembly_for_tutorial. The assembly has a COPP PC device used as downloader of customware. Further, it has a PD 610 COPP device used to create an Ethernet connection.
You will now need a project.
1. Select "create new type" and select project.
3. Add your new main assembly "XX_Temperature_regulator_notification_main".
You will reuse the testbed from tutorial 2 with the same wiring.
5. Save and build.
6. Start the COPP-PC and power on the modules.
7. Connect PD 610 to the PC via an USB-Ethernet Adaptor. We prefer D-link-1312.
1. Press the "Start project downloader" button.
A system window opens.
2. Press "config all modules".
a. Wait for the program to finish.
b. Check that there are no failed modules.
Now your code is loaded into the modules.
Your display PC will show you the view, and you can change the input by moving the knob on the input.
3. Change the setpoint by keying in a value.
4. See how the output changes from on to off, when you change the temperature and the setpoint.