Basic connections that will help you design circuit for 8051/2 microcontrollers properly.
Power supply circuit
Voltage requirements: mostly +5Vdc

The basic circuit to make microcontroller AT89C51/AT89S51/AT89C52/AT89S52 work at start is given below (Here our main aim is only to start a controller assuming there is no external RAM).

And to interface microcontrollers AT89C2051 and AT894051 we keep the circuit same accept the pins change this time.

Interfacing input to the microcontroller
There are lots of ways you can do that. I usually use two methods.
1. Pull up resistor type.
2. Transistor driver type.
Transistor driver type has high successful rate of driving inputs and outputs of microcontrollers. The input can be another microcontroller output or driver output or any other logic circuit.

The above circuit will work only if the input signal is digital to the transistor. Value of R1 and R2 are calculated according to maximum ratings. Assuming the source of the signal and transistor Q1 are same.
R2 = Vin/Ib
where Vin is digital input voltage (+5v) , Ib is ideal base current to drive Q1 (5mA).
R2 = 5 / 0.005 = 1k ohms
To calculate R1 we need to know what is the ideal drive current for At89c51 microcontroller. If you check our the datasheet you will find it is 20mA.
R1 = Vcc/Imax = 5/.020 = 250Ohms
In this configuration, when the input at transistor is high (+5V), the input at the microcontroller will be low (0V). And when input at transistor is low (0V), the input at the microcontroller will be high (+5V). If the voltage varies at the input of R2. You need to see the max value of voltage there and adjust the value of R2 according to the above formula.
Interfacing a switch

This configuration of Switch Input can also be given to External Interrupt Pins ( INT0, INT1) for interrupt based switch trigger in the case of using power down modes to save power.
Outputs of microcontroller
Typically the output varies from 2.4V to 4.5V here. You need to find out which port gives what voltage after constructing basic circuit on bread board.
Assuming voltage 2.4V lets construct our output driver for 5V logic circuit.

In this case, the input voltage to the transistor now varies from 2.4V to 4.5V depending on full load over the IC.
In this configuration, when the input at transistor is high (+5V), the digital output will be low (0V). And when input at transistor is low (0V), the digital output will be high (+5V). If the voltage varies at the input of R2. You need to see the max value of voltage there and adjust the value of R2 according to the above formula.

But make sure you do not cross limit of 25mA on each pin. Sinking above 25mA will cause heat up on the IC causing loss of power. For low power LED's this mode can be applied. Even can be applied for 7 - Segment display.
For serial communication, if you need USB interface and to use serial communication through virtual com port on PC (For users without RS-232 Interface).

RS-232 Interface
You can also replace DB9 with 3 Pin Terminal Block and make use of multi-stranded wires for communication in case of two microcontrollers at distance of 15meters. For larger distance communication RS-485 is used. The circuit configuration for RS-485 is different. We use MAX485 IC.

To change this configuration to only receive, you need to remove resistor R4 and change R6 to 10K ohms.
This will now configure above circuit strictly to receive data on RS485 line.
For far away communications I recommend to use two chips and separate Transmit and Receive, because at far distance duplex mode of communication is necessary. RS485 lines can go up to 1km distance.



