AduJava - Binary Basics Tutorial

This is a basic tutorial about binary numbers. It begins with a discussion about decimal numbers and then moves on to binary numbers. The tutorial then applies this knowledge to ADU200 boards.

Decimal

The numbers we use in daily life are based on the number 10. We call these base 10 or decimal numbers.

For instance take the number 1,111 which is spelled out as
one thousand one hundred and eleven.

The number 1,111 can be broken into a sum
1111 = (1*1000) + (1*100) + (1*10) + (1*1)
Factoring the numbers gives
1111 = 1*10*10*10 + 1*10*10 + 1*10 + 1*1
Expressing the value with exponents gives
1111 = 1*10**3 + 1*10**2 + 1*10**1 + 1*10**0

Generally

To convert a four digit number "abcd" in base "y" to decimal base 10 simply plug the value for "y" into the formula.
abcd = a*y**3 + b*y**2 + c*y**1 + d*y**0

Binary

To treat 1111 as a binary number we use the value 2 as the base. Note that we will use red to indicate a binary number and black to indicate a decimal number.
1111 = 1*2**3 + 1*2**2 + 1*2**1 + 1*2**0

Calculating the exponents gives
1111 = 1*8 + 1*4 + 1*2 + 1*1 = 15

ADU200 Relays

The ADU200 relays are labelled K3, K2, K1 and K0. The mk command is used to set the relays on an ADU200 board. To compose the mk command treat the desired states of K3,K2,K1,K0 as a binary number and convert it to decimal. Append the decimal value to the command.

For example: the mk15 will turn all the relays on, since as shown above, binary 1111 = 15 in decimal.

Similarly to turn on K3 and K2 with K1 and K0 off send the command mk12 since binary 1100 = 12 in decimal.
1100 = 1*2**3 + 1*2**2 + 0*2**1 + 0*2**0 = 8 + 4 = 12
The following screen shot shows the mk4 command being sent to the ADU200. This will set relay K2 on since binary 0100 = 4 in decimal.
0100 = 0*2**3 + 1*2**2 + 0*2**1 + 0*2**0 = 4

The response shown in the screen shot is the ADU200's reply to an rpk command to show the relay status. Each character corresponds to a relay on the board K3, K2, K1, K0. A 1 means the relay is on and 0 means the relay is off. The response of 0100 means that relays K3, K1, K0 are off and relay K2 is on.

The state of the ADU200 can be seen in this photo.

The following screen shot shows the mk10 command being sent to the ADU200. This will set relays K3 and K1 on since binary 1010 = 10 in decimal.
1010 = 1*2**3 + 0*2**2 + 1*2**1 + 0*2**0 = 8 + 2 = 10

The effect on the ADU200 can be seen in this photo.

Tabular Method

If you are uncomfortable with binary you can simply look up the relays in this table and add up the corresponding values to derive the mk command.
RelayK3K2K1K0
Value8421

For the ADU208 which has 8 relays the table is:
RelayK7K6K5K4K3K2K1K0
Value1286432168421

For example to turn on relays K6 and K2 on the ADU208 send the command "mk68" (ie. 64 + 4).



AduJava Help File Version 1.0.0.0
Copyright 2005 Ontrak Control Systems Inc.