How Siemens 1200PLC displays time on Weiluntong HMI

First generate the timer DB, and then bind variables to the pins. In Siemens PLC, DINT and TIME can be converted implicitly.

The first method: set the touch screen component to DINT type

The data format of the numerical component is 32-bit Signed, corresponding to the DINT type in the PLC. There are no digits below the decimal point. This is for us to test the time running and remaining time display to see if there is any problem.  At this time, we input 5 and think it is 5 seconds, but it is only 5ms when it actually reaches the timer pin.

Then we can think of a way: change the components below the decimal point on the touch screen to 3 digits. In this way, when we enter 5.5, it will be 5500ms inside the PLC, which is 5S_500MS.

But this also has disadvantages, that is, whether it is the set time or the remaining time, it must be three digits after the decimal point. It is equivalent to changing the data size when inputting into the PLC by modifying the number of bits of the HMI component. Then let's look at the second method.

The second method: set the touch screen component to REAL type

Program internal variables are also set to REAL type.

At this time, you will see that the set time is OK, but the remaining time display is still not satisfactory.

So you need to divide the remaining time by 1000.

But the effect presented by the touch screen is that the remaining time cannot display the change of the number of digits below the decimal point. This is because when the DINT type is converted to the REAL type, the precision of the PLC content is lost, and we need to manually convert the data type.

Note here: the data type must be converted first and then divided by 1000. First convert DINT to REAL so that the number of decimal places can be retained, and then divide by 1000 to display the number of digits below the decimal point.

For example: if it is divided by 1000 first and then converted, the data may be 1500, divided by 1000 to become 1.5, but because it is a DINT type, the decimal point will be erased, and the data precision will be lost. Program 1, then convert it to REAL at this time The type is still 1, which doesn't make any sense!

Now the final display effect can be perfectly realized, and the number of digits behind the decimal point can be adjusted at will without affecting the data size.

Guess you like

Origin blog.csdn.net/viixin/article/details/130629576