Extended Codes

Which One Should I Use, Part XVII

Phil Kingery

There are 10 types of people in the world -- those who understand binary, and those who don't.

Q: Why do computer programmers confuse Halloween and Christmas? A: (See the bottom of this article.)

If you do not see the humor in these 2 "jokes", then this article is for you!

Over the years I have written many technical articles and have always appreciated all the kind emails I get about them. A couple of years ago, I wrote an introduction to the published X-10 protocol. Then I jumped ahead and wrote an article on the "X-10 Extended Code" data set. That article concentrated more on how the extended code data set is used in ACT products. The intent of this article was to go deeper into the protocol itself but as I write it, I now see that I will have to break it up into two parts. Even though these two will be the seventeenth and eighteenth articles in this series, they kind of fit between #13  and #14 .

I also want to clarify the "tuxedo" remark. That sub-title may have caused you to doubt my sanity, but please let me explain. When I wrote WOSIU#13, I created a graphic that explained the binary bit pattern of the X-10 protocol. That graphic was all ASCII text but I converted it to a gif so that your web browser's "word wrap" feature would not misalign the columns. Unfortunately, there was one serious (but silly) error. In the explanation of how some commands had changed over the years, I used the word "formally". That was the wrong choice of words. I meant "formerly", as in "was before", not "formally" as in "evening attire". Therefore, one of the first things I did for this article was to recreate that chart with a few improvements including the necessary change to the word "formerly". You will see that chart later on.

Before we really get into this, let's make sure that we are all talking the same language, I would like to explain some of the terms I will use in this article (or you can skip directly to the binary and hex explanation). In many cases, I have already discussed these terms in other articles, but in case you came into the middle of the show, I might as well go over them again.

X-10 = This is probably the most misunderstood of all, because almost everyone who is reading this "thinks" he knows what it means. The company that used to go by "X-10" has changed their name to "X10" (notice, no hyphen). Why? I'm not sure but I have a guess. It may be because that anytime you put a hyphen into an internet search engine it is usually the same as putting two words in quotes.

In other words, searching for two words linked by a hyphen, like this:

…is pretty much the same as entering the two words enclosed by quotes, like this:

Therefore, when you are trying to find the X-10 company, you may inadvertently be searching for any website that has an X and a 10, side by side. That means that any website that talks about:

"8 x 10 glossy pictures of Uncle Phil in a thong "

… would show up on the list. (Not a pretty sight.) Therefore, when I use X-10 in a sentence, I (usually) mean the protocol not the company. Occasionally I slip, but I try to catch my mistakes before these articles are put out on the internet.

X10 = This is pretty simple since I already explained this one in the definition above. When I use X10 in a sentence, I mean the company.

Basic Code = This is going to take a bit of explaining. Back in WOSIU#15 , I said that: "… the X-10 protocol is not a "standard". There is no governing body who has adopted nor regulates the use of, changes, additions and adherence, to the protocol. Instead of being a "standard", it is simply a "published" protocol." Therefore I want to make a change in the way I use certain words, in the hope that this will increase the clarity of the subject and avoid any misunderstandings in its meaning. When comparing "Extended Code" to the older command set that we all know and love, we have all used the term "Standard Code" (as in "Standard Code" versus "Extended Code"). That seems confusing since I have also used the word "standard" to describe how the X-10 protocol is not a "Standard". Therefore, beginning with this article, I will endeavor to use the phrase "Basic Code", (as in "Basic Code" versus "Extended Code"). That seems to make more sense to me.

Extended Code = This is not as simple as it may seem, because with the publication of the extended code protocol at ftp://ftp.x10.com/pub/manuals/xtc798.doc, X10 said that there would now be three different "extended codes". (Confused yet?)


However, as far as I know, only "Extended Code 1" is defined. Therefore, for the purposes of this article (who knows what the future will bring), when I use the term "Extended Code" or the shortened version of "Ext'd Code", I mean it as "Extended Code 1".

And now, on with the show…

Binary, Decimal and Hexadecimal (with a bit of Octal, thrown in, just for fun):

Okay, stop what you're doing and look at your fingers, all ten of them (don't be picky, your thumbs are fingers, too). We humans count using a "base-10" system. This is called "decimal", from the same root as "decade", which is déci-, from the Latin decem meaning "ten", or decimus meaning "tenth". If we had only 4 fingers on each hand (3 fingers and a thumb, evolution guided by the hand of God), we probably would use a "base-8" counting system. Interestingly, there already is a base-8 number system. It is called "octal". Octal means eight, like an octagon is an 8-sided figure (a stop sign, for instance). What good is it? Well, for purposes of this article not much, except I still have to explain that joke at the top of this article.

Surprisingly, our common base-10 numbering system evolved to where it is not one through ten, but instead, it is zero through nine. The next number above nine is a one in the next column with a zero in the original column. Ah, I think you are beginning to see the pattern here. The true meaning of base-10 refers not only to the digits, but also to the "multiplier" from one column to the next.

Okay, this base-10 system is early grade school stuff, so let's move on.

Let's talk about binary. Transistors don't have fingers (or thumbs, for that matter). They need a much simpler way to count. The only thing they can do is zeros and ones (like Off and On). If you have only one transistor, it can only count to 1. If you had two transistors, together, they can count all the way up to three.

002 = 010 = Zero
012 = 110 = One
102 = 210 = Two
112 = 310 = Three

If this is all new to you (or you are a parent struggling to help your kids with their homework), it may be necessary to explain the method of notation. Allow me to take that first statement and break it down a bit.

002 - This is usually read, "zero-zero". But purists may read it as "zero-zero base 2" or "zero-zero binary". That little "2" lower than the other numbers (subscript) is to show the base, in this case, binary.

010 - This one is easy. It's just "zero", but purists (especially when talking about converting from one counting base to another) may read it as "zero base ten" or "zero decimal". That little "10" shows the base as being decimal. Whenever you see a number with no explanation, it is assumed to be decimal.

Using "zero" as an example may not show the depth of the differences since zero in any counting system is the same. When we get into anything higher is when the differences become increasingly clear.

Let's expand on this binary nature. Since we all use computers every day, you may think you understand the term "megabyte". You may not realize that, technically speaking, it does not always mean "one million bytes". No indeed, most of the time, it means "1,048,576 bytes" (at least, when talking about data storage).

Why such an odd number? Why "one million, forty-eight thousand, five hundred, seventy-six bytes"? One would expect it to be a nice round number, wouldn't one? That is easy to explain. But first, I have to send something to your computer…give me a second… Okay! I have just sent you a special calculator. You now have a calculator on your computer (no matter if it is Win95, Win98, WinME, Win2K, etc.) that will allow you to convert binary to decimal (and hexadecimal, even though we haven't explained that yet).

Now, I want you to scroll this text until this line is right at the very top of your screen. While you are reading this, click on the "Start" button on your task bar, then "Programs", then go to "Accessories", then open your "calculator". It will probably look like this:

