All computers transfer their data internally, for instance to the hard disk, in parallel - eight, sixteen or even thirty two bits at a time, and yet nearly all external communications, eg to the internet, your keyboard, mouse or USB devices is serial - one bit at a time. The reason for this is two-fold - more bits need more wires, so we would need fatter cables, and the long cables and the environment outside the computer means that we get noise on the line which corrupts the data. To solve the interference problem the designers have to drop the speed, and they have to drop it so much that the faster speeds we can use with a single bit means that the whole data transfer using serial is faster.
Given that serial communications is so important to computers, let's have a look at it. All serial communications, whether USB, ethernet or anything else, use the same basic structure - something to mark the start, some data, maybe some error checking, and something to mark the end. They implement this in various ways. We will have a look at the simplest, that used by basic asynchronous serial communications, otherwise known as RS232. This method was used for some printers, older GPSs, and almost anything else you might connect to a computer aside from the display, mouse and keyboard. Although we don't see it at home much anymore, it is still heavily used in industry due to its simplicity.
RS232 communications has a standard set of parameters:
- Speed: the speed at which the data bits arrive.
- Data bits: 7 or 8.
- Parity type: o-Odd, e-Even or n-None.
- Stop bits: 1 or 2.
- Start bits, but that is always just one.
The speed many systems can work out on their own, but everything else they need to told about (except for the number of start bits, as that never changes). So we often see serial specifications such as 9600,7,e,1. This one means 9,600 bits per second, seven data bits, one bit for even parity, and a minimum of one stop bit. And don't forget the one start bit. The even parity means that value of the parity bit has been set such the total number of ones in the data and the parity bit is even. Odd parity means that the total number of ones in the data and the parity bit is odd. The other option is no parity - the parity bit has not been included in the bitstream. There is always one start bit, and its value is always 0. There may be one or two stop bits, and their value is always 1. Note that the stop bit count is a MINIMUM - stop bits may be infinitely many - it is the gap between characters. But the actual number of stop bits may not be LESS than the specified value.
Let's look at an example: If we are told 9600,7,o,1, and we have an instrument on the serial line that allows us to inspect the voltages on it, we might see this: 1111001101101111 (where 0 represents a low voltage and 1 represent a high voltage). We ignore the first 1s, which is just empty line, or maybe continuation of the stop bit from an earlier character. The first 0 is the start bit. This is always 0. The next seven bits, 0110110, must be the seven bits of data. The next 1 is the parity bit and the remaining 1s are the stop bit - which is always 1. There must be a minimum of one of these. There are five 1s in the data and the parity bit, which matches the odd parity specified, so this data packet is valid.
Let's look at another, using 115000,8,e,2: 000111011011 The first 0 is the start bit, there are eight data bits so they must be 00111011. Then there is the parity bit, which is 0, and finally the two stop bits, which must be, and are, 1s. Let's check the parity - there are five 1s in the data and the parity bits, but the specification says even parity, so this packet has been corrupted - a bit has been "flipped", perhaps by some electrical interference. We should ask for this packet to be resent.
And here come the cache coordinates, streaming into our serial port, using the most popular set of serial protocols, 9600,8,n,1:
111100101001110001101001000110000100010000010001100101000110001100010111010001110 001000110111100011100110001011001110001000001001000101100011000110001101111000110 101100010000010001100111000110100100010111010001101011000110101100011000111111111
Oh - you still do not know what the data represents? Binary to ascii (text) conversion is a whole other lesson on its own, so for now I recommend you use an online tool, such as Roubaix Interactive's binary to text converter.
The cache is a 200ml Sistema, within David Spring Park. Good luck!