Step7 Real Data types

Stuntman

Member
Join Date
Mar 2012
Location
Arkansas
Posts
33
I am working on an application where I am controlling the ramp of a web and I want to increase the web speed by .1 feet per minute every x seconds. In the attached logic diagram I am just showing the addition of .1 to my web speed.

If web speed actual is less than web speed sp, increase web speed actual by .1

If web speed actual is less than web speed sp, decrease web speed actual by .1

If the web speed actual is equal to the web speed sp, do nothing

The problem lies in the way Siemens handles the real value

.1 Plus 0.7 = 0.8000001 not 0.80000000000000000000

Say my web speed set point is 0.8
My logic will always be speeding up and slowing my web speed because we will never truly be at the web speed set point.

I tried converting to an integer multiply .7 * 10 then adding 1 then converting back to a real but still get the same problem 0.8000001

Another problem is the extra values that are showing up after the decimal would be compounded so my ramp rate would not be steady.

I have done 3 other projects with Siemens but I have never ran into this type of task and I was wondering how a Siemens programmer would solve this problem.

Thanks

FYI In my logic diagram in the add and subtract functions I have the IN 1 and IN 2 backwards IN 1 should be the web speed actual.
 
Last edited:
I am working on an application where I am controlling the ramp of a web and I want to increase the web speed by .1 feet per minute every x seconds. In the attached logic diagram I am just showing the addition of .1 to my web speed.

If web speed actual is less than web speed sp, increase web speed actual by .1

If web speed actual is less than web speed sp, decrease web speed actual by .1

If the web speed actual is equal to the web speed sp, do nothing

The problem lies in the way Siemens handles the real value

.1 Plus 0.7 = 0.8000001 not 0.80000000000000000000

Say my web speed set point is 0.8
My logic will always be speeding up and slowing my web speed because we will never truly be at the web speed set point.

I tried converting to an integer multiply .7 * 10 then adding 1 then converting back to a real but still get the same problem 0.8000001

Another problem is the extra values that are showing up after the decimal would be compounded so my ramp rate would not be steady.

I have done 3 other projects with Siemens but I have never ran into this type of task and I was wondering how a Siemens programmer would solve this problem.

Thanks

FYI In my logic diagram in the add and subtract functions I have the IN 1 and IN 2 backwards IN 1 should be the web speed actual.


I suggest you make a reusable FC to compare the two values, and set them equal if they are within a dead band limit.

You need 3 real inputs:
rIn1
rIn2
rBand // Dead band

and 3 boolean outputs:
xGT // rIn1 - rIn2 > rBand
xEQ // ABS (rIn1 - rIn2) <= rBand
xLT // rIn2 - rIn1 > rBand

It seem to me you are well capable of filling in the code yourself
icon12.gif
.

And in 90% of my coding, I use the wrong comparator, please check this.

Kalle
 
In the example you have posted, 0.7 + 0.1 = 0.8 as verified by examining the hexadecimal representation of the floating point numbers.

Instead of using floating point approximations for numbers, use a double integer suitably scaled.

float5.JPG
 
The ramp generator appears it would work but what i am trying to solve the math problem i have because i see this could be a problem in the future with other applicatiins
 
Hi!
What if you put something like this in the preceeding network, and use the negated 'Equal' in your rungs?

Yes, that is nice. I rolled my own ramp block ages ago and used this similar method. I couldn't remember how to do it quickily but I had the block saved in my library.

Test this and see if it works for you...
 
Well I figured out how to make it work. Pretty simple, sometimes its best to work on something else then when you come back to the problem the answer is right there.
Multiply the real value web speed actual by 10 to get the.x decimal into the whole number side (x.). Add 1 to the whole number which would actually be adding (.1) then divide by 10 to place the decimal in the correct place.

ScreenHunter_01 Sep. 16 12.28.jpg
 

Similar Topics

Hi, I'm writing a program to perform some basic math calculations, but somewhere in the middle something's going wrong, and variables with a real...
Replies
1
Views
3,109
Hey All, I'm looking for a simple way to take an incoming value in DWORD format and convert it to a real number. Does anyone know of a simple way...
Replies
4
Views
9,311
i want to store data values (real values) from analogue inputs in step7 using Data block.(hardware s7-300). also how can i monitor these stored...
Replies
2
Views
2,499
Hi, How can I know if a value is double integer or real? I use this for a check a input parameter in a function. Thx.
Replies
16
Views
5,919
Hi. I have a situation where I need to convert Integer to floating point(real) in step-7, which command can this be done with?
Replies
3
Views
21,517
Back
Top Bottom