Nhãn hiệu của chúng tôi

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

Chào mừng bạn đến với Trang web của Schneider Electric

Chào mừng đến với trang web của chúng tôi.
		
Hôm nay chúng tôi có thể giúp gì cho bạn?
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.

Schneider Electric Việt Nam

Tìm hiểu thêm
Phạm vi:
Tìm hiểu thêm
Phạm vi:
  • Tài liệu về Sản phẩm
  • Tải xuống phần mềm
  • Công cụ chọn Sản phẩm
  • Thay thế và thay đổi sản phẩm
  • Trung tâm Hỗ trợ
  • Tìm Văn phòng của chúng tôi
  • Nhận báo giá
  • Tìm Nhà Phân phối
  • Cộng đồng Schneider Electric
  • Cơ hội nghề nghiệp
  • Hồ sơ doanh nghiệp
  • Báo cáo hành vi sai trái
  • Khả năng truy cập
  • Phòng tin tức
  • Nhà đầu tư
  • EcoStruxure
  • Tìm việc
  • Blog
  • Chính sách bảo mật
  • Thông báo về Cookie
  • Điều khoản sử dụng
  • Change your cookie settings