BCD code and hexadecimal number that are easy to confuse - Database & Sql Blog Articles

Probe domestic switch needle KG-300K needle head diameter is 3.0mm normally open switch needle
SMD aluminum electrolytic capacitor
Brand AVX TPSE226M035R0125 Low impedance tantalum capacitor AVX 22

The BCD code (Binary-Coded Decimal) is an abbreviation for a binary coded decimal number, and the BCD code uses a 4-bit binary number to represent a decimal number. The value range of each bit of the BCD code is 2#0000 to 2#1001, which corresponds to the decimal number 0 to 9. The BCD code cannot use the six digits of A~F (2#1010~2#1111) in hexadecimal. The BCD code is essentially a decimal number, so the next two digits go up to ten.
The highest-order binary number of the BCD code is the sign bit, the negative sign bit is 1, and the positive number is 0. The 16-bit BCD code ranges from –999 to +999.
The DIP switch in the figure below converts the displayed number to a 4-digit binary number. Plc reads the 3-digit BCD code with 12 digital input points, and its value is 2#1000 0010 1001, which is the hexadecimal number 16#829.

The BCD code does not have a separate representation, but borrows a hexadecimal representation, so the two are easily confused.
The following figure shows the BCD code and integer conversion instructions of the S7-300/400. It can be seen that the BCD codes are expressed in hexadecimal form in the instruction.

In the program, how do you know if a number is a BCD code or a hexadecimal number?
1) Look at the source and use of the data. The BCD code is generally used for input and output. For example, the data from the DIP switch is a BCD code, and the BCD code is sent to the decoder chip that displays the elevator floor.
2) See the specification of the manual, for example, the date and time value in the data type DATE_AND_TIME is the BCD code, the preset value PV of the counter and the current count value CV_BCD are BCD codes.
How to monitor BCD code?
In the variable table and program status monitoring, the BCD code is monitored in hexadecimal format.
How to enter BCD code?
As can be seen from the above figure, the BCD code is input in hexadecimal format, and its highest bit (sign bit) is 16#F(2#1111). The lower 3 bits of the BCD code can only be 0~9. If it is 16#A~16#F, it will be wrong.
The preset value of the counter PV is a BCD code of 0 to 999. The constant of the C# (C#1~C#999) can be used as the preset value of the counter.
The following figure uses the MW42 to provide the preset value PV of the counter. If the decimal number 348 (the corresponding hexadecimal number is 16#15C) is transmitted to the MW42 by the MOVE instruction, the operating system converts it to the BCD code when entering the RUN mode. An error occurred (16#15C is not a BCD code) and cannot be switched to RUN mode.
When entering the preset value 348, C#348 should be transferred to MW42 instead, it will automatically become W#16#348, of course, you can also directly input 16#348. It is not necessary to convert 348 to BCD code W#16#348 with the I_BCD command and then to MW42.

Flum Float

Flum Float,Flum Float 3000Puffs,Fruits Flavors Flum Float,Electronic Cigarettes Flum Float

Nanning Nuoxin Technology Co., LTD , https://www.nx-vapes.com