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?
TelePACE Studio BCD to Integer

Question:

Is it possible to convert a 4 digit BCD (binary-coded decimal) register into an integer value?

Solution:

A binary coded decimal is where each digit is represented by a fixed number of bits (typically 4). BCD takes advantage of the fact that any one decimal number can be represented by a 4-bit pattern. The most common way of encoding a decimal digit is by its corresponding four-bit binary value.

Simple BCD, also called BCD 8421 encoding is the most common encoding method.

Most BCD values will typically encode 2 digits within a byte (8 bits). This is sometimes called a packed BCD.

Now a 16-bit SCADAPack register in TelePACE can store an unsigned integer between 0-65535. The same 16-bit register can store a BCD value between 0-9999.

The following TelePACE code takes a single register with a BCD value and converts it to an unsigned integer in the SCADAPack. It uses modular math to extract the value for each digit. It then multiplies and adds the pieces back together as an unsigned integer.

Modular math operations to take a BCD value and convert it to an unsigned integer.

A hexadecimal BCD value is input into register 41000 in the decimal range of 0-9999. Let's call it WXYZ. The SCADAPack will interpret the BCD value as an incorrect unsigned integer.

  • Register 41001 MODU 4096 gives the remainder XYZ and puts it in register 43005
  • Register 41001 DIVU 4096 gives the number of thousands W
  • Register 43005 MODU 256 gives the remainder YZ and stores it in register 43003
  • Register 43005 DIVU 256 gives the number of hundreds X
  • Register 43003 MODU 16 gives the remainder Z and stores it in register 43001
  • Register 43003 DIVU 16 gives the number of tens Y

Once the values are determined for W, X, Y and Z, they can be combined together to form an unsigned integer.

This logic recombines the digit values calculated earlier and recreates the value as an unsigned integer  (W*1000) + (X*100) + (Y*10) + Z

  • This logic calculates (W*1000) + (X*100) + (Y*10) + Z and stores the result in register 42001

Schneider Electric Việt Nam

Tìm hiểu thêm
Phạm vi:
Tìm hiểu thêm
Phạm vi:

Bạn cần trợ giúp?

  • Công cụ chọn sản phẩm

    Nhanh chóng và dễ dàng tìm được sản phẩm và phụ kiện phù hợp cho các ứng dụng của bạn.

  • Nhận báo giá

    Bắt đầu gửi yêu cầu bán hàng trực tuyến và chuyên gia sẽ liên hệ với bạn.

  • Nơi mua hàng?

    Dễ dàng tìm nhà phân phối Schneider Electric gần bạn nhất.

  • Trung tâm Hỗ trợ

    Tìm sự hỗ trợ cho mọi nhu cầu của bạn tại một nơi.

  • 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ơ 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