(My computer is set to 800x600, so if yours is different, this may not line up as well as mine does.

Obviously, I was just joking about sending you a special calculator. This is the standard calculator that always comes with MS-Windows, but most of you may not realize that it has some nifty scientific capabilities.

Click on "View". It probably says "Standard". Change that by selecting "Scientific.


Now it looks bigger!! And it has more buttons!!

Now, I want you to scroll this text until this line is right at the very top of your screen. Of course, as soon as you clicked your mouse pointer on the scroll bar, the calculator went "behind" your browser, so we will deal with that right now. Go down to your task bar and bring the calculator back to the front. It should still be in the "Scientific" view. Move it so that it sits in this big open area.

Make sure that "Dec" (for decimal) is selected. Now using either your keyboard, or your mouse, enter this base10 number: 1048576. Now, click on "Bin" (for binary).

What came up? Isn't that amazing! It really is a nice round number, binaurally speaking!

Now, go back to "Dec", clear the previous number and enter one less, or 1048575

Now, click on "Bin". Pretty neat, huh? Okay, now click on "View" and select "Digit Grouping" at the bottom. (Sorry, this won't work in Win95 nor Win98)

Now the digits are grouped together into sections. Here in North America, we tend to put commas (",") into large numbers so that the digits are divided into groups of three, like 1,048,575, but remember our common numbering system is decimal.

Grouping binary numbers into fours makes more sense. And, we don't use a comma, we simply use a space. But why groups of four? Well that is the next part. Eight "bits" (bit = binary digit) equals a "byte". And half a "byte" (don't laugh) is a "nibble". Honest, I'm not making this up. (Depending on your browser and screen settings, you may have already had to scroll down, which means that your calculator is, once again, hiding one layer back. Just let it stay there for a while. I will tell you with you can bring it back to the front.)

Okay, so 4 bits equal a nibble, so what. Well, since digital engineers usually work with a bunch of very long binary numbers, it sure would make things easier if there were some sort of shorthand method for working with them.

Look at this chart. The binary numbers are on the left and the decimal equivalents are on the right. Both of them are often awkward to use. One of them is just a bunch of 1's and 0's and the other goes from one digit to two digits. How can we come up with a way of "noting" these sixteen numbers in a way that would "represent" them, but would stay at one character in length? In order to do that, we would have to invent a base-16 numbering system.

Don't worry, they already did that. It's called hexadecimal (hex=6 and deci=10, or 16 total).

If I had invented a base16 numbering system, I might have used sixteen different symbols, combining astrological, chess, musical and a happy face…. But who could memorize all those?

Instead, whoever did invent it (at least the notation for it), decided to use the standard Arabic digits 0-9, then the capital letters A-F.

Since it is often difficult to read some people's hand writing, it was decided that we needed a different way of showing that the "digit" was a hex number. After all, a "B" can be a letter, or it can mean eleven, or it can mean "1011" in binary (which is the old basic code command for "Preset Dim 1", but I am getting ahead of myself).

We can't rely on 'subscript' numbers since most programming is done in ASCII text. Therefore, "they" decided to use "0x" as a prefix (who knows why). Therefore, when you see "0xA" you will know that it means "A" in hex, which is equal to 'ten' in decimal, and 'one-oh-one-oh' in binary. (Hint: Look at the blue keys on your AT004.)

Okay, it's time to scroll this text so that this paragraph disappears above the very top of your screen (read it first). Then go down and click on your task bar so you can see the calculator again. This time, I'm just going let you put the calculator anywhere you want just as long as you can read the next paragraph.

Okay, if you have been following my instructions to the letter, your calculator still says, "1111 1111 1111 1111 1111". Now click on "Hex" and see what pops up. How about that, it is "F FFFF". You have been able to reduce 20 characters down to only 5. I see that look on your face, that look of discovery! You have just realized that a group of four binary digits can now be reduced to a single hexadecimal digit. Ah yes, you have grown much my young math grasshopper!

Now, try this. Go back to "Bin" and then clear the calculator. Now enter as many 1's and 0's as you can. I don't care what you enter, just bang out any random order of 1's and 0's until you can't put any more in. Now click on "Hex". Pretty cool, huh?

Okay, one more. Go back to "Bin", enter enter 0001 1100 0011 0001 (actually the first 3 zeros won't show up), then click on "Hex". You get 1C31. Now lets pretend that you have a way to enter that data string into some gizmo that is capable of sending that data onto the powerline in the X-10 format. This gizmo also has the means to insert the X-10 address in front of that data so that it fits within the published protocol from X10. Once you get all that entered, you could then press the TRANSMIT button, and sent it out onto the powerline.

Do you know what you just did? You just sent your first ext'd code command. If you had a sophisticated dimmer, like the ACT PCC RD104, you would have just commanded it to go immediately to dim level 28. It doesn't matter if it was higher, lower, on or off, whatever it was doing before, it would receive that data string and go right to that dim level.

Assuming that the RD104 was set to the X-10 address "A01", this is what the complete data frame would look like: A[1]011C31. Unfortunately, this is a confusing mix of "X-10 notation", "ACT notation", and "hexadecimal notation", all thrown together.

Allow me to break it down for you:

A[1]011C31 - The first character is the letter "A" and refers to the major letter group. X10 calls this the "house code" but since ACT does huge industrial/commercial installations, we call it the letter code. (The term "house code" is rather insulting to the owner of a 30 story building.) As you should already know, there are sixteen letter codes, A-P. This is NOT hex! The X10 engineers simply assigned a certain bit pattern to be "A" (see the big chart below).

A[1]011C31 - The "[1]" lets you know that this is an extended code data frame. ACT adopted this method of notation to make it easier to differentiate ext'd code from basic code. In reality, the [1] is a command, that tells the receiver that this is an "Extended Code 1" data frame. It means that the number portion of the address has been shifted to the right, then there are a bunch more bits to follow. Instead of the data frame being only 11 cycles long, it will now be almost three times longer, actually 31 cycles long. That sounds like a lot, but with ext'd code, the command is included into the same data frame as the address. Again, this is NOT hex! The X10 engineers simply assigned a certain bit pattern ("0111" in this case) to be "Extended Code 1". We at ACT have adopted the "bracket-one-bracket" as a notation shortcut to help document extended code 1 data frames.

A[1]011C31 - The "01" is just the second half of the address. In this case, this dimmer receiver is set for address "A01". (I always try to use three characters in my address notation, so that it is more consistent throughout.) It is an often held misunderstanding that ext'd code automatically allows for more than 256 addresses. Technically speaking, there are still only 256 addresses, however, many ACT products also use "Extended Addressing" to allow for 4,096 addresses. As above, this is NOT hex! The X10 engineers simply assigned a certain bit pattern to be "01" (see the big chart below).

A[1]011C31 - From here on, everything is written in hexadecimal notation. The part where the "1C" resides in the data frame is, of course, two nibbles, or one byte. This part of the ext'd code data frame is the "data byte". When you need to send a value from one X-10 compatible device to another X-10 compatible device, this is where you put that data. You can send any decimal value from 0-255 (or 00-FF in hex). Specifically, "1C" is 2810. At this moment, we don't know what that 28 means, it is only a value. How that value is to be interpreted comes later.

A[1]011C31 - The last two nibbles (the 316 + the 116) comprise the "Command" section, but I will discuss each part individually. The first half of the command section is the "Type" and identifies for whom the data is intended. Since this is a nibble, you know that there are 16 possible values (0-F). X10 has already assigned many of them. For instance, "Type = 3 Control Modules (Dimmers and Appliances)". Therefore, this data frame is intended for a dimmer or appliance module. It can be to a dimmer or appliance module, or it can be from a dimmer or appliance module. (I will put a chart in the next article that goes into the "types" in detail.)

A[1]011C31 - Finally, we come to the "1". The is the last nibble of the "Command" section. This last half of the command section is the "Command". I know that seems redundant (X10 came up with this, not me), but in other "Types", it is called the "Function". The first half of the command tells the "who" and the last half tells the "what". A command "1" means "dimmer, go to whatever dim level is specified in the data byte". (I call this a "direct dim" command.) Since we already know that the data byte value was 28, the dimmer receiver should ramp up (or down) to about 44%. (I will put a chart in the next article that goes into the "commands" and "dim levels" in detail.)

As a refresher, below is the new and improved binary bit pattern chart with the corrected word "formerly".

X-10 data is usually sent in predetermined length "frames" each beginning with a start code designated as "1110".  The next 4 bits represent a major group category and the following 4 bits represent either a unit designation or a command, the selection of which is determined by the last function bit.
Every data frame is always transmitted twice (as illustrated below).

Okay, time to catch our collective breath. I've been working on this article off and on for months. I am proud of you for sticking with it to the end. You now have a better than average understanding of X10's Extended Code 1. But there is still so much to learn. In the next article, I will give you more specific information on using extended code to do scenes, direct dims and other nifty things.

We are just about done for this edition. There are only a couple of things left to do. At the beginning of this article, you read this:

"There are 10 types of people in the world -- those who understand binary, and those who don't."

You, just like everyone else, read that as, "There are ten types of people…" Now you know that it could have been read as, "There are one zero types of people…" That's 1-0 in binary, which, of course, means two in decimal.

Then you read this:

Q: Why do computer programmers confuse Halloween and Christmas?

Scroll your browser until this is near the top of your screen. If your calculator is still open, it is most likely back one layer behind your browser. Bring it to the front.

Your calculator probably still says, "1C31" . Click on "Dec" to go back to decimal (base-10). Then clear it.

Now while in DEC enter "25".

(You can see this coming, can't you.)

Now click on "Oct" (for Octal or base-8).

And 'that' is why programmers confuse Halloween and Christmas.

To infinity…AND BEYOND!!

"Uncle" Phil Kingery
Phillip Kingery is a representative of Advanced Control Technologies, Inc. pkingery@act-solutions.com

Comments (0)

This post does not have any comments. Be the first to leave a comment below.

Post A Comment

You must be logged in before you can post a comment. Login now.

Featured Product

Art Diffusor® Model D by Acoustics First

Art Diffusor® Model D by Acoustics First

The ArtDiffusor® Model D (patent applied for) is the newest in the ArtDiffusor® Series. The Model D is an organic, quadratic diffuser; fusing diverse design concepts such as MLS, QRD, bicubic interpolation and boolean logic mapping. These rolling, asymmetric diffusers minimize specular acoustic reflections while improving sound clarity and ambience. Their design encourages developing customized patterns, allowing for a truly unique installation - every time.