Timers in Step7

MD4 is REAL
MD8 is DINT
MW10 is INT
MW12 is INT

To convert from REAL to INT, you have to either ROUND or TRUNC the REAL into a DINT. Then you extract the 2 high bytes into an INT.
On the downside, depending on what your REAL value is, you're losing all of the data after the decimal point. There are ways around that too, holler if you need help with it.
It's super fun and totally intuitive. Thanks Siemens. Good Luck
View attachment 39942
Thank you.

The function i need is that i read a 4-20mA signal and i will use this value to compare set points (3 set points) i have set in the HMI.

For each of this 3 set points of the analog input value i have a set point that should transfer a value to a analog output. As every set point and actual is read and write on a HMI i want everything to be in INT.

So i want a integer value from the input and then the set points are integer so i can use the compare equal or higher INT . So if the value is equal or greater i will move the set value for the analog output for the corresponding set value of the analog input.
 
Siemens analog inputs and outputs are integers with values 0..27648.
There is no need to change first to real and then back to integer, if you only need integers
 
Siemens analog inputs and outputs are integers with values 0..27648.
There is no need to change first to real and then back to integer, if you only need integers
But if i want to have the analog value showed as for example 0-100 in integer format i ned to scale it? The only reason for real value scaling is the show a bigger number?
 
But if i want to have the analog value showed as for example 0-100 in integer format i ned to scale it? The only reason for real value scaling is the show a bigger number?

You can scale also on scada and HMI and use raw data on PLC. integers don't have decimals, so you need multiplies of 10, 100 to get decimals if you scale from raw data to lower values.

With real values you can scale to same values than measurement is allready on PLC (real have decimals), and on hmi and scada is scaling is 1:1. (no scaling)

Both methods have cons and pros.
 
You can scale also on scada and HMI and use raw data on PLC. integers don't have decimals, so you need multiplies of 10, 100 to get decimals if you scale from raw data to lower values.

With real values you can scale to same values than measurement is allready on PLC (real have decimals), and on hmi and scada is scaling is 1:1. (no scaling)

Both methods have cons and pros.

Because of the values are send on the bus with configurated as Words i want to do at as easy as possible without so to convert to much.

All my timers are in INT so thats ok.

The reason for i want to use INT is because of the HMI and the values being read and set as INT.

But if i read the 4-20mA and want to have a scale from 0-100 in the program and HMI and the output as for example as 20-100 (4-20mA) Both of this values will be compared to set points set in the HMI.
 
Because of the values are send on the bus with configurated as Words i want to do at as easy as possible without so to convert to much.

All my timers are in INT so thats ok.

The reason for i want to use INT is because of the HMI and the values being read and set as INT.

But if i read the 4-20mA and want to have a scale from 0-100 in the program and HMI and the output as for example as 20-100 (4-20mA) Both of this values will be compared to set points set in the HMI.

Then use travispedley's example, but on PLC values don't need to be necessary same format as on HMI, you can do comparsion also on with raw data scale (0..27648) and show it on HMI at 0..100.0 format

But if you want use 0.100 values on plc, then it is useful to scale with FC105 to real 0..1000.0 or 0..10000.0 and convert this to int (0..1000 or 0..10000). That way you get more accuracy on int variables (1 or 2 decimals). On HMI you need to move decimal place to right place (scale on HMI variables PLC 0..1000 -> HMI 0.100.0)

For output do conversions same way. int -> dint -> real -> FC106 -> AO


With Siemens PLC's and HMI's it usually still easiest to use real variables. Siemens assumes that you use reals. PID-blocks and so on are maded that way that default data type is real for measurement and setpoints.
I assume that you have non Siemens HMI now, because you use integers for communication.
 
Last edited:
Will the timer values remain after a powerloss? Maybe making the values retentive? Because it might be a problem if an operator has to type in all values each time after a powerloss.

Jonas
 
Here's an example implementation. I've coded it so the motors are controlled via the DB so it can be tested in one plc (I used plcsim).

If you want to control the motors using the timerQs in the other plc, you will have to modify this program so the timerQs stay on (I don't see how you will know when to reset them without having to have another handshake bit back from the other plc).

If i want to have an extra timer "if enable" when it has elapsed it will stop all the timers and functions on the timers made here. And also have an extra reset bit sent to another function that is going to stop. What is the easiest to do?
 
Then use travispedley's example, but on PLC values don't need to be necessary same format as on HMI, you can do comparsion also on with raw data scale (0..27648) and show it on HMI at 0..100.0 format

But if you want use 0.100 values on plc, then it is useful to scale with FC105 to real 0..1000.0 or 0..10000.0 and convert this to int (0..1000 or 0..10000). That way you get more accuracy on int variables (1 or 2 decimals). On HMI you need to move decimal place to right place (scale on HMI variables PLC 0..1000 -> HMI 0.100.0)

For output do conversions same way. int -> dint -> real -> FC106 -> AO


With Siemens PLC's and HMI's it usually still easiest to use real variables. Siemens assumes that you use reals. PID-blocks and so on are maded that way that default data type is real for measurement and setpoints.
I assume that you have non Siemens HMI now, because you use integers for communication.
So i can use use this in stl.

L
ITD
DTR
T

And

the other way?
 
If i want to have an extra timer "if enable" when it has elapsed it will stop all the timers and functions on the timers made here. And also have an extra reset bit sent to another function that is going to stop. What is the easiest to do?

A timer that stops the the three timers when it has been elapsed. What is the easiest?
A NC contact with timerQ adress on the enable and start for the the timer sequence?
 

Similar Topics

Can I reuse the same timer in a Function Block? I have a bunch of time delays that never run concurrently. I would like to just reassign a the...
Replies
4
Views
2,319
I am setting up the structure on a project that uses 6 identical manifolds. Each manifold has I/O, HMI events, timers , recipe steps, etc. I...
Replies
4
Views
4,961
Hello, How can we use the timer S_ODT with a variable instead of constant time. For exmaple not typing "S5TIME#2S" for TV, but using a time...
Replies
6
Views
3,989
Hello guys, I have another, very weird problem with Step 7 functions. In the attachments, you can find sorces for OB1 and two functions. Both...
Replies
9
Views
3,462
Hello guys, I have one small problem Idea is: 1. After time 10 s set "Step1" 2. After 8 s, set "Step2" and reset "Step1" 3. After 5 s, set...
Replies
5
Views
2,654
Back
Top Bottom