Quantcast
Channel: pic12f629 | Battery Guide
Viewing all 85 articles
Browse latest View live

How to getting started with microcontrollers projects using PIC12F629 microcontroller

$
0
0

Microcontrollers are, basically, a computer in a single chip. It contains memory, processor, I/O ports (I/O = Input/Output) and other periphericals. Can you believe a single chip does contain RAM, ROM, CPU, I/O Ports, timers and other gadgets? It only needs a keyboard and display to be a working computer…

getting started with microcontrollers projects

…I almost forgot; It also needs Software.

 

Microcontrollers are expensive ccompared with CMOS or TTLs chips, but using it on any electronic project allows to save parts and money. Here is an example of the same project using Microcontroller and without microcontrollers:

Traffic Light

 WITHOUT Microcontroller:

Without microcontroller

WITH Microcontroller:

A simple 8-pin chip replaces diodes, ICs, resistors, capacitors and transistors. Why? Because the 12F629 chip is a MICROCONTROLLER and replaces all those parts with the SOFTWARE. The software, also known as “code”, “program” or “instructions”. The software looks like this:

 

skpnz
decf bres_hi,f
decfsz bres_mid,f
goto 0xFE
tstf bres_hi
skpz
goto 0x45

 

No idea what is this about? Don’t worry. You will be able to find the HEX files that contains the software for the microcontroller. After some time, you will be able to undestand and make your own programs. Meanwhile, let’s learn what we need to start to build some projects with Microcontrollers.

 

I do use MICROCHIP microcontrollers, also known as Microchip PIC or just PIC. There are some reason why I only use PICs:

 

1. Inexpensive – Some PICs cost less than $2.00 USD.

 

2. Documentation available – All technical specifications and datasheets are available at the Microchip website.

 

3. Lots of projects available – The web shows thousands of projects using Microchip Microcontrollers. Plenty of projects.

 

4. Low cost development – With less than $10.00 USD, I can make my own programmer and start making projects!

For more detail: How to getting started with microcontrollers projects using PIC12F629 microcontroller

The post How to getting started with microcontrollers projects using PIC12F629 microcontroller appeared first on PIC Microcontroller.


A simple display that uses the POV to display messages in the air using PIC12F629 microcontroller

$
0
0

A simple rotating display. Just spin and enjoy. While the “Air display” is rotating, it writes the message on the air. Because the “persistence of the vision”, you will be able to read the message. Here is the circuit:

A simple display

Download the HEX file HEREProgram the PIC with this HEX file. (Use right-click and “Save as”)

 

UPDATE: Nov 6, 2005 – Algorithm is available. You can create your own program in any language using any microcontroller.

 

Build your own Air Display using this algorithm. Sorry, no longer available.

Air Display schematic

The operation is super simple and you don’t need an user manual. Press the button to turn it on. Press the button to change the message and press the button to turn it off.

For more detail: A simple display that uses the POV to display messages in the air using PIC12F629 microcontroller

The post A simple display that uses the POV to display messages in the air using PIC12F629 microcontroller appeared first on PIC Microcontroller.

Ir Light Dimmer v.1 adjusting lights with remote controller using PIC12F629

$
0
0

This is a device for adjusting lights in your home with any type of remote controller (tv, dvd, video,…). Today we are using many devices in our homes to improve quality of our life and this is another example on how you can enhance a simple procedure like switching the lights ON/OFF. It may be difficult to many of us to stand up from our chair only to switch lights, so try imagining yourself doing this with your remote controller.

Here is a solution for you:

The Ir LightDimmer is simple to use, you only need two keys of your remote controller, which are not often used (like teletext keys or similar) or which are not used at all and one push-button that you will put in place of the existing light switch. Ir LightDimmer can memorize two remote controller keys (see “memorizing the remote controller keys” section), so that the first one will be used to turn on lights or increase light intensity, and the other will be used to turn off lights or decrease light intensity.

Schematic Ir Light Dimmer

How it works

We have two ways to control light: either with push-button or with remote controller. Using the push-button, when we apply a short press we can turn ON or OFF lights, but if we press and hold the button more than 300ms the light intensity is increasing to maximum or decreasing to minimum continuously until you press the button. If we press and hold the button so that lights go to maximum 3 times, then device enters “memorizing the remote controller keys” mode.

In a new software version, I will add a “double click” mode (like PC mousses), so when you double click the push-button, the lights go ON to 70%, and slowly decreasing light intensity to minimum in a period of 1 minute. This mode is good for your bedroom, so when you go to sleep just double click the button and go to bed. If you don’t like to wait lights to go OFF in 1 minute, you can break this mode by pressing button or by pressing remote controller keys.

Using remote controller key to control the dimmer you can turn on lights or increase light intensity. With a short press, lights turn ON to maximum and if you press and hold key then light intensity increases until you press that key.

The same thing happens with second remote controller key which is used to turn lights off or decrease light intensity. When you short press that key, the lights will turn OFF and if you press and hold key then light intensity decrease until you press that key.

When turning lights ON or OFF they are not reacting immediately but they change state slowly so your bulbs will have longer life duration. Also with adjusting light intensity you save on electrical energy.

highlights about 5%

highlights about 50%

highlights 100%

Memorizing the remote controller keys

If you have chosen which remote controller keys will be used as controlling keys, we can start with memorizing process. Press and hold button until lights go 3 times to maximum. After that, light will turn OFF, and that is indication of successful entering “memorizing the remote controller keys” mode, then you can release button. In the next 5 seconds, you must press the first key on remote controller, if you do, lights will blink several times. After that, you must press the second remote controller key, if you do, lights will also blink several times. That’s all, memorizing process is finished.

You can change the assigned remote controller keys when you wish. After powering down the Ir LightDimmer, it will keep in memory these remote controller keys, so you don’t have to memorizing remote controller keys again when the device powers up.

Instructions

Ir LightDimmer is a small device (36*32mm) and can be easily mounted in electrical case where electrical wires terminate. Device works only with 220V/50Hz and only for resistive loads of 40W-400W. With Ir LightDimmer you can’t use inductive or capacity loads (only bulbs).

Device is based on PIC12F629 which is a small microchip microcontroller and therefore overall device is small and uses a few components. On circuit board you can find the IR-receiver, which in our case is TSOP1738, but you can use any other type of IR-receiver which has frequency of 38KHz. For output power stage you can use triac TIC206 or TIC216. For loads more than 150W you must add a heat sink on triac. The rest of parts are defined in schematic.

You must be careful when you connect IrLightDimmer to electrical wire, so you must break fuse switches of your lights. All connections must be like in my schematic, otherwise device will definitive burn out.

