USB IO Board PIC18F2455 / PIC18F2550 using pic microcontoller




 USB IO Board Component List:
1x PIC18F2455 / PIC18F2550 Programmed Microcontroller (MCU)
1x USB Type B Connector
1x 20MHz Crystal Resonator
2x 10K Resistor (brown black orange gold)
1x 470 Resistor (yellow purple brown gold)
1x 470nF Ceramic Capacitor
1x 100nF Ceramic Capacitor
  Technical Specifications:

Voltage Supply: 5V (USB powered)
Current Consumption: 5mA
I/O PINs: 16

About PIC18F2455 / PIC18F2550 USB IO Board

USB Input / Output Board is a spectacular little development board / parallel port replacement featuring PIC18F2455 / PIC18F2550 microcontroller. USB IO Board is compatibile with Windows / Mac OSX / Linux computers. When attached to Windows IO board will show up as RS232 COM port. You can control 16 individual microcontroller I/O pins by sending simple serial commands. USB Input / Output Board is self-powered by USB port and can provide up to 500mA for electronic projects. USB IO Board is breadboard compatible. Simply solder included 12-PIN & 8-PIN headers on the bottom side of the PCB and the board can be plugged into a breadboard for quick prototyping.

These are examples of what can be built using USB IO Board
USB Relay Controller (turn ON/OFF lights or appliances in the house)
Control LEDs, toys, electronic gadgets, wireless control, etc.
USB LCD Controller
USB Volt / Ampere / Wattage Meter
USB CNC Controller
USB Data Logger
USB Temperature Meter / Logger
USB Thermostat Controller
USB Humidity Meter / Logger
USB Stepper Motor Controller
USB RC Servo Controller
USB Countdown Timer with Relay

electronics-diy.com USB_IO_Board.php
USB IO Board PCB Layout
R1, R2 10K resistor
C1 470nF capacitor
C2 100nF capacitor
5-PIN header on the left is an ICSP connector (In Circuit Serial Programming) for downloading future firmware releases.
Quick Start

Download USB IO Board drivers and unzip it.

2) Connect USB IO Board to a computer using standard USB cable.

3) Windows will ask you if you want to install a driver. Point it to drivers you unzipped.

Windows 2000 / XP
Under Windows 2000 or XP you will be prompted twice to install two drivers. On the first prompt please browse and point to MCHPUSB driver folder. On the second prompt please browse and point to USB CDC driver folder.

Windows 7 / VISTA
Under Windows 7 or VISTA you might be only prompted once to install USB CDC driver if MCHPUSB driver is already installed.

4) After the drivers are installed go to the Device Manager (right click on My Computer and click Properties->Hardware->Device Manager), and look under the Ports (COM & LPT) section, and you should see a new serial port there. Note the COM port number.

5) Open up your favorite serial emulator; the really awful HyperTerminal that comes with Windows, or my personal favorite USB IO Board Controller which can be downloaded here.

6) After launching USB IO Board Controller select the COM port from the drop-down list to connect to the board, type “V” in the input box and hit Enter or click on “Send” button. You should get back a firmware version number from PIC18F2455 / PIC18F2550 chip. This proves that USB IO Board is working properly. Now you are ready to learn about the commands that can be used to control USB IO Board.

USB IO Board Controller

USB IO Board can be controlled with just about any serial port emulation program such as Hyper Terminal that comes with every Windows OS. The problem with Hyper Terminal is that you can’t see the commands as you type them and that could be very annoying. With Hyper Terminal you also have to go through the wizard for setting up a serial port connection, and if the COM port changes you pretty much have to do it over and over again.

Luckily we have released our own little application called USB IO Board Controller that is so much easier and fun to use than Hyper Terminal. It only takes 25KB of space so it’s very lightweight. USB IO Board Controller will also show you COM port of USB IO Board so that will save you the trip (and time) to Device Manager to find out USB IO Board COM port number.

To use USB IO Board Controller select the COM port from the drop down list, type the command and hit “Enter” key (or click on Send button). Each command returns “OK” message to acknowlege that the command was received and processed successfully.

Download USB IO Board Controller (Win 2K, XP, VISTA, Win7)




Note: If you try to execute USB IO Board Controller and it doesn’t work you will need to download and install
Microsoft .NET Framework 3.5

Below you will find USB IO Board Controller source code written in C# and Visual Basic .NET using free Visual Studio 2008 Express IDE software. Use it as a foundation to get started on any projects of your choice. The code demonstrates how to list COM ports, connect to COM port, send commands and receive data from USB IO Board.

USB IO Board Controller – C# Source Code

//=============================================================================
// USB IO Board Controller v2.0
// Copyright www.Electronics-DIY.com © 2002-2012. All Rights Reserved. 
// THIS SOURCE CODE CAN ONLY BE USED FOR PERSONAL USE
// DO NOT REPRODUCE WITHOUT PERMISSION
//=============================================================================
// Compiled with free Visual C# 2008 Express  
// http://www.microsoft.com/visualstudio/en-us/products/2008-editions/express
//=============================================================================

using System;
using System.Windows.Forms;
using System.IO.Ports;

namespace USB_IO_Board_Controller
{
    public partial class Form1 : Form
    {
        public SerialPort Port = new SerialPort("COM1", 57600, Parity.None, 8, StopBits.One);

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            ListCOMPorts();
        }

        // List COM Ports
        private void ListCOMPorts()
        {
            foreach (string s in SerialPort.GetPortNames())
            {
                cboCOMPorts.Items.Add(s);
            } 
	        cboCOMPorts.Sorted = true;
        }

        // Connect to COM Port
        private void cboCOMPorts_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                Port.PortName = cboCOMPorts.Text;

                if (!Port.IsOpen)
                {
                    StatusBar.Text = "Connected to " + Port.PortName;
                    Port.Open();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        // Send Command to USB IO Board
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (Port.IsOpen)
            {
                //Port.Write("C,0,0,0,0" + '\r'); //Example: Configure all ports as outputs
                Port.Write(cboCommandInput.Text + '\r');
                System.Threading.Thread.Sleep(100); //ms
                ReceiveData();
            }
            else
            {
                StatusBar.Text = "Select COM port";
            }
        }

        // Receive Data from USB IO Board
        private void ReceiveData()
        {
            string output = null;
            byte[] Buffer = new byte[Port.BytesToRead];

            Port.Read(Buffer, 0, Port.BytesToRead);

            for (int i = 0; i <= Buffer.Length - 1; i++)
            {
                output += Microsoft.VisualBasic.Strings.Chr(Buffer[i]);
            }
            txtOutput.Text = output  + txtOutput.Text;
        }
    }
}

Download USB IO Board Controller Project Files
USB IO Board Controller – VB.NET Source Code
'=============================================================================
' USB IO Board Controller v2.0
' Copyright www.Electronics-DIY.com © 2002-2012. All Rights Reserved. 
' THIS SOURCE CODE CAN ONLY BE USED FOR PERSONAL USE
' DO NOT REPRODUCE WITHOUT PERMISSION
'=============================================================================
' Compiled with free Visual Basic 2008 Express 
' http://www.microsoft.com/visualstudio/en-us/products/2008-editions/express
'=============================================================================

Imports System.IO.Ports

Public Class Form1
    Public WithEvents Port As SerialPort = New SerialPort("COM1", 57600, Parity.None, 8, StopBits.One)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ListCOMPorts()
    End Sub

    ' List COM Ports
    Private Sub ListCOMPorts()
        For Each s As String In SerialPort.GetPortNames()
            cboCOMPorts.Items.Add(s)
        Next
        cboCOMPorts.Sorted = True
    End Sub

    ' Connect to COM Port
    Private Sub cbo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) 
Handles cboCOMPorts.SelectedIndexChanged
        Try
            Port.PortName = cboCOMPorts.SelectedItem

            If Not Port.IsOpen Then
                StatusBar.Text = "Connected to " & Port.PortName
                Port.Open()
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

    ' Send Command to USB IO Board
    Private Sub btnSendCommand_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) 
Handles btnSendCommand.Click
        If Port.IsOpen Then
            'Port.Write("C,0,0,0,0" & vbCr) 'Example: Configure all ports as outputs
            Port.Write(cboCommandInput.Text & vbCr)
            System.Threading.Thread.Sleep(100) 'ms
            ReceiveData()
        Else
            StatusBar.Text = "Select COM port"
        End If
    End Sub

    ' Receive Data from USB IO Board
    Private Sub ReceiveData()
        Dim output As String
        Dim Buffer(Port.BytesToRead - 1) As Byte

        Port.Read(Buffer, 0, Port.BytesToRead)

        For i As Integer = 0 To Buffer.Length - 1
            output &= Chr(Buffer(i))
        Next
        txtOutput.Text = output & txtOutput.Text
    End Sub
End Class

Download USB IO Board Controller Project Files
Testing USB IO Board

Lets run some sample commands to see how easy it is to turn LED ON/OFF.
Connect LED to microcontroller; longer leg to PIN28 (RB7), shorter leg to ground (GND) via 470 Ohm resistor. Now, to turn LED ON and OFF type these commands using USB IO Board Controller. Remember to hit “Enter” key after each command is entered.Configure Port A, B and C as outputs:
C,0,0,0,0

Turn LED ON (+5V):
PO,B,7,1

Turn LED OFF (0V):
PO,B,7,0

Here’s an example on how we can measure voltage on PIN2 (AN0) and still be able to use other ports as outputs. Maximum input voltage of PIC18F2455 / PIC18F2550 microcontroller is limited to 5V but with a simple two resistor voltage divider we can easily measure up to any voltage we want. Use 1K resistor connected to PIN2 and GND and 100K resistor connected to PIN2 and input to measure up to 500V. Please see USB Voltmeter page for more information.

Configure Port A – PIN2 as analog input, B and C as outputs:
C,1,0,0,1

Sample input voltage on PIN2:
A

USB IO Board will return digital representation of voltage and display it on the computer.

Turn LED ON on PIN28 (+5V):
PO,B,7,1

Turn LED OFF on PIN28 (0V):
PO,B,7,0

Please read more about “C” command below on how to configure more analog inputs.

electronics-diy.com USB_IO_Board.php
Commands

Notes for ALL commands:

  • You end a command by sending a <CR> or <LF> or some combination of the two. This is how all commands must be terminated to be considered valid.
  • The total number of bytes of each command, counting from the very first byte of the command name up to and including the <CR> at the end of the command must be 64 bytes or less. If it is longer than 64 bytes, the command will be ignored, and other bad things may or may not happen. This limitation will hopefully be removed in future FW D versions.
  • You can string together as many commands as you want into one string, and then send that string all at once to the USB IO Board. As long as each individual command is not more than 64 bytes, this will work well. By putting many commands together (each with their own terminating <CR>) and sending it all to the USB IO Board at once, you make the most efficient use of the USB bandwidth.
  • After successful reception of a command, the USB IO Board will always send back an OK packet, which will consist of “OK<CR><LF>”. For just testing things out with a terminal emulator, this is very useful because it tells you that the USB IO Board understood your command. However, it does add extra communications overhead that may not be appreciated in a higher speed application. Starting with this version (1.4.0) you can use the CU command to turn off the sending of “OK” packets. Errors will still be sent, but not any “OK” packets.
  • Currently, the backspace key does not work. For example, if you are typing a command to the USB IO Board from a terminal emulator and you make a mistake and try to backspace to correct your mistake, the USB IO Board will not recognize the backspace and will generate an error. This will hopefully be correct in a future FW D version.
  • All command names (“C”, “BC”, etc.) are case insensitive.
  • All port names (“A”, “B”, “C”) are case insensitive

For more detail: USB IO Board PIC18F2455 / PIC18F2550




Current Project / Post can also be found using:

  • usbio c#

Leave a Comment

*
= 3 + 6

Read previous post:
ESR Meter using pic microcontoller

The ESR meter is perfect for any electronics repair technicians, engineers or hobbyist. This handy meter measures electrolytic capacitor equivalent...

Close
Scroll to top