PIC Ports Analyzer
Dumps status of your PIC microcontroller ports into a nice rack.
In this project we'll use a Microchip
PIC16x84 microcontroller connected on a PC serial port.
The code burnt in microcontroller will send to the Easy Control status of its ports to be displayed
into a nice rack designed in Rack Designer.
Design rack in Rack Designer, or you may download example archive which contains the
picports rack (see screenshot on the left side of this article).
Controls on this rack are:
- a few borders
- a few labels
- a few leds
Write for your microcontroller a program that will do next:
- make all ports inputs. Don't forget to enable weak pull-ups or (better) place pull-ups yourself (if needed)
- wait for the "go" string to be received on its rx pin
- fill a 16 bit variable (for PIC16c84) with state of the ports, like this:
- send this variable as ASCII representation of its binary value on its tx pin
- and repeat, and repeat all
Below is the equivalent PicBasic code for this.
PicBasic is a very good Basic compiler for PIC microcontrollers. Take a look and you'll love it
meanless var byte
ports var word
myportb var ports.lowbyte
myporta var ports.highbyte
trisa=255 'PORTA input
trisb=%11111011 'PORTB.2 output (for tx), the rest inputs
starthere: serin portb.6,6,["go"],meanless
serout2 portb.2,16468,[bin16 ports,13,10]
Write or open in Easy Control this script code (note: syntax is for Easy Control v. 1.4):
#Open rack. Don't forget to write the right file path
#Setup and open port
label39="Connected on port "&myport
#You may show terminal window if you want to watch data flow
#Send "go" command to PIC
#Wait for data ended with CRLF to be received from PIC
#Extract bit by bit and set leds accordingly
#Flush receive buffer, to have fresh data next time
Download this project :
PIC Ports Analyzer
Well,change code for bigger/other microcontrollers, timeouts, memory dumps, visual enhancements,...