# BUG in SCALE\_R

**URL:** <https://oscat.discourse.group/t/bug-in-scale-r/1728>\
**Category:** Bestehende Module / Existing Modules\
**Created:** [3. März 2014 um 08:58 UTC](https://oscat.discourse.group/t/bug-in-scale-r/1728 "2014-03-03T08:58:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_EWW](https://avatars.discourse-cdn.com/v4/letter/c/a8b319/32.png) [@Christian\_EWW](https://oscat.discourse.group/u/Christian_EWW)\
**Post date:** [3. März 2014 um 08:58 UTC](https://oscat.discourse.group/t/bug-in-scale-r/1728/1 "2014-03-03T08:58:53Z")

</div>

In der SCALE\_R aus der oscat\_basic\_333.lib ist seit einem Update seitens Beckhoff ein Problem aufgetreten.  
TwinCAT 2.11.2234 hat ein Problem mit der Länge des Ausdruckes, wenn ein ARM-Prozessor ausgewählt wird.

Lösung:  
[i]IF I\_LO = I\_HI THEN  
SCALE\_R := O\_LO;  
ELSE  
TEMP := LIMIT(I\_LO, X, I\_HI);  
SCALE\_R := (O\_HI - O\_LO) / (I\_HI - I\_LO) \* (TEMP - I\_LO) + O\_LO;  
END\_IF;

(\* revision history  
hm 18. may. 2008 rev 1.0  
original version

hm 13. nov. 2008 rev 1.1  
corrected formula for negative gradient

hm 11. jan 2011 rev 1.2  
avoid division by 0

Christian Kreuzer  
03.März 2013 rev 1.3  
splitted formula to avoid error “expression to complex” at Beckhoff ARM devices  
\*)[/i]

Vielleicht kann diese Änderung in eine der nächsten Versionen eingearbeitet werden.  
Danke,  
Christian\_EWW
