Version:

This lesson is part of the Vision Components and Property Bindings course. You can browse the rest of the lessons below.

LESSON LIST

Autoplay Off

Supplemental Videos

LESSON

Control Components

Description

Learn how to use various input components (such as Numeric Text Field, Spinner, Formatted Text Field or Slider) and buttons (such as 2 State Toggle, Multi-State, One-Shot, or Momentary) to write values back to the database or PLC.

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] When creating real-time status and control screens, we often want operators to use control components to write values to PLCs. Control components are the core of data entry in ignition, and we will cover the most commonly used ones in this lesson. You can find the control components that come with ignition under the input and buttons tabs in the component palette of the designer. Let's start with the numeric text field. This component allows us to write a numeric value to PLC and the value we can write is dependent upon the number type property. The type can be an integer, double long or float, so it's important to select the appropriate number type to match the value property binding. If I bind the writeable integer one simulator tag to the component, you'll see the correct value integer binding was created to match the integer number type.

[01:05] If I look at the binding, it is marked as bi-directional, so I can write integer values to the PLC tag with the component. For example, I can go into preview mode and update the value to 25. However, if I try to enter a decimal value like 25.5, it does not get written because the value does not match the current number type property. We also have control over the value entered with the used bounds property. Enabling this property would enforce our value to be between the maximum and minimum properties. Additionally, enabling the error on out of bounds property would produce an error message. When we are out of bounds looking at the rest of our components properties, we have other notable options. The defer updates property makes it so our numeric value is updated after hitting the enter key.

[02:05] Otherwise, the update would occur with each keystroke. Typically, it's best to leave this enabled to avoid unwanted update consequences. Additionally, we can enable or disable editing on this component or disable it entirely with the protected mode. Let's move on to the spinner component. The spinner component allows you to modify a numeric value like a numeric text field would, and it allows you to spin the value up or down by some step size. The type of value that can be used is dependent upon the spinner mode property, which can be an integer double or date. For example, I can drag writeable double one to the component, and I can set the numeric step size to five. If I go into preview mode, I can actually spin this up by five every time and you can see it's writing that value to the PLC. Let's move on to the next input component, which is the slider.

[03:06] This component allows the user to drag an indicator along a scale to choose a specific value within a given range and right back to the PLC. It uses only an integer type for its value and it's very easy to use. I can drag rideable integer two onto the component and go into preview mode to drag my indicator along the scale. You can see the value of the PLC will update once I stop moving the slider. This is because the defer updates property is also enabled on this component as we likely wouldn't want the value to update while passing over each value. The scale of the slider can be changed by altering the minimum and maximum values and if the PLC value is outside these bounds an overlay will apply to the component. The slider also has a few appearance properties we can change. Disabling the horizontal slider property will change this slider to a vertical orientation and we can change the colors for the foreground and background and adjust the tick spacing.

[04:17] The final input component we will go over is the formatted text field. This component is a specialized text field used for alpha numeric text input that matches a specific pattern or format in a specific way. The format of the text depends on the validation mode, which can either be a regular expression or a formatted mask. A formatted mask user input is automatically formatted and restricted to a pattern. There are several commonly used formatted mask patterns to choose from, such as phone number percent or date. I will set the formatted mask pattern to a phone number and I can bind the committed value of the text field to writeable string one.

[05:05] If I go into preview mode, the formatted text field restricts my input to integers and it automatically formats my input around the special characters. This will write the formatted text to our writeable string one. Let's try a regular expression patternn next. First, I will assign the validation mode to a regular expression. The regular expression user input is validated against a special string that defines a set of allowed strings. There are several commonly used regular expression patterns like email address, IP address, and H-T-T-P-U-R-L and more input that matches the regular expression is allowed and input that doesn't match is restricted. Regular expression is very complicated, so don't worry if you don't understand each of the sample patterns. I can set the pattern to a last first name expression to see this in action.

[06:05] I can provide incorrect input like some numbers. However, the tag won't update because the regular expression is not looking for those numbers. However, if I provide accepted input, then the writeable string one tag will update. We also have additional properties to allow invalid text and to commit values while typing rather than after hitting the enter key. Now that we've covered the common input components, let's move on to the control component buttons. The first button we will discuss is the two state toggle button. This component can be used to toggle a value between two states on a machine like on and off. It makes use of four values, control value, indicator value and the values that define the two different states. State one and state two, each time the two state toggle button is pressed, one of the state values is written to the control value.

[07:06] The indicator value property determines which state the machine is currently in. For example, I can take the writeable integer three tag, drag it onto the component, and what it's going to do is bind the control and indicator value properties to the tag. For me and the control value is bound bidirectionally 'cause that's what you use to write back to the PLC. Right now the button is toggled to off, so our PLC value is reading a zero. If I put it to on, it's going to be a one. If I set state one's value to say 10 and state two's value to 20, then I could toggle between 10 and 20 and we can configure what we want this button to look like. By right clicking into the style customizer, we can specify how we want the colors and texts to look for those two different states. The next button is the multi-state button, which is just like the two state toggle button that allows you to do more than just two states.

[08:07] You can right click on the component and go down to customizers. Then multi-state button customizer to add the states you want. This shows the current three states for hand off and auto with available configurations for their text and styling, and we can add more states with the plus button. If I bind writeable integer four to the button, we can see the state changes are written to the tag as the control indicator is bound bidirectionally, just like how we saw in the two state button. Another button we have is the one shot button. This button allows the operator to only press the button once to write a value to the PLC and then it waits for the PLC to reset the value before becoming available again. For example, if I take rideable bole one and drag it onto the one-shot button, I can go into preview mode and click on this button and it will write a value of one to our tag.

[09:07] Setting the boolean to true. It will stay in the waiting or writing state until I reset the tag. The last button we'll look at is the momentary button. This button sets the value in the PLC for a specified number of seconds or however long the button remains held down, whichever is longer. The button uses a min hold time property that resets the value after a minimum number of seconds, which you can specify. Let's drag on rideable integer five. To see this, I can set the min hold time to five seconds and go into preview mode to write it to the tag. You can see after clicking the button, the control value that reads, our on value state was written to the tag for five seconds. Holding the momentary button longer than the minimum hold time will keep our value written to the tag and we can ensure our value is held for a maximum amount of time using the max hold time.

[10:10] So there's quite a few different components that you can work with to write back to tags in the PLC.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.