If you have IrLightDimmer mounted and connected and you want to change your lights, you must break fuse switches because there is risk of electric shock.

Circuit board can be downloaded here:
IrLightDimmerSfh.pcb or IrLightDimmerTsop.pcb
Ir LightDimmerTsop.pdf – circuit board in pdf format

Dimming The Lights with remote controller, device Ir Light Dimmer, has got a new and simplest version. The most significant change is microcontroller PIC12F629 in Small-Outline Integrated Circuit (SOIC) package, TSOP2238 ir receiver instead of TSOP1738, and less components on circuit board.
So, at that way dimension of circuit board is shrink from 36 x 32 mm, to 27 x 21 mm.

All function of that version is the same like above described device Ir Light Dimmer v.1, so it’s no diference in software, only in schematic and in circuit board.

You must be careful when you connect IrLightDimmer to electrical wire, so you must break fuse switches of your lights. All connections must be like in my schematic, otherwise device will definitive burn out. experience in electrics, it’s better way t call skilled person to mount your Ir Light Dimmer.If you don’t have any

Schematic Ir Light Dimmer – PIC12F629 smd

Ir Light Dimmer v.1 works only with 220V/50Hz and only for resistive loads of 40W-400W. With Ir LightDimmer you can’t use inductive or capacity loads (only bulbs).

Source : Ir Light Dimmer v.1 adjusting lights with remote controller using PIC12F629

The post Ir Light Dimmer v.1 adjusting lights with remote controller using PIC12F629 appeared first on PIC Microcontroller.

Radio Button Switch Control using PIC12F629

$
0
0

Overview

The original purpose behind this circuit was to provide manual switching of three relays such that only one relay was on at any time.  It was also a requirement that there was a specific overlap (or make-before-break) period.  The code was then further developed to provide deadband (break-before-make) as well as overlap switching.  The mode and timing delay are stored as parameters in the PICs EEPROM memory making editing of these straightforward without the need to reassemble the source code.

Switch Control

This circuit controls up to three outputs using a ‘radio button’ type switching control.  When any one of the channel inputs is selected, the corresponding output is turned on and all other outputs are turned off.

In addition to this the controller features adjustable deadband or overlap of the outputs during switchover.

  • With dead band delay or break-before-make operation the active output is turned off before the new output is turned on.
  • With overlap or make-before-break operation the new output is turned on before the active output is turned off.

The delay is configurable in 0.512mS intervals from 0 to 130.56mS

The control inputs also feature a configurable debounce timer with the same range of timings making it suitable for use with simple switches directly attached to the PIC or logic interface.

Although designed to control relays the firmware is quite generic and can be used in any application where ‘radio button’ functionailty is needed.

(14/11/2012 – Source code and firmware for 8 Channel version for PIC16F628A)

schematic #3

The schematics above are intended to show the general application of the Radio Button Switch Control. Schematic #1 and #3 in particular can be used to build a simple firmware evaluation circuit.


Mode Examples

In this section I’ve used a Saleae Logic tool to illustrate the output operating modes and effect of input switch debounce delay.


Make-before-break

In the example below Output 3 turns on before Output 2 turns off.  The overlap is 99.36mS as the T1-T2 marker flags show

Firmware notes:

  • All timings are derived from the PICs internal RC oscillator and accuracy is dependant on the same.

  • The main code is interrupt driven so all switching events are synchronous with the interrupt interval of 512uS (0.512mS)

  • The switch inputs are only sampled at each interrupt so even with the switch debounce timer set to zero there may be a delay of up of up to 512uS before a output switching event occurs.

  • Within the interrupt handler there are additional delays depending on the mode and switch debounce timing. These are not specified but fall in the range of 10-30 microseconds and are deterministic.

    Since the firmware code was originally written to operate mechanical relays under the control of manual push button switches this timing accuracy was considered sufficient and is likely to be so for any similar application.
    However, you should take this into account when considering it for use in a specific application.

For more detail: Radio Button Switch Control using PIC12F629

The post Radio Button Switch Control using PIC12F629 appeared first on PIC Microcontroller.

IR Remote Control Repeater using PIC12F629

$
0
0

This circuit receives the signal from a IR remote control, like those used to control your TV or DVD player and allows the signal to be repeated in another location.  

IR Remote Control Repeater

To get a 40Khz carrier requires an output to be toggled on and off 40,000 times a second, which means the code needs to execute in 1,000,000/40,000 instruction cycles; this gives a very tight 25 instructions in which to do the job. Fortunately it’s an easy job to do so most of the instructions are just used to waste cycles.  It’s not easy to get an accurate frequency with so little time and  few instructions cycles to play with but the IR receivers  will work several Khz either side of their design detection frequency so it’s not a problem.

This code can generate a 40Khz, 38.4Khz or 37Khz carrier with a ~15% duty cycle.  The frequencies are configurable in the source code such that once programmed GPIO5 input on the PIC allows the selection of two frequencies.  By default the code is set to produce 40Khz and 37Khz carriers which are modulated by the logic level on GPIO2.  This would generally be connected to a IR decoder IC.

One thing I did find with the Sony equipment (I haven’t tested it with anything else), 875nM IR LEDs don’t seem to work, but the 950nM one specified works well. (TSUS5400, Mfg Vishay. Available from Farnell, part number 178302)

  • Source Code (supports 12F629, 12F675, 12F683 21/06/2009)
  • Hex (right-click Save As) for 12F675 / 12F629.
  • Hex (right-click Save As) for 12F683
  • Schematic

 

For more detail: IR Remote Control Repeater using PIC12F629

The post IR Remote Control Repeater using PIC12F629 appeared first on PIC Microcontroller.

Internal Oscillator Recalibration Utility for PIC12F629

$
0
0

Description

The PIC 12F629 and 12F675 devices have an internal 4Mhz oscillator that enables the devices to be used without an external crystal or RC network.  This frees up one or two pins for I/O use and allows the device to be built into minimum component count designs.

The internal oscillator needs to be calibrated and this is achieved by reading a factory programmed calibration setting and writing it into the OSCCAL register during initialisation of the device by the application software.

Internal Oscillator Recalibration

The calibration word is located at the last address in the user program memory area, address 0x3FF.  It is in the form of a RETLW instruction and the user code should include a CALL 0x3FF instruction which will return with the calibration setting in the W register. This can then be written into the OSSCAL register.

Problems arise if by accident or otherwise, the program memory at address 0x3FF is erased or over written.  Since the calibration value is unique to each individual PIC there is no way to know what it was, but it is possible to recover it by recalibrating against a known frequency.

