Invalid Cast Exception
CODESYS Forge
talk
(Thread)
Invalid Cast Exception
Last updated: 2022-11-07
LREAL from four WORDs?
CODESYS Forge
talk
(Thread)
LREAL from four WORDs?
Last updated: 2022-11-18
LREAL benötigt
CODESYS Forge
talk
(Thread)
LREAL benötigt
Last updated: 2008-04-16
Expt Funktion für lreal??
CODESYS Forge
talk
(Thread)
Expt Funktion für lreal??
Last updated: 2010-01-11
LREAL binary compatibility
CODESYS Forge
talk
(Thread)
LREAL binary compatibility
Last updated: 2008-11-28
function arguments and types/cast
CODESYS Forge
talk
(Thread)
function arguments and types/cast
Last updated: 2018-07-20
Split int to int array?
CODESYS Forge
talk
(Thread)
Split int to int array?
Last updated: 2016-06-22
Confusion with Lreal to dword
CODESYS Forge
talk
(Thread)
Confusion with Lreal to dword
Last updated: 2013-12-30
LREAL support in target device
CODESYS Forge
talk
(Thread)
LREAL support in target device
Last updated: 2019-08-07
explicit cast ENUM to UINT and vice versa
CODESYS Forge
talk
(Thread)
explicit cast ENUM to UINT and vice versa
Last updated: 2021-03-11
64 Bit Wert in ein LREAL umwandeln
CODESYS Forge
talk
(Thread)
64 Bit Wert in ein LREAL umwandeln
Last updated: 2016-09-21
Array of 5000 int
CODESYS Forge
talk
(Thread)
Array of 5000 int
Last updated: 2017-08-16
String to INT / REAL
CODESYS Forge
talk
(Thread)
String to INT / REAL
Last updated: 2017-12-03
Anzeige INT in Webvisu
CODESYS Forge
talk
(Thread)
Anzeige INT in Webvisu
Last updated: 2010-12-13
Dividing DINT/INT variables
CODESYS Forge
talk
(Thread)
Dividing DINT/INT variables
Last updated: 2020-10-24
Convert INT to Binairy
CODESYS Forge
talk
(Thread)
Convert INT to Binairy
Last updated: 2022-08-31
Convert WORD to INT
CODESYS Forge
talk
(Thread)
Convert WORD to INT
Last updated: 2017-12-06
Post by mondinmr on Unexpected behavior in cyclic encoder read method during INT overflow (wrap-around)
CODESYS Forge
talk
(Post)
Hi everyone, I’m investigating a potential issue with a cyclic method we use for reading incremental encoders in our libraries. I’ve come across two implementations that, at first glance, appear to perform the same operation: motionUnit.vlPositionActualValue is UINT due strange encoder type. Version A METHOD PROTECTED cyclicReadField VAR_INST actPosFieldOld: INT; rI: INT; delta: INT; END_VAR rI := TO_INT(motionUnit.vlPositionActualValue); delta := rI - actPosFieldOld; m_actPosRaw := m_actPosRaw + TO_LREAL(delta); actPosFieldOld := rI; IF settings.velocityFeebackMapped THEN m_actVelRaw := TO_LREAL(motionUnit.velocityActualValue); END_IF Version B METHOD PROTECTED cyclicReadField VAR_INST actPosFieldOld: INT; END_VAR m_actPosRaw := m_actPosRaw + TO_LREAL(TO_INT(motionUnit.vlPositionActualValue) - actPosFieldOld); actPosFieldOld := TO_INT(motionUnit.vlPositionActualValue); IF settings.velocityFeebackMapped THEN m_actVelRaw := TO_LREAL(motionUnit.velocityActualValue); END_IF Both use INT and the same delta logic, so they seem equivalent. However, when an overflow (wrap-around) occurs, version A continues correctly as expected, while version B unexpectedly resets to -32768 without a clear reason. Has anyone experienced similar behavior or can shed light on what might be happening here? It almost seems as if the cast to LREAL is being applied before the calculation — but that would be illogical and potentially very dangerous in many situations! Thanks!
Last updated: 2025-05-13
FUP: Verschaltungen Real, Int usw.
CODESYS Forge
talk
(Thread)
FUP: Verschaltungen Real, Int usw.
Last updated: 2018-02-02
Data conversion INT to UDINt (double)
CODESYS Forge
talk
(Thread)
Data conversion INT to UDINt (double)
Last updated: 2017-01-30
Konvertierung von String in INT Variable
CODESYS Forge
talk
(Thread)
Konvertierung von String in INT Variable
Last updated: 2006-03-20
Überlauf einer INT-Variable abfangen
CODESYS Forge
talk
(Thread)
Überlauf einer INT-Variable abfangen
Last updated: 2009-09-02
Deklaration eines 25Bit Int Wert
CODESYS Forge
talk
(Thread)
Deklaration eines 25Bit Int Wert
Last updated: 2007-11-23
Int Variable mit 1 Kommastelle
CODESYS Forge
talk
(Thread)
Int Variable mit 1 Kommastelle
Last updated: 2011-01-23
Convert 2 INT to Real
CODESYS Forge
talk
(Thread)
Convert 2 INT to Real
Last updated: 2021-08-15
To search for an exact phrase, put it in quotes. Example: "getting started docs"
To exclude a word or phrase, put a dash in front of it. Example: docs -help
To search on specific fields, use these field names instead of a general text search. You can group with AND
or OR
.