30.12.04

Links

http://www.epanorama.net/links/pc_index.html
http://www.epanorama.net/links/pc_interface.html#serial
http://www.vision.net.au/~timotsc/null/nullmodem.htm
http://support.microsoft.com/kb/q142324/
http://vasc.ri.cmu.edu/old_help/Misc/Serial/serial.txt
http://www.tldp.org/LDP/lpg/index.html
http://www.delmar.edu/Courses/CIS415L/Lesson2.htm
http://www.google.co.uk/search?hl=en&q=python+module+serial+cable&meta=
http://py.vaults.ca/parnassus/apyllo.py/77689886
http://fab.cba.mit.edu/classes/863.04/people/arikan/index.html
http://en.wikipedia.org/wiki/RS-232http://en.wikipedia.org/wiki/Asynchronous_start-stop
http://en.wikipedia.org/wiki/HDLC
http://www.experts-exchange.com/Programming/Programming_Platforms/Linux_Programming/Q_20818626.html
http://en.tldp.org/HOWTO/Serial-Programming-HOWTO/
http://www.comptechdoc.org/os/linux/programming/c/linux_pgcserial.html
http://pyserial.sourceforge.net/
http://balder.prohosting.com/ibarona/en/python/uspp/uspp_en.html
http://docs.python.org/lib/module-asyncore.html
http://www.experts-exchange.com/Programming/Programming_Languages/Python/
http://www.faqs.org/docs/howtos3.html

More on Serial Ports

Check out the hex numbers for your parallel and serial ports. They are used in python (e.g. in rx.py) for receiving data from the microcontroller. In windows, Device manager > Ports (COM&LPT), right click > properties on the ports, go to Resources tab, it is the I/O Range - usually 0x378. In Linux, the serial port devices are usually called /dev/ttyS* where * is a number starting with 0.

Traditionally IBM PC systems have allocated their first four serial ports according to the configuration in the table below.

PORT Interrupt Starting I/O Ending I/O
COM1 IRQ 4 0x3f8 0x3ff
COM2 IRQ 3 0x2f8 0x2ff
COM3 IRQ 4 0x3e8 0x3ef
COM4 IRQ 3 0x2e8 0x2ef

RS-232
In RS-232, characters are sent one by one as a pattern of bits. The most common encoding format is the asynchronous start-stop format which uses a "start bit" followed by seven or eight data bits, possibly a "parity" bit, and one or two "stop bits". Thus 10 bits are used to send a single character, which has the nice side effect that dividing the signaling rate by ten results in the overall transmission speed. The most common alternative to asynchronous start-stop is HDLC.

The RS-232 standard defines the voltage levels that correspond to logical one and logical zero levels, the standard transmission speeds and connector types. Signals are plus or minus 3 to 15 volts. The range near zero volts is not a valid RS-232 level; logic one is defined as a negative voltage, the signal condition is called marking, and has the functional significance of OFF. Logic zero is positive, the signal condition is spacing, and has the function ON. Signal levels of +-5, +-10, +-12, and +-15 are all commonly seen depending on the power supplies available within a device.

http://www.lvr.com/serport.htm

Serial Ports

Essentially, serial ports provide a standard connector and protocol to let you attach devices, such as modems, to your computer. The name "serial" comes from the fact that a serial port "serializes" data. That is, it takes a byte of data and transmits the 8 bits in the byte one at a time.

Before each byte of data, a serial port sends a start bit, which is a single bit with a value of 0. After each byte of data, it sends a stop bit to signal that the byte is complete. It may also send a parity bit.

Serial ports, also called communication (COM) ports, are bi-directional. Bi-directional communication allows each device to receive data as well as transmit it. Serial devices use different pins to receive and transmit data -- using the same pins would limit communication to half-duplex, meaning that information could only travel in one direction at a time. Using different pins allows for full-duplex communication, in which information can travel in both directions at once.

Serial ports rely on a special controller chip, the Universal Asynchronous Receiver/Transmitter (UART), to function properly. The UART chip takes the parallel output of the computer's system bus and transforms it into serial form for transmission through the serial port. In order to function faster, most UART chips have a built-in buffer of anywhere from 16 to 64 kilobytes. This buffer allows the chip to cache data coming in from the system bus while it is processing data going out to the serial port.

9-pin connector:
1 - Carrier Detect - Determines if the modem is connected to a working phone line.
2 - Receive Data - Computer receives information sent from the modem.
3 - Transmit Data - Computer sends information to the modem.
4 - Data Terminal Ready - Computer tells the modem that it is ready to talk.
5 - Signal Ground - Pin is grounded.
6 - Data Set Ready - Modem tells the computer that it is ready to talk.
7 - Request To Send - Computer asks the modem if it can send information.
8 - Clear To Send - Modem tells the computer that it can send information.
9 - Ring Indicator - Once a call has been placed, computer acknowledges signal (sent from modem) that a ring is detected.

Voltage sent over the pins can be in one of two states, On or Off. On (binary value "1") means that the pin is transmitting a signal between -3 and -25 volts, while Off (binary value "0") means that it is transmitting a signal between +3 and +25 volts.

An important aspect of serial communications is the concept of flow control. This is the ability of one device to tell another device to stop sending data for a while. The commands Request to Send (RTS), Clear To Send (CTS), Data Terminal Ready (DTR) and Data Set Ready (DSR) are used to enable flow control.

Example of how flow control works:
You have a modem that communicates at 56 Kbps. The serial connection between your computer and your modem transmits at 115 Kbps, which is over twice as fast. This means that the modem is getting more data coming from the computer than it can transmit over the phone line. Even if the modem has a 128K buffer to store data in, it will still quickly run out of buffer space and be unable to function properly with all that data streaming in.
With flow control, the modem can stop the flow of data from the computer before it overruns the modem's buffer. The computer is constantly sending a signal on the Request to Send pin, and checking for a signal on the Clear to Send pin. If there is no Clear to Send response, the computer stops sending data, waiting for the Clear to Send before it resumes. This allows the modem to keep the flow of data running smoothly.

http://computer.howstuffworks.com/serial-port4.htm
http://www.lvr.com/files/spcch1.pdf