ATmega328P with Integrated USB FT232RL - Simulation and Animation

 In the previous note on ATmega328P with Integrated USB using FT232RL, I explained in detail how the circuit works. That is how to interface USB to FT232RL, and how to interface FT232RL with ATmega328P IC. Along with this I wrote about power supply (LM11117), Schottky diode roles, decoupling capacitors and other components and their roles. This is the 2nd part of the note on USB integration with ATmega328P using FT232RL USB to TTL converter IC. Here I will show via simulation how the circuit work. I will show how the USB is connected and show data transfer to and from PC to ATmega328P.

ATmega328P with Integrated USB FT232RL - Simulation and Animation

To show data transfer from ATmega328P to the PC via FT232RL USB, I will connect a virtual terminal to PC5 and PC4. 

ATmega328P with virtual terminal

I have used software serial to configure these two pins as Tx and Rx to mimic USART. The reason is ATmega328P has only one hardware UART and that UART is used for communicating ATmega328P with FT232RL. If I connect the virtual terminal to that hardware UART then there will be signal contention on the TX and RX lines. 

The code for the ATmega328P is provided below.


/**
 * PROJECT: Bi-Directional Serial Bridge by ee-diary.net
 */
#include <SoftwareSerial.h> // --- CONFIGURATION: CHANGE PINS HERE --- // Based on your working setup: A5 is RX (hears VT), A4 is TX (talks to VT) const int softRX = A5; const int softTX = A4; const long baud = 9600; // Initialize: SoftwareSerial(Receive_Pin, Transmit_Pin) SoftwareSerial debugSerial(softRX, softTX); void setup() { // 1. Physical Pin Setup (Matching your working logic) pinMode(softRX, INPUT_PULLUP); pinMode(softTX, OUTPUT); digitalWrite(softTX, HIGH); // 2. Start Communication Serial.begin(baud); // To Tera Term debugSerial.begin(baud); // To Virtual Terminal delay(500); // 3. Status Messages (Only in Setup to avoid loop lag) Serial.println("--- TERA TERM LINK: OK ---"); debugSerial.println("--- PROTEUS VIRTUAL TERMINAL: OK ---"); } void loop() { // Path 1: Tera Term -> ATmega -> Virtual Terminal if (Serial.available() > 0) { debugSerial.write(Serial.read()); // Single byte transfer for speed } // Path 2: Virtual Terminal -> ATmega -> Tera Term if (debugSerial.available() > 0) { Serial.write(debugSerial.read()); // Single byte transfer for speed } }

Next, I start the simulation. You can watch the simulation video below. 



I have opened Tera Term which is a terminal used for serial communication. The tera term has detects the COM 12 USB serial port and I select that. 

So, I have two terminals, one for ATmega328P and one for PC (tera term). The terminal windows are arranged so that we can see transfer and print of messages.

And I start by typing into the Virtual terminal and you will see that the text message is transferred from ATmega328P to Tera Term terminal. So, what's happening is data goes from ATmega328P to FT232RL which then goes to the USB port in the circuit. 

Next, I send text message from PC, using tera term terminal. This text message is sent to virtual terminal, that is the ATmega328P. The tera term is connected to PC COM port 12, and the USB port with FT232RL is connected to it. So, when the FT232L receives the message it sends that data to ATmega328P UART hardware which then gets printed on the virtual terminal. 

That's it, we have successfully transferred text data between PC and ATmega328P using FT232RL USB to TTL converter IC as a bridge/

Don't forget to watch the first part of this note where I showed how to make the circuit and explained each component and ATmega328P interfacing with FT232RL IC.

Related notes:

Post a Comment

Previous Post Next Post