Binary Numbers

Have a read through Phil's tutorial (click learn PLC's at the top of the page) he has a section on numbering systems, that might answer your question

Paul
 
Yep, I was doing so and got ahead of myself. In other words if I had been patient I would have answered my own question. So thanks for answering anyway.
 
Hi there,

I think it is very helpful to have a basic understanding of binary, octal, and hexadecimal numbering systems. Knowing these numbering systems helps with certain PLC addressing and data storage situations, and it also helps in interpreting error codes that certain PLC's and modules give.
 
Well, probably one does not NEED to know binary.
And higher the programming language level, less he needs it.
But it is useful to know. What is the problem to learn it?
All you can know about it may be learned and understood in couple hours. Nobody expects you to make brief binary calculations mentally.
 
Sergei Troizky said:
Well, probably one does not NEED to know binary.
And higher the programming language level, less he needs it.
But it is useful to know. What is the problem to learn it?
All you can know about it may be learned and understood in couple hours. Nobody expects you to make brief binary calculations mentally.

i dont see how you can expect to get around learning at minimum binary numbers and boolean logic,i mean heck,,its what its all about,,off and on,,and no matter what level of programming language you are talking about,,its still necessary,,

Fred Raud
 
Sooner or later, if you are serious about this field...

...you will have to know Binary, BCD, HEX... and more!

By the way, Binary is the easiest to both recognize and work with.

Numerically, BCD is easy to understand (that is, read)... but, only if you KNOW the data is in BCD! Although, it's a pain to work with!

HEX can also be relatively easy to understand (read)... but, again, only if you KNOW it is HEX! This also is a pain to work with.

Far and away, Binary is the easiest to understand and work with!

So... bite the bullet and learn Binary... it's easy!
 
I'm a little in the dark about what the OP means by 'Know Binary'.
Is it absolutely essential to know that 0000 1011 (base 2) is equal to 11(base 10) ?

Probably not.

It is, though, a good idea to have a feeling for the numeric representations used in PLC's (and other programming). If only to recognize common tricks. But also, it is necessary to understand typical 'binary' (as in the terms, not the numbering system) operations.

In AB terms, for example, N7:20 OR 5 will set bits 0 and 2 to a 1. In any PLC, shifting an integer is the same as a multiply or divide by powers of 2.

At the very, very least, it is useful to know (in most, NOT all, cases) how to use the Windows Calculator in 'scientific' mode to convert between the most common integer systems.

Base 2 (binary) is just a simple way of representing integers (read, actually, 'Pre-defined ranges of Whole Numbers') that is 'natural' to computers.

I had to specify 'Pre-defined... yada', because I'm positive that someone will point out that integers can be virtually any length, (being defined as the 'Natural Data-Width of a Particular CPU'...).

As far as numbering systems go, in addition to 'knowing binary', you also need to be aware of the natural size of the word on your particular platform, as well as how numbers are represented.

For 'SIGNED' 16 bit integers, represented by 2's complement, the numeric range is -32768 to 32767. The exact same word, interpreted as 'UNSIGNED' represents 0 to 65535.
Also, the representation (in base 2) might at first be counter-intuitive. Same 16 bit integer, (bit-count starting at 0), bit 15 is the 'sign' bit. If true, the number is negative... So, 16 bit, signed, 2's complement, 0000 0000 0000 0001 is equal to a decimal 1. The odd part, is 1111 1111 1111 1110 {{{EDITED As per Peter's 100% accurate post below pointing out that once again, I'm in error!, Thank you Peter Nachtway... Credit where Credit is due}}} is equal to (-1) in decimal.

Why? Because using 2's complement, there is a unique representation for every possible whole number in the range. Another, older, though sometimes seen format, called 1's complement looks at first glance to be more 'natural', representing (-1) decimal as 1000 0000 0000 0001. This has a HUGE problem though.... as an exercise, let me know what the problem is :)
 
Last edited:
rdrast said:
representing (-1) decimal as 1000 0000 0000 0001. This has a HUGE problem though.... as an exercise, let me know what the problem is :)
Actually -1 is 1111 1111 1111 1110 in ones complement which is the complement of
0000 0000 0000 0001 which is why it is called ones complement.
http://burks.bton.ac.uk/burks/foldoc/56/83.htm

TimothyMoulder said:
When Peter Nachtwey sees this, he's gonna have fun with it...
I don't answer rookies questions. I leave these for others. Regulars that get their facts wrong and mislead rookies are fair game.

Since I am answering. Knowing binary should be as natural as breathing. How can one understand the bit tricks without knowing binary?
 
Damn you Peter.. You are 100% as always, but the problem with 1's complement remains to be answered.

(aside... How much would it cost to hire you for a year or so and fix all my problems Peter?)
 
To help understand the various numerical types I would suggest you have a look at Windows Calulator in scientific mode. But then there is IEEE 754 floating point, IEEE 754 double precision etc - hmmmmmm.

At least it would get you started.
 

Similar Topics

Hi folks, I'm trying to parse a binary string on a Red Lion DA30D using a Raw UDP/IP input port. I've done this before with ASCII strings so I do...
Replies
38
Views
978
So here's my situation, I have been tasked with modifying the logic to mimic a button press in the PLC. I have two identical machines however one...
Replies
6
Views
539
Hi, I want to extract every second bit of a double word and place it in a new word but the position of placement should be from 0,1,2......15...
Replies
17
Views
3,068
Hello, I am trying to convert a incoming string that is in Binary format (See attachment) to a DINT. Any ideas? When I use the STOD command it...
Replies
6
Views
2,215
How can I read individual binary bits from a SLC500 within FTH SE? With the Tag Browser I can get to the Binary Files and get each Integer from...
Replies
5
Views
1,603
Back
Top Bottom