Introduction: PicLink RS232 Low Cost Development Controller With ADC

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.       

Features

· 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
H1 1 ICSP
H3 1 PORTA
H4 1 PORTB
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 URFC.zip 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
#
# SDCC_HOME
# SDCC_INCLUDE
# SDCC_LIB
# GPUTILS_HEADER_PATH
# GPUTILS_LKR_PATH
# GPUTILS_LIB_PATH
#
# Generates project .hex file
#
# Tools
RM := rm -f
MV := mv -f

#
#PROJECT
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
GPUTILS_HEADER_PATH := $(GPUTILSDIR)\header
GPUTILS_LKR_PATH := $(GPUTILSDIR)\lkr
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
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)
OBJS = $(OBJS_C) $(OBJS_ASM)

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

# All Target
all: $(TARGET)

# Build Tool evocations
$(TARGET): $(OBJS)
@echo 'Building target: $@'
@echo 'Invoking: SDCC Linker'
$(GPLINK) $(GPLINK_FLAGS) $(LINKOPTS) -o $(TARGET) $(OBJS) $(LIBS)
@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
$(GPASM) $(GPASM_FLAGS) -c $<

# Other Targets
clean:
-$(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
.SECONDARY:

-include ../makefile.targets 

URFC.HEX ( inhx8m)

:1000000000007C2B00340034F200030E8301F10069
:100010000A088A01F000040883120313C200831245
:1000200003138B128C1E15282421831203138B1C9F
:100030001A28A221831203130C1F1F28CA2183121E
:1000400003130B1D2428CE21831203130C1C292813
:10005000D221831203138C1C2E28DA21831203135E
:100060008B16831203134208840070088A008301F0
:10007000710E8300F20E720E0900B02083228312EB
:100080000313B70183120313201C4928831203139F
:10009000B70A831203133708003003190130B80080
:1000A000B70183120313061C582883120313B70ADF
:1000B000831203133708003003190130B900B80563
:1000C0003808031DCF2083120313B70183120313D3
:1000D000201C6D2883120313B70A83120313B8017F
:1000E00083120313A01C772883120313B80A831208
:1000F00003133808B900B705370803193F288312DE
:10010000031306183F281010213083120313B70081
:10011000B801B901831203130F08FD008312031302
:100120003708FE000030FF00003023242230831205
:100130000313B700B801B901831203130E08FD00C1
:10014000831203133708FE000030FF000030232421
:10015000831203132010A0100D30E9203F2808005F
:100160004430831603138100E030831203138B00A5
:100170000730831603138500C33086008112811176
:10018000831203139001831603130C1483120313B9
:100190008F018E01A001A101A20186150800FC308B
:1001A0008312031381000B118B12831203130B199B
:1001B000DC2886112014D528831203130B118B160B
:1001C0008615201CE8288F018E010C1010140B16C8
:1001D000080083120313B40083120313010883126F
:1001E0000313B500831203138B120B11003083121B
:1001F000031334040319FF280130B60002298312C7
:100200000313B601003083120313360403191929AE
:1002100064308312031381006430831203130102DC
:10022000031C1529013075220C2983120313B40312
:10023000F628831203130B1183120313350883125C
:10024000031381008B160800831203130B13043071
:1002500083120313B200F630B1008030B3003108CE
:10026000FE003208FF0033082322043083120313F8
:10027000B2007130B1008030B3003108FE003208A6
:10028000FF0033082322043083120313B2005030DE
:10029000B1008030B3003108FE003208FF0033089F
:1002A0002322043083120313B200AD30B10080303A
:1002B000B3003108FE003208FF0033082322043067
:1002C00083120313B200F630B1008030B30031085E
:1002D000FE003208FF003308232204308312031388
:1002E000B200E330B1008030B3003108FE003208C4
:1002F000FF00330823220230FD002130FE000030D1
:10030000FF000030A52283120313B3007F08B20060
:100310007E08B100FE003208FF00330823220430BB
:1003200083120313B200F630B1008030B3003108FD
:10033000FE003208FF0033082322502283120313E9
:100340000B170800831203138B1083120313AF01E2
:1003500083120313201CAF2983120313AF0A8312E5
:100360000313B00183120313061CB929831203136C
:10037000B00A831203133008AF052F080319C929E7
:100380008312031310108F018E010C100B12A01496
:1003900010140800831203130C13080083120313B4
:1003A0000B110800831203130C1010100B122010F5
:1003B000A0100800831203138C1008000130831270
:1003C0000317CB002030CA00CC01831203138C1A10
:1003D000EB295A307522831203138C1E222A8316AE
:1003E00003138C12103083120317CD0083120317EE
:1003F0004D08803E7F3E031C1F2A502283120317A4
:10040000CE00FD004A08FE004B08FF004C082324E4
:10041000831203174E080D3A03191F2A4A08FE00DB
:100420004B08FF004C08102483120317CE004E081F
:1004300003191F2ACA0A0319CB0ACD03F62983160A
:1004400003138C16080083120317C8007F08C70027
:100450007E08C600831203174608FE004708FF0007
:100460004808102483120317C900490803194F2AAA
:1004700049086422831203174608FE004708FF005C
:100480004808102483120317C9000D3A03194F2A94
:10049000490803194F2AC60A0319C70A2A2A08005D
:1004A00083120317C501831203138C1E5B2A1A08DB
:1004B00083120317C50083120313981C602A6E224F
:1004C000831203174508080083120313990083164B
:1004D000031398186D2A5A307522080083120313EB
:1004E000981C742A18121816080083120317C500E6
:1004F0000A30FF004508902483120317AF00000064
:10050000AF0B7F2A080083160313861406150A30E2
:1005100099000430980080308312031398008316EA
:1005200003138C16831203131816831603130C126D
:10053000981298161030FD00831203133F08FE0036
:100540004008FF0041085423080083120317BB0032
:100550007F08BA007E08B9007D08BC00BD011030DC
:10056000FD00831203133F08FE004008FF0041080E
:1005700054231030831203173C02BE01031C3E14A7
:10058000BF01831203173C083F0203184C2B3E089F
:1005900003194C2B3908FE003A08FF003B081024D1
:1005A00083120317C000400E0F39C1001030FF0046
:1005B0004108902483120317C200C0020A3041028E
:1005C0000318F62A3D08C200BD0A4208203EC200B8
:1005D00001300318013EC30030304107C400420817
:1005E0008400831343188317440880000A30831261
:1005F00003174102031C0F2B3D08C200BD0A42082D
:10060000203EC20001300318013EC3003730C1074D
:1006100042088400831343188317410880000A307E
:10062000831203174002C101031C411403182C2B31
:100630003D08C200BD0A4208203EC2000130031836
:10064000013EC30030304007C400420884008313D9
:1006500043188317440880000030831203174104B5
:10066000031D452B3D08C100BD0A4108203EC100C5
:1006700001300318013EC2003730C0074108840032
:100680008313421883174008800083120317B90AA6
:100690000319BA0ABF0AC12A831203133F08FE00D6
:1006A0004008FF004108080083120317B3007F08C9
:1006B000B2007E08B1007D08B400B50183120317B3
:1006C0003408350203187B2B35083107B600320891
:1006D0000318013EB70033080318013EB80000308C
:1006E000FD003608FE003708FF0038082324831277
:1006F0000317B50A5E2B0800C930FE000430FF0066
:100700008030000000002F2400000000831203133B
:10071000A4007F08A300CB30A5000430A6008312FC
:1007200003132308A7002408A800FF30A307031C15
:10073000A4032708280403190C2C04302507A7005C
:10074000A801A80D2608A8072708FE002808FF0012
:100750008030000000002F240000000083120313EB
:10076000AA007F08A9002508FE002608FF008030A7
:10077000000000002F240000000083120313AC00CF
:10078000A8007F08AB00A70002302507A700A8013A
:10079000A80D2608A8072708FE002808FF008030BB
:1007A000000000002F240000000083120313A800A3
:1007B000AE007F08A700AD00831203132908AD0027
:1007C0002A08AE00FF30A907031CAA032D082E0437
:1007D0000319052C2B08FE002C08FF0080300000B8
:1007E000000010240000000083120313AD0027084E
:1007F00084008313281883172D088000AB0A03197F
:10080000AC0AA70A0319A80ADC2B063083120313CB
:10081000A5070318A60A8F2B000000003D2808003A
:10082000003A0319172C803A03191E2C00347E0855
:10083000840083137F188317000808007F088A004C
:100840007E0882000800003A0319272C08007E0861
:10085000840083137F1883177D0880000800003A06
:100860000319372C803A0319412CFF0100347E080C
:10087000840083137F1883170008FF00840A000890
:100880000800000000001E24FD00FE0FFF03FF0A09
:10089000000000001E24FC007D08FF007C0808000A
:1008A0005434753478344D346934633472346F346D
:1008B00020344434653476346934633465347334B5
:1008C0002034283443342934203432343034313421
:1008D00030342D3432343034313431340A340D3440
:1008E000003455346C3474347234613473346F347E
:1008F0006E34693463342034523461346E34673476
:1009000065342034463469346E346434653472346A
:10091000203455345234463443340A340D340034D0
:1009200083120313BA007F08BB00BC010830BD006E
:10093000831203133A1C9E2C3B08BC07831203133B
:100940003A08BE0003103E0CBA0003103B0DBE0077
:10095000BB00BD0B982C3C08080046346934723447
:100960006D347734613472346534203456346534F0
:100970007234733469346F346E343A3420344C3406
:1009800045345334203431342E3431340A340D3468
:10099000003404340034023400342134003402348E
:1009A0000034FC3404342F34013401340034F9347D
:1009B00004343F34003403340034FD34043443340D
:1009C00000340134003409345434313449344E3461
:1009D0002034443469347334743461346E34633491
:1009E00065343A3420343034783400340A340D34E9
:0C09F000003420340134003400340034A2
:02400E00223F4F
:00000001FF
 

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
H1-4 PGD – ICSPDAT
H1-5 PGC – ICSPCLK

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
H1-2 RB3 TTL IO
H1-3 RB4 TTL IO
H1-4 RB5 TTL IO

Notes : 

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

Comments

About This Instructable

5,403views

8favorites

License:

Bio: 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 ... More »
More by tuxmicro:picLink RS232 low cost development controller with ADC
Add instructable to: