Here is my first PCB project I made using Diptrace, I wanted to make a board that gave me access to all the data pins and to use a LCD display for prototyping. So I designed a schematic using Diptrace and then created my own PCB layout and made it onto some copper clad.
I decided to use a 40pin microcontroller, 20mhz crystal, 8 leds and 8 buttons, LCD display which can be detached from the board, and many strip pins to give me access to any pin on the microcontroller. I did not incorporate any microchip functions like USB and USART as I thought I could make my own daughter boards etc for them..
I did include a PicKit ICSP connector for programming the microchip and an external power supply from three 1.5volt batteries..
Click on the below slides to view the board from different angles.
The code that I quickly put together to test the board is here:
{
*****************************************************************************
* Name : Gavs Proto Board.BAS *
* Author : Gavin Wiggett *
* Notice : Copyright (c) 2010 *
* : All Rights Reserved *
* Date : 04/12/2010 *
* Version : 1.0 *
* Notes : Demo program ver1 *
*****************************************************************************
8 buttons connected to PORTB (with pullup resistor on 5v)
8 leds connected to PORTD
LCD connected on data lines PORTC.4,5,6,7 with RS on PORTE.0 and EN on PORTE.1
Special LCD commands added, thats not included in the LCD module.
}
// Name of Program
ProgramGavs_Proto_Board_Demo // useful for documentation purposes
// Device and Clock
Device = 18F452
Clock = 20
// LCD optional settings
#option LCD_DATA = PORTC.4 // LCD setup data port (sets it to 4 data lines only)
#option LCD_RS = PORTE.0
#option LCD_EN = PORTE.1
// Modules
Include "LCD.bas" // include LCD module
Include "convert.bas"
Include "RandGen.bas" // this module will give us a random numbers
// LCD special Commands to shift LCD screen left and right (not included in the LCD module)
Public Const
cmdDisplayRight = %00011100,
cmdDisplayLeft = %00011000
// Setup ALL our PORTS
Dim button0 As PORTB.0 // button port
Dim button1 As PORTB.1
Dim button2 As PORTB.2
Dim button3 As PORTB.3
Dim button4 As PORTB.4
Dim button5 As PORTB.5
Dim button6 As PORTB.6
Dim button7 As PORTB.7
Dim led0 As PORTD.0 // led port
Dim led1 As PORTD.1
Dim led2 As PORTD.2
Dim led3 As PORTD.3
Dim led4 As PORTD.4
Dim led5 As PORTD.5
Dim led6 As PORTD.6
Dim led7 As PORTD.7
// Variable Declarations
Dim led_count As Byte
Dim i As Byte
// Random number Gen
DimRandomVal As Byte // used to store the random number
Dimmyvalue As Byte // used to store random number
// Subroutines ====
Sub menu_text ()
LCD.WriteAt(1,17,"Gav's Proto Board 2010") // Send text to the LCD screen
LCD.WriteAt(2,20,"(Demo functions)")
Command(cmdDisplayLeft) // Scrolls the text left along LCD
DelayMS(380) // delay to display the text on the LCD
End Sub
Sub function_1 () // turns on a led at a time and can turn them all on.
LCD.Cls // clear the LCD
LCD.WriteAt(1,3,"function one")
LCD.WriteAt(2,2,"Leds = "</span>,BinToStr<span class="br0">(PORTD,8)) // write data to LCD
DelayMS(1260) // delay for button bounce
If led_count >= 0 Then
Inc(led_count) // increase our led counter
EndIf
Repeat
If button0 = 0 Then // check button pullup resistor connected to 5v SET ADCON1 to $07
DelayMS(400)
led_count = led_count + 1 // increase our led counter
ElseIf button1 = 0 Then
DelayMS(400)
led_count = led_count - 1 // decrease our led counter
EndIf
Select led_count
Case 1
High (led0)
Case 2
Low (led0)
High (led1)
Case 3
Low (led1)
High (led2)
Case 4
Low (led2)
High (led3)
Case 5
Low (led3)
High (led4)
Case 6
Low (led4)
High (led5)
Case 7
Low (led5)
High (led6)
Case 8
Low (led6)
High (led7)
Case 9
Low(led7)
End Select
LCD.WriteAt(2,2,"Leds = "</span>,BinToStr<span class="br0">(PORTD,8)) // write data to LCD
If led_count = 10 Then
led_count = 0
End If
Until led_count = 0
If led_count = 0 Then
LCD.Cls // clear LCD
PORTD = %00000000 // clears portd
EndIf
End Sub
Sub function_2 () // flashes all leds from left to right.
LCD.Cls // clears LCD
LCD.WriteAt(1,3,"function two")
DelayMS(750) // delay before function starts
Toggle (led0)
DelayMS(200)
Toggle (led0)
DelayMS(200)
High (led1)
DelayMS(200)
Low (led1)
DelayMS(200)
High (led2)
DelayMS(200)
Low (led2)
DelayMS(200)
High (led3)
DelayMS(200)
Low (led3)
DelayMS(200)
High (led4)
DelayMS(200)
Low (led4)
DelayMS(200)
High (led5)
DelayMS(200)
Low (led5)
DelayMS(200)
High (led6)
DelayMS(200)
Low (led6)
DelayMS(200)
High (led7)
DelayMS(200)
Low (led7)
DelayMS(200)
LCD.Cls // clears LCD
End Sub
Sub function_3 () // flashes leds randomly
LCD.Cls // clears LCD
LCD.WriteAt(1,2,"function three")
DelayMS(500)
For i = 0 To 15
RandomVal =RandGen.Rand // get random value
PORTD =RandomVal
DelayMS(250)
LCD.WriteAt(2,2,"Leds = "</span>,BinToStr<span class="br0">(RandomVal,8))
DelayMS(1000)
Next
PORTD = %00000000
LCD.Cls // clears LCD
End Sub
Sub function_4 () // LEDs connected to PORTD (from RD0 to RD7)
LCD.Cls // clears LCD
LCD.WriteAt(1,2,"function four")
DelayMS(500)
'RightToLeft
For i = 0 To 7
PORTD.Bits(i) = 1
DelayMS(500)
PORTD.Bits(i) = 0
Next
'LeftToRight
For i = 7 To 0 Step -1
PORTD.Bits(i) = 1
DelayMS(500)
PORTD.Bits(i) = 0
Next
'CenterToOut
For i = 3 To 7
PORTD.Bits(i) = 1
PORTD.Bits(7-i) = 1
DelayMS(500)
PORTD.Bits(i) = 0
PORTD.Bits(7-i) = 0
Next
'OutToCenter
For i = 0 To 4
PORTD.Bits(i) = 1
PORTD.Bits(7-i) = 1
DelayMS(500)
PORTD.Bits(i) = 0
PORTD.Bits(7-i) = 0
Next
PORTD = %00000000 // clear LED port
DelayMS(200)
'AllFlash
For i = 0 To 4
PORTD = %11111111 Or PORTD
DelayMS(500)
PORTD = %00000000 And PORTD
DelayMS(500)
Next
LCD.Cls // clears LCD
End Sub
// Set Ports
// Delay for LCD and Ports setup
DelayMS(200) // Allow LCD to warm up
ADCON1 = $07 // Make all pins digital I/O's - check datasheet
TRISA = %111111 // Make PORTA all inputs
TRISB = %11111111 // Make PORTB all inputs
TRISC = %00000000 // Make PORTC all outputs
TRISD = %00000000 // Make PORTD all outputs
TRISE = %000 // Make PORTE all outputs
// clear LCD before we start and then write our data
LCD.Cls // Clear the LCD screen
Input (PORTB.0) // make sure ALL our buttons are set input
Input (PORTB.1)
Input (PORTB.2)
Input (PORTB.3)
Input (PORTB.4)
Input (PORTB.5)
Input (PORTB.6)
Input (PORTB.7)
Low (led0) // make sure we start prog with ALL leds OFF
Low (led1)
Low (led2)
Low (led3)
Low (led4)
Low (led5)
Low (led6)
Low (led7)
led_count = 0
// myvalue is the Initial primary number for the random gen
myvalue = 7
RandGen.Initialize (myvalue) // Initialize the Random Number generator
// Main Program Here.
While 1 = 1 // Main program loop that is multi-tasked
menu_text // call sub for scrolling text (Gav's Proto Board)
If button0 = 0 Then
function_1 // call sub function one
EndIf
If button1 = 0 Then
function_2 // call sub function two
EndIf
If button2 = 0 Then
function_3 // call sub function three
EndIf
If button3 = 0 Then
function_4 // call sub function three
EndIf
Wend
// End of program.
End