Vous êtes sur la page 1sur 8

Log in or Sign up

Forums
...

Forums
Forums

...

The Completed Projects Collection

Project: PIC LED Sequencer


Previous Thread Next Thread
1

Next >

Mar 17, 2012

#1

MMcLaren
Thread Starter
Active Member

For my very first project submission I'd like to present a relatively simple PIC based LED sequencer project. By "relatively simple"
I mean each LED is directly driven from an I/O pin, and while this method generally uses more pins when compared to
multiplexing to drive the same number of LEDs, it does make the PIC program much simpler.

Prerequisites
While you don't need to be a micro controller expert to build this project and create nifty LED FX (effects), you will need the
(free) Microchip MPLAB IDE (integrated development environment) installed on a PC and a programmer such as the PICKIT2 to
"burn" the program which contains your LED 'FX' sequences into the PIC device. You also need the basic skills and tools
necessary to build the project on a solderless breadboard or a prototype board.
Hardware
While the project requires very few parts, you need to decide how you want to build it. I used an inexpensive phenolic
prototype board available from Radio Shack (sku 276-149) with a plastic coated paper silkscreen glued onto the top, but you
might decide to build the circuit on a solderless breadboard or perhaps etch your own printed circuit board.

Code:
Parts List
1
8
8
1
1
1
1
1

ea.
ea.
ea.
ea.
ea.
ea.
ea.
ea.

C1, 0.1uf monolithic ceramic capacitor


D1-D8, generic discrete LED
R1-R8, 470 ohm, 1/8th watt carbon film resistor
R9, 10 kohm, 1/8th watt carbon film resistor
SW1, generic PCB momentary contact switch
U1, PIC16F628A micro controller
prototype board or solderless breadboard
regulated 5 volt D.C. power source

Software
The program is designed to continuously display LED sequences contained in one of eight FX (effects) tables. Each table can
contain up to 255 sequences or steps and each step contains two parts, (1) the LED <pattern>, and (2) the <duration> for
that pattern. The <pattern> part of each step is simply eight bits which match the position of the eight LEDs on the project
board. A '1' bit will turn an LED on while a '0' bit will turn an LED off. The <duration> part of each step must contain a value
from 1 to 255 which corresponds to the time the pattern will be displayed in 10-ms increments (1..255 duration = 10..2550
msecs) before going on to the next step. When the program has finished displaying the last step in an FX table, it wraps around
to start again at the first step in that table. When you press the push button switch, the program will move on to displaying
the next FX table. Here's what one of the program FX tables looks like (for a Knight Rider type effect);

Code:
fx2
dt
dt
dt
dt
dt
dt
dt
dt
dt
dt
dt
dt
dt
dt
dt

(fx3-fx2)/2
b'00000001',8
b'00000010',8
b'00000100',8
b'00001000',8
b'00010000',8
b'00100000',8
b'01000000',8
b'10000000',8
b'01000000',8
b'00100000',8
b'00010000',8
b'00001000',8
b'00000100',8
b'00000010',8

; <steps>
; <pattern>, <duration>
;
;
;
;
;
;
;
;
;
;
;
;
;

|B0
|B0
|B0
|B0
|B0
|B0
|B0
|B0
|B0
|B0
|B0
|B0
|B0
|B0
|B0

fx3
Using MPLAB, the user can edit or modify any line in an FX table or insert and delete lines in an FX table and the program will

automatically keep track of the number of steps in each table.


Summary
Short of teaching someone how to use MPLAB, which is beyond the scope of this article, feel free to ask questions if, as I
suspect, I've left out some important piece of information.
Cheerful regards, Mike
Attached Files:
Sequencer Top.png
File size:
Views:

266.1 KB
540

16F628A LED Sequencer.asm.txt


File size:
13.2 KB
Views:
109

Sequencer Bottom.png
File size:
Views:
Sequencer Silkscreen.png
File size:
Views:

275.5 KB
127

24.9 KB
82

Simple 8-C han LED Sequencer.png


File size:
32.5 KB
Views:
53

Last edited: Jun 2, 2014


