Posted 12 Feb 2020 (edited) 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 12 Feb 2020 by SillyBoy Share this post Link to post Share on other sites
Posted 12 Feb 2020 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
Posted 18 Feb 2020 Can u attach a file with program? Share this post Link to post Share on other sites
Posted 20 Feb 2020 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
Posted 29 Feb 2020 On 18/02/2020 at 3:56 PM, zpassha said: Can u attach a file with program? Did you checked ? Share this post Link to post Share on other sites
Posted 4 Mar 2020 On 29/02/2020 at 1:07 PM, SillyBoy said: Did you checked ? Today i try it Share this post Link to post Share on other sites