Easy PIC-III: User Manual
Easy PIC-III: User Manual
Easy PIC-III: User Manual
User Manual
Features
• 18 Pin PIC Microcontroller
• HD44780 based 16x2 character LCD interface
• 4 LED indicators
• 1 channel analog input
• DC motor / relay controller (100ma)
• 38KHz modulated infra red remote controller sensor
• 2 push switches
• PIZO Buzzer
• Serial Port with RS232 Level converter and DB-9 Connector
• On board 5V 1A power regulator
• In circuit serial programming Interface (ICSP)
• JDM type In Circuit Serial Programmer
Package Contents:
• Easy PIC-III Motherboard
• 16x2 character LCD with Backlight (optional)
• LM-35 temperature sensor (optional with 16F819)
• Serial Cable (optional)
• JDM Programmer
• Software:
• Proton Basic Lite version (Supports 16F628A)
• PIC PGM Programmer software
An Overview of the Hardware
ICSP
Microcontroller
LCD Connector
Analog Input
Buzzer
Buzzer Enable 4 LED Indicators FAN / DC Load
Jumper
Figure 1 shows arrangement and location of various devices on Easy PIC-III board. In order to use these
devices in your program one needs to know exactly where they are connected on the microcontroller. All I-
O lines are usually general purpose lines and can be used to connect the devices the way you want in your
project. However some lines have dedicated internal hardware attached to them, so if you want to use that
functionality the particular device must be connected to the specified pins. This board does not use any
dedicated hardware so the devices have been connected to Microcontroller solely on the basis of ease to
draw circuit. Serial communication however has been connected to special I-O lines, we shall talk about it
in appropriate section.
Summary of Connections
The above screen shot shows how it should look. Note the areas where Programmer and microcontroller
have been automatically detected. Note the Button on toolbar that will be used to activate program transfer
into the microcontroller. Also note the Select hex file section where you will select the .hex file to be trans-
ferred. Note if you have selected a .hex file and transferred it, you do not need to close the PICPgm when
you recompile the program to generate a newer version of .hex, when you press the program button it will
automatically detect that hex file already loaded and one on file do not match so it will load the new one
automatically. Alternately if you close it and run again, it will load the new file automatically. However if
file name has been changed you have to browse for the new .hex.
Compiler
A number of programming languages and compilers are available. You can chose any of your choice. Com-
monly used are Proton Basic, MikroBasic, MikroC, MPLAB Assembler, Hi-techC, CCS-C, JAL and so on.
Most of these have free to download demo versions with some limitations available. We shall use PRO-
TON BASIC for this demonstration. Note Free to download PROTON BASIC supports 16F628A but not
16F819. Since most of the examples can be run on 16F628A the free version is OK. However if you want
to work with analog data you need to work with 16F819 that will require Full version of PROTON BASIC.
MikroBASIC from (www.mikroe.com) on the other hand also gives demo version free to download. It sup-
ports all microcontrollers, but limit is code size of 2K. This is enough for beginner. So you can work with
analog section using MikroBASIC, or if you are comfortable work entirely in MikroBASIC. MikroBASIC
however does not has library to decode the IR remote control codes, rest of it is fine.
We supply Easy PIC-III in two configurations:
1: Standard Configuration, with 16F628A (includes Free Version of Proton Basic, and does not include
LM35 sensor)
2: Extended Configuration, with 16F819 (includes Full version of Proton Basic and LM35 Temperature
sensor)
Depending upon your purchase install the Proton Basic Compiler. The exact method will be written in the
software folder. Once Compiler has been installed, and configured your Integrated development environ-
ment should look like this.
The Proton Compiler has two parts, an IDE (Integrated development environment) the one which is shown
in this screen shot and an actual compiler that runs in background when IDE instructs to compile. When
free version is installed this is set automatically, but when full version will be installed you will have to tell
the IDE where to find the compiler. This is done by clicking view > Compiler and program options.
As you can see we have already pointed it to the folder containing our compiler files. If you need to set it
use Find Manually button and locate the appropriate folder.
To setup the Programmer is optional. As you have already setup your PICPGM you will have to load it
every time a new hex file is generated and needs to be transferred. Although not a big issue but it will be
more convenient if we get PICPGM popup right from the Proton IDE. To do that click on programmer tab.
When you firs time run, it has no idea about your programmer indeed it believes in its own. So click over
Install New Programmer.
The list does not have our particular Hardware (JDM) listed. So we need to create a new custom program
entry. Select Create a Custom Program entry option and click Next.
In the display name choose anything you want, this is just a name that will be displayed in list of program-
mers. Now click Next.
As you can see here that program folder has been selected.
The parameters list can pass the programmer name of .hex file. If you leave this empty PICGM will load
and ask you to select the hex file. If you want the entire thing to go automatic enter $hex-filename$ here.
Click Finished. Now your Programmer has been set to load from within the Proton Basic IDE.
Writing Your First test program
Well now is the time to write a first ‘Hello World’ program. This is the usual program most people do to
get a response sort of thing to see if everything works. In Microcontroller world this usually means turning
LED’s ON. Since our LEDs are connected to PORTB pins RB4..RB7 turning these pins high will light up
the LEDs.
So in ProtonIDE click File > new and a new program entry editor will open the left pan will show the vari-
ous registers of chosen microcontroller (16f628A by default) and other variables that you will be declaring
in your program. The right pane is empty where you can write your program. So write this program.
Notice as you type various keywords the IDE highlights them to show that they are commands (Bold
Black) Declares (Bold red) or PORT Names (Bold Green)
Also notice that the processor name is in bold. This all gets automatically. If the processor is not supported
by your compiler this will not get bold and left pane (code explorer) will not show the processor name.
So in this program we have declared that PORTB will act as output and set its value to 255 that will turn all
pins of PORTB high including ones on which LEDs are connected.
Now lets compile the program. To be on the safer side click a small arrow on side of the program button on
toolbar and make sure your newly created programmer entry is selected.
Make sure your hardware is connected and powered on.
Now click ‘Compile and Program’ Button this will bring up compiler and then automatically load PIC
PGM. Note if the program has not been saved before it will ask you to save it first. So create a folder in
some accessible location (better not on desktop or my documents) as the compiler can not work on long
paths. I prefer to create a folder named ‘PICProjects’ in D:\ and then create subfolders for each project.
Lets say we name this program Hello it will be saved as Hello.bas (this is your source file). The compiler
will generate a number of intermediate files, and finally a .hex file , Hello.hex in our case.
When the PICPGM shows up click browse to locate your hello.hex. Now click program button of
PICPGM and the new program should be transferred into the microcontroller.
After the program has been successfully transferred, disconnect the board from programmer. Turn the
power OFF and ON again and your LEDs should be ON. See screen shots next.
See Microtronics PICPGM is in list and selected.
Notice I had set the $hex-filename$ parameter so my .hex file has been automatically loaded and pro-
grammed.
Now turn power off and disconnect programmer. Turn Power ON and All 4 LEDs should be ON.
If you got this result, congratulations you have successfully created a complete cycle of editing and pro-
gramming the software into microcontroller.
Now lets say we want to modify the same program to blink these LEDs.
So back to PROTON IDE and modify the program like this.
Device=16F819 'use 16f628 if you have that processor
Xtal = 20
All_Digital true
Output PORTB
loop:
PORTB=255
DelayMS 500
PORTB=0
DelayMS 200
GoTo loop
End
This time I will not show you the screenshots, follow the same steps, Connect hardware, turn power ON,
and click ‘Compile and Program’ when the new program has been successfully transferred turn power off
disconnect programmer, turn Power on and you should see blinking LEDs.
Example Projects
In this section we shall develop small projects to give you an idea how different devices on Easy PIC-III
can be used. This section only serves as a guide as to how these devices should be used. This section does
not act as a tutorial to programming PIC microcontrollers.
Using LED Indicators
Four LED indicators are provided on board. They have been connected to RB4..RB7 of PORTB. The posi-
tive side of LEDs is connected through a current limiting resistor to microcontroller pin and negative side
has been grounded.
High LED1
DelayMS 500
Low LED1
High LED2
DelayMS 500
Low LED2
High LED3
DelayMS 500
Low LED3
High LED4
DelayMS 500
Low LED4
GoTo AA
This example declares friendly name LED1, LED2 etc to port pins PORTB.4, PORTB.5 etc. the sequen-
tially makes them high and low with a delay of 500 ms in between.
Using LCD
LCD is the most commonly used output device in projects for communication with the user. The LCD con-
nections in Easy PIC-III use 6 I-O lines. The data is transmitted through RB4..RB7 to D4..D7 pins of LCD
Register Select (RS ) pin of LCD is connected to PORTB.3 and Enable (E) pin of LCD is connected to
PORTB.0.
We need to inform this information to the compiler so that it can generate signals on appropriate lines of
microcontroller.
Device=16F819
Xtal=20
All_Digital true
'LCD Declarations
LCD_DTPin PORTB.4 ' Lcd data starts at portb.4
LCD_RSPin PORTB.3
LCD_ENPin PORTB.0
GoTo Loop
This program first declared the LCD connections that this board is using, then displays a message on line 1,
“hello world”
It then runs a loop on variable X, varying its value from 0 to 100. each time it changes the value of X it is
displayed on LCD. To show you how you can display variables on display.
You can see how dramatically Proton Basic has reduced the headache of programmer (you) to display data
on LCD.
Using Buzzer
Buzzer is connected to PORTA.1 and it will be activated when PORTA.1 is Low. Make sure that the
Jumper near Buzzer has been connected to enable it.
Device=16F819
Xtal=20
All_Digital true
Output PORTA.1
Symbol Buzzer PORTA.1
Loop:
Low Buzzer
DelayMS 500
High Buzzer
DelayMS 1000
GoTo Loop
This command will turn the buzzer ON for half a second and then turn it Off. A more useful command
called sound is present in Proton, you can try it to produce varying sounds. However this command works
best with simple pizo, or a speaker. This buzzer has in built circuit for 1KHz, so its not ideal for making
varying frequency sound. You can however make various notes by enableing and disabling it for various
timings.
Motor Control
Truly speaking this is not a motor control, but a simple DC load control. It uses one NPN transistor to pro-
vide ground for the load. The other end of load is directly connected to positive of adapter. Thus if 12V
adapter is being used the DC load will operate at 12V. The NPN transistor can drive a maximum load of
100-200 mA. This is enough for a brushless DC Fan, or a small relay. If you are using a relay, make sure
you place a diode across its Ground and positive connections of coil. Because when the current is switched
ON and OFF the magnetic recoil produces a high spike that can damage the transistor.
Since DC Load control is also connected to PORTA.1 it is recommended to take the buzzer jumper off. The
DC load however gets activated when the PORTA.1 pin is high.
Device=16F819
Xtal=20
All_Digital true
Output PORTA.1
Symbol FAN PORTA.1
Loop:
High FAN ' Turn Fan ON
DelayMS 5000 'keep it on for 5 seconds
Low FAN ' Turn Fan Off
DelayMS 2000 'Keep it Off for 2 seconds
GoTo Loop
Analog Input
Analog input connected to PORTA.0 can be used only with microcontrollers containing ADC channels.
16F819 has this channel, whereas 16F628A does not have it. Notice in previous examples we have been
declaring All_Digital True statement. This indicates that we want to use Analog input pins in digital mode.
So when we want to use these pins as analog we do not issue this statement. However not issueing this
statement means all portA pins will be analog, and we can not perform any digital I-O on these pins. There-
fore we have to configure a few internal registers in 16F819 to select which pins are analog and what others
are digital.
Device=16F819
Xtal=20
'LCD Declarations
LCD_DTPin PORTB.4 ' Lcd data starts at portb.4
LCD_RSPin PORTB.3
LCD_ENPin PORTB.0
Loop:
x=ADIn 0
Cls
Print At 1,1,"Raw:", Dec x
y=(5/1023) * x
Print At 2,1,"Volts:", Dec y
DelayMS 1000
GoTo Loop
Apart from that there are few settings that need to be done to configure the analog module, like in what
resolution we want the data to be converted. A 10 bit resolution means, it will break the 0-5V data into
1024 steps. So at full 5.0 V input the output register will give us a value of 1023. thus each division or in-
crement represents (5/1023=0.004887 V) thus the input register value multiplied by this number will give
us the exact input volts. You can use any Input source, a simple method is to take a variable resistor like
POT, and connect to the input header. You can measure the input volts at center pin, exactly same volts
must be shown on LCD Display.
Cls
Print "Waiting for"
loop:
Repeat
SONYIN_WORD=SonyIn 'get remote control data
Until SONY_COMMAND <> 255
Cls
Print At 1,1,"System:", Dec SONY_SYSTEM
Print At 2,1,"Command:", Dec SONY_COMMAND
GoTo loop
etc. and Low Byte contains the actual command or code of the button that has been pressed.
If no key is being pressed, the Command byte gives 255. Therefore a loop is placed to continuously read
the IR sensor, until a valid data is received. Once the data has been received into variables, you can per-
form any task depending upon the data.
Push Buttons
Two push buttons have been provided they give a logic ‘0’ when pressed to the accompanying pin of mi-
crocontroller. To read their state simple IF statement can be used.
Device=16F819
Xtal=20
All_Digital true
Input PORTA.3
Input PORTA.4
Output PORTB.4
Output PORTB.5
Loop:
If SW1= 0 Then
Toggle LED1
DelayMS 200
EndIf
If SW2=0 Then
Toggle LED2
DelayMS 200
EndIf
GoTo Loop
Rsout_Mode TRUE
Loop:
After this basic overall introduction you are now ready to dig deeply through more complete programming
references.