Converting Unsigned Double Integer (UDINT) to Floating Point (FP) in TelePACE Studio
In TelePACE Studio, data is stored in 16 bit holding registers. Depending on the data format, a value might need one or two registers. In some instances, a programmer may need to have a value converted between two different data formats. TelePACE Studio does have some function blocks to help convert between formats. For example:
- UTOF: Unsigned integer To Floating point (FP)
- STOF: Signed integer To FP
- FTOU: FP To Unsigned integer
- FTOS: FP to Signed integer
Although TelePACE Studio does work with unsigned double integers (UDINT), it does not have any function blocks to convert to or from UDINT.
Unsigned Double Integers (UDINT):
A single unsigned integer (UINT) requires 1 register (16 bits) to store its value whereas a UDINT value requires 2 consecutive registers (32 bits), a high register and a low register. A UINT value can count up to 65535, whereas a UDINT can count up to 4,294,967,295
For small integers, 65535 or lower, a UDINT will be able to store the value in the low register and have a 0 in the high register. If the UDINT is increased by 1 to a value of 65536, it will cause the high register to increase to 1, and the low register will have a value of 0.
Essentially, for an UDINT value of 1,000,000, the high register stores the number of times 65536 divides into 1,000,000 and the low register stores the remainder. To represent 1,000,000 as a UDINT, the High Register would have a value of 15 and the Low Register would have a value of 16960. (1,000,000 = 15*65536 + 16960).
Floating Points (FP):
A 32-bit floating point also requires two 16-bit registers. A FP can represent very large numbers (123,456,000,000,000) or very small number (0.000 000 000 123 456). The limitation with 32-bit floating point math is that it can only accurately represent a little more than 7 digits.
Converting UDINT to FP:
The TelePACE Studio sample code below has a UDINT value in registers 48001-48002. To convert this value to a FP, the logic looks at both the UDINT High Register and Low Register separately and then combines the result in registers 49007-49008.
In a second example, a larger UDINT value of 12,000,001 ends up getting converted to 12,000,000 as a floating point.
This is a limitation of 32-bit math in general and it will be up to the user to decide if their UDINT values will get large enough to introduce this issue OR if the decrease in accuracy is significant for their application.
게시 대상: 슈나이더 일렉트릭 Korea


도움이 필요하신가요?
제품 선택기
애플리케이션에 적합한 제품과 액세서리를 빠르고 쉽게 찾을 수 있습니다.
견적 받기
영업 관련하여 온라인으로 문의하시면 전문가가 연락드립니다.
구매처
해당 지역의 가장 가까운 슈나이더 일렉트릭 대리점을 쉽게 찾을 수 있습니다.
지원 센터
한 곳에서 모든 요구 사항에 대한 지원 리소스를 찾아보십시오.