That’s where this software and circuit come into their own.  Load a PIC with the code on this page and drop it into the circuit described here and within a couple of seconds it will provide a new calibration value to ensure the internal oscillator runs within 1% of 4Mhz.

PICkit 2 update

If you have a PICkit 2 programmer, get version 2.50 (or later) software from the Microchip website.  This includes a menu option to recalibrate and reprogram the OSSCAL setting in one operation.  This project page remains here for those who don’t have access to a PICkit2.

How it works

In order to calibrate the internal oscillator a known reference frequency is needed. Fortunately we don’t need signal generators or calibrated test equipment for this. In fact an accurate reference is available from the AC utility electric supply.  In most parts of the World the utility electricity supply is generated at a frequency of either 50 or 60Hz (many digital clocks take advantage of this fact to keep time)

Using almost any transformer (or Wall Wart) with a 6 to 12 volt RMS AC output we can obtain an accurate reference source to calibrate the PICs oscillator against.

Schematics, Construction, and Code

So let’s get on with it.  Construct the circuit shown below using a piece of strip or pad board, or just hook it up on a solderless breadboard.


 

For more detail: Internal Oscillator Recalibration Utility for PIC12F629

The post Internal Oscillator Recalibration Utility for PIC12F629 appeared first on PIC Microcontroller.

WORLD’S SIMPLEST PROGRAM using PIC12F629

$
0
0

This is where you start with programming. Build the PIC Programmer MkV and build the World’s Simplest circuit on a PC board for a PIC12F629 chip, LED and resistor.
When the World’s Simplest Program is “burnt” into the chip, the LED will flash.
This is not a “normal” program as the Watch-Dog Timer has been turned ON and after 18mS it resets the chip to “org 0X00” and the program executes the 8 instructions again.

Worlds Simplest programme


At the 6th and 7th instruction, the state of GP4 will change from HIGH to LOW or LOW to HIGH and this will toggle the LED.
At the 8th instruction the micro will go to sleep and after about 18,000 microseconds, it will be woken up by the watch-dog timer and go to location 0x00.
At instruction 3, we have added a pre-scaler to the WDT to extend its timing to 18mS x 8 = 0.144Secs. You can change this value and note the different flash-rate.
Making bit 3 of the option_reg = 0 will produce a very fast flash-rate as the prescaler will be removed from the WDT.
This program tests your programmer and the chip you are burning as well as the circuit containing the LED.
It also shows the function of the watch-dog timer.
Normally, when the WDT is turned ON, it must be periodically cleared (reset) via the instruction clrwdt so that it does not come into operation.
For instance, before entering a delay loop, the WDT is reset.
If not, it may reset your program and you will be wondering why your project does not work.
Go to
PIC12F629 data and read page 12: OPTION Register. It shows how the bits are allocated to the WDT. Change these bits and see how the flash-rate changes.

Here are the files:
World’sSimplest.asm
World’sSimplest.hex

;*************************************
;WORLDS SIMPLEST PROGRAM             *
;  18-5-2010                         *
;                                    *
;************************************

	list	p=12F629
	radix	dec
	include	"p12f629.inc"		
		
	__CONFIG  _MCLRE_OFF & _CP_OFF & 
                _WDT_ON & _INTRC_OSC_NOCLKOUT  ;Internal osc.

;************************************
;Beginning of program
;************************************
	org	0x00
	bsf	status, rp0 	;bank 1		
	bcf	TRISIO,4	;GP4 output		
	movlw   b'00001011' ;bit3=1=WDT  011=/8 WDT=18mSx8=0.144Sec
        movwf   option_reg     	;must be in bank 1
        bcf	status, rp0	;bank 0	
        movlw	b'00010000'	;to toggle GP4
	xorwf	GPIO,f
	sleep
		
	END

Here are some changes you can make to see the differing flash-rates: 
change
sleep
to:
goto    $

change

movlw   b’00001011′
movwf   option_reg

to:

movlw   b’00001111′
movwf   option_reg

or to:

movlw   b’00000111′
movwf   option_reg

 

Source : WORLD’S SIMPLEST PROGRAM using PIC12F629

The post WORLD’S SIMPLEST PROGRAM using PIC12F629 appeared first on PIC Microcontroller.

HAPPY BIRTHDAY using PIC12F629 Microcontroller

$
0
0

Why spend $10.00 on a Happy Birthday musical card when you can produce the tune yourself.
This project uses just 4 components and a small prototype PC board to produce a project that will teach you a lot about programming.
The circuit uses a piezo diaphragm connected to pins 3 and 5.
That’s the only component.
All the work is done by the program.
The project is so easy, we don’t need to provide any construction details

Happy Birthday

 

Here are the files:
HappyBirthday.asm
HappyBirthday.hex

Here is the program.
You must use the .hex file to “burn” the chip or the .asm file as these are laid out so that the compiler and programmer can understand the data.
The following program is just for viewing.

 

For more detail: HAPPY BIRTHDAY using PIC12F629 Microcontroller

The post HAPPY BIRTHDAY using PIC12F629 Microcontroller appeared first on PIC Microcontroller.


RGB LED PWM Driver Standalone PWM controller for RGB LEDs using PIC12F629

$
0
0

Want to build an RGB LED controller that you can program with your own custom sequences and effects? Then read on. 

The RGB LED controller has proved to be very popular project and has been the most frequently downloaded code on the site since it was made available.  I’ve been contacted by people who have incorporated this project into all kinds of things including mood lamps, lighting for a sculpture, accent lighting for rooms and an illuminated prize trophy.

For 2006 I  completely rewrote the application making it much easier to add, edit and change the sequence data.  I also added a sleep function so a battery operated version can be built that doesn’t need a power switch. 

For 2008 I’ve released version 3 of the code which now allows you to stop the running sequence at any point so you can ‘freeze’ a colour.

All code runs on the 12F629, 12F675 and the newer 12F683 which, with 2K of program memory has plenty of room for user sequences.

RGB LED PWM Driver

Description

The original RGB PWM driver application that I wrote in 2004 had a few shortcomings. Probably the biggest was that it was not easy to add to or change the sequences.  This new version addresses that problem, is more flexible and now includes the ability to put the PIC to ‘sleep’ and ‘wake’ it again using the sequence select switch, eliminating the need for an on/off switch in battery powered applications.

The circuit uses (RGB) Red, Green and Blue high brightness LEDs that are pulse width modulated (PWM) to vary the intensity of each colour LED.  This allows effectively any colour to be generated with rapid changing strobe effects, fast and slow colour fades as well as static colours.   The data used to set and change the colours is held in an easy to edit file so if you don’t like the sequences provided with it, you can modify the sequence data include file yourself and reprogram with your own sequences.

