Write I/O (Tutorial)

The following exercise assumes that you have completed all the tutorial lessons prior to this in the menu. If so, ignore this note and continue.

If not, you can still do this exercise. Load the Training Simulator, as described in Add Applications (Tutorial). Navigate to the Sample Pages >> Demo Page and follow the instructions there to enable the Demo System tags. You will need to make adjustments in the exercise steps since the path to the tags won't be the same, and the Demo System has been built to a state that may not match that of the previous chapter in this tutorial.

The simulated system that you're building will be more interesting if you have a way to control it. In this section you'll see how to open and close the valve that allows fluid to flow into the tank. You'll also see how to adjust the speed of the pump that drains it.

Preparation: Monitor flow into and out of the tank.

  1. Open the Tag Browser.
  2. Navigate into Station 1 to select CommChannel.
  3. Right-click on CommChannel to open the pop-up menu.
  4. Select New Child.
    The Select Type dialog opens.
  5. Select I/O and Calculations.
  6. Name the tag, Inflow
  7. Set the description to Flow into storage
  8. Ensure that the data type is set to Analog.
  9. Select the I/O tab.
  10. Ensure that the I/O Device is set to [*Driver] Simulator connection
  11. Set the read address to 40003/float.
    Why "/float"? Just for the sake of seeing & using an alternative addressing format. Look in the reference section of the documentation for a list of data suffixes for tag I/O addressing.
  12. Set the scan interval to 2.
    In general, scan as often as needed, but not any more often than needed.
  13. Select the Scaling tab.
  14. Set the Unscaled Process Data values to 0 and 200 for Min and Max.
  15. Set the Scaled Process Data values to 0 and 200 for Min and Max.
    The Display Range and Expected Range values are blank.
  16. Select the Display tab.
  17. Set the Engineering Units to gpm.
  18. Set Digits After Decimal to 1.
  19. Set the color to a shade of blue other than set for the Level tag.
  20. Click OK to save your work and close the properties dialog.
  21. Draw this tag as a Numeric Value on the Station Status page.
    (Step-by-step instructions not provided. You've seen enough by now to do this on your own. Refer to the documentation if you need help.)
  22. Use the text tool in the Home ribbon to add a text label above the Numeric Value: Flow into storage.

 

In the simulator's code, the inflow rate is set to change randomly every few minutes.

Where Inflow belonged to the station in general, outflow is a direct result of what the pump is doing, so you'll put the next tag into that context.

 

  1. Close the Idea Studio and open the Tag Browser.
  2. Find and right-click on Pump 1 to open the pop-up menu.
  3. Select New Child.
    The Select Type dialog opens.
  4. Select I/O and Calculations.
  5. Name the tag, Flow
    Since this is a child of Pump 1, there should be no need to explain "flow of what" in the name.
  6. Set the description to Flow rate
    Notice that the description from the last tag was still there? This can save you time when creating several similar tags.
  7. Ensure that the data type is set to Analog.
  8. Select the I/O tab.
  9. Ensure that the I/O Device reads, [*Driver] Simulator connection
  10. Set the read address to 40033.
  11. Set the scan interval to 2.
  12. Select the Scaling tab.
  13. Set the Unscaled Process Data values to 0 and 200 for Min and Max.
  14. Set the Scaled Process Data values to 0 and 200 for Min and Max.
  15. Select the Display tab.
  16. Set the Engineering Units to gpm.
  17. Click OK to save your work and close the properties dialog.
  18. Draw this tag as a Numeric Value placing it near the pump Equipment widget.

 

If Running is 0, that's also what the Flow rate will be. As soon as the pump re-starts you'll see a flow.

Create a digital control

The control for the inlet valve is simple. It can be open or closed. There is no control over how much it is open.

The controller has two input coil addresses for the valve: 00002 monitors the current state (feedback for the open or closed state) and 00001 is used for control. Both will be used in this tag.

  1. Open the Tag Browser if it is not already open.
  2. As a child of CommChannel, create a new I/O and Calculations tag.
  3. Name the tag, Inflow Valve.
  4. Set the description to Inflow control valve
  5. Change the data type to Digital.
  6. Select the I/O tab.
  7. Set the Read Address to 2
  8. Set the Write Address to 1
  9. Click OK to save your work and close the dialog.
    Do not close the Tag Browser

 

That's all there was to creating the I/O. But, you still need a widget so that you can tell it what to write, and when.

Care is required when configuring both a read and a write address. Only values from the read address are shown as the value of the tag. If the value at the read address differs from the value written, the tag's Mismatch variable is set to TRUE, as reflected in widgets linked to this tag. The value at the read address is NOT sent to the write address on change.
In this example, the read address is providing independent feedback of the value written to the write address.

Draw a digital control widget

You will draw this control as a pair of Set Value Button Widgets. One button will write a 1 to open the valve and the other will write a 0 to close it.

  1. While continuing to work in the Tag Browser, right-click on the tag you just created, Inflow Valve.
  2. In the pop-up menu, select Draw.
    The Idea Studio opens, and in front of it a separate window for the widgets palette.
  3. In the floating widgets palette, open the Buttons & Switches folder.
  4. Open the Basic Controls folder.
    (You may need to scroll down to see it.)
  5. Select the Set Value Button and drag it to the Idea Studio page, placing it near the number that shows the inflow rate.
    (Careful! Be sure that you've selected the Set Value Button, not the Momentary Button.)
  6. When the Tag Browser reopens, close it.
  7. Now working in the Idea Studio, right-click on your Set Value button.
    A pop-up menu opens.
  8. Select Properties from that menu.
    The Set Value Button Properties dialog opens.
  9. In the space for the State 0 Label, type Open
  10. In the space for the State 1 Label, type Opened
  11. Select the option, Write 1 Immediately

  1. Select OK to save your work and close the dialog.

 

To create the Close control, you'll copy and paste the last button rather than create a new one.

 

  1. Ensure that the "Open" button is selected in the Idea Studio.
  2. Press the keyboard combination Ctrl + C to copy it.
  3. Press the keyboard combination Ctrl + V to paste.
    The copy will appear in the center of the page.
  4. Drag the new copy to a position below the original button.
  5. Right-click on the copy and select "Properties" from the dialog that opens.
  6. Change the two labels to Closed and Close, in that order.
  7. Select the option, Write 0 Immediately.
  8. Close the Idea Studio and operate the valve.

 

You should see the inflow rate drop to zero when the valve is closed. Give the simulator time to process each operation. Note that if the inflow valve stays closed for very long, not much else is going to happen in this system. You'll want to leave it open most of the time.

Create an analog control

The pump has a slightly better control system than the valve. It's top running speed is 1200 rpm and it can be set to any value between that and zero. The controller uses holding register 40037 for the speed setpoint. It also uses holding register 40039 for independent confirmation of that setpoint. Not every system will be programmed this way, but it's nice when available. And you still need only one tag.

 

  1. Open the Tag Browser.
  2. Right-click on Pump 1 and select New Child from the menu that opens.
  3. Select I/O and Calculations as the type.
  4. Name the tag, Speed Set.
  5. Describe it as Motor speed setpoint
  6. Set the data type to Analog.
  7. Select the I/O tab.
  8. Set the Read Address to 40039
  9. Set the Write Address to 40037
  10. Select the Scaling tab.
  11. Set both the Max Unscaled Process Data and the Max Scaled Process data to 1200
    (Inputs use scaling only to map raw values to engineering units. The value is not limited to these settings.
    Outputs use the Scaled Process Data settings as limits.)
  12. Open the Display tab.
  13. Set the Engineering Units to rpm
  14. Select OK to save your work and close the properties dialog.

A moment or two after saving, the system should read the feedback address (40039) and the tag's value will show as 640, the default for the simulation.

Draw an analog control widget

There are several widgets that you could use for operator control of this tag; Rotary Control Widget (Knob), Slider Widget, Set Analog Value Widget, and more. The next exercise uses a rotary control, but you can choose any of the others if you prefer.

 

  1. Continuing to work in the Tag Browser, right-click on the tag you just created, Speed Set.
  2. In the menu that opens, select Draw.
  3. In the widgets palette, navigate to the Analog Controls folder.
  4. Drag a Silver Knob to the open page in the Idea Studio, placing it below or near the pump.
  5. When the Tag Browser reopens, close it.
    The Multi Image Widgets panel opened on the right of the Idea Studio. Close it.
  6. Close the Idea Studio.
    You could adjust the display properties of this widget, but there's no need.

 

Operate the controls. When the pump is on, you should be able to change the flow rate by turning the knob. If the pump is off, the flow rate is going to be zero, no matter what the speed setpoint is.

Feeling impatient while waiting for the tank to fill and the pump turn on? If you work in the Training Simulator application and navigate to the Sample Pages folder, then Demo Pumping System page, you'll see a speed factor. The default is 25. The bigger the number, the faster the simulator will run. (maximum: 75) A lower number gives a more realistic-looking simulation.

Bonus Step: Practice what you've learned

The pump includes the following analog I/O. Create tags and draw them as widgets of your choice. In both cases, the scale value is the maximum for both the unscaled process data and the scaled process data.

Tag Name Description Read Address Scale Eng. Units
Current Electric current drawn 40031 50 Amps
Speed Motor Speed 40035 200 gpm

 

Ready to continue? Open Selector Switches (Tutorial)