Upload
krimo-kitouchi
View
220
Download
0
Embed Size (px)
Citation preview
Log in or Sign up
All About CircuitsHome Forums > Circuits and Projects > The Completed Projects Collection >
Project: PIC LED SequencerDiscussion in 'The Completed Projects Collection' started by MMcLaren, Mar 17, 2012.
Previous Thread Next Thread Loading... Page 1 of 2 1 2 Next >
1.
MMcLaren Thread Starter Active Member Joined:
Feb 14, 2010 Messages:
657 Location:
Michigan, USA
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.
PrerequisitesWhile 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.
HardwareWhile 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 ea. - C1, 0.1uf monolithic ceramic capacitor8 ea. - D1-D8, generic discrete LED8 ea. - R1-R8, 470 ohm, 1/8th watt carbon film resistor1 ea. - R9, 10 kohm, 1/8th watt carbon film resistor1 ea. - SW1, generic PCB momentary contact switch1 ea. - U1, PIC16F628A micro controller1 ea. - prototype board or solderless breadboard1 ea. - regulated 5 volt D.C. power source
SoftwareThe 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 (fx3-fx2)/2 ; <steps> |B0 dt b'00000001',8 ; <pattern>, <duration> |B0 dt b'00000010',8 ; |B0 dt b'00000100',8 ; |B0 dt b'00001000',8 ; |B0 dt b'00010000',8 ; |B0 dt b'00100000',8 ; |B0 dt b'01000000',8 ; |B0 dt b'10000000',8 ; |B0 dt b'01000000',8 ; |B0 dt b'00100000',8 ; |B0 dt b'00010000',8 ; |B0 dt b'00001000',8 ; |B0 dt b'00000100',8 ; |B0 dt b'00000010',8 ; |B0fx3
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.
SummaryShort 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: 266.1 KB
Views: 540
Sequencer Bottom.png
File size: 275.5 KB
Views: 127
16F628A LED Sequencer.asm.txt
File size: 13.2 KB
Views: 109
Sequencer Silkscreen.png
File size: 24.9 KB
Views: 82
Simple 8-Chan LED Sequencer.png
File size: 32.5 KB
Views: 53
Last edited: Jun 2, 2014 MMcLaren, Mar 17, 2012 #1 RRITESH KAKKAR likes this.
2.
Sparky49 Active Member Joined:
Jul 16, 2011 Messages:
777 Location:
Cambridgeshire
Hi,
I am interested in your project, but it looks like your image links are broken.
Sparky49, Mar 18, 2012 #2
3.
Bill_Marsden Moderator Staff Member Joined:
Mar 24, 2008 Messages:
19,402 Location:
Dallas, TX (GMT-5 w/ DST)
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 #3
4.
Georacer Moderator Staff Member Joined:
Nov 25, 2009 Messages:
4,959 Location:
Athens, Greece (GMT +2)
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 #4
5.
Bill_Marsden Moderator Staff Member Joined:
Mar 24, 2008 Messages:
19,402 Location:
Dallas, TX (GMT-5 w/ DST)
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 #5
6.
DerStrom8 Well-Known Member Joined:
Feb 20, 2011 Messages:
2,011 Location:
Vermont, U.S.A. (GMT-5)
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, Mar 18, 2012 #6 Sparky49 likes this.
7.
gerty Well-Known Member Joined:
Aug 30, 2007 Messages:
947 Location:
Tennessee GMT -5
Am I the only one who uses stripped wires on the underside of the perfboard
Click to expand...
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: 156.5 KB
Views: 68
back.png
189.3 KBViews:
69Last edited: Mar 19, 2012 gerty, Mar 19, 2012 #7
8.
RRITESH KAKKAR Well-Known Member Joined:
Jun 29, 2010 Messages:
1,388 Location:
India
Nice work!
RRITESH KAKKAR, Apr 9, 2012 #8
9.
BillO Well-Known Member Joined:
Nov 24, 2008 Messages:
974 Location:
Canada
Cool.
I also use wire wrap wire to hook up circuits.
BillO, Apr 9, 2012 #9
10.
Bill_Marsden Moderator Staff Member Joined:
Mar 24, 2008 Messages:
19,402 Location:
Dallas, TX (GMT-5 w/ DST)
If someone could go through the programing steps that would be useful.
That, and I'm eradicating a spammer trace.
Bill_Marsden, Apr 26, 2012 #10 DerStrom8 likes this.
11.
MMcLaren Thread Starter Active Member Joined:
Feb 14, 2010 Messages:
657 Location:
Michigan, USA
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: 77.7 KB
Views: 24
4-Digit Silk.jpg
File size: 61.5 KB
Views: 16
MMcLaren, Apr 26, 2012 #11
12.
Sparky49 Active Member Joined:
Jul 16, 2011 Messages:
777 Location:
Cambridgeshire
Videos please!!!
Sparky49, Apr 26, 2012 #12
13.
tracecom Well-Known Member Joined:
Apr 16, 2010 Messages:
3,342 Location:
West Tennessee
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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexHalting 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.41Preprocessor 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 #13
14.
DerStrom8 Well-Known Member Joined:
Feb 20, 2011 Messages:
2,011 Location:
Vermont, U.S.A. (GMT-5)
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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexError[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 complexHalting 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.41Preprocessor symbol `__DEBUG' is defined.Tue May 08 15:06:34 2012----------------------------------------------------------------------BUILD FAILED
Can someone tell my why and how to fix the problem? Thanks.Click to expand...
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 #14
15.
tracecom Well-Known Member Joined:
Apr 16, 2010 Messages:
3,342 Location:
West Tennessee
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.
Click to expand...
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 #15
16.
DerStrom8 Well-Known Member Joined:
Feb 20, 2011 Messages:
2,011 Location:
Vermont, U.S.A. (GMT-5)
tracecom said: ↑
I think I chose relocatable code, but I could be wrong.Click to expand...
Sorry, please read my edited post. I had relocatable and absolute backwards.
DerStrom8, May 8, 2012 #16
17.
tracecom Well-Known Member Joined:
Apr 16, 2010 Messages:
3,342 Location:
West Tennessee
DerStrom8 said: ↑
Sorry, please read my edited post. I had relocatable and absolute backwards.
Click to expand...
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 #17
18.
DerStrom8 Well-Known Member Joined:
Feb 20, 2011 Messages:
2,011 Location:
Vermont, U.S.A. (GMT-5)
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?
Click to expand...
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 #18
19.
tracecom Well-Known Member Joined:
Apr 16, 2010 Messages:
3,342 Location:
West Tennessee
It works! I have LEDs flashing.
tracecom, May 8, 2012 #19
20.
MMcLaren Thread Starter Active Member Joined:
Feb 14, 2010 Messages:
657 Location:
Michigan, USA
tracecom said: ↑
It works! I have LEDs flashing.Click to expand...
hi tracecom,
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, May 8, 2012 #20
Previous Thread Next Thread Loading... (You must log in or sign up to reply here.) Show Ignored ContentPage 1 of 2 1 2 Next > Similar Threads Forum Title Date
The Completed Projects Collection
Silly little project - bicycle rear light
Dec 3, 2014
The Completed Projects Collection
Project : Battery Buckets
Oct 17, 2014
The Completed Projects Collection
Project : Electronic Load
Sep 16, 2014
The Completed Projects Collection
Project: TA1000PS - PSU for audio amplifiers with protection, sofstart and fan contro
Jul 20, 2014
The Completed Projects Collection
Project : Mono Preamp
Nov 24, 2013
Share This PageTweet
Log in with Facebook Log in with Twitter Log in with Google
Your name or email address:
Do you already have an account? No, create an account now.
Yes, my password is:
Forgot your password?
Stay logged in
All About CircuitsHome Forums > Circuits and Projects > The Completed Projects Collection >
Home Forums
ForumsQuick Links
Search Forums Recent Posts Today's Posts
Textbooks
TextbooksQuick Links
Vol. I - Direct Current (DC) Vol. II - Alternating Current (AC) Vol. III - Semiconductors Vol. IV - Digital Vol. V - Reference Vol. VI - Experiments
Videos Worksheets Gallery
GalleryQuick Links
Categories Explore User's Albums New Albums New Photos New Videos Collections Locations Cameras Streams Cloud
Blogs
BlogsQuick Links
Blogs Home Page All Blogs
Members
MembersQuick Links
Notable Members Current Visitors Recent Activity
Menu
Search
Search titles only
Posted by Member:
Separate names with a comma.
Newer Than:
Search this thread only Search this forum only
Display results as threads
Useful Searches Recent Posts
More...
Style vB 3.x - Fluid
Contact Us Help Home Top RSS
Terms and Rules
Forum software by XenForo™ ©2010-2014 XenForo Ltd.