PC-Microcontroller Communications

Introduction
Many times an embedded system or microcontroller needs to be connected to a PC. This topic discusses the various methods for doing this. This is one of a series of articles on Microcontroller Serial Communications, rooted at this site here: Microcontroller Serial Communications Articles. This article is for working on the PC side, for information on the microcontroller side see: []

Serial Communications from a PC to Microcontrollers -- Terminal Emulators
This is often done using Hyperterminal ( a program bundled with MS Windows ) to communicate with the microcontroller using RS232 or virtual RS232 over USB. This program is pretty painful to use, we list some alternatives to it here:

( for the search engines: dump HyperTerminal find a better communications program )

For some notes on how to plan the microcontroller end of the communications see: RS232 and for a particular implementation take a look at BitWacker PIC USB Development Board and the specialized PC program for it and similar devices: BitWacker Java Communications

For general information on terminal emulators see: Terminal emulator From Wikipedia, the free encyclopedia

Advantages
 * Relatively simple firmware and PC software
 * Ability to use terminal emulators to test hardware
 * Long cable lengths

Disadvantages:
 * Slow
 * Requires bulky connectors and level translators
 * Many new computers especially laptops don't have rs232 serial ports

Serial Communications from a PC to Microcontrollers -- Writing Programs
Writing PC programs to communicate with Microcontrollers can be very challenging, or not so much. The easiest I have encountered are the libraries for the Arduino which are part of the Processing environment. Look at the Arduino examples. You do not have control over all rs232 parameters or the ability to manage all possible errors, but you do have a quick way to program that works. Under the hood this is based on using Java. Should run on all major operating systems. This is free and largely open software.


 * insert links here

The USB Bitwacker comes with a Liberty Basic program that seems to work quite well. Liberty Basic is not free, but I think has a demo version that is enough ability to run reasonable programs. If you can live with this situation and Basic, this could be for you.


 * insert links here

I have written several programs using Java, there has not been much interest on the net so I have worked on them only for my own use and from time to time.


 * insert links here.

I have heard VB proponents claim that it is pretty easy with VB. Someone else will have to provide more information. I

USB Communications from a PC to Microcontrollers
Many modern computers especially laptops do not have serial ports and the serial connector port is big and bulky. RS232 communication requires the use of level shifters which add parts. Serial communication can also be slow. Note that USB often appears as virtual RS232 on the PC which allows you to use RS232 on the microcontroller and rs232 techniques on the PC.

An alternative is more and more microcontrollers now have native support for USB which has smaller connectors, is faster, and works with the plug and play architecture of modern OSs. The disadvantage is that the firmware is much more complex and the PC side requires an device driver and corresponding INF file. Lucky, many generic drivers are available and many microcontroller manufacturers that support USB provide sample firmware.

Advantages:
 * Fast
 * Plug and Play
 * No level translators and small connectors
 * Works with computers that don't have serial ports
 * Ability to implement standard devices such a keyboards, mice, memory card readers, and sound cards without writing a device driver.

Disadvantages:
 * Complex Firmware and PC software
 * Requires OS specific device drivers and installers
 * PC application software is more OS specific
 * Short cable lengths
 * May require the use of an expensive hardware bus analyzer

Ethernet-TCP/IP Communications from a PC to Microcontrollers
Ethernet and the Internet is everywhere so many embedded devices now have Ethernet connections. Network connections can be very long and it's possible to use cheap commodity hardware such as WiFi bridges. Several microcontroller manufacturers are now providing sample TCP/IP stacks some of them with embedded web servers so that the hardware can be controlled from a PC via a web browser such as IE or Firefox. PC programming has a mostly OS independent API called sockets that is available on both Windows and Unix.

Advantages:
 * Fast
 * Long cable lengths and commodity equipment
 * PC API is mostly OS independent
 * No device drivers required
 * Many OSs include free packet sniffers for easy analysis of network traffic

Disadvantages:
 * More complex firmware then either serial ports or USB
 * High part count and complex hardware
 * Device detection is not plug and play. It can be complex to find the IP address of an embedded device.

Bluetooth-SPP Communications from a PC to Microcontrollers
Many laptops and even desktops now have bluetooth support or a bluetooth dangle can be purchased for a small amount of money. This makes bluetooth a good choice for controlling microcontrollers wirelessly. Several drop inn modules are available that implement the Bluetooth SPPprotocoll which allows direct emulation of a serial cable. The models usually have an AT command set for configuring the module and establishing connections. Most Bluetooth stacks on the PC have support for SPP and will expose the device as a COM port. Detection of the COM port is difficult since Bluetooth doesn't have a standard stack for Windows.

Advantages:
 * Fast
 * Wireless
 * Quick conversion of existing serial port based devices to wireless
 * No device drivers to install

Disadvantages:
 * Pairing devices can be complex
 * Difficult to make the system plug and play
 * AT command set can get in the way of data if binary data is sent.

RS232 Level Translation
Many microcontrollers do rs232 but do not output levels that are rs232 standard. I have often seen statements that they work anyway. Could be true. The standard solution is to use a MAX232 chip. Rather than put one in every project you can use a separate board or cable.

Some links:


 * P4 Adapter/Serial Cable My favorite, think is comes from next reference


 * The Shoppe at Wulfden


 * RS232 Interface


 * The RS-I Serial Interface Adapter


 * RLC-1 RS232 to CMOS/TTL Level Converter


 * RS232 to TTL (5V Signal) Converter Kit The RLC-1 is a compact, reliable RS232 to logic level converter ideal for interfacing microcontroller projects or products to a computer. The logic level interface supports 5 volt or 3 volt logic levels and draws only a small amount of power.


 * More links from the PIC List