Serial Communications



Similar documents
Using Xbee in Serial Communication

Software User Guide UG-461

Serial Communications

Elettronica dei Sistemi Digitali Costantino Giaconia SERIAL I/O COMMON PROTOCOLS

Introduction the Serial Communications Huang Sections 9.2, 10.2 SCI Block User Guide SPI Block User Guide

Bluetooth HC-06 with serial port module Easy guide

Lab Experiment 1: The LPC 2148 Education Board

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science Microprocessor Project Laboratory

Objectives. Basics of Serial Communication. Simplex vs Duplex. CMPE328 Microprocessors (Spring ) Serial Interfacing. By Dr.

USART and Asynchronous Communication

Application Note 83 Fundamentals of RS 232 Serial Communications

Display Message on Notice Board using GSM

USER GUIDE EDBG. Description

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

Tutorial for MPLAB Starter Kit for PIC18F

Accurate Measurement of the Mains Electricity Frequency

EVAL-UFDC-1/UFDC-1M-16

Location-Aware and Safer Cards: Enhancing RFID Security and Privacy

In-System Programmer USER MANUAL RN-ISP-UM RN-WIFLYCR-UM

The Bus (PCI and PCI-Express)

Orbit PCI Mk 2 Network Card. User Manual. Part No Issue 4

PC Base Adapter Daughter Card UART GPIO. Figure 1. ToolStick Development Platform Block Diagram

RS232 Board datasheet

Work with Arduino Hardware

SUDT AccessPort TM Advanced Terminal / Monitor / Debugger Version 1.37 User Manual

How to connect to a Class II router using a mobile-phone data cable specifically for Solwise & Safecom routers

GSM Interfacing Board

BE635 User Manual. Rev. V Bolymin, Inc. All Rights Reserved.

R10 22k. R9 10k PICAXE-08M RXD. Sample Program: main: high 4 pause 1000 low 4 pause 1000 goto main R7 330 D7 LED-RED.

TCP/IP MODULE CA-ETHR-A INSTALLATION MANUAL

s!nus-elektrotechnikai bt. Industrial IT & Automation

Bluetooth to serial HC-06 wireless module

I2C PRESSURE MONITORING THROUGH USB PROTOCOL.

Part Number Description Packages available

Why you need to monitor serial communication?

Manual Serial PCI Cards

Serial port interface for microcontroller embedded into integrated power meter

The Programming Interface

SKP16C62P Tutorial 1 Software Development Process using HEW. Renesas Technology America Inc.

RDF1. RF Receiver Decoder. Features. Applications. Description. Ordering Information. Part Number Description Packages available

Keep it Simple Timing

Bluetooth to Serial Adapter

Chapter 13. PIC Family Microcontroller

RS-232 Communications Using BobCAD-CAM. RS-232 Introduction

1.1 Connection Direct COM port connection. 1. Half duplex RS232 spy cable without handshaking

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

RS-422/485 Multiport Serial PCI Card. RS-422/485 Multiport Serial PCI Card Installation Guide

CHAPTER 11: Flip Flops

Microcomputer Protocol Implementation at Local Interconnect Network Georgi Krastev

Parallel IO. Serial IO. Parallel vs. Serial IO. simplex vs half-duplex vs full-duplex. Wires: Full Duplex. Wires: Simplex, Half-duplex.

RN-131-PICTAIL & RN-171-PICTAIL Web-Server Demo Application

USB to RS-422/485 Serial Adapter

Design and Verification of Nine port Network Router

Programming and Using the Courier V.Everything Modem for Remote Operation of DDF6000

The Answer to the 14 Most Frequently Asked Modbus Questions

TURBO PROGRAMMER USB, MMC, SIM DEVELOPMENT KIT

2-Port RS232/422/485 Combo Serial to USB2.0 Adapter (w/ Metal Case and Screw Lock Mechanism) Installation Guide

IP Link Device Interface Communication Sheet

Solutions for Increasing the Number of PC Parallel Port Control and Selecting Lines

Real-Time Vehicle Data Logging System Using GPS And GSM

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

Current Loop Application Note 1495

Part 1. MAX BIT DAC with an Arduino Board. MIDI to Voltage Converter Part1

TOSR0X-D. USB/Wireless Timer Relay Module. User Manual. Tinysine 2013 Version 1.0

PM1122 INT DIGITAL INTERFACE REMOTE

1. SAFETY INFORMATION

ET-BASE AVR ATmega64/128

Computer Performance. Topic 3. Contents. Prerequisite knowledge Before studying this topic you should be able to:

ARM Thumb Microcontrollers. Application Note. Software ISO 7816 I/O Line Implementation. Features. Introduction

ENET-710. ENET Ethernet Module ENET-710 JAN / 06 FOUNDATION

Chapter 02: Computer Organization. Lesson 04: Functional units and components in a computer organization Part 3 Bus Structures

Wireless Security Camera

1. Make sure that no client accounts are open. 2. Click on Setup, then click Modem. The Modem Setup window will appear.

8051 Serial Port. Crystal TXD. I/O Device RXD. Embedded Systems Peripherals