The code can be assembled for use with the following PICs: 12F629, 12F675, 12F683.  Just select the correct processor in the MPLAB IDE before assembling.

How bright are the LEDs

That depends on the specific LEDs you use, the current you drive them with, the angle your view them from etc……..

If you want to know I suggest the best thing to do is buy the LEDs you’re planning to use and connect them up directly to a power supply using a suitable current limiting resistor.  If the brightness meets your expectations than go ahead and build this project, but if they don’t they aren’t going to be any brighter in this circuit so you probably need to look at an alternative solution like a large array of LEDs driven with the Power MOSFET Driver project  

Download schematic as PDF

Since I do not know exactly which LEDs you will use I’ve specified the LED current limiting resistors on the conservative side.  You may want to change the value of these resistors to suit the actual LEDs used.  Keep the current per channel to under 40mA maximum.

LED resistor calculator http://led.linear1.org/led.wiz

If you wish to etch your own board, you can download the PCB artwork as PDF
For the component overlay, please refer to the photo’s below

 

For more detail: RGB LED PWM Driver Standalone PWM controller for  RGB LEDs using PIC12F629

The post RGB LED PWM Driver Standalone PWM controller for RGB LEDs using PIC12F629 appeared first on PIC Microcontroller.

RGB LED Strip Controller high-side LED drive for PIC12F629

$
0
0

Recently I acquired a 5M length of RGB LED strip using SMD5050 RGB LEDs.  It has built in current limit resistors designed for operation from a 12 volt supply.  Having thought this would directly attach to the Picprojects MOSFET RGB LED driver project  I went ahead and bought one only to discover when it arrived that it wasn’t going to be that easy.

Despite the description and markings on the supplied strip indicating it had a common anode connection it is in fact common cathode.  The terminal marked ‘+’ in the photo below is a common ground connection – go figure?

Assembled board

What is required is a high-side driver so the three LED anodes can be controlled by the PWM output from the PIC microcontroller while the common wire connects to ground. 

With the requirement defined I decided to put together a quick project to work with the LED strip.  The controller on this page is an adaption of the RGB Mood Light 101 project, firmware is the same and can be downloaded from that project page.

You should be aware that not all LED strips use a common ground, I have 1 metre strip that is wired with a common ‘+’ or high-side and works pefectly using the Power MOSFET RGB LED driver kit 106  See my notes on LED strips here

Please note:

This project is NOT available as a kit, or PCB nor can I supply the LED strip.

Circuit Description

The circuit is essentialy the same as the RGB101 Mood Light project and uses exactly the same fimware.  Where it differs is in the LED output drive stage.  Instead of the BC548 transistor (Q1-Q3) driving the LEDs directly they are used to switch a second set of transistors (Q4-Q6).  These are STX790A medium power PNP transistors switching the 12 volt or high-side of the power supply.  

The current rating of each colour in the strip is around 1.5 amps which needs a medium power transistor to control it.  I’ve avoided using a P-channel MOSFET as they are both expensive and less easy to obtain.

The transistor used for the final output is an STX790A  rated at a maximum collector current of 3 amps, with a minimum current gain of 100. The LED strips I used require about 1 to 1.5 amps per colour.    Base current for Q4-Q6 is derived from the collector current of the BC548 transistors (Q1-Q3) via R1 – R3.  Resistors R1-R3 provide around 20mA of base current to the STX790A.  I’ve used 560R 0.25 watt carbon film resistors here, they are operating right on their power dissipation limit for a 0.25 watt resistor.  Since the transistors are driven with a PWM signal average power dissipation is lower so not an issue.

If you decide to use an alternative transistor type for Q4-Q6 and need to increase the base current you’ll need to use a 1/2 watt resistor or go for a metal film 0.4 watt or 0.6 watt which are the same physical size as a 0.25 watt carbon film.

For Q1-Q3 any small signal NPN transistor will work.  BC546, BC547 or BC549 are also suitable and have the same pinout as the BC548.

If you need more than 2 amps per LED channel you will need to do some redesign of the final transistor output section since the circuit is not designed to handle more than 2 amps on each channel.

The rest of the circuit is straight forward.

The 12 volt input to the board is fed through D1 to a 78L05 5-volt regulator (IC2).  D1 provides reverse polarity protection to the regulator though it should be noted this does not protect the LEDs and final driver transistors since due to the high current requirements of the LED strip it is not practical to use a diode here.

Capacitor C1 provides decoupling of the 5 volt supply.  Capacitor C2 provides filtering on the input side of the regulator.  C1 should be as close to the PICs Vdd/Vss power input (pins 1/8) as practical.  The 78L05 and C2 should also be reasonably close to each other and the PIC.  R7 provides a pull-up for the PICs MCLR reset input.

S1 is the mode control switch.  JP3 just provides a pair of 0.1″ spaced pads for connecting a remote switch if the board is built into a housing.

JP2 is the LED output connector.  Take note of the connections on this.  The ground, red, green and blue connections have been placed to match the LED strip I was using.  You should verify the connections to the specific LED strip you use to ensure they are the same. (see notes on LED strips here)

Also remember the board switches the high or 12 volt side with the ground connection being common to all three LED colours.   If you have a common anode strip you will need the Power MOSFET project.

R8/C3/JP1 are not used, do not fit components.

 

For more detail: RGB LED Strip Controller high-side LED drive for PIC12F629

The post RGB LED Strip Controller high-side LED drive for PIC12F629 appeared first on PIC Microcontroller.

Pic RGB color generator using PIC12F629

$
0
0

Description

PIC RGB is a circuit that generates random RGB colors using a RGB LED and fades between them. The idea for this circuit came from the candle simulator [1] and another project called TinyRGB [2] .
The challenge was to create an algorithm that could fade 3 independent colors at different speeds in the same time interval, using integer math, (of course).

There are other enhanced versions of this project named Pic RGB Power board and Pic RGB Power board with Infrared remote control. Both circuits drive a powerful 3W Prolight RGB LED.

RGB color generator

Design and Implementation

The PIC may be any small 12F***, as long as they have 1KWords of flash and two timers. Below at the downloads section are two hex files for PICs 12F629 and 12F675 [3].

 

Schematic

Basic schematic includes a voltage regulator 78L05, the PIC with a decoupling capacitor and a few resistors.

Since each PIC pin can supply a maximum of 25mA of current, and the LED specification indicates a maximum of 25mA, the LED resistors were calculated to provide 20mA of current in each color.

