我們的品牌

Impact-Company-Logo-English Black-01-177x54

歡迎造訪施耐德電機全球網站

歡迎訪問我們的網站
		
我们今天能为您提供什么帮助?
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.

UDINT 1,000,000, converted to FP 1,000,000

In a second example, a larger UDINT value of 12,000,001 ends up getting converted to 12,000,000 as a floating point.

Converting UDINT 12,000,001 to FP 12,000,000

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.

施耐德電機Taiwan

探索更多
系列:
探索更多
系列:
  • 產品文檔
  • 軟體下載
  • 產品選型工具
  • 產品替代和替換
  • 幫助和聯絡中心
  • 尋找我們的辦公室
  • 取得報價
  • 施耐德電機社群
  • 人才招募
  • 公司簡介
  • 舉報不當行為
  • 無障礙
  • 新聞中心
  • 投資者
  • 專業洞察
  • 台灣施耐德電機學院
  • 綠色影響力落差調查
  • Schneider Go Green 2025
  • 隱私政策
  • Cookie通告
  • 使用條款
  • Change your cookie settings