TP- 051 GPS RECEIVER

Vicon Flash Upgrade Software

Single channel data transceiver module WIZ2-434

Virtual Integrated Design Getting started with RS232 Hex Com Tool v6.0

What is Easy-Radio? Devices Covered. Frequency Hopping Transceiver. Where x00 denotes frequency of operation. E.g. 400 = 433MHz

Microtronics technologies Mobile:

RN-131-PICTAIL & RN-171-PICTAIL Evaluation Boards

DUKANE Intelligent Assembly Solutions

INFORMATICA INDUSTRIALE

USB TO SERIAL ADAPTER

Vicon Flash Upgrade Software

Embedded Systems Design Course Applying the mbed microcontroller

RS232C < - > RS485 CONVERTER S MANUAL. Model: LD15U. Phone: / 97 / 98 (M)

OWNERS MANUAL. WattsVIEW. Power Monitor Model: DC WattsVIEWTM. Models: DC Serial DC-1000 USB DC-25000

INFORMATICA INDUSTRIALE

MANUAL FOR RX700 LR and NR

DK40 Datasheet & Hardware manual Version 2

Modification of an AOR AR-8600 receiver to tune it with a ACECO FC-3002 frequency finder

Guangzhou HC Information Technology Co., Ltd. Product Data Sheet

Data Cables. Schmitt TTL LABORATORY ELECTRONICS II

Von der Hardware zur Software in FPGAs mit Embedded Prozessoren. Alexander Hahn Senior Field Application Engineer Lattice Semiconductor

DECT Module UM-9802 Datasheet

Quectel Cellular Engine

RS-232 Baud Rate Converter CE Model 232BRC Documentation Number 232BRC-3903 (pn5104-r003)

Designing VM2 Application Boards

Block 3 Size 0 KB 0 KB 16KB 32KB. Start Address N/A N/A F4000H F0000H. Start Address FA000H F8000H F8000H F8000H. Block 2 Size 8KB 16KB 16KB 16KB

Transcription:

April 2014 7

Serial Communications Objectives - To be familiar with the USART (RS-232) protocol. - To be able to transfer data from PIC-PC, PC-PIC and PIC-PIC. - To test serial communications with virtual serial ports with Mikrobasic and Proteus programs tools. Introduction Serial communications is the process of sending data one bit at one time, sequentially, over a communications channel or computer bus. This is in contrast to parallel communications, where all the bits of each symbol are sent together. Serial communications is communications and most computer networks, where the cost of cable and synchronization difficulties makes parallel communications impractical. Serial computer buses are becoming more common as improved technology enables them to transfer data at higher speeds. Examples of serial communication architectures includes: RS-232, RS-485, Universal Serial Bus (USB), SPI, I2C and others. Serial interfaces have certain advantages over parallel interfaces. The most significant advantage is simpler wiring. In addition, serial interface cables can be longer than parallel interface cables. 2 Embedded Systems Lab

USART Protocol USART stands for the Universal Synchronous/Asynchronous Receiver/Transmitter. Universal means that it can be used with a wide scope of devices Synchronous devices that communicate with each other require an external synchronization line (the clock). Asynchronous The Asynchronous mode (without the common clock) is easier to implement, although it is generally slower than the synchronous. It is also the older way older versions of PIC did not have the possibility of working in synchronous mode, therefore the devices they had were more appropriately named as UART (without S) Receiver/Transmitter means that this device can receive and transmit (send) data simultaneously. It is also called the two-way or full duplex communication. USART Asynchronous Mode Asynchronous transmission allows data to be transmitted without the sender having to send a clock signal to the reciever. In the case, the sender and reciever must agree on timing parameters(baud Rate) prior transmission and special bits are added to each word to synchronize the sending and receiving units. The sender sends a Start bit, 5-8 data bits, an optional parity bit, and 1-2 stop bits. TTL Level Most microcontrollerswith usart uses TTL (Transistor-transistor Logic) level. 3 Embedded Systems Lab

The USART transmits and receives data using standard non-return-to-zero (NRZ) format. As seen in figure below, this mode does not use clock signal, while the data format being transferred is very simple: Briefly, each data is transferred in the following way: In idle state, data line has high logic level (1); Each data transmission starts with START bit which is always a zero (0); Each data is 8- or 9-bit wide (LSB bit is first transferred); and Each data transmission ends with STOP bit which always has logic level which is always a one (1). For example Data is H 90 = B 01011010 (LSB bit is first transferred) Each USART contains a shift register which is the fundamental method of conversion between serial and parallel forms. After waiting a further bit time, the state of the line is sampled and the resulting level clocked into a shift register. After the required number of bit periods for the character length (8,9 bits typically) have elapsed, the contents of the shift register is made available. 4 Embedded Systems Lab

RS-232 The RS-232 standard defines the voltage levels that correspond to logical one and logical zero levels for the data transmission and the control signal lines. Valid signals are plus or minus 3 to 15 volts - the range near zero volts is not a valid RS-232 level. Beside voltage level, RS-232 also has a few extra pins: 5 Embedded Systems Lab