Vred = 2.1V, Vgreen=3.4 and Vblue=3.5V

R=V/I

Rred = 145 Ohm -> 150 Ohm

Rgreen = 80 Ohm -> 82 Ohm

Rblue = 75 Ohm -> 82 Ohm

The push-button switches between running modes, random and sequence.

Schematic Pic RGB color generator

PCB

The PCB and Schematic were created using Eagle from Cadsoft and are available below at the downloads section. Click on the image below to expand it and have a look at the top placement information.

Note: PIC pin1 is the lower right one.

 

For more detail: Pic RGB color generator using PIC12F629

The post Pic RGB color generator using PIC12F629 appeared first on PIC Microcontroller.

Ir On-Off using PIC12F629 microcontroller

$
0
0

Turn ON or OFF electrical devices using remote control is not a new idea and you can find so many different devices doing that very well. For realization of this type of device, you must make a receiver, a transmitter and understand their way of communication.

Ir On-Off

Here you will have a chance to make that device, but you will need to make only the receiver, because your transmitter will be the remote controller of your tv, or video …This is one simple example of this kind of device, and I will call it IrOn-Off or Ir-switch.

How it works

Choose one key on your remote controller (from tv, video or similar), memorized it following a simple procedure and with that key you will able to turn ON or OFF any electrical device you wish. So, with every short press of that key, you change the state of relay in receiver (Ir-switch).

circuit board

components

Memorizing remote controller key is simple and you can do it following this procedure: press key on Ir-switch and led-diode will turn ON. Now you can release key on Ir-switch, and press key on your remote controller. If you do that, led-diode will blink, and your memorizing process is finished.

Schematic Ir On-Off

Instructions

To make this device will be no problem even for beginners in electronic, because it is a simple device and uses only a few components. On schematic you can see that you need microcontroller PIC12F629, ir-receiver TSOP1738 (it can be any type of receiver TSOP or SFH) and for relay you can use any type of relay with 12V coil.

Program code for this device is used from IrLightDimmer and it’s only a subroutine, which is used for memorize and recognize ir-protocol.

Source : Ir On-Off using PIC12F629 microcontroller

The post Ir On-Off using PIC12F629 microcontroller appeared first on PIC Microcontroller.

The IR Widget Using pic12f629

$
0
0

Simple IR capture for multitasking operating systems

The IR Widget captures the infrared signals used by remote controls. It operates in a way that makes it compatible with modern multitasking operating systems. It is able to determine the carrier frequency and demodulate the carrier in the digital or analog domain. The captured information can be used to view, recognize or reproduce the signal. The hardware is designed to be as simple and low cost as possible. A PIC12F629 was used for development, but almost any PIC that uses the 12 or 14 bit instruction set could be used.

IR Widget

Limitations of simple IR capture circuits

The usual approach to low cost IR capture typically consists of an IR detector or demodulator module connected to a serial or parallel port. This can work quite well when the CPU is dedicated to servicing the port. It often performs poorly within a preemptive multitasking operating system. The OS is constantly servicing hardware interrupts even when the system is idle, so the IR capture is constantly interrupted. Disabling hardware interrupt handling is dangerous and may be prohibited by the OS. CPU usage is high when polling is used. Using the hardware interrupt capability of the port can greatly reduce CPU load, but interrupt latency may cause inaccurate results. Boosting thread priority may help, but results vary. Parallel and serial ports are becoming less common, and USB adapters do not work for these simple circuits.

Limitations of microcontroller based circuits

There are many DIY and commercial products that use a microcontroller to process the IR signal. These are typically intended for remote control rather than research. Many of them have only an IR demodulator, so they can not determine the carrier frequency or report precise timing. The data sent to the host computer may be in a format that does not allow reconstruction of the actual literal IR signal. The acquisition duration is often limited to a single key press of the remote, making capture of macros difficult or impossible.

A different approach to simple IR capture

The IR Widget solves these problems by using a microcontroller to process the IR signal without interruption and send the data to the PC using ordinary asynchronous serial transmission. This allows the OS to service the serial port with standard drivers and allows the use of USB to serial converters. Simple circuits built with 74HC series parts can also be used. The data is sent in real time and is in a format that allows reasonably precise reconstruction of the actual IR signal received.

An infrared detector module is used to allow the microcontroller to see every infrared pulse at close range. This allows for greatest detail and accuracy. An optional infrared demodulator module can also be used to allow for long range reception with less detail.

The circuit is powered from the serial port. USB to serial converters work well and their use is recommended.

schematic IR Widget

Carrier frequency measurement

Infrared remotes typically use a carrier frequency of 30 to 60 kHz. The carrier is keyed full on and full off. Carrier on durations typically range from 400 microseconds to several milliseconds. Carrier off durations typically range from 400 microseconds to more than 100 milliseconds. The IR Widget requires minimum on and off durations of 300 microseconds. This ensures that there will be at least 3 consecutive 100 microsecond sample periods during the on and off states.

To measure the frequency of a pulsed carrier, a short gate time is required. An ordinary frequency counter with 1 second gate will not give an accurate reading. The frequency could be determined from the period of one cycle, but this would require a rather high resolution measurement for a precise reading.

The IR Widget counts the number of infrared pulses that occur within a 100 microsecond period. The count is sent to the PC at 115200 bps. This repeats every 100 microseconds. This is effectively a frequency counter with a 100 microsecond gate time.

A single sample period can not provide a precise frequency measurement. To calculate the carrier frequency with greater precision many sample periods are used. All the non-zero counts are summed excluding the first and last in a burst. As long as there are pulses of 300 microseconds or greater duration, there will be samples from periods where the carrier was on for the entire sample period. The frequency is simply the sum of the pulse counts divided by the sum of the period durations. The result is not exact, but is accurate enough to determine which of the common frequencies was used.

Pulse time measurement

Once the carrier frequency is know, the first and last sample periods of each burst can be evaluated to determine the duration of the carrier during those periods. The on duration is the count of pulses within the period multiplied by the duration of each pulse (reciprocal of the carrier frequency). The off duration is simply the period duration minus the on duration.

For more Detail: The IR Widget Using pic12f629

The post The IR Widget Using pic12f629 appeared first on PIC Microcontroller.

Build your own Wireless Network detector using PIC12F629

$
0
0

What This Is

This project is for a small electronic unit that allows the user to sense the presence and relative signal strength of wireless hotspots. It can be worn as a pendant or carried in a pocket. It is “always on” and communicates the presence and signal strength of an in-range hotspot by way of sequences of pulses – like a heartbeat you can feel. The stronger and faster the “heartbeat”, the stronger the wireless signal detected.

