Sandor-CRX
Member
Hello guys,
I'm using SCL to create the control for my drive.
I have a value in the OS (0-100%) what stands for the speed of the drive= setpoint. The setpoint is tranferred to process image output-> QW. to the selected drive.
At first my program looked like this:
//Convert OS value to drive logic (100% = 16384)
act_sp := act_sp * 163.84;
//Set max. and min. range
IF act_sp > MAX_SPEED
THEN act_sp := MAX_SPEED;
END_IF;
IF act_sp < MIN_SPEED
THEN act_sp := MIN_SPEED;
END_IF;
qact_sp_i := REAL_TO_INT(act_sp);
qact_sp_w := INT_TO_WORD(qact_sp_i);
//Send speed to drive
QW [MRV] := qact_sp_w;
When I set the setpoint to 100, I see the process value which is converted from WORD to INT and then from INT to REAL and displayed at 99.99999. Also If I set the setpoint to 20, the PV will be 21.9, so there is a conversion problem.
I want to round this value...i'm not enable to use the ROUND function. Also, I then have to convert from DINT to WORD.
What is the best approach for this function?
Thank you,
I'm using SCL to create the control for my drive.
I have a value in the OS (0-100%) what stands for the speed of the drive= setpoint. The setpoint is tranferred to process image output-> QW. to the selected drive.
At first my program looked like this:
//Convert OS value to drive logic (100% = 16384)
act_sp := act_sp * 163.84;
//Set max. and min. range
IF act_sp > MAX_SPEED
THEN act_sp := MAX_SPEED;
END_IF;
IF act_sp < MIN_SPEED
THEN act_sp := MIN_SPEED;
END_IF;
qact_sp_i := REAL_TO_INT(act_sp);
qact_sp_w := INT_TO_WORD(qact_sp_i);
//Send speed to drive
QW [MRV] := qact_sp_w;
When I set the setpoint to 100, I see the process value which is converted from WORD to INT and then from INT to REAL and displayed at 99.99999. Also If I set the setpoint to 20, the PV will be 21.9, so there is a conversion problem.
I want to round this value...i'm not enable to use the ROUND function. Also, I then have to convert from DINT to WORD.
What is the best approach for this function?
Thank you,