MikroElektronika’s “Ready for PIC” board talks to “Processing”

Processing display window on PC

Ready for PIC is one of MikroElektronika‘s compact prototyping boards for 28 and 40 pin PIC microcontrollers. The board comes with PIC16F887 microcontroller which is preprogrammed with an UART bootloader firmware and thus eliminates the need of an external programmer. The on-board USB-UART module allows the serial data transfer between the PIC and a PC using an USB cable. It has also got a reasonable size prototyping area to add more functionalities to the board as required. These features make this board an ideal candidate for doing embedded projects that require PC interfacing. This article first reviews the basic features of the Ready for PIC board and then demonstrates how to write a PC application in Processing (an open source programming language) to communicate with the board through the on-board USB-UART module.

Ready for PIC board and PC interfacing using Processing

A brief review of Ready for PIC board

Ready for PIC is a compact development tool for 28/40 pin PIC microcontrollers. The board by default is equipped with PIC16F887 MCU placed in a DIP40 socket but it does provide connection holes to accommodate a 28-pin device. To program the MCU you can either use the pre-installed bootloader or an external programmer. For using an external programmer, you need to make a few adjustments on the board. Please read the User’s Manual for further instructions on this. Four 2×5 male header pins are available on the board for easy access to the MCU I/O pins. The on-board FT232RL chip provides a USB to asynchronous serial data transfer interface so that the MCU can communicate with a PC through a virtual COM port using a USB cable. The board has two LEDs marked with Rx and Tx which blink when data transfer via USB UART module is active. The board can also be used with a 3.3 V type PIC microcontroller. There is an on-board jumper for selecting between 5 V and 3.3 V supply voltage for the MCU.

Ready for PIC development board

On-board features and specifications

Little about Processing

Processing is an open-source software development environment designed for simplifying the process of creating digital images, animations and interactive graphical applications. It is free to download and operates on Mac, Windows, and Linux platforms. The Processing Interactive Development Environment (IDE) has the same basic structure as that of the Arduino IDE and is very easy to use. The programming language is so simple that you can create an interactive graphics with just a few lines of code. Here we will not discuss much of the graphics capability of Processing. We will rather focus on the Processing Serial library that will allow to transfer data between the PC and the Ready for PIC board.

We will write a simple program in Processing to create a graphics window that displays the current computer time, and will send the same information to the Ready for PIC board through the virtual COM port. The PIC microcontroller will then display the time on a 8-digit seven segment LED display module. The seven segment LED module used here is mikroElektronika’s Serial 7-Seg 8-Digit Board. It uses a MAX7219 chip to drive 8 seven segment LEDs. The chip receives the display data from a microcontroller through an SPI serial interface. An User’s Manual is available for the Serial 7-Seg 8-Digit Board that describes how to use it with mikroElektronika’s various development boards. The LED board comes with an IDC10 connector cable that can be plugged into one of the 2×5 male header connectors on the Ready for PIC board. I connected it to PORTC of PIC16F887 (as shown below) because the SPI data and clock pins are multiplexed with PORTC I/O pins (see PIC16F887 datasheet for detail).

Connecting the serial seven segment LED module to Ready for PIC board

Software

There are two softwares in this little project: one runs on PC and other resides on the flash memory of PIC16F887. The PC application is written Processing language. It retrieves the current time from the computer system and displays it on a graphics window. Meanwhile, it also sends the hour, minute and second information to PIC16F887 through the USB-UART interface. The Processing code for doing this is provided below. You must be familiar with this language in order to understand this code more clearly. If you are not, it is easy and quick to learn, please visit the Processing Tutorial page for that.

/*
 Title: PC Serial Clock
 Description: Transfer realtime clock info to Ready for PIC board
*/
 
// import the Processing serial library
import processing.serial.*;
 
Serial myPort;  // Create object from Serial class
int[] PC_time = new int[3];
PFont font22, font48;
 
void setup()
{
  size(220, 200);   // Graphics window size
 // My Ready for PIC board is connected to COM5 port.
 // You can find this info from the bootloader PC application
  myPort = new Serial(this, "COM5", 115200);
  font22 = loadFont("Tahoma-Bold-22.vlw");
  font48 = loadFont("Arial-BoldMT-48.vlw");
  fill(0,46,250);
}
 
void draw() {
  background(255);
  PC_time[2] = second();  // Values from 0 - 59
  PC_time[1] = minute();  // Values from 0 - 59
  PC_time[0] = hour();    // Values from 0 - 23
  String RTC = join(nf(PC_time, 2), ":");
  textFont(font22);
  text("Digital Clock", 35, 60);
 
  myPort.write(PC_time[0]);
  myPort.write(PC_time[1]);
  myPort.write(PC_time[2]);
  textFont(font48);
  text(RTC, 15, 120);
  delay(100);
}

In Processing,

  • Code inside setup() is executed once.
  • Code inside draw() is executed from top to bottom and then repeats continuously.
  • Global variables are declared outside the setup() and draw() blocks.

The firmware for PIC16F887 is written in mikroC Pro for PIC. The built-in UART and SPI library routines make the programming part on PIC side much easier. The UART data rate is set to 115200 baud. The received hour, minute and second data from the PC is sent to the MAX7219 chip (through SPI serial interface), which then drives 8 seven segment LED modules to display the computer time. The chip select (CS) pin of MAX7219 is driven through RC0 pin of PIC16F887. SPI serial data out (SDO) and serial clock (SCK) pins are multiplexed with RC5 and RC3 pins.

Download MikroC Project files 

Download Processing program

Displaying computer time on seven segment LED module

Processing display window on PC

Summary

Processing is very popular among Arduino fans. You can find plenty of examples online that show how to make Arduino talk to Processing through the USB-UART port. However, the use of Processing is not limited to Arduino. It can be used to interact with any hardware that has a UART port. The simplicity of Processing allows hobbyists to quickly develop graphics PC applications for their embedded projects. This tutorial demonstrated a simple example with mikroElektronika’s Ready for PIC board. This board has got some prototyping area to solder additional components and a USB-UART module to communicate with PC through a virtual COM port. The Ready for PIC board and Processing can be used together for doing embedded projects with interactive PC applications. Guess what? You will be seeing more Processing in our future projects.

 

We recommend EasyEDA for circuit design and PCB prototype
Schematic Drawing to PCB Production, Just Need One Tool
Cheap PCB Prototype: 10 pcs 2 layers only $10, quick delivery, 100% E-test

Related Posts

3 comments

Leave a Reply

Your email address will not be published. Required fields are marked *