sensor guts illustrated

It does not actually authenticate or otherwise interact with a hotspot in any way. It is a 100% passive device, meaning it transmits nothing — it can detect hotspots, but cannot be detected itself.

How It Was Made

This project consists of a microcontroller, some custom interface electronics, a small vibe motor, and an off-the-shelf Wi-Fi detector – the one I used is by D-Link and is keychain-sized.

Here is the sensor I used, and some pictures of the construction. Details of the design will follow.

How It Works

The microcontroller periodically “presses” the button on the detector to initiate a reading. Then the microcontroller “reads” the output from the indicator LEDs on the detector, and uses this as the basis for pulsing out a signal on the vibe motor, which the wearer can feel.

In this way, the unit keeps you updated on the presence and signal strength of a wireless hotspot in your vicinity. No pulses means no signal. Short pulses means a weak signal. Faster, more frequent pulses means a stronger signal. This feedback is very much like a heartbeat, and is extremely intuitive to interpret.

How To Make Your Own

First of all, I use a microcontroller in this project. If you aren’t familiar with terms like 12F629 or .HEX files and how to blast them into a PIC, you will have trouble with this project.

The D-Link sensor I used works like this — press the button and the LEDs light up in a “scanning” pattern while it looks for a signal. It can be in this scanning pattern for up to a few seconds. Afterwards, it lights up either one, two, three, or four of the green LEDs to indicate relative signal strength. If there is no signal detected, a single red LED is lit. The LED(s) remain lit for a few seconds, then the sensor shuts off.

If your chosen sensor works differently, you will need to adjust the electronic interface and the program in the microcontroller accordingly.

 

For more detail: Build your own Wireless Network detector using PIC12F629

The post Build your own Wireless Network detector using PIC12F629 appeared first on PIC Microcontroller.

Lift Counter using PIC12F629 Microcontroller

$
0
0

This project has been developed due to a request from Mr Moshweunyane (dmoshweunyane8@gmail.com). He asked for a circuit that would count up when someone entered a lift and count down when someone exited, using two infra-red sensors.
All we had to do was take the 2-digit up/down counter and add two optical sensors.
These sensors could be any type of detector and we have shown two LDR’s (Light Dependent Resistors) and two amplifying transistors mounted on a sub-board. You can use infrared or photo-transistors as the sensors to get equal results.
All the “detection” is done via the software and the program “polls” the detectors and works out if a person is entering or leaving the lift.

Lift Counter
The reason for polling the sensors is clever. It prevents the micro being caught in a loop and allows the program to display numbers at the same time.
The same design can be used for a shop or any activity where you need to know if a room is getting too crowded.
This arrangement has been requested for bathrooms in an attempt to control and avoid unsavory behavior.
The circuit is designed around a PIC16F628A. It has been presented on an experimental PC board using surface-mount components and was built in less than 1 hour, with about 2 hours to write and finalise the program.
It uses “In Circuit Programming” via PICkit-2 or Talking Electronics Multi-Chip Programmer, plus the adapter (specific to each programmer) shown below.
You can add an alarm feature if the lift gets overcrowded or if someone is in the bathroom when the shop is closing.

This project has been created as an add-on for the 2-Digit Counter. We placed the two transistors, LDR’s and pots on a small PC board and connected it to the 2-Digit Counter via a plug and socket.

The light detectors have to be set up for the application. The best is to use infra-red detectors as they are not upset by ambient light.
Each detector has to be set up so that light falling on the detector makes the input line LOW.
When the beam is broken, the line goes HIGH.
We have directly coupled the output of the detector to the micro however you could use capacitor coupling  and breaking the beam will produce a pulse.

The files for Lift Counter
LiftCounter.asm  
LiftCounter.hex
LiftCounter-asm.txt (.asm)
LiftCounter-hex.txt (.hex)

 

For more detail: Lift Counter using PIC12F629 Microcontroller

The post Lift Counter using PIC12F629 Microcontroller appeared first on PIC Microcontroller.


MUSIC BOX using PIC12F629 Microcontroller

$
0
0

This project is an extension of a number of musical projects (Happy Birthday and It’s a Small World) and puts 11 melodies into a single design.
It’s called EVOLUTION.
From the previous projects we learnt a lot about producing a tune.
The first thing we learnt: it takes a lot of memory.
Each note needs one, two, or even three bytes and this severely limits the length of the tune, as the PIC12F629 has a maximum of 256 bytes for a table and this can only be placed in the first page of memory (the chip does not have the facility to access a table in any other part of  memory).
We had to re-design the program so all of the 1024 locations of program-space could be used.

Music Box
This was done by omitting tables and using the program-space for the data-bytes.
We reduced the data-requirement further by requiring only a single byte to produce the length of the HIGH. The length of the LOW was obviously the same duration.
But now we had a problem.
To produce a note of say 300mS, we had to supply data for the number of cycles. Obviously a high frequency needs more cycles for 300mS, than a low-frequency note.
The answer was to complement the data-bye.
This produced a result very near to 300mS.
The only other thing we had to produce was a note of a suitable length.
This was done by shifting the file right (rrf) to get a value of 50% and adding it to the original value, plus performing other operations to generate the correct length.
This has changed the capacity of the project from 2 tunes to 11, with NO bytes to spare. You cannot use location 3FF for your program as it is used by the micro to store the oscillator value.
We have also included a button to increment through the tunes.
When the project is first turned on, it will play each tune twice. If the switch is pressed, the project will go to the first tune and it will be repeated. If it is pressed again, the second tune will be selected and repeated.  See below for more details on this.
The melodies are recognisable but some of the notes are very hard to reproduce in monotone and we have left it up to an aspiring musical person to alter the tones to create an improvement.

THE CIRCUIT
The circuit uses just a few components on a small prototype PC board. It’s easy to construct and ideal for a beginner.  It’s just a PIC chip, a piezo diaphragm and a switch. You can put it together in a few minutes on a prototype board and download the program from the website.
The pull-up resistor for the switch is inside the chip and this saves one component. We have not placed a 100n across the chip and this is another component saved.  The circuit takes less than 1mA and everything else is inside the chip via a program.
The photo shows the prototype.
If you want to buy a kits, there are two versions:
Version 1 comes as a piece of matrix board consisting of solder lands. After placing and soldering the components to the lands, they are joined with fine tinned copper wire to represent the tracks of a printed circuit board.
Version 2 has a PC board and a battery snap for a 9v battery. Three LEDs on the board regulate the voltage to 5v and also act as an “ON” indicator.
Music Box has a memory feature.  Any of the tunes can be selected and when the project is turned on  again, the selected melody will repeat.
Simply increment through the melodies via the button and turn the project off. Turn the project on to hear the selected melody.
To erase the selection, push the button when the project is off and turn it on. Release the button immediately and the program will start at the first melody and play each twice.
This feature uses the EEPROM and the program below shows exactly how to use these instructions to perform read and write operations.
When creating your own program, these instructions should always be copied and pasted to prevent a mistake.
The full 1024 program locations have been used in this project plus the first location in EEPROM.


