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 11:56 am

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 
Offline

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

Example:
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.

Thanks!


Top
   
PostPosted: Wed Feb 20, 2019 4:10 pm 
Offline

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.


Top
   
PostPosted: Thu Feb 21, 2019 4:19 am 
Offline
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.
www.kebblog.com
www.kebamerica.com


Top
   
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 2 guests


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