RS-232 HW Connection Concerning with voltage levels, all that is required (at the hardware) is an external level shifter to translate TTL signals from PIC to RS232 levels, and vice-versa. This can be achieved by using a MAX232 chip. 6 Embedded Systems Lab

USART Library Functions Usart_Init Initializes hardware USART module with the desired baud rate. Usart_Init(9600) Usart_Data_Ready Function returns 1 if data is ready or 0 if there is no data. if Usart_Data_Ready () then or Usart_Data_Ready ()=1 read end if Usart_Read Returns the received byte. If byte is not received, returns 0. if Usart_Data_Ready () then portb = Usart_Read() end if Usart_Read_Text Reads characters received via USART until the delimiter sequence is detected (here: ok ). The read sequence is stored in the parameter output (here:txt). Usart_Read_Text(txt, ok ) << hello ok txt:hello Usart_Write Function transmits a byte (data) via USART. Usart_Write(portb) Usart_Write_Text Sends text (parameter uart_text) via USART. Text should be zero terminated. Usart_Write_Text( hello ) If the device wants to load to USART: write (input is from his side) If the device wants to load from USART: read (output is from his side) 7 Embedded Systems Lab

Serial communication from PIC to PC Lab Work 1 1. Write a basic program that sends a text from PIC to PC. 1. 2. Simulate the circuit using Proteus ISIS program. Proteus We will use virtual terminal (V.T.) for implementing PC 8 Embedded Systems Lab

Double click << Change the baud rate to 9600 TX and RX are on pins C6 and C7, connect them to RX and TX of V.T. << MAX232 IC is already connected to the board >> For all parts, Don t forget to change the internal clock frequency of the PIC to 8MHz 9 Embedded Systems Lab

Mikrobasic After run, black window appears with the result, if you close it you can get it back by: Click right on the V.T. << choose virtual terminal (last choice). Result 10 Embedded Systems Lab

Serial communication from PC to PIC Lab Work 2 1. Write a basic program that sends a text from PC to PIC and view on LCD. 2. Simulate the circuit using Proteus ISIS program. Proteus 11 Embedded Systems Lab

<< When you are typing the text, it will not appear onto the black window.. continue your work, results will be appeared on LCD normally >> Mikrobasic Every text must end with $ in order to be read and shown on LCD (Choose any delimiter you want) Serial communication from PIC to PIC Lab Work 3 1. Write a basic program that sends the state of switch from master PIC to slave PIC (leds). 2. Simulate the circuit using Proteus ISIS program. 12 Embedded Systems Lab

Proteus TX <> RX, RX <> TX Mikrobasic Master 13 Embedded Systems Lab

Mikrobasic Slave Connect Proteus Virtual Serial Port with Windows Terminal >> To connect Proteus virtual terminal with windows terminal, use compim DB-9 connector. 14 Embedded Systems Lab

>> Connect Rx to Rx & Tx to Tx only. Don't make cross connection here. (Connector will be connected to the pic as the same side not opposite side) >> Now get Virtual Serial Port Driver & install it in your system. >> Then run this tool & create a virtual ports pair. >> Choose COM3 and COM4 << add pair << pair will appear as virtual ports. 15 Embedded Systems Lab

>> In order to be sure that you can work with these ports as a real prts on windows chek this: Computer << Click right <<properities << device manager: your ports are added! >> Our work will depend on implementing the compim connecter (which is connected to PIC) as a COM4 then send and receive data for a pic using it. Double click << physical port: COM4, physical baud rate & virtual baud rate: 9600. 16 Embedded Systems Lab

Connection Establishment In order to establish the communication, PC must have communication software installed. One such communication terminal is part of MikroBasic IDE. It can be accessed by clicking Tools > USART Terminal from the drop-down menu. Terminal allows you to monitor transfer and to set all the necessary transfer settings. First of all, we need to set the transfer rate to match the microcontroller's rate. Then, select the appropriate communication port and finally press Connect button. 17 Embedded Systems Lab

COM3: USART Terminal Tool of Mikrobasic COM4: COMPIM that connected to PIC at Proteus << Now your Proteus Tx, Rx & Terminal Tx Rx are cross connected >> Lab Work 4 1. Write a basic program that sends the text from terminal to the PIC side and view it on LCD. 2. Simulate the circuit using Proteus ISIS program. Mikrobasic 18 Embedded Systems Lab

USART terminal Proteus 19 Embedded Systems Lab

You can send text as typing by enabling this << text will appear on LCD as soon as you type it. Lab Work 5 1. Write a basic program that sends the text from the PIC side to the terminal. 2. Simulate the circuit using Proteus ISIS program. 20 Embedded Systems Lab

Mikrobasic Result (immediately after the Run) 21 Embedded Systems Lab

Homework 1. Write a basic program that shines the led connected to PIC if the pc (V.T.) entered hi word. 22 Embedded Systems Lab

2. Write a basic program that send the pressed number on keypad to the terminal. Good Luck Good Luck 23 Embedded Systems Lab