12-21-2008:Bug fix for PC side code and PIC code for Cheap Logic Analyzer to get it to work again with sample rates slower than 250 us. I blew my computed goto tables by letting them strattle a 256 byte page when I added the 400ns code. Sorry about that. Also, fixed triggering bug in host code where it was not possible to change from a 1 back to an X.12-17-2008:Updated PC side code and PIC code for Cheap Logic Analyzer to add 96 sample 2.5M sample per second mode (400ns sample rate) and to allow firmware to be downloaded and verified from the PC application. The window can now be resized to fill the screen with the waveform.10-31-2008:Added 4 channel PWM plugin to SourceBoost Plugins10-20-2008:Added example active low button plugin to SourceBoost Plugins9-22-2008:Updated Serial Port PIC Boot Programmer project to fix version typo in PIC boot code for 16F877A device. I left the version as 1 instead of 2 which prevented this device from working with the latest PC side code.Development Tools:
- Microchip website that has nice (and free) development environment www.microchip.com
- GNU C compiler with bug and quality fixes I made. ccpic.zip
- Get this one!. SourceBoost Technologies www.sourceboost.com/home.html offers a free limited code size C compiler with a very low cost upgrade policy for a unlimited memory size which support the 16 and 18 series processors. They also offer a Basic and C++ compiler. The simulation/debug environment is very good.
Links:
- The main Microchip web site www.microchip.com
- Where to go for help and example code www.piclist.com or www.sourceboost.ipbhost.com
- Where to buy www.digikey.com , www.mypioneer.com or www.mouser.com
All Projects:SourceBoost Plugins Completed Projects:
Library of C Routines
Serial Port PIC Programmer
Serial Port PIC Boot Programmer
Digital Clock
Funky Digital Clock
Lego Robot Controller
LCD Terminal
Cheap Logic Analyzer
Temperature Logger
Camera Controller
Cassette Interface
SourceBoost Plugins:
Description Plugin Example Active Low push buttons BoostDigIO.zip CButtonTest.zip 4 Channel Pulse Width Modulation monitor BoostPWM.zip CPWMTest.zip Library of C Routines:Library of C routines: CBLib.zipThis zip file contains the following files:
clock.c clock.h Code to implement a real-time clock plus functions to perform math on time in day, hour, minute, second format. This code also includes the ability to trim the clock to make up for crystal errors. I've tuned to a 1 second error ever 3 or 4 days. Without triming, the error can be as high as 10 to 20 seconds per day. Most crystals are accurate but have a fixed error from their stamped frequency of 20 parts per million. Do the math. It is a big error when being used as a clock. ExtEeprom.c ExtEeprom.h Code to interface to an external serial EEPROM. Just change the defines at the top of ExtEeprom.c to use any two pins for the interface. Lcd2Line.c Lcd2Line.h Code to interface to a 2 line by 16 character LCD module using 6 pins. Lcd.h Header file for interfacing to a the serial 4 line by 20 character LCD terminal. legocore.c legocore.h Code to implement PWM conrtrol and direction of 4 motors as well as sampling 8 analog channels. This code is used for the Lego Robot Controller project. Serial.c Serial.h Code to implement RS-232 interface using PIC hardware. String.c String.h Code to implement a limited version of sprintf (sprintf1, sprintf2 .. sprintfx) Timer.c Timer.h Code to implement delays using hardware timers and interrupts Camera Controller:
Serial Port PIC Programmer:![]()
Click on picture for larger viewPC side Code: picprog.zip (Source code: HostPicProg.zip Lib Code: common.zip)Serial Port PIC Boot Programmer:
PIC project: SerialProg.zip (just the source serprog.asm )
Schematic: PicProgrammer.jpg
Device: 16F84A or 16F628This project allows flash based PIC microcontrollers to be programmed using the serial port on a PC. The serial interface runs at 115K baud. I found parallel port connection solutions to be flaky and dependent on which PC/OS was used so I made my own. The only bummer is that you need to program a 16F84A to build this programmer. Only locations that need to be modified are programmed to limit the erase/program cycles and speed up programming.This updated version now supports 16F87xA as well as the non A versions.
PC side Code: PicBootProg.zip (Source code: PicBootProgSource.zip [V 1.8 1-14-2008])Digital Clock:
Lib Code: common.zip
PIC project: BootLoader.zip (just the source bootload.asm ) [9-22-2008]
Schematic: None. Just software
Device: 16F87x and 16F87xA and 16LF versionsThis project allows flash based PIC microcontrollers (16F87x and 16F87xA parts) to be programmed using a simple in circuit serial interface once the device has been programmed with the code in bootload.asm. The RS-232 interface needs to be connected to the standard RS-232 pins of the device PORTC[TX] and PORTC[RX]. In addition to this connection, PORTC[2] is used to select, at power up, whether to run the user program (low) or to run the boot loader code (high). The device must be running with a 20MHz crystal but other frequencies could be used with a slight modification to the baud rate value in the boot loader. The serial transfer rate is 115K baud. Slower frequencies may require the baud rate to be reduced which would require the PC code to change as well.Note that the last 256 words of program memory are used by the boot loader. The first 4 locations of the user program can be used as they are copied into the bootloader space by the loader while it then puts a jump into the first 3 locations.
Note: Since the 4-28-2006 version, PORTC[2] is used instead of PORTC[5] for the mode pin. Also, the sense is was inverted at that time. Grounding PORTC[2] will run the user code instead of the boot code. Previous versions required a pull up resistor. The PC side software does not support the pre-4-28-2006 version of bootload.asm so keep an old version or reflash your PICs.
![]()
Click on picture for larger viewPIC project: Clock.zip (just the source clockasm )Funky Digital Clock:
Schematic: Clockjpg
Device: 16F84AThis project uses a 3 and a half digit 7-segment LED display from a broken bread machine to show the time of day. The non-resetable TRM0 timer (if it is reset time drifts) is used to generate interrupts at a rate of 610 and 45/128 Hz using a 20 MHz crystal (488 and 9/32 Hz using a 4 MHz crystal). This is the display refresh rate. The interrupts are counted to get seconds, minutes and hours using some games to implement the fractions. The time is set using two push button switches that are scanned using the digit drive enables and sampled using a free input pin. This circuit consumes less than 20mA at 5V using a 20 MHz crystal.Lego Robot Controller:PIC project: FunkyClock.zip (just the source funkyclk.asm )![]()
Click on picture for larger view
Schematic: FunkyClockjpg
Device: 16F84AThis project uses the same circuit as the Digital Clock but runs at 4 MHz and uses different software to add some visual effects. The time is displayed for a random amount of time followed by one of several effects for a random amount of time. This loop is repeated.The stand is made from the metal brackets of a file folder.
![]()
Click on pictures for larger viewLibrary of C routines: Library of C
LCD Terminal:
SourceBoost project 1: CBLegoBumper.zip (just the source Bumper.c )
SourceBoost project 2: CBLegoCrane.zip (just the source Crane.c)
Schematic: LegoController.jpg
Device: 16F877
This project controls Lego robots in a way similar to Lego Mindstorms. Two dual H-bridge chips(L283) are used with the PIC microcontroller to control 4 motors. Each motor has speed, direction, float and brake control. Eight A/D inputs are sampled sequentially and the motor PWM control is done in an interrupt routine so that user code can treat the inputs and outputs as continuous values.
User level control is done in C (compiled with the SourceBoost compiler). The controller is packaged with 8 Lithium-Ion AA batteries in a brick of legos using no glue or special parts. Programming is done through a RS-232 port using the Serial Port PIC Boot Programmer described above.
This is really cool stuff.
![]()
Click on pictures for larger viewPIC project: LcdTerminal.zip (just the source LcdTerminal.asm )
Cheap Logic Analyzer:
Schematic: LcdTerminal.jpg
Device: 16F628
This project controls a 20 character by 4 line LCD display so that a simple serial RS-232 or TTL interface can treat the display as an ASCII terminal. The source code explains all the control characters and escape sequences to control scrolling the display, clearing the display, downloading custom characters and other features. The interface runs at 115K baud by using a software FIFO to handle input characters during a vertical scroll. A select pin is provided that allows the interface to run at 9600 baud.
Demo:
SourceBoost Project: CBMeter.zip (just the source CMeter.c )
Library of C routines: Library of C
This is a demo program that uses a 16F873 and the LCD Terminal to implement a volt meter. The CBLib.zip file is required as well as the SourceBoost C compiler. See the Lego Robot Controller for details.
![]()
![]()
Just a little thingPIC project: CheapLA.zip (just the source CheapLA.asm ) (Version 2.01: 12-21-2008)
PC side Code: LogicAnalyzer.zip (Version 1.08: 12-21-2008)
Schematic: CheapLogicA.jpg
Device: 16F873, 16F873A or 16F876A
This is a very cheap logic analyzer that can be built for about $10. The hardware is simply a 16F873 with 20 MHz crystal and an RS-232 interface. The specs are not very good but it can be used to solve many problems. I found it very useful for debugging an interface to a serial EEPROM.
My other logic analyzer: CDP1802CD CMOS processor built in 1985 using 1970's Technology
Number of Channels Number of Samples Max Sample Rate Min Sample Rate 8 96 400ns/sample - 8 160 1us/sample 20ms/sample 4 320 2us/sample 20ms/sample 2 640 2us/sample 20ms/sample 1 1280 2us/sample 20ms/sample ![]()
Click on pictures for larger viewPIC project: CBTimelapse.zip (just the main source TimeLapse.c)
Cassette Interface:
Schematic: TimeLapse.jpg
Device: 16F876A
This project controls my old cannon S10 digital camera using a soleniod to take pictures during a specified time at a specified rate. The images are then processed to create a movie that can be played on a computer or authored onto a DVD. A serial port is included to allow the firmware to be upgraded or used for direct computer control or to allow custom time tables to be downloaded. My dream is to hook ups some stepper motors to be able to control the view as well one day.
PIC project: CBCassetteInt.zip (just the source CassetteInt.c ) (V1.0 1-31-2007)
PC Side Code: CassetteInt.zipcommon.zip
Schematic: CassetteInt.jpg (V1.0 7-16-2007)
Device: 16F876A
This project replaces a cassette recorder which was used for program and data storage for a vintage computer with a box and an RS-232 interface to a modern computer. This allows old programs and data to be saved as ASCII hex files and then later played back. The PIC processor A/D block is used to sample the REC input and convert the serial data to 8-bit binary numbers. These values are saved in RAM and then set to the modern computer via the RS-232 interface. The speaker out jack is driven out to the vintage computer in response to commands sent from the modern computer from the RS-232 interface. The timing and voltage settings have been hard wired for my first computer using constants but a slight change to the PIC code could be made to allow the values to be changed via host PC side software.
Here is a link to my first computer that uses this machine.
Half Baked Projects:Temperature Logger:PIC project: DataLog.zip (just the source datalog.asm )
Schematic: DataLogger.jpg
Device: 16F873This project uses a LM325Z temperature sensor to measure the temperature once an hour and save the value into internal RAM, then internal EEPROM then internal flash memory as more samples are taken (an external EEPROM may be used instead). The temperature is converted using the on chip analog to digital converter. The data can be uploaded using an RS-232 connection.The project is battery powered so games will be played to conserve power.
Future Projects:
Last Updated December 22nd, 2008
Home
Send Comments