MMcLaren,
RRITESH KAKKAR likes this.

Mar 18, 2012

#2

Sparky49
Active Member

Hi,
I am interested in your project, but it looks like your image links are broken.
Sparky49,

Mar 18, 2012

#3

Bill_Marsden
Moderator
Staff Member

Nice job! It is approved. I'll post a link in the index ASAP.


Much better submission than most. It sets the standard.
I put it in the Lighting, LED Flashlights, Etc catagory.
If you want me to move it to the Microprocessors / Micro Controllers class let me know.
Bill_Marsden,

Mar 18, 2012

#4

Georacer
Moderator
Staff Member

Neat project, very compact.


I wonder: Am I the only one who uses stripped wires on the underside of the perfboard? I feel they 're more manipulable this
way.
Georacer,

Mar 18, 2012

#5

Bill_Marsden
Moderator
Staff Member

I like the insulation. I did buy some specialty teflon ultra fine wire though, both 28 and 30 gauge. Teflon won't melt when
soldered, but it is expensive and soft (cold flows).

Bill_Marsden,

Mar 18, 2012

#6

DerStrom8
Well-Known
Member

Well done, MMcLaren.


@Geo, I use insulated wire for a few reasons--One, it prevents shorts, two, it prevents shorts, and three, it prevents shorts.

DerStrom8,
Sparky49 likes this.

Mar 19, 2012

#7

gerty
Well-Known
Member

Am I the only one who uses stripped wires on the underside of the perfboard
I use 30 gauge wire wrap wire (insulated) for jobs like this. I use standard sockets and solder the connections.
Edit: here's a couple of lousy pics of the sequencer we made in class here for future students to learn programming.
It shows the type of wire I'm referring to.
Attached Files:
front.png
File size:
Views:

156.5 KB
68

back.png
File size:
Views:

189.3 KB
69

Last edited: Mar 19, 2012


gerty,

Apr 9, 2012

#8

RRITESH
KAKKAR
Well-Known
Member

Nice work!
RRITESH KAKKAR,

Apr 9, 2012

#9

BillO
Well-Known
Member

Cool.
I also use wire wrap wire to hook up circuits.
BillO,

Apr 26, 2012

#10

Bill_Marsden
Moderator
Staff Member

If someone could go through the programing steps that would be useful.


That, and I'm eradicating a spammer trace.
Bill_Marsden,

DerStrom8 likes this.

Apr 26, 2012

#11

MMcLaren
Thread Starter
Active Member

While a printed circuit board (PCB) would be best, using 30 gauge kynar wire-wrap wire for these little point-to-point wiring
projects does work quite well. The same wiring method will be used on an upcoming project board (preview below).
Cheerful regards, Mike
Attached Files:
4-Digit #2.jpg
File size:
Views:

77.7 KB
24

4-Digit Silk.jpg
File size:
Views:

61.5 KB
16

MMcLaren,

Apr 26, 2012

#12

Sparky49
Active Member

Videos please!!!
Sparky49,

May 8, 2012

#13

tracecom
Well-Known
Member

I am a complete novice to PIC programming, so the answer to this question may be obvious to everyone but me. When I try to
build the project, it fails with the following report.
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 182 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 182 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 183 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 183 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 184 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 184 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 185 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 185 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 186 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 186 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 187 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 187 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 188 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 188 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 189 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM PLAYTIME
PROJECTS\16F628A LED SEQUENCER.ASM 189 : Operand contains unresolvable labels or is too complex
Halting build on first failure as requested.
---------------------------------------------------------------------Debug build of project `C:\Documents and Settings\Charles R. Hampton\Desktop\PIC MCU's\CRH Project Files\MPASM Playtime

Projects\PIC16F628A LED Sequencer.mcp' failed.


Language tool versions: MPASMWIN.exe v5.43, mplink.exe v4.41, mplib.exe v4.41
Preprocessor symbol `__DEBUG' is defined.
Tue May 08 15:06:34 2012
---------------------------------------------------------------------BUILD FAILED
The errors seem to point to this section of the code.

