2016-11-06

The 8 pins PIC12F683 microcontroller is one of the smallest members of the Microchip 8-bit microcontroller families but equipped with powerful peripherals such as ADC and PWM capabilities. This make this tiny microcontroller is suitable for controlling the DC motor speed. In order to demonstrate the PIC12F683 capabilities and to make this tutorial more attractive, I decided to use the PIC12F683 microcontroller to generate simple and yet fascinating laser light show from a cheap keychain laser pointer.



The basic of laser light shown in many entertainments club or park mostly use two method; the first one is to beam the laser shower on the spectators and the second one is to display the laser drawing pattern on the screen. On this tutorial we are going to build the laser projector that displays the spirograph pattern on the screen using the tiny Microchip PIC12F683 microcontroller.

The principle of making the spirograph laser projector is to use at least two DC motors with the attached mirror on it, these mirrors then will deflect the laser beam from one DC motor mirror to the second DC motor mirror and then finally to the screen. By controlling each of the DC motors spinning speed we could generate a fascinating laser spirograph pattern on the screen as shown on this following picture.

The best way to control the DC motor speed is to use the PWM (pulse wave modulation) signal to drive the DC Motor and because we want to change the DC motor speed manually, therefore we need to use the trimport or potentiometer to control each of the DC motors speed. Hmm, this sound like an appropriate job for the microcontroller but could we use this tiny 8 pins PIC12F683 microcontroller to handle this task?

From the datasheet you will notice that the Microchip PIC12F683 microcontroller only has one PWM output (CCP1) and four ADC input channel (AN0, AN1, AN2 and AN3). Because we need two PWM output, therefore instead of using the PIC12F683 microcontroller build in PWM peripheral, in this tutorial I will show you how to generate the PWM signal base on the PIC12F683 microcontroller TIMER0 peripheral. The following is the complete electronic schematic for the laser projector project.

Ok before we go further with the detail; let’s list down the supporting peripherals needed to complete this laser projector project:

Hot glue gun

Keychain laser pointer or any available laser pointer

3xAA, 4.5 volt battery holder for powering the laser pointer, please use the same voltage rate used by your laser pointer.

Two DC motor taken from the discarded PS2 Dual shock joystick

Two toy’s car tire taken from tamiya racing car

CD/DVD for the mirror, use a kitchen scissor to cut the CD/DVD into the two circle shape mirror with approximately 38 mm in diameter

Some toys plastic bricks for holding the DC motor

Breadboard

Hardboard or acrylic is used for the base of our laser projector

Double Tape

The following are the electronic parts and the software development tools that I used to make this laser projector project:

Resistor: 330 (3), 1K (5) and 10K (1)

Trimport: 10K (2)

Capacitor: 100nF (2) and 10nF (1)

One 100uH Inductor

Two 1N4148 Diodes

Two Blue and one Red Light Emitting Diode (LED)

Two 2N2222A transistors

One Mini Push Button Switch

One Microchip PIC12F683 Microcontroller

Microchip MPLAB v8.46 IDE (Integrated Development Environment)

Microchip Macro Assembler MPASMWIN.exe v5.35, mplink.exe v4.35

HI-TECH C Compiler for PIC10/12/16 MCUs (Lite Mode) V9.70

Microchip PICKit3 Programmer (Firmware Suite Version: 01.25.20)

This project is aim as the continuing lessons to my previous posted blog Introduction to PIC Assembly Language Part-1 and Introduction to PIC Assembly Language Part-2, therefore I used the same PIC12F683 board presented in the part 2 which you could down load both of the electronic schematic and the PCB layout designed in Eagle CAD format. The other interesting feature of this laser projector project is; besides the PIC assembly code I also provide the C language version of this project for the C language lover and is compiled with the HI-TECH C Compiler (recently the HI-TECH Software has been acquired by Microchip). This C language version could be used for learning as well as the embedded system programming language comparison.

In this project I also use a new Microchip PICKit3 programmer but of course you could use the Microchip PICKit2 programmer to download the hex code to the PIC12F683 microcontroller flash.



The following is the Laser Projector code in PIC Assembly Language:

The following is the Laser Projector Project code in C Language version:

Generating the PWM (Pulse Width Modulation)

For more detail: Building your own Simple Laser Projector using the Microchip PIC12F683 Microcontroller

The post Building your own Simple Laser Projector using the Microchip PIC12F683 Microcontroller appeared first on PIC Microcontroller.

Show more