Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
Could someone please explain to me how I can hook up a serial port of a computer to a PIC or some other type of chip so that I can control the outputs via the computer, want to do it serialy so that there are minimum wires.
You can use a PIC16F874 and hook up 3 wires. One will be the common ground. The other one will be the Transmition Line Tx (data out from the PIC) and the last one will be the receive line Rx (Data Into the PIC). As long as you are using the same baud rate serial comunication is really easy.
Your PC being a DTE device (Data Terminal Equipment) will transmit (Data out of PC) throught PIN3 of a DB9 (9 pin) connector. IT will receive data through the PIN2 of the DB9 and share a common in PIN5 of the DB9 connector.
To be able to connect to the computer to your PIC, it will have to be a DCE (Data Comunication Equipment). What this means is that the PIC trabsmit pin will have to go to PIN2 in a DB9 connector (since the PC receives data through PIN2). Same goes for the receive pin on the PIC, this one will have to be connected to the PIN3 of the DB9 connector. Common or ground will have to be connected to the PIN5 of the DB9.
:!: Note: If you make you PIC a DTE then you will need to link both devices through a NULL MODEM cable. This only is a cable with PIN3 of one side connected to PIN2 of the other side. So that the transmit of one device will be connected to the recieve of the other device
Now you set your PC to send for example a 9600 baud rate 8N1 (8 data bits, No parity, One stop bit). Connect the Tx and Rx and GND to a MAX232 chip's (this chip is only a voltage level converter) Tx and Rx. And its outputs to the Tx, Rx and GND of the pic........ and viola!! ready to transmit.
:idea: Having said about the MAX232, I have been able to conect the PIC to the PC serial port straight thru some resistances, and no voltage converter without any problems at all and I have always had a reliable communication as long as you keep the cable short.