## Walkthrough - Create a TwinCAT HMI Project - General layout. Solution Explorer on the left, Canvas in the middle, Properties and Toolbox on the right. - The Properties pane is split into 3 with a Properties section, an Events section and a Permissions section (buttons in the top right). - The Document outline is also useful for HMI development. It shows all of the components of the HMI. Press the top button on the right of the canvas. Allows controls to be hidden and locked during development. - Create a PLC project within the overall Solution - Create variables in the PLC program. - Need to bind HMI properties to PLC variables. You can do this by clicking on the little squares to the right of property fields in the Properties pane. This will bring up a symbols window from which you can select variables. The symbols include data that resides in the HMI project (the Controls tab) or from the PLC via the ADS communications channel - Symbols from the PLC should be found in the Server Symbols tab. You may need to press the refresh button. - The property of a button to bind to to know if it has been pressed or not is "State Symbol" (True if pressed, false if released). - If you can't see the PLC symbols in the picker then it might be because the project is not targeting the correct runtime. On the Lenovo I have been using the usermode runtime (UmRT) due to issues with hyperthreading. By default the HMI is setup to look at the local runtime. So I needed to go to TwinCAT HMI > Windows > TwinCAT HMI Server Configuration > ADS > Runtimes > PLC1 and set the AmsNetId to the correct address. - It is useful to have the "TwinCAT HMI Configuration" pane visible along the bottom of the screen. It can be found in TwinCAT HMI > Windows. - The "TwinCAT HMI Configuration" pane allows for Symbols to be mapped manually. Find the Symbol in the Server Symbols > All Symbols section, right click and select "Map Symbol". You can then change the name if desired. - To bind the ellipse use the events section. There are 3 types of events - Custom - Typically "On Change" events - Put some data in the first field and the HMI will monitor it for any changes - The HMI will execute code if the variable changes - Framework - These are used by the HMI system itself in order for everything to work - The Framework category holds basic operations which happen to the Control itself - Operator - These items relate to the things that the operator can do - The second part is to configure the code that will run when the variable changes. Clicking on the pencil icon brings up the Actions and conditions window. - Along the left are a set of things that you can place in the steps canvas. Some of the items are logic and others are pieces of data that can be used by the logic steps. - We bring "Conditional" over. Bind the IF variable to the bProcess_Run so that we can change the colour of the ellipse based on whether it is true or not. To set the colour we look for the "FillColor" item inside the "Selected Control" (the ellipse). - Performance of the HMI is related to the update rate for the PLC data. This can be changed globally (all data) or for an individual variable. - Global setting can be reached by selecting the HMI project in the Solution Explorer and then finding the Deployment > Interval in the Properties pane. By default it is set to 500msec. - To set it for an individual variable we can find the Interval (ms) in the Settings section under the "Select Binding Source" window (set to 50ms as a test). Button - The label is in Common > Text - You can bind the button state to a BOOL in the PLC using the StateSymbol Combo Box Control - The initial text in the control is in Properties > Data > Combobox Text - Selection options can be setup within the PLC or within the HMI. - To set the options go to Properties > Common > SrcData. There is a button with ... that brings up a window that allows for options to be created in the HMI. - Need to use an event for communicating the selection back to the PLC. In particular the .onSelectionChange. Use a Write to Symbol with the Combobox Selected Value as the value. - Enabling another control when a Combobox has a value selected is done in a similar way to above. When the Combobox selection is changed you want to Write to Symbol for the other controls isEnabled property. TextBlock - The Multiline editor is a more convenient way of editing long text blocks. - You can concatenate strings in the editor by enclosing text blocks in '', and placing + symbols between blocks. You can load variables using a format that includes bracing the variable name in %i% characters (some examples below). The easiest way to find the correct string is to select the variable in the binding window and then copy the Symbol expression from the bottom of the window (do this in another property and then cancel that fake binding). - %i%VariableName%/i% - %s%ADS.PLC1.MAIN.tVariableText%/s% TextBox - Bind the "Common/Text" property of the TextBox to the PLC variable that you want it to mirror. - By default it will be a 1 way binding, meaning that the HMI will display the PLC variable but you won't be able to change the PLC variable from the HMI field (even though you can change the field itself) - [Right click](https://infosys.beckhoff.com/english.php?content=../content/1033/te2000_tc3_hmi_engineering/4995383179.html&id=5958415696114998347) on the binding token to "Edit Symbol". - Change the Binding mode to TwoWay. - You probably want to set the Binding event to .onTextChanged as well. DataGrid Appears to be relatively simple. - Define a struct with the data that will be in each row of the table - Create an array of these structs - Drag a DataGrid onto your Desktop.view. - Setup the columns - The name field needs to match the name of the data in the struct for each column of data - You can set if the data should be sortable or editable - Bind the DataSymbol to the array of structs - SrcData isn't required (as best I can tell) You need to setup the columns. The Name field needs to match the names of the variables in the struct that ## Known Problems I was initially unable to get the software to see the HMI server that was running on the PLC. The issue ended up being too many End points. In the Config webpage for the server the default Endpoints were - http://0.0.0.0:1010 - https://0.0.0.0:1020 - http://[::]:1010 - https://[::]:1020 With that in place I was unable to get the TcXaeShell to locate the server when attempting to setup the publishing process. With help from tech support I removed the bottom two lines, leaving only - http://0.0.0.0:1010 - https://0.0.0.0:1020 and things started working. I believe that the 0.0.0.0 address means that the server will be accessible from any of the computers network ports via IPv4. The [::] address (I think) indicates that the webserver will be accessible from any of the PLCs network ports via IPv6. So not sure why including the IPv6 wild card addresses would cause this problem. I've had difficulties with HMI projects when the server is on the PLC. You publish to the remote profile but you also need to set the default profile for ADS to the PLC so that you can access the symbols that are on the PLC itself.