Code:
;******************************************************************
; directory of fx tables (index 0..7 -> fx1..fx8)
*
;******************************************************************
fxdir
dt
fx1%256,fx1/256 ; fx1 array address
|B0
dt
fx2%256,fx2/256 ; fx2 array address
|B0
dt
fx3%256,fx3/256 ; fx3 array address
|B0
dt
fx4%256,fx4/256 ; fx4 array address
|B0
dt
fx5%256,fx5/256 ; fx5 array address
|B0
dt
fx6%256,fx6/256 ; fx6 array address
|B0
dt
fx7%256,fx7/256 ; fx7 array address
|B0
dt
fx8%256,fx8/256 ; fx8 array address
|B0
Can someone tell my why and how to fix the problem? Thanks.
tracecom,

May 8, 2012

#14

DerStrom8
Well-Known
Member

tracecom said:
I am a complete novice to PIC programming, so the answer to this question may be obvious to everyone but me.
When I try to build the project, it fails with the following report.
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM
PLAYTIME PROJECTS\16F628A LED SEQUENCER.ASM 182 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM
PLAYTIME PROJECTS\16F628A LED SEQUENCER.ASM 182 : Operand contains unresolvable labels or is too complex
Error[151] C:\DOCUMENTS AND SETTINGS\CHARLES R. HAMPTON\DESKTOP\PIC MCU'S\CRH PROJECT FILES\MPASM
Click :toOperand
expand...contains unresolvable labels or is too complex
PLAYTIME PROJECTS\16F628A LED SEQUENCER.ASM 183
Could you post your present code, please?
I think your problem is that you're building the program as relocatable code. If you change it in MPLAB to absolute code, it
shouldn't give you the error. I may be wrong, but it's worth a shot.
Last edited: May 8, 2012
DerStrom8,

May 8, 2012

#15

tracecom
Well-Known
Member

DerStrom8 said:
Could you post your present code, please?
I think your problem is that you're building the program as absolute code. If you change it in MPLAB to relocatable
code, it shouldn't give you the error. I may be wrong, but it's worth a shot.
I think I chose relocatable code, but I could be wrong.
I tried to post the code, but it exceeds the 10000 character limit. It's the code that was attached to the original post in this
thread.
tracecom,

May 8, 2012

#16

DerStrom8
Well-Known
Member

tracecom said:
I think I chose relocatable code, but I could be wrong.
Sorry, please read my edited post. I had relocatable and absolute backwards.
DerStrom8,

May 8, 2012

#17

tracecom
Well-Known
Member

DerStrom8 said:
Sorry, please read my edited post. I had relocatable and absolute backwards.
OK, I just changed it to absolute and it compiled.

What I don't know about programming PICs is limitless.

So, I programmed the chip. Now, I have to disconnect the wires that were connected to pins 12 and 13, and use those pins
(plus others) to connect to LEDs per the schematic. Correct?
tracecom,

May 8, 2012

#18

DerStrom8
Well-Known
Member

tracecom said:
OK, I just changed it to absolute and it compiled.

What I don't know about programming PICs is limitless.

So, I programmed the chip. Now, I have to disconnect the wires that were connected to pins 12 and 13, and use
those pins (plus others) to connect to LEDs per the schematic. Correct?
if 12 and 13 are PGC and PGD, and you want to use them as ports, then yes-- You'll need to disconnect your programmer from
the circuit in order for it to work.
DerStrom8,

May 8, 2012

#19

tracecom
Well-Known
Member

It works!

I have LEDs flashing.

tracecom,

May 8, 2012

#20

MMcLaren
Thread Starter
Active Member

tracecom said:
It works!
hi tracecom,

I have LEDs flashing.

Thank you for trying the project and my apologies for forgetting to say it was an "absolute" mode project.
Have fun... Cheerful regards, Mike
Last edited: May 8, 2012
MMcLaren,

Previous Thread Next Thread


(You must log in or sign up to reply here.)
1

Next >

Forums

...

The Completed Projects Collection

vB 3.x - Fluid
Forum software by XenForo

Contact Us Help Top


Terms and Rules