beautypg.com

Basics of programming – SoundTraxx SoundCar Users Guide User Manual

Page 10

background image

bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0

Tsunami SoundCar User’s Guide

Page 6

127 converts to a simple 7F in hex. If your command station’s interface allows

a limited number of digits, hex numbering can allow your cab to display a

greater range of numbers.

Binary – Binary numbers get their name from the fact that they only use two

digits, 0 and 1, which are called “bits.” Binary is the fundamental numbering

system used by computers, including those found inside a digital decoder.

Because there are only two bit values, more digits are required to represent

a number when using binary. For example, the decimal number 127 is written

as 01111111 in binary notation. A “byte” is a binary number made up of eight

bits, and a “nibble” is one‑half of one byte, or four bits.

Each CV is made up of one byte (i.e., eight bits) and can store any number

from 0 to 255. Most CVs contain a single piece of data that can be easily

represented in any of the three number formats described above. For

example, CV 3 (Baseline Acceleration Rate) can be loaded with any value

from 0 to 255 and it will always and only affect one thing – the acceleration.

Now, a little more about those bits: Some CVs use the individual bits to

control various features. This keeps the number of CVs more manageable

and allows up to eight distinct features to be controlled using a single CV. Bit

variables require binary input and will only respond to input values of 0 and

1. For this reason, programming by the bits is usually reserved for simple

variables that are either ON or OFF, disabled or enabled, etc. Unfortunately,

bit variables are difficult to represent in any form other than binary while still

preserving their meaning. As most DCC system user interfaces don’t use

binary representation, programming by the bits using binary requires a little

bit of math (just simple addition though!) to convert values into the decimal or

hex representations used by most DCC systems.

To facilitate programming, we have tried to use decimal representation in this

manual when defining advisable values to program into a given CV; however,

you will occasionally find binary values listed in the Tsunami SoundCar

Technical Reference.

Now, let’s try a programming example for CV 29 (Configuration Register 1),

which works best when programmed by the bits. When programming

individual bits, we suggest the following procedure to determine the correct

decimal value. Referring to the CV description in the

Tsunami SoundCar

Technical Reference, write down the value that will produce the desired

response for each bit. In this example, we want to program this CV so that

speed tables and 28 speed‑step mode are enabled. As indicated in the

technical reference, bits 1 and 4 should both be set to 1 to enable the desired

features, with all of the other bits set to 0. Write down the individual bit

values as shown below:

Basics of Programming