Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched.
Close
i am new with programming so i'm asking maybe stupid questions, so if i have analog input what gives value from 400 to 1000. Value 400 is for example 80 cm and 1000 is 1100cm. How i can make a program which tells automatically how many cm is value 500?Hope somebody understand this...
thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2015-09-16
Originally created by: scott_cunningham
This is a linear equation of style y = ax + b. I will leave you to fill in the blanks on the equation details.
So create a FUNCTION - but you first need to decide your data type. INT or REAL... You are using nice rounded numbers, so I will pick INT (using ST language):
Hello!
i am new with programming so i'm asking maybe stupid questions, so if i have analog input what gives value from 400 to 1000. Value 400 is for example 80 cm and 1000 is 1100cm. How i can make a program which tells automatically how many cm is value 500?Hope somebody understand this...
thanks
Originally created by: scott_cunningham
This is a linear equation of style y = ax + b. I will leave you to fill in the blanks on the equation details.
So create a FUNCTION - but you first need to decide your data type. INT or REAL... You are using nice rounded numbers, so I will pick INT (using ST language):
Then in your regular program you can simply write:
HINT: Always make sure you don't overflow the data type! INT only goes to +32767.