Writing pins to the RS232

Michael Schneider michaelschneider at fuse.net
Sat Dec 31 13:21:41 EST 2005


Jay,

Couple of points that may help you.

1) A serial port does not have data ports 0-n.  A serial port takes a 
byte (8 bits), then shifts them down a single pipe using a chip called a
UART (feel free to google for unfamiliar terms).

example

Bit pattern 1010 1010

would be shifted one bit at a time

1
0
1
0

1
0
1
0

a one is +5 volts on single send line of the UART and 0 is 0 volts.

RS232 uses a different mapping for 1's and 0's (but is still serial)

1 - ~-3V - -12 V
0 0-12 V

So you slap a chip on between the UART and the RS232 pin  (usually a 
MAX232)  that translates the voltages for you.

On the other end of the wire

232 socket
MAC232
UART (usually built into the microcontroller)
Register in Microcontroller


I like playing at this level.   I would recommend using AVR 
microcontroller (easiest to program and there is an open source
gcc compiler).

for $20.00 US you can buy the butterfly eval board with:
- microcontroller
- max232 all wired up for rs232 connection from your computer
- lcd display
- temperature sensor
- light sensor
- the avr mega169 has many goodies
     - analog - digital converter
     - digital -> analog converter
     - LCD controller

This is a great bargin.

If you are starting out in microcontrollers.  I would suggest that you 
go to:

http://smileymicros.com/

They sell a nice package for $90.00

- butterfly eval board
- great, easy to follow book on how to develop on microcontrollers for 
the beginer.
- project kit - includes everything you need to build all of the 
projects (even includes the wire ;-)


There are python libs that support Ateml Avr connections:


It is easy to use your rs232 serial with a microcontroller at the other 
end of the wire.  Microcontrollers are cheap.  If you fry why is 
connected to your devices, you are only out the microcontroller.


Have fun,
Mike



jay.dow at gmail.com wrote:
> I want to write to the pins of an RS232 without using the serial
> protocol.  The use would be every pin could act to complete a circuit
> in customized hardware.  I could use python to communicate serially to
> a BASIC stamp or a Javelin stamp and then use the stamp to set however
> many pins as 0's or 1's but should it be that hard to do with python.
> I've looked through how python does serial with the "serial" module but
> it just uses Java's javax.comm libraries.  Is there anyway to do very
> low level device writing to COM ports?
> 
> In summary I'm looking for something like:
> ser = serial.Serial(0)
> ser.pin0 = 1
> ser.pin1 = 1
> ser.pin2 = 1
> ....
> 
> 
> or
> ser.write('0xFF')
> which would set 8 pins on the RS232 cable to 1's
> 


-- 
The greatest performance improvement occurs on the transition of from 
the non-working state to the working state.



More information about the Python-list mailing list