Controlling led with the pc's serial port

Thread Starter

arthur92710

Joined Jun 25, 2007
307
I built an RS232 circuit with a max232 and connected it to my pc's serial port. I was able to cntrole the speed of a fan by sending pulses with different frequencys. so it does work:D

serial comes out in 8 bit pieces like 10100110, it can pwm a fan but how can I get it to light up different leds with different pulses? like 00000000 keeps all leds off. 00000001 will turn on led one and 00000010 will light led 2.

Its to control a 7seg or a matrix of leds. Any suggestions?
 
Last edited:

mik3

Joined Feb 4, 2008
4,843
I built an RS232 circuit with a max232 and connected it to my pc's serial port. I was able to cntrole the speed of a fan by sending pulses with different frequencys. so it does work:D

serial comes out in 8 bit pieces like 10100110, it can pwm a fan but how can I get it to light up different leds with different pulses? like 00000000 keeps all leds off. 00000001 will turn on led one and 00000010 will light led 2.

Its to control a 7seg or a matrix of leds. Any suggestions?

btw the smilies dont work
How do you control the ports of the PC?
 

Thread Starter

arthur92710

Joined Jun 25, 2007
307
go to Start>all programs > accessorys > hyperterminal
then you connect to the port you want, I connect to com1, then you can hit keys and it will send it in binary to the serial port.
 

SgtWookie

Joined Jul 17, 2007
22,230
Get an 8-bit shift register with latching outputs. Have the latching outputs control something like a ULN2803 Darlington driver to sink the current from your LEDs.

Don't use the MAX232 power to light your LEDs if you want it to last for any length of time. It wasn't designed for that.
 

Thread Starter

arthur92710

Joined Jun 25, 2007
307
ok I have a 8bit shift register but it needs 2 clock inputs, but i dont think that rs232 has clock, if I use a 555 to make the clock will it work? what frequency should I use? The baud rate is 9600 , should the clock frequency be the same?
 

Thread Starter

arthur92710

Joined Jun 25, 2007
307
can I use a TPIC6C595N?

EDIT: SN74LV8153 is a serial to parallel converter and it does not have any clock inputs.
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
You're aware that the MAX232 is simply a level converter, right? It converts RS232-level signals to TTL levels. That's it!

You're going to have to do the processing of the individual bits yourself. You'll need to build a circuit to recognize the start bit, and then start clocking the succeeding data bits through at a rate that matches your RS232 port settings.

You'll need to have your clock pretty precise. The best way to do this is by using a crystal-controlled clock and divider. There are ICs out there dedicated to doing just this kind of thing.

As far as a shift register, you could use something like a 74x164 or 74x299. The latter is more flexible if you want to use it for additional experiments later.

I have no clue what a TPIC6C595N is - do you have links to datasheets for the IC's you mentioned?
 

SgtWookie

Joined Jul 17, 2007
22,230
That TPIC6C595 is a nifty IC!
Yeah, that'll work. :)

OK, basically what you'll need to do is watch the output of the MAX232 for that starting bit. Then send 9 clocks to the shift register at whatever baud rate you're running.
That's assuming you're running 8N1 (8 data bits, no parity, 1 stop bit)

The first item clocked through the shift register will be the start bit. Then you'll get 8 data bits. There's also going to be a stop bit at the end, but you stop clocking before the stop bit hits, and then delay a couple of clocks before looking for the next start bit.

I suggest using a slow baud rate, since you're only going to be sending a byte at a time anyway. Try 1200 baud.

Try this search:
http://www.google.com/search?hl=en&q=RS232+specification
Have a look at this link:
http://www.lammertbies.nl/comm/info/RS-232_specs.html
 

Thread Starter

arthur92710

Joined Jun 25, 2007
307
What do you think about the SN74LV8153?
It does serial to parallel with no external clock, it has few external parts, but a price of $1.37 each and a max of 24kbps are negative, but thats not really bad, were just controlling leds,
I have a question about one thing on it , it says "up to 8 devices on one bus" is that 8 on each Y output? for a total of 64? or just one on each of the eight Y outputs?
 

SgtWookie

Joined Jul 17, 2007
22,230
If you really want to get away from having to deal with all of the start/stop/data bits/parity bits, FIFO's, buffering, etc. - you need a UART IC. Universal Asynchronous Receiver/Transmitter.

With UARTs, you basically just tell it what to expect as far as start/stop/bits/parity, and it hands you the data on a silver platter.

The MAX232 is just a level translator; from RS232 to TTL. It gives you access to the primitives of the communication protocol, and you have to figure out what to do with the primitive data. UARTS handle the primitives for you, and line up all those little data bits in a row for you.

Try doing some research on UARTS.

After you find a suitable UART, you'll find that it'll be pretty easy to hook up the TPIC6C595 to it.

Either that, or look at programming a microcontroller such as a PIC, Basic Stamp, ATMEL, etc.
 

Thread Starter

arthur92710

Joined Jun 25, 2007
307
Actually I have been looking into AVR's, but I can get the programmer until mid-late June:mad:. Even if I built one of the cheap one's I still cant get any chips till June. I was hoping to get this to work with out any of those. Still got a whole month to wait until all my exams are over:mad:.

But thanks for helping!
 
Top