Proteus is electronics system design, PCB design and electronics system simulation software. In many cases we want to test serial communication with microcontroller. For example we want to communicate with Arduino over serial port. This tutorial show how we can create serial communication from PC COM serial port to the Arduino serial port in proteus. This requires the use Serial Port Emulator with Proteus.
To follow this tutorial we need the following:
1. Serial Terminal such as Tera Term(free)
2. Virtual Serial Ports Emulator
Both of these PC application can be downloaded for free. Just search google and install them.
The following is the circuit diagram in proteus.
The serial communication is used to send character H or L from PC serial terminal(Tera Term) to the Proteus Virtual serial COM Physical port. When H character is sent from PC serial port, this is sent to proteus serial com physical port to the Arduino and a LED connected to pin12 is turned on. Similarly, when character L is sent via the PC serial port the LED is turned off.
The Arduino program is below.
const int ledPin = 12; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
}
// if it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite(ledPin, LOW);
}
}
}
The program configures the pin 12 as an output for LED. It configures the serial port with baud rate of 9600. In the loop we read in the character coming into Arduino and if the character is H then we turn on the LED and if the character read is L then we turn off the LED.
To connect the PC serial port is connected to Arduino in Proteus the COMPIM labelled P1(physical com port in proteus) in above diagram is used. The setting for this COMPIM is below.
Notice the com port selected is COM1 and the physical and virtual baud rate are set to 9600.
Now to connect the PC serial com port to this proteus physical com port we use the virtual serial ports emulator software. Once downloaded and installed, open the application. Then create a new connector. Select COM port COM1, then start the emulator as shown below.
Next open tera term, open serial port with COM1 selected. Then go to Setup > Serial port and confirm that baud rate is set to 9600.
Also to see what is being typed on the tera term enable the local echo on as shown below.
On the proteus diagram above, the virtual terminal is used to display the character received from the PC com port. It's baud rate must also be set to 9600 as shown below.
Now run the proteus program and then type H and L on the tera term terminal. This will turn on or off the LED. By typing character H or L on tera term, the character is sent to the physical serial port on proteus because of the virtual serial port emulator software. The physical serial port then sends the character the Arduino serial port. Arduino then turns on or off the LED according to the character received. The character received is also shown in the virtual terminal. This is as shown below.
The following video illustrates this.
For example of using serial communication between PC and Proteus see the next tutorial How Arduino L293D motor shield works with simulation in Proteus.