快捷搜索:  汽车  科技

plc里面常见的数字(PLC基本知识--5.2)

plc里面常见的数字(PLC基本知识--5.2)where D = the value of the digit and R= # of digit symbols used in the given number system. Nbase = Ddigit * R^unit .... D1R^1 D0R^0让我们分别来看一下:As we do consider the following formula (Math again!):先看看下面的数学公式:

Number Systems / 数字类型系统

Before we get too far ahead of ourselves let's take a look at the various number systems used by PLCs.

Many number systems are used by PLCs. Binary and Binary Coded Decimal are popular while octal and hexadecimal systems are also common.

在我们超越自己之前,让我们先来看看PLC使用的各种数制系统。PLC使用许多数制系统,二进制和二进制编码的十进制很流行,而八进制和十六进制也很常见。

Let's look at each:

让我们分别来看一下:

As we do consider the following formula (Math again!):

先看看下面的数学公式:

Nbase = Ddigit * R^unit .... D1R^1 D0R^0

where D = the value of the digit and R= # of digit symbols used in the given number system.

The "*" means multiplication. ( 5 * 10 = 50)

The "^" means "to the power of".

As you'll recall any number raised to the power of 0 is 1. 10^1=10 10^2 is 10x10=100 10^3 is 10x10x10=1000 10^4 is 10x10x10x10=10000...

其中D=给定数制系统中使用的数字的值,R=给定数制系统中使用的数字的符号#。

“*”表示乘法(比如5*10=50)。

“^”表示几次幂。

大家应该还记得0的任何次方都是1。10^1=10 10^2=10x10=100 10^3=10x10x10=1000......

This lets us convert from any number system back into decimal. Huh? Read on...

