SillyBoy

Analog Scalling in GX Works 3 for Mitsubishi FX5U PLC

6 posts in this topic

Hello all,

I am trying to write one FB for Analog Scaling in GX Works 3 Software for my Mitsubishi FX5U Plc...

Unfortunately i am not aware very much about ST Language instructions of Mitsubishi Softwares.

So the Code is Giving 5 Errors, i think the error are due to incorrect data conversion expressions, Can you please correct me with my code ?

Here are the Variables

RAW_MIN                   Word [Signed]                      VAR_INPUT
RAW_MAX                  Word [Signed]                      VAR_INPUT
SCAL_MIN                  FLOAT [Single Precision]    VAR_INPUT
SCAL_MAX                FLOAT [Single Precision]    VAR_INPUT
AI_RAW                      Word [Signed]                       VAR_INPUT
SCALED_OP_REAL   FLOAT [Single Precision]    VAR_OUTPUT
SCALED_OP_INT      Word [Signed]                       VAR_OUTPUT

Here is the Code

SCALED_OP_REAL:=(((SCAL_MAX-SCAL_MIN)*(INT2FLT(AI_RAW)-INT2FLT(RAW_MIN)))/(INT2FLT(RAW_MAX)-INT2FLT(RAW_MIN)))+SCAL_MIN;
SCALED_OP_INT:= FLT2INT(SCALED_OP_REAL);

Edited by SillyBoy

Share this post


Link to post
Share on other sites

AI_RAW    Word [Signed]    VAR_INPUT
RAW_MIN    Word [Signed]    VAR_INPUT
RAW_MAX    Word [Signed]    VAR_INPUT
SCAL_MIN    FLOAT [Single Precision]    VAR_INPUT
SCAL_MAX    FLOAT [Single Precision]    VAR_INPUT
SCALED_OP_REAL    FLOAT [Single Precision]    VAR_OUTPUT
SCALED_OP_INT    Word [Signed]    VAR_OUTPUT
RAW_MIN_REAL    FLOAT [Single Precision]    VAR
RAW_MAX_REAL    FLOAT [Single Precision]    VAR
AI_RAW_REAL    FLOAT [Single Precision]    VAR
 

 

ENO:=INT2FLT(TRUE,AI_RAW,AI_RAW_REAL);
ENO:=INT2FLT(TRUE,RAW_MIN,RAW_MIN_REAL);
ENO:=INT2FLT(TRUE,RAW_MAX,RAW_MAX_REAL);

SCALED_OP_REAL:= (((SCAL_MAX-SCAL_MIN)*(AI_RAW_REAL-RAW_MIN_REAL))/(RAW_MAX_REAL-RAW_MIN_REAL))+SCAL_MIN;
ENO:=FLT2INT(TRUE,SCALED_OP_REAL,SCALED_OP_INT);

 

Looks like above modification is correct...what you say ?

but this is strange to create separate variable for each data conversion......

Share this post


Link to post
Share on other sites
On 18/02/2020 at 3:56 PM, zpassha said:

Can u attach a file with program?

Along with that, how to assign address to my variables ? (In this backup, in Analog_Scaling Task, PT_Min,PT_Max,PT_Scaled)

PLC.gx3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now