PRODUCING A TONE
Producing a tone is very easy. All you have to do is make an output go HIGH then LOW at a controlled rate.
The output goes HIGH and stays HIGH for a certain number of microseconds then goes LOW and stays LOW for the same time. If the HIGH and LOW times are not the same, the tone is not very “clean” and does not have a “ring” about it.
In our case, we have connected the piezo diaphragm to two outputs to increase the volume.
When one output goes HIGH the other goes LOW and vise versa. This causes the piezo to see an increased voltage because the piezo is actually a capacitor of about 22n and when it gets a voltage on one direction, it charges to a voltage equal to the applied voltage.
To make the discussion easy to understand, let’s say one lead is fixed at 0v, and the other lead is now supplied with a reverse voltage. The potential of the other lead will change from say a positive voltage to a negative voltage. This is a swing of twice the value of the supply and the additional voltage produces a louder output.

 

For more detail: MUSIC BOX using PIC12F629 Microcontroller

The post MUSIC BOX using PIC12F629 Microcontroller appeared first on PIC Microcontroller.

SKY WRITER using PIC12F629 Microcontroller

$
0
0

We have seen many projects using a set of LEDs to produce words “in the air,” but none have the clever feature we have included.
Most of the projects are “shaken in the air” and produce messages that are “all over the place.” But if the words are jumping they are difficult to read.
Our project solves this. It produces words that re-appear in the same position so they are easy to read.

SKY WRITER

The secret is called REGISTRATION.
Our design detects the start of the sweep and starts to display the letters.
This is due to the inclusion of a switch called an INERTIA SWITCH that detects rapid deceleration and starts the display. More about this later.

THE CIRCUIT
The circuit is very simple. All the work is done by the micro. We have produced two different prototypes to show the effect using surface-mount LEDs and super high-bright white LEDs with two LEDs per output and this is really effective.  

THE INERTIA SWITCH
There are two types of inertia switch. One is a weight on a spring and the other is a ball riding up an incline.
We have used both and they work equally-well and it’s just a matter of which type you want to use.

To make the inertia switch yourself, it is a small ferrule on a wire. A length of tinned copper wire wound around it and pulled tight and acts as a spring to keep the contacts open.  These contacts are connected to pin 4 of the microcontroller.
You can check the operation of this switch by connecting a LED and resistor to the supply and waving the PC board. You will find the LED illuminates at almost the exact same place “in space” making it an ideal registration-mark for aligning the words.
Once you have a reliable starting-point for creating the display, you can make almost any effect using the 5 LEDs. There are almost no limits as the display can be 100 or more pixels long, and 5 pixels high.
You can change the wording and add more features. To do this you need a programmer and software. For details on this, see Pick A PIC Project.

The table we have used in the program occupies nearly all the space available (for a table), however you can add other features by studying some of our other projects.

The circuit has two super high-bright LEDs on each output to give a very impressive display. The “inertia switch is shown as the blue rectangular component. It has a ball-bearing that hits both the top and bottom conductors (without jamming) when the ball rolls in one direction. The plastic molding prevents the ball touching both conductors when it rolls in the opposite direction.

 

For more detail: SKY WRITER using PIC12F629 Microcontroller

The post SKY WRITER using PIC12F629 Microcontroller appeared first on PIC Microcontroller.

SOLAR TRACKER-1 using PIC12F629 Microcontroller

$
0
0

This project will improve the output of your solar panel by about 40%. It uses a motor and gearbox from a 3.6v power screwdriver, however a number of different voltage motors can be used. The project has its own 6v power-supply made from five 1.2v NiCad cells and a charging circuit using a separate 3v to 6v solar panel to make the project self-sufficient and universal.
It has one advantage over many of the other designs. It can be connected to an existing solar panel that is hinged or has a pivot-point so it can move to align with the sun. You do not have to add any gear-wheel to the panel as it can be adapted to move the panel via a linkage. This is much easier to do than adding gears etc.
SolarTracker

Here is just a few of the Power Screwdrivers available on the market. Remember, you do not need an expensive unit. The cheapest will be quite suitable, providing it is 3.6v or 4.8v or 6v.

The 3.6v power screwdriver is available from a number of electronics shops, hardware suppliers and warehouses for between $10.00 and $20.00. You do not need a charger but you will need two more NiCad cells (from an electronics store at a cost of about $2.50 each).
Here is the cost of some of the other components: The threaded rod costs about $5.00 plus $4.00 for wing nuts. You will need Solar Tracker-1 kit $15.00 plus some wood to hold the motor and gearbox and about $15.00 for 6 solar cells to produce a 3v (100mA) solar panel. Alternatively you can get a 2v solar panel and 1 NiCad cell from a Solar Garden Light for $5.00. You will need two of these. The solar panels will need to be placed in series and connected to the booster-circuit on the Solar Tracker-1 PC board, to produce the voltage required to charge the NiCads.

You will need eight solar cells (100mA type) to produce a 4v solar panel or six solar cells (200mA type) to produce a 3v solar panel to maintain the charge in the NiCads

We have included a boost-converter circuit to take the voltage from a 3v to 6v solar panel, so it will charge five NiCad cells. Normally a 6v solar panel will not do this as you need a small “headroom voltage” to delver a current to the cells. This means you need a solar panel with an output of at least 8v to charge the cells and this voltage is generally only available when the panel is receiving very bright sunlight. Our design will allow a panel with an an output as low as 3v to charge the 6v set of NiCad cells. We need a charging current of only about 30mA to replace the energy taken from the cells during normal operation so almost any small solar panel can be used. But if you are using a 6v motor, the requirements will increase to abut 100mA
We have suggested using NiCad cells because they are cheap and you will possibly have some lying around your workshop. We do not need high-capacity cells as they are constantly being charged and we only need them to convert a low-current device (the solar panel) into a high-current supply.
The motor from a 3.6v electric screwdriver is ideal, as it is cheap, comes with an inline planetary gearbox and 3 NiCad cells. You only have to find two more cells and this part of the project is ready.
If you want to use a 6v (or higher) motor, a few components will need to be changed. The supply will need to be 8v (or higher) and a 78L05 voltage regulator will be needed to supply 5v for the micro. The two LEDs will need to be replaced with 4 LEDs (or more) as shown in the modified circuit. The LEDs operate as a zener diode when the supply voltage is higher than 5v as the output of the chip is clamped at 5v via the components in the chip and the voltage on the base of the BC557 must not be lower than 0.6v (with reference to the supply rail), otherwise the transistor will not turn off. The LED also shows when one of the arms of the H-bridge is operating and this arm will also turn on the diagonally opposite arm.

