CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Tue Oct 22, 2019 12:42 pm

All times are UTC+01:00

Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Variable Type detection?
PostPosted: Sat Feb 16, 2019 8:11 pm 

Joined: Tue Mar 28, 2017 3:43 pm
Posts: 1
Can CoDeSys do conditional variable type identification?

I have a scale function that takes in a REAL value and scales it to some new range, then outputs a REAL. But, sometimes I’m trying to scale an INT, or a DINT, or a BYTE or SINT, etc. how can I make this function automatically recognize the input type, do a xxx_TO_REAL, run my scale function, then do a REAL_TO_xxx, then output the result as an xxx instead of a REAL?

Any solution besides “make a different function for each variable type” would be awesome.


PostPosted: Wed Feb 20, 2019 4:10 pm 

Joined: Tue Mar 11, 2014 2:43 am
Posts: 16
In this case I would use; INT_TO_REAL(your_var) or WORD_TO_REAL(your_var) etc.

PostPosted: Thu Feb 21, 2019 4:19 am 
Frequent User
Frequent User

Joined: Fri Sep 02, 2011 8:02 pm
Posts: 305
Codesys V3 now supports the ANY_TYPE, which would work, but I don’t believe this is available on Codesys V2.3.

Scott Cunningham
KEB America, Inc.

Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited