16F628A pinout and basic stuff

Image

here is the pinout of the 16F628A PIC chip, VDD is +5v only, VSS is ground, MCLR is reset pin, just tie that to +5v.

when you open microcode studio, just select the 16f628a from the dropdown box at the top, and write your code.

to use PortA as digital and not the analog comparators, which is what you use for robotics and such, add this to the top of your code.

Just copy/paste it at the top.

@ __config _XT_OSC & _BODEN_OFF & _WDT_OFF & _PWRTE_OFF & _LVP_OFF
CMCON = 7
VRCON = 0

The 7805 regulators, looking at the front of it, the pinout going from left to right is

1. input, 2. ground, 3. +5v regulated out.

You’ll need the mplabs stuff installed to use that stuff, when you go to compile the code, it’ll try to autofind it.

In all, the programs that should be installed are picbasic pro, microcode studio, and mplab, and the programmer software.

here’s the basic layout for the pic chips with the crystal and capacitors, the capacitors for the crystals are labeled 22 for 22pf, and are the smaller ones, the 104 ones are 0.1uf and used for power filtering.

index index2

just dont worry about the diode on the 7805, it’s added to add more current as an output, and the 330n one can be replaced with one of the 1uF caps.

there’s alot of code examples in C:/pbp/samples, or in the microcode studio folder which should show up as soon as you click open in microcode studio

Advertisements

PICBasic Pro and gEdit

First, install gEdit’s external tools using “sudo apt-get install gedit-plugins”,

Then add the pbp.lang file to /usr/shared/gtksourceview-2.0/language-specs/

You need to close out of all gEdit windows at this time and restart it to get the new language to show up.

Dont forget to go to edit/plugins, and enable the External Tools plugin.

Finally, go to gEdit and went to Tools/Manage External Tools, and create an entry called Compile PBP code, and add this into the codebox at the right:

#!/bin/sh
pic=”16f628a”
wine c:/pbp/pbpw -e -s -ac:/Program Files/Microchip/MPASM Suite/MPASMWIN -p$pic $GEDIT_CURRENT_DOCUMENT_NAME
var=$GEDIT_CURRENT_DOCUMENT_NAME
var2=${var%???}
outasm=$var2″ASM”
wine c:/Program\ Files/Microchip/MPASM\ Suite/mpasmwin /q /e /l $outasm

Just name that command something like “Compile PBP Code” and save it.

You may need to modify the include files hidden in the pbp, just look for the pic chip that you are using with the .inc extension and open it in a text editor. look for the _config line towards the bottom and add a ; to the beginning of the line to comment the line out.

Then add pickit2 by installing the official pk2cmd from microchip’s site, and did this mod to the system:
http://gatemaze.blogspot.com/2009/06…er-ubuntu.html
This allows you to run pickit2 as a normal user, which is what we want.
Then add this code to the external tools dialog in qEdit:

#!/bin/sh
pic=”16f628a”
wine c:/pbp/pbpw -e -s -ac:/Program Files/Microchip/MPASM Suite/MPASMWIN -p$pic $GEDIT_CURRENT_DOCUMENT_NAME
var=$GEDIT_CURRENT_DOCUMENT_NAME
var2=${var%???}
outasm=$var2″ASM”
wine c:/Program\ Files/Microchip/MPASM\ Suite/mpasmwin /q /e /l $outasm
outhex=${var2}”HEX”
pk2cmd -B/usr/share/pk2/ -PPIC$pic -F$outhex -M -R

Just name it something like “Compile and Burn PBP Code using PICKit2” and click close.

Here’s the commands for using a JDM type program with the picprog software.

#!/bin/sh
comport=”/dev/ttyS0″
pic=”16f628a”
wine c:/pbp/pbpw -e -s -ac:/Program Files/Microchip/MPASM Suite/MPASMWIN -p$pic $GEDIT_CURRENT_DOCUMENT_NAME
var=$GEDIT_CURRENT_DOCUMENT_NAME
var2=${var%???}
outasm=$var2″ASM”
wine c:/Program\ Files/Microchip/MPASM\ Suite/mpasmwin /q /e /l $outasm
outhex=${var2}”HEX”
picprog –erase –burn –input $outhex –device pic$pic –p $comport

Just name it “Compile and Burn PBP code with JDM programmer”

To change the PIC type, just change the 16f628a in the “PIC=”16f628a” to whatever chip you use in each script, and in the JDM programmer script, just set the /dev/ttyS0 to whatever your serial port the jdm programmer is attached to.

Here is the pbp.lang file, just extract it and place it where it’s supposed to go.

pbp.lang.zip

After everything is set up and programmed in, just open a .bas file or .pbp file and go to tools/external tools, then click either the compile pbp code or use jdm programmer, or the pickit2.