For more detail: SOLAR TRACKER-1 using PIC12F629 Microcontroller

The post SOLAR TRACKER-1 using PIC12F629 Microcontroller appeared first on PIC Microcontroller.

Touch Switch using PIC12F629 Microcontroller

$
0
0

You can add this circuit to all sorts of projects that require on-off control.

Our design allows up to 4 touch sensors using a PIC12F629. The output of each touch sensor is active LOW and this can be connected to an additional circuit to control a LED, motor or relay etc.

The photo of the project shows one output with the two LEDs connected in series to produce an infinitely high input impedance so that one of the input/output lines of the micro can be used as both input and output. Two LEDs drive the base of a transistor and a third LED is connected to the collector of the transistor to indicate it is being activated.

Prototype PC board
The input lines to a PIC microcontroller contain FETs and a FET has an almost infinite input impedance (resistance). This mean it is very sensitive and will detect
voltages that are called STATIC ELECTRICITY.

These voltages (Static Electricity and radiation from power cables and wiring) are all around the home and are produced by a number of things including the electromagnetic radiation from the 110v or 240v mains wiring, the radiation from a TV that uses a picture-tube (Cathode Ray Tube) by the electrons being fired by the gun towards the screen, the static produced when walking on carpet or produced by clothing hen it is moved on the body and the movement of paper and plastic items.
You will be amazed at where static electricity can be found and the input to the microcontroller we are using in this project will detect these charges, simply by connecting a wire to one of the input pins.
In fact the micro is so sensitive it will react uncontrollably when moved around the home.
The whole essence of this project has been to remove the uncontrollability-factor and create a touch wire that will only respond when it is touched.
This is a very difficult thing to do as we are using the very sensitive input of a pin to detect the charge (or lack of charge) produced by a finger and at the same time masking the charge from the surroundings.
The answer is to charge a small capacitor and see if the finger discharges it. This means the input will not be responsive to any static charges in the room.
For this to work, we are assuming the body is uncharged and some-times clothing etc will create a charged condition and the touch sensor will not work.
That’s why this project will not work in all situations and with all users.
However when it does work, it is amazing.
The slightest touch of the wire with a finger will turn on the LEDs.
You can build 1, 2, 3 or 4 sensors and use them with touch pads to control all types of devices.

One of the clever features of this circuit is the use of a single input/output line as both an input and output.
This is called multiplexing or “sharing.”
The line is firstly set up as an output and the 100p capacitor is charged. It is then turned into an input line and a 20mS delay is called to give a short period of time for a finger to discharge the capacitor.
The charge on the capacitor is then detected after this time and if it is low, the line is turned into an output to activate the base of the transistor via two LEDs.
These LEDs have been included to produce an infinitely high impedance on the line so that the charge on the 100p capacitor will not be affected.
The two LEDs and base-emitter junction of the transistor will produce an infinite impedance to voltages below the turn-on voltage of the combination.
Another clever circuit-design is placing a diode between the “ground” or Vss line of the micro and the 0v rail.
This reduces the 6v supply to 5.4v (as this is the maximum voltage the chip can be delivered). But more importantly it increases the sensitivity of the input line and makes the project much more sensitive by actually raising the zero-detection-point by about 0.5v.  

 

For more detail: Touch Switch using PIC12F629 Microcontroller

The post Touch Switch using PIC12F629 Microcontroller appeared first on PIC Microcontroller.

20 LED BADGE using PIC12F629 Microcontroller

$
0
0

This project drives a number of LEDs via a very clever circuit.
There are 3 ways to dive a LED from an output of a micro.
The simplest is called “dump.”
This is where the LED is connected directly to the output via a resistor and when the output is HIGH, the LED illuminates. But if the micro has 5 outputs, only 5 LEDs can be illuminated.
A LED will only illuminate when the voltage is applied in the right direction.
We can take advantage of this and connect 2 LEDs across each other with one LED in the opposite direction.
When voltage is applied, one LED will illuminate and when the voltage is reversed, the other LED will illuminate. This will allow us to illuminate more than 5 LEDs.
But if the LED-pairs are connected to the outputs as shown in the diagram below, up to 20 LEDs can be driven from 5 lines. However only 2 LEDs can be on at any one time and these LEDs produce full brightness.
If you turn on the wrong set of output lines, more LEDs will illuminate but the 25mA capability of each line will be shared between the LEDs.
Since only two LEDs can be on at the same time, the duty cycle is 10%.

20 LED BADGE

Another way to drive 20 LEDs is via MULTIPLEXING.
This is the same as SCANNING.
To turn on LEDs 11,2,3,4,  the drive lines are made LOW and the fifth line is taken to a transistor. When the fifth line is taken HIGH, the transistor supplies rail voltage to the 4 LEDs and they illuminate. They are then turned off and 4 outputs drive LEDs 5,6,7,8. The fifth output (GP4) drives the transistor.
In this way 4 LEDs are turned on at a time and each LED gets a 20% duty cycle.
The result is a display that is brighter than Charlieplexing.

THE PROGRAM
Build the circuit so that the transistors and LEDs are in exactly the same places as the symbols on the circuit diagram.
This is very important as the display as the display will be “scanned.” In other words each column will be turned on for a short period of time and then the next column will be turned on.
If you do this fast enough, all the LEDs will appear to be turned on at the same time.
There is a reason why we have to scan the display.
Although each LED can be turned on and off individually, we cannot turn on some combinations of LEDs will turning on other LEDs that have the same lines that feed them. For example, we cannot turn on LEDs 1,4,5,8 at the same time, because to turn on LED4 GP5 has to be LOW and to turn on LED5 GP4 has to be HIGH. Rather than deal with all these conflicts, we scan the columns.
To show this feature, the first program you should burn into the chip is the “Column Test” routine:
Here are the files:
ColumnTest.asm
ColumnTest.hex

 

For more detail: 20 LED BADGE using PIC12F629 Microcontroller

The post 20 LED BADGE using PIC12F629 Microcontroller appeared first on PIC Microcontroller.

Viewing all 85 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>