这使得我们可以把任何数制系统转换成十进制。嗯,继续阅读吧……

  • Decimal - This is the numbering system we use in everyday life. (well most of us do anyway!) We can think of this as base 10 counting. It can be called as base 10 because each digit can have 10 different states. (i.e. 0-9) Since this is not easy to implement in an electronic system it is seldom if ever used. If we use the formula above we can find out what the number 456 is. From the formula: Nbase = Ddigit * R^unit .... D1R^1 D0R^0
    we have (since we're doing base 10 R=10)

N10 = D4*10^2 D5*10^1 D6*10^0

= 4*10*10 5*10 6*1

= 400 50 6

= 456.

十进制数 - 这是我们在日常生活中最常使用的数字编码系统(反正我们大多数人都是这么做的)。我们可以把它看成是以10为基数的计数,它可以被称为以10为基底,因为这些数字可以有10种不同的状态(即0-9)。由于这在电子系统中不容易执行,因此很少使用在电子系统中,如果有的话,我们可以用上面的公式求出456是多少。

从公式 Nbase = Ddigit * R^unit .... D1R^1 D0R^0

我们可以得出:(因为我们以10为基数,所以R=10)

N10 = D4*10^2 D5*10^1 D6*10^0

= 4*10*10 5*10 6*1

= 400 50 6

= 456.

  • Binary- This is the numbering system computers and PLCs use. It was far easier to design a system in which only 2 numbers (0 and 1) are manipulated (i.e. used). The binary system uses the same basic principles as the decimal system. In decimal we had 10 digits. (0-9) In binary we only have 2 digits (0 and 1). In decimal we count: 0 1 2 3 4 5 6 7 8 9 and instead of going back to zero we start a new digit and then start from 0 in the original digit location.
    In other words we start by placing a 1 in the second digit location and begin counting again in the original location like this 10 11 12 13 ... When again we hit 9 we increment the second digit and start counting from 0 again in the original digit location. Like 20 21 22 23.... of course this keeps repeating. And when we run out of digits in the second digit location we create a third digit and again start from scratch.(i.e. 99 100 101 102...)
    Binary works the same way. We start with 0 then 1. Since there is no 2 in binary we must create a new digit.
    Therefore we have 0 1 10 11 and again we run out of room. Then we create another digit like 100 101 110 111. Again we ran out of room so we add another digit... Do you get the idea?
    The general conversion formula may clear things up:
    Nbase= Ddigit * R^unit .... D1R^1 D0R^0. Since we're now doing binary or base 2 R=2. Let's try to convert the binary number 1101 back into decimal.

N10 = D1 * 2^3 D1 * 2^2 D0 * 2^1 D1 * 2^0

= 1*8 1*4 0*2 1*1

= 8 4 0 1

= 13

(if you don't see where the 8 4 2 and 1 came from refer to the table below).

二进制 - 这是计算机和PLC使用的数字编码系统。设计一个只操纵(或使用)两个数字(0和1)的系统要容易得多。

二进制系统使用与十进制系统相同的基本原则。十进制有10位数字(0-9),在二进制中,我们只有两位数字(0和1)。在十进制中,我们数:0、1、2、3、4、5、6、7、8、9,当达到9时我们不是回到0,而是从一个新的数字开始,然后在原始的数字位置从0开始。

换句话说,我们首先在第二个位置放一个1,然后在原来的位置重新开始计数,比如10、11、12、13、14、15、16、17、18、19,当再次达到9时,我们继续增加第二个位置的数字,并再从0开始在原始数字位置重新计数,比如20、21、22、23、24、25、26、27、28、29,当然这个过程一直重复。当第二个数字位置的数字用完时,我们创建第三个数字,然后从头开始(例如99、100、101、102、103、104、105、106、107、108、109)。

二进制也是如此。我们从0开始,然后是1,因为二进制中没有2,所以我们必须创建一个新的数字,如10、11,然后我们又没地方了,然后我们又创建另一个新的数字,比如100、101,再然后110、111,再然后1000、1001;1010、1011;1100、1101……这样一直继续,你明白了吗?

用下面的公式可能能解释清楚:Nbase= Ddigit * R^unit .... D1R^1 D0R^0.

因为我们现在用的是二进制或者以2为基数,所以R=2。让我们试着把二进制数字1101转换成十进制。

N10 = D1 * 2^3 D1 * 2^2 D0 * 2^1 D1 * 2^0

= 1*8 1*4 0*2 1*1

= 8 4 0 1

= 13

(如果您不知道8、4、2和1是从哪里来的,请参考下面的表)

Now we can see that binary 1101 is the same as decimal 13. Try translating binary 111. You should get decimal 7. Try binary 10111. You should get decimal 23.

现在我们可以看到二进制数1101和十进制数13是一样的。尝试翻译二进制数111,应该是十进制数7;试试二进制数10111,应该是十进制数23。

Here's a simple binary chart for reference. The top row shows powers of 2 while the bottom row shows their equivalent decimal value.

这里有一个简单的二进制图供参考。第一行显示2的乘方,而后一行显示是它们的等效十进制数值。

plc里面常见的数字(PLC基本知识--5.2)(1)

  • Octal - The binary number system requires a ton of digits to represent a large number. Consider that binary 11111111 is only decimal 255. A decimal number like 1 000 000 ("1 million") would need a lot of binary digits! Plus it's also hard for humans to manipulate such numbers without making mistakes. Therefore several computer/plc manufacturers started to implement the octal number system. This system can be thought of as base 8 since it consists of 8 digits. (0 1 2 3 4 5 6 7)
    So we count like 0 1 2 3 4 5 6 7 10 11 12...17 20 21 22...27 30 ... Using the formula again we can convert an octal number to decimal quite easily. Nbase= Ddigit * R^unit .... D1R^1 D0R^0 So octal 654 would be: (remember that here R=8)
  • N10= D6 * 8^2 D5 * 8^1 D4 * 8^0

    = 6*8*8 5*8 4*1

    = 384 40 4

    = 428

    (if you don't see where the white 64 8 and 1 came from refer to the table below).

    八进制 - 二进制数制系统需要大量的数字来表示一个较大的数字。考虑到二进制数11111111只是十进制数255,但像1 000 000(100万)这样的十进制数需要很多二进制数字来表示,此外,我们很难在不出错的情况下操纵这么多的数字。

    因此,一些计算机或者PLC制造商开始实施八进制数制系统。

    这个系统可以被认为是基于8的,因为它是由8位数字组成的(0 1 2 3 4 5 6 7)。

    所以我们数数0、1、2、3、4、5、6、7,10、11、12…17,20、21、22…27 30、31……。

    再次使用这个公式,我们可以很容易地把八进制数转换成十进制数:

    Nbase= Ddigit * R^unit .... D1R^1 D0R^0

    所以八进制654是(记住这里基数是8,即R=8):

    N10= D6 * 8^2 D5 * 8^1 D4 * 8^0

    = 6*8*8 5*8 4*1

    = 384 40 4

    = 428

    (如果您不知道8、4、2和1是从哪里来的,请参考下面的表)。

    Now we can see that octal 654 is the same as decimal 428. Try translating octal 321. You should get decimal 209. Try octal 76. You should get decimal 62.

    现在我们可以看到八进制数321和十进制数209是一样的。试着转换八进制数76,应该是十进制数62;试试八进制数100,应该是十进制数64。

    Here's a simple octal chart for your reference. The top row shows powers of 8 while the bottom row shows their equivalent decimal value.

    这是一张简单的八进制表,供你参考。第一行显示8的乘方,而后一行显示它们的等效十进制数值。

    plc里面常见的数字(PLC基本知识--5.2)(2)

    Lastly the octal system is a convenient way for us to express or write binary numbers in plc systems. A binary number with a large number of digits can be conveniently written in an octal form with fewer digits. This is because 1 octal digit actually represents 3 binary digits.

    最后,八进制系统为我们在PLC系统中表达或写入二进制数字提供了方便。一个具有大量数位的二进制数可以用较少数位的八进制形式方便地写出来,这是因为一个八进制数实际上代表三个二进制数。

    Believe me that when we start working with register data or address locations in the advanced chapters it becomes a great way of expressing data. The following chart shows what we're referring to:

    相信我,当我们在更高级的章节中开始处理寄存器数据或地址位时,它将成为表达数据的一种很好的方式。下面的图表显示了我们所讲到的情况:

    plc里面常见的数字(PLC基本知识--5.2)(3)

    From the chart we can see that binary 1110010011100101 is octal 162345. (decimal 58597) As we can see when we think of registers it's easier to think in octal than in binary. As you'll soon see though hexadecimal is the best way to think. (really)

    从图表中我们可以看到二进制数1110010011100101是八进制数162345(十进制58597)。正如我们所看到的,当我们想到寄存器时,八进制比二进制更容易理解。不过,您很快就会看到,十六进制是最好的思考方式(真的)。

    • Hexadecimal - The binary number system requires a ton of digits to represent a large number. The octal system improves upon this. The hexadecimal system is the best solution however because it allows us to use even less digits. It is therefore the most popular number system used with computers and PLCs. (we should learn each one though) The hexadecimal system is also referred to as base 16 or just simply hex. As the name base 16 implies it has 16 digits. The digits are
      0 1 2 3 4 5 6 7 8 9 A B C D E F. So we count like
      0 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 ...
      1A 1B 1C 1D 1E 1F 20 21... 2A 2B 2C 2D 2E 2F 30... Using the formula again we can convert a hex number to decimal quite easily. Nbase= Ddigit * R^unit .... D1R^1 D0R^0 So hex 6A4 would be:(remember here that R=16)

    N10= D6 * 16^2 DA * 16^1 D4 * 16^0

    = 6*256 A(A=decimal10)*16 4*1

    = 1536 160 4

    = 1700

    (if you don't see where the 256 16 and 1 came from refer to the table below)

    十六进制 - 二进制数制系统需要大量的数字来表示一个较大的数字。八进制系统在此基础上进行了改进,但不管怎么样十六进制是最好的解决方案,因为它允许我们使用更少的数字。因此,现在十六进制是计算机和PLC中使用的最流行的数字系统(当然我们应该了解每一种数制系统)。

    Now we can see that hex FFF is the same as decimal 4095. Try translating hex 76. You should get decimal 118. Try hex 100. You should get decimal 256.

    现在我们可以看到十六进制数FFF和十进制数4095是一样的。尝试转换十六进制数76,应该得到的十进制数是118;试试十六进制数100,应该得到的十进制数是256。

    Here's a simple hex chart for reference. The top row shows powers of 16 while the bottom row shows their equivalent decimal value. Notice that the numbers get large rather quickly!

    这里有一个简单的十六进制图表供参考。第一行显示16的乘方,而后一行显示它们的等效的十进制数值。注意,你可以看到数字会很快变大!

    plc里面常见的数字(PLC基本知识--5.2)(4)

    Finally the hex system is perhaps the most convenient way for us to express or write binary numbers in plc systems. A binary number with a large number of digits can be conveniently written in hex form with fewer digits than octal. This is because 1 hex digit actually represents 4 binary digits.

    最后,十六进制系统可能是我们在PLC系统中表达或写入二进制数最方便的方法。一个有大量数字的二进制数可以用比八进制数更少的数字写成十六进制形式,这是因为1个十六进制数字实际上代表4个二进制数字。

    Believe me that when we start working with register data or address locations in the advanced chapters it becomes the best way of expressing data. The following chart shows what we're referring to:

    相信我,当我们在更高级章节中开始处理寄存器数据或地址位时,十六进制将成为我们表达数据的最佳方式。下面的图表显示了我们所讲到的情况:

    plc里面常见的数字(PLC基本知识--5.2)(5)

    From the chart we can see that binary 0111010010100101 is hex 74A5. (decimal 29861) As we can see when we think of registers it's far easier to think in hex than in binary or octal.

    从图中我们可以看到二进制数0111010010100101是十六进制数74A5(十进制数29861)。正如我们所看到的,当我们想到寄存器时,用十六进制比用二进制或八进制要容易得多。

    猜您喜欢: