Introduction: PicLink RS232 Low Cost Development Controller With ADC

About: Our solutions empower our clients to leverage data acquisition, ADC, RC, peripheral IO, and embedded device technologies under one hood. We specialize in the development of environmental controls, RC, embedded…

PICLink RS232 Embedded Controller

The PICLink RS232 controller module affords any microcontroller enthusiast an
easy to construct mini-microcontroller module. This embedded microcontroller is
ICSP (in circuit serial) programmable and provides separate PORTA, PORTB,
RS232 I/O ports, 4 Channel Analog to Digital converter as well as an integrated ICSP port to implement in circuit  programming and debugging. On board host RS232 USART may be used to interface with a PC (USB to RS232) or any other serial communications device like our 2.4 GHz Wi-Fi or 915MHz wireless modules. In this instructable you will need to manufacture a double sided circuit board (circuit board dimensions are given below), assemble the board with the necessary components (see components list) and then program the controller with LES firmware version 1.1.  For this you will need an ICSP programmer such as the USBPIC Programmer   or the PICKit 2 which is what I currently use as an engineer and firmware developer.  I would recommend for those whom are serious about embedded device engineering spending the $30 dollars (USD) for the PICKit. The PICKit2  LogicTool will serve to be a great development tool when developing embedded control devices.      

LES 1.1 Firmware

LES-1.0 (version 1.0) is a miniaturized embedded framework written in
C currently for PIC micro-controllers which supports basic input/output, memory
and RS232 asynchronous communications. Because of its small foot print the
entire system can fit into 1K (1024 Bytes) of program memory. In addition LES
greatly simplifies bit level control of IO ports through macros like BIT_SET,
BIT_CLEAR, BIT_IS_SET and BIT_COMP. Port register control
is achieved through PORTx macros which reduce bit level TRISx calls this saving
critical program memory space.

LES 1.1 Firmware was developed using Eclipse SDCC and GPUTILS. The PICLink (LES) build environment is simple to set up and requires no proprietary licensed software. SDCC and GPUTILS are opensource development tools published under the GNU Public License agreement and are free for download and use.  As soon as I get a chance I will update the LES article with download and SDCC install instructions.    

URF 1000 Sonar  

The PICLink RS232 embedded controller was developed to calculate distance and transmit telemetric data to host terminal when interfaced with TuxMicro's URF 1000 Series Ultrasonic Sonar Range Finder DSM module.       


· Supply Voltage – 5.0 to 5.5 VDC H1-2
· Supply Current – 10 mA typ
· ICSP (In-Circuit Serial Programmable)
   Supports Microchip device debugging via H1
· 20 MHz Crystal controlled SBC
· 11 bi-directional I/O Pins
· 4 channel ADC (PORTA)
· Dedicated RS232 USART Port 120 kbit/s
· RS232 speeds 1200 to 155200 bit/s
· 128 Bytes EEPROM
· 224 Bytes SRAM
· 2 K Bytes program memory (1k when running LES)
· LES firmware version 1.1

Module Dimensions

52.5 mm L x 41 mm W x 1.6mm H (2.06in x 1.61 in x 0.63 in)

Step 1: PicLink Mother Board Fabrication - Bottom Layer

Circuit Board fabrication materials using DirectEtch

Toner Transfer pape r, environmentally friendly etchant (2oz hydrogen peroxide mixed with 1oz muriatic acid) a plastic well of water (sandwich container or 8" brownie pan), paper towel, plastic gloves, sandwich container (found at Dollar Tree two for one dollar), fine steel wool and a small can of Acetone to remove the toner foil "resist" image from the board after etching. You will need either a laser printer or copier to transfer copies of the circuit templates to the toner transfer paper. Also it would be extra easy is you could gain access to a laminator such as a GBC Creative Laminator. The GBC Creative Laminator makes producing double sided circuit boards very easy since both sides of the circuit board is heated evenly during the toner transfer to circuit board.   

1/2oz Copper, .032" thick Double Sided Copper clad circuit board is recommended to make this product since it can be cut with a pair of heavy duty utility scissors.

Cut a piece of double sided board to 55mm x 45mm then clean both surfaces with Acetone and buff with fine steel wool until a mirror finish is obtained. For best results after buffing clean sides with Denatured alcohol or Marine stove fuel.      

Step 2: PicLink Mother Board Fabrication - Top Layer

Toner Transfer Direct-etch 

Reproduce image art of circuit board onto a single sheet of 8.5 x 11" toner transfer paper shiny side to to image. Be sure to handle the materials with plastic gloves on since the oils in one skin can distort the image quality.

How to make Direct Etch Transfer paper 

Toner Transfer paper is business card stock with a layer of Dextrin (cooked corn starch). Dextrin can be made from ARGO Corn Starch by sprinkling a thin layer of corn starch on a cookie sheet an baking in an oven at 350° F for 120 minutes. During the baking cycle it is necessary to stir the starch at 30 minute intervals to help insure even drying. After baking the cornstarch the dried powder (Dextrin) can be mixed with water to make paste (approximately 1.5 tablespoons of powder to one cup of water). Kiwi Water repellent (silicone spray) is then applied to a sheet of the paper stock dried and then coated with a thin layer of Dextrin paste. Once the paste dries you have homemade Toner Transfer Paper ready to make circuit boards.

After circuit board is cut, polished, washed with solvent it is ready for transfer of image art. 

Once art is copied onto a sheet of Toner Transfer paper the art is then cut out in squares so that the target symbols on both top and bottom layers will match up when facing each other. Remember your image must be on the shiny side of the transfer paper so that when both top and bottom images face each other the circuit trace donuts will line up. This is necessary to check since the copper clad board will actually be placed between these two sheets and taped with Scotch tape on one end in order to help prevent slippage.  Keeping this in mind lay out the squares of art as to make a laminator pouch from them by taping one end together while insuring the two images and target symbols mate evenly.   

After making the lamination pouch from the circuit art squares place the prepared circuit board in the pouch making sure the board surface area (copper) is centered over the art. Later after etching the corner lines will be visible to help trim to board to its actual size before assembly.
Preheat the laminator for about 20 minutes then run circuit board lamination pouch (made of toner transfer paper) through the laminator about 8 times. Each time flip the board feeding opposite ends into the laminator. This will insure the toner image is transfered evenly.

As soon as the lamination is complete place the pouch in a container of water (before is cools) and let soak for about 6 minutes or until the transfer paper separates from the copper circuit board. Check images and traces for pits which can be removed with a fine tip black sharpie pen. Once the board is prepared mix etchant (2oz hydrogen peroxide with 1 oz muriatic acid wearing gloves) adding the acid to the hydrogen peroxide. Stir etchant with a plastic spoon and then pour in plastic sandwich container. Place board into acid and etch for about 5-8 minutes while slightly rocking the container side to side. Once copper board is etched place board in water to neutralize the mild acid. Excess acid can be diluted with water and flushed down the drain where it will help make sure your sink drain is clean. Pat dry circuit board with paper towels the finalize for assembly.              

To finalize the board for assembly transfer the last image (cb-silkscreen) using the laminator to the board top. Laminate the toner transfer paper cb-silkscreen image to the top of the board a coupe of times making sure to line up the edges and target symbol. Soak in water well (plastic sandwich container) until transfer paper separates the once more pat dry.   

Drill board donuts with #72 drill bit (.635) and header donuts with #66 (.838) using a Dremel 2001 or similar drill. PCB drill bits can be obtained on line from companies like Electronics Express or Jameco.  

Step 3: PicLink Mother Board Assembly

Obtain necessary parts, assemble and solder components making sure component leads bottom side feed through leads on components meeting top side trace donuts. This is necessary sine Via's are not present so we are using component leads as via's. Solder in headers bottom side down then solder top side. Use multimeter continuity tester to check port continuity to IC's using schematic diagram. This electronics solder is recommended with a 30 watt soldering iron which can be obtained at Wal-Mart or you local ACE hardware store. Thin Kester 44 Rosin Core Solder 60/40 031 assembly solder is recommended.   

Parts List 

U1 1 MAX232N (Mouser - 595-MAX232N)
R1 1 10K
C1 1 10uf (Mouser - 647-UVZ1E100MDD1TD)
U2 1 16F628 (Mouser - 579-PIC16F628A-I/P)
D1 1 1N4148
C3,C4,C5,C6 4 1uf 50v (Mouser – 647-UVR1H010MDD1TD)
XTAL 1 20MHz (Mouser – 559-FOXS200-20-LF)
C3,C4 2 22pf
H2 1 RS232

H1-4 (Mouser – 649-68000-420HLF) .100 FCI snap off header strip

Step 4: Programming PicLink Using H1 ICSP Port

Programming picLink via ICSP (Header H1 bottom right)

Find release firmware in package included unzip package and locate URFC.hex file.
the URFC.hex file is located in the Release directory of the firmware build. If one needs to change the software you will need to install Eclipse SDCC (CDT)  compiler plugin version 1.0.0 as well asGNU Win32 File core, file utils and GPLINK. This can be done on Linux, XP and Vista and I recommend using the Eclipse platform Version: 3.4.0 (Ganymede) and the C/C++ CDT. I have included the SDCC project files which can simply be imported into an existing workspace.   

SDCC and GPUTILS can be downloaded from sourceforge and is royalty free and published under the GNU GPL. All C sources provided were compiled using SDCC and does include a master makefile which assumes SDCC and GPUTILS are both installed under drive C:\. If this is not the case you will need to edit the makefile (SDCCDIR and GPUTILSDIR) to reflect the proper locations of those tools.

Video of how I use the picLink RS232 controller to measure distance using Sonar 

URF 1000 Sonar DSM Module and picLink

SDCC Build Makefile  

# Embedded Build Script for use with SDCC and GPUTILS
# for PIC14 abd PIC16 Series Devices 
# Make Project Hex and ASM files from C Source file
# DEP LIBS = crt0i.o libsdcc.lib pic$(CPU).lib
# CLI build: sdcc --debug -mpic14 -p16f84 source.c
# CLI compile: sdcc -V -mpic14 -p16f84 -c source.c
# SDCC MAKEFILE for PIC16 & PIC18 Series Builds 
# Project: PICLink Lightweight Embedded System (Rev 1.1) for URFC (Ultrasonic Range Finder Controller) 
# Date: Feb 2, 2011
# Auth: TuxMicro Devices (C) 2010-2011
# Flags sdcc:
# -c :compile only
# -S :stop after assembly
# -V : show actual command line the compiler executing
# --verbose: Shows the various actions the compiler is performing
# Flags for gplink:
# -c : -m: -w : -r : -I dir : -s file: the linker file
# Environment Settings
# Generates project .hex file
# Tools
RM := rm -f
MV := mv -f

PRJ = urfc
TARGET = $(PRJ).hex

# CPU Target options
ARCH = pic14
CPU = 16f628a

# GPUTILS Build Environment
SDCCDIR := c:\sdcc
GPUTILSDIR := c:\gputils
GPASM := $(GPUTILSDIR)\bin\gpasm
GPLINK := $(GPUTILSDIR)\bin\gplink
SDCC := $(SDCCDIR)\bin\sdcc
LIBDIR := $(SDCCDIR)\lib\pic

# Output File Hex Format (inhx8m, inhx8s, inhx16, inhx32)
LINKFMT = inhx8m
LINKOPTS = --hex-format $(LINKFMT) -m

#SDCC Flags
CC := $(SDCC)

# GPASM Flags

#SDCC Debug
#SDCC_FLAGS = -S -m$(ARCH) -p$(CPU) --debug -c
#SDCC Compile
SDCC_FLAGS = -S -m$(ARCH) -p$(CPU) -c

# Linker Options
GPLINK_FLAGS = -c -m -w -r -I $(LIBDIR) -s $(GPUTILSDIR)\lkr\$(CPU).lkr

# C Sources
SRCS_C := urfc.c RS232Serial.c
OBJS_C := $(SRCS_C:.c=.o)
OBJS_ASM = $(SRCS_ASM:.asm=.o)

# Dependancies Libs
LIBS := libsdcc.lib pic$(CPU).lib

# All Target
all: $(TARGET)

# Build Tool evocations
@echo 'Building target: $@'
@echo 'Invoking: SDCC Linker'
@echo 'Finished building target: $@'
@echo ' '
@echo 'Releasing files'
-$(MV) $(PRJ).cod ./Release
-$(MV) $(PRJ).cof ./Release
-$(MV) $(PRJ).hex ./Release
-$(MV) $(PRJ).lst ./Release
-$(MV) $(PRJ).map ./Release

%.o: %.c
@echo 'Building file: $<'
@echo 'Invoking: SDCC Compiler'
$(CC) $(SDCC_FLAGS) $<
@echo 'Invoking: GPASM'
$(GPASM) $(GPASM_FLAGS) -c $*.asm
@echo 'Finished building: $<'
@echo ' '

# compiling standalone asm files into object file if needed
%.o: %.asm

# Other Targets
-$(RM) *.o
-$(RM) *.asm
-$(RM) *.lst
-$(RM) *.sym
-$(RM) *.map
-$(RM) *.cof
-$(RM) *.cod
-$(RM) *.hex
-$(RM) Release/*.map
-$(RM) Release/*.cof
-$(RM) Release/*.cod
-$(RM) Release/*.lst
-$(RM) Release/*.hex
@echo "------ Project directory cleaned."

.PHONY: all clean dependents

-include ../makefile.targets 

URFC.HEX ( inhx8m)


Step 5: PicLink Port Identification

H1 Port 5 Pin ICSP

H1-1 Vpp (programming voltage 13.2vdc max)
H1-2 Vdd 5-5.5vdc
H1-3 GND

H2 Port 3 Pin RS232 I/O

H2-1 GND
H2-2 Rx
H2-3 Tx

H3 Port 5 Pin PORTA (4 channel ADC)

H3-1 RA0/AN0 TTL IO or Analog Channel 0
H3-2 RA1/AN1 TTL IO or Analog Channel 1
H3-3 RA2/AN2/Vref TTL IO or Analog Channel 2 (vref in)
H3-4 RA3/AN3/CMP1 Analog Channel 3 or Comparator output 1
H3-5 RA4/CMP2 Comparator output 2

H4 Port 4 Pin PORTB (TTL IO)

H1-1 RB0/INT TTL IO Interrupt

Notes : 

H1-4 .100 header (2.5mm) allows the module to be plugged into a solderless
breadboard. Header H1 compatible with Microchip PICKit series

Microcontroller Contest

Participated in the
Microcontroller Contest