UD70
Issue code: 70nu2
7-8 Reference
BCD2BIN
Syntax
int% = BCD2BIN (integer expression%)
This function converts a binary coded decimal number to a normal binary
integer. It is used to operate on digital inputinput data from from the I/O Box
(eg. thumbwheel switches). (Binary coded decimal is a method of writing a
decimal number in a binary format.)
954 in decimal format is represented as 1001 0101 0100 in BCD.
954
100101010100
Example
r% = BCD2BIN(#82.46)
BIN2BCD
Syntax
int% = BIN2BCD (integer expression%)
This function converts a normal binary integer to a binary coded decimal
number. It is used to operate on digital output data to the I/O Box
.
See
BCD2BIN
instruction for an explanation for converting decimal to binary
coded decimal.
BCD2SEG
Syntax
int% = BCD2SEG (integer expression%)
This function converts binary coded decimal to 7-segment
LED codes and is
used to operate on digital output data to the I/O Box. The output consists
of drive signals for up to three 7-segment display digits, as follows:
Bit number 7 6 5 4 3 2 1 0
Segment – g f e d c b a
The least significant byte represents the first of the three digits. The
maximum value which can be converted is 999. Leading zeroes are sent.
Example
a% = BIN2BCD(123)
seg
_data% = BCD2SEG(a%)
#83.46 = seg
_data% ;output 5200646 (0x4F5B06 = 321)