Tag Archives: Serial

Serial Communication with PIC16F877A

This article series aims at teaching serial communication between a PIC microcontroller and a PC. We first introduce you with what is serial communication is and how it can used. Then we tell you how to perform serial communication using PIC microcontroller and how we use the USART peripheral for the purpose. We will tell you how our usart library for PIC16F series can be used for easy serial communication, in this part we also discuss how to set up a MPLAB X project for using the USART library. After that we will build a demo project to explore the library. Finally we will burn this demo in a PIC16F877A and establish a serial communication with PC. Serial Communication Their are several serial communication standards like RS232, SPI, I2C etc. Of which RS232 is a asynchronous method. That means it does NOT have a synchronizing clock line. One way data requires only one conductor line. Since it is a two way communication their are two lines between the two device. One for sending data called the Tx and one for receiving data called the Rx. The communication is full duplex, that means data can be sent at the same time data is being received. generally other serial communication like SPI and I2C are used for short range communication like between […]

eXtreme Burner – AVR 1.3 Beta Test

Hi All, I was adding support for some chips with big flash memory (like ATmega2560 etc.) in my Programmer Software eXtreme Burner – AVR. But right now I do not have any ready setup with ATmega2560 so I ask anyone of you who have got a ATmega2560 (or ATmega128) setup to please carry out a simple test. Just download the eXtreme Burner AVR 1.3 Beta. And try to flash the following hex files. Test Hex File for ATmega128 and ATmega2560. And update me the details via a comment on this page. Serial Interface. Now your USBasp can double as a USB to serial converter at NO extra cost! We now have a basic serial terminal integrated in the eXtreme Burner AVR ! The terminal can be launched from the Tool Menu. But you need a modified USBasp Firmware to use the terminal. It is available from here. USBasp Firmware with UART Support. eXtreme Burner AVR v1.3 Beta !

Digital Humidity Sensor

Digital Humidity sensors are of great help in maintaining suitable environmental condition in places such as ware houses, green houses, factories, smart homes etc. They are also very easy to interface with MCU and PC. When coupled with a PC or Microcontroller they can be used in wide variety of smart automation. One such sensor I will present today is a serial humidity sensor. The interface is very simple. The communication is done over a standard asynchronous serial line. The interface parameters are as follows. UART 9600 bps. Start bit: 1 Stop bit: 1 Parity Bit : 0 (No parity bit) No Flow Control. Fig.: Serial Humidity Sensor.   Command Set All commands are begin by "$sure" followed by space (ascii 32) All UART Command are in ASCII Commands are NOT case sensitive. All commands ends with a CR LF pair (ascii \r\n in C language). Get Current Temperature in Degree Centigrade Command : $sure temp -c Returns: XXXCentigrade Where XXX is current temperature. Example in C UWriteString("$sure temp -c\r\n"); Get Current Temperature in Degree Fahrenheit Command : $sure temp -f Returns: XXXFahrenheit Where XXX is current temperature. Example in C UWriteString("$sure temp -f\r\n"); Get Current Humidity Command : $sure humidity Returns: XXX%RH Where XXX is current relative humidity. Example in C UWriteString("$sure humidity\r\n"); Get Current Status Command : $sure […]

RS232 Communication using PIC18F4520’s USART – PIC Microcontroller Tutorial

Hello Friends! In this tutorial I will discuss how to practically do a simple communication over RS232 interface. For those who are completely new to this I clarify that the motive is to send and receive data between two device using a standard called RS232. RS232 is serial interface that means that data is transferred BIT by BIT at a time. Since data is transferred BIT by BIT so we need only a single wire two send data and an another one to receive data. One more common wire (called GND) is required between two separate circuit to enable current flow. So a total of three wire are required for communication. RS232 can be used to communicate between a variety of devices. Like your MCU and a GSM module or a PC. In this tutorial we will demonstrate a link between a PIC18F4520 MCU and a standard PC. On PC we will run a terminal program like RealTerm or Hyperterminal. A terminal program is used to send and receive text data. So any text send by the MCU will be visible on Terminal Screen and Any keypress you make on the PC keyboard will be send over RS232 to your MCU. This configuration is the simplest setup to test and understand RS232 communication. When you have enough knowledge you can […]

Using the USART of AVR Microcontrollers.

Welcome to the third part of my RS232 serial communication tutorial. Till now we saw the basics of RS232 communication and made our level converter. Now its time to understand the USART of AVR microcontroller and write the code to initialize the USART and use it to send and receive data. Like many microcontrollers AVR also has a dedicated hardware for serial communication this part is called the USART – Universal Synchronous Asynchronous Receiver Transmitter. This special hardware make your life as programmer easier. You just have to supply the data you need to transmit and it will do the rest. As you saw serial communication occurs at standard speeds of 9600,19200 bps etc and this speeds are slow compared to the AVR CPUs speed. The advantage of hardware USART is that you just need to write the data to one of the registers of USART and your done, you are free to do other things while USART is transmitting the byte. Also the USART automatically senses the start of transmission of RX line and then inputs the whole byte and when it has the byte it informs you(CPU) to read that data from one of its registers. The USART of AVR is very versatile and can be setup for various different mode as required by your application. In this […]