pic exemple
-
Upload
krimo-kitouchi -
Category
Documents
-
view
10 -
download
2
description
Transcript of pic exemple
2 Next >
Previous Thread Next Thread
Project: PIC LED Sequencer
Forums ... The Completed Projects Collection
1
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 tomultiplexing 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 toolsnecessary 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 phenolicprototype board available from Radio Shack (sku 276-149) with a plastic coated paper silkscreen glued onto the top, but youmight decide to build the circuit on a solderless breadboard or perhaps etch your own printed circuit board.
MMcLarenThread StarterActive Member
Mar 17, 2012 #1
Forums
Forums
Forums
......
Log in or Sign up
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 cancontain up to 255 sequences or steps and each step contains two parts, (1) the LED <pattern>, and (2) the <duration> forthat pattern. The <pattern> part of each step is simply eight bits which match the position of the eight LEDs on the projectboard. 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 valuefrom 1 to 255 which corresponds to the time the pattern will be displayed in 10-ms increments (1..255 duration = 10..2550msecs) before going on to the next step. When the program has finished displaying the last step in an FX table, it wraps aroundto start again at the first step in that table. When you press the push button switch, the program will move on to displayingthe 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
File size: 266.1 KBViews: 540
Sequencer Top.pngFile size: 275.5 KBViews: 127
Sequencer Bottom.png
File size: 13.2 KBViews: 109
16F628A LED Sequencer.asm.txtFile size: 24.9 KBViews: 82
Sequencer Silkscreen.png
File size: 32.5 KBViews: 53
Simple 8-Chan LED Sequencer.png
MMcLaren,
RRITESH KAKKAR likes this.
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 Isuspect, I've left out some important piece of information.
Cheerful regards, Mike
Attached Files:
Last edited: Jun 2, 2014
Sparky49,
Hi,
I am interested in your project, but it looks like your image links are broken.
Sparky49Active Member
Mar 18, 2012 #2
Bill_Marsden,
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_MarsdenModerator
Staff Member
Mar 18, 2012 #3
Georacer,
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 thisway.
GeoracerModerator
Staff Member
Mar 18, 2012 #4
I like the insulation. I did buy some specialty teflon ultra fine wire though, both 28 and 30 gauge. Teflon won't melt whensoldered, but it is expensive and soft (cold flows).
Bill_MarsdenModerator
Staff Member
Mar 18, 2012 #5
Bill_Marsden,
DerStrom8,
Sparky49 likes this.
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.
DerStrom8Well-KnownMember
Mar 18, 2012 #6
File size: 156.5 KBViews: 68
front.pngFile size: 189.3 KBViews: 69
back.png
gerty,
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:
Last edited: Mar 19, 2012
gertyWell-KnownMember
Am I the only one who uses stripped wires on the underside of the perfboard
Mar 19, 2012 #7
RRITESH KAKKAR,
Nice work!
RRITESHKAKKARWell-KnownMember
Apr 9, 2012 #8
BillO,
Cool.
I also use wire wrap wire to hook up circuits.
BillOWell-KnownMember
Apr 9, 2012 #9
Bill_Marsden,
If someone could go through the programing steps that would be useful.
That, and I'm eradicating a spammer trace.
Bill_MarsdenModerator
Staff Member
Apr 26, 2012 #10
DerStrom8 likes this.
File size: 77.7 KBViews: 24
4-Digit #2.jpgFile size: 61.5 KBViews: 16
4-Digit Silk.jpg
MMcLaren,
While a printed circuit board (PCB) would be best, using 30 gauge kynar wire-wrap wire for these little point-to-point wiringprojects does work quite well. The same wiring method will be used on an upcoming project board (preview below).
Cheerful regards, Mike
Attached Files:
MMcLarenThread StarterActive Member
Apr 26, 2012 #11
Sparky49,
Videos please!!!
Sparky49Active Member
Apr 26, 2012 #12
I am a complete novice to PIC programming, so the answer to this question may be obvious to everyone but me. When I try tobuild 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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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 PLAYTIMEPROJECTS\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
tracecomWell-KnownMember
May 8, 2012 #13
tracecom,
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.
DerStrom8,
tracecom said: ↑
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, itshouldn't give you the error. I may be wrong, but it's worth a shot.
Last edited: May 8, 2012
DerStrom8Well-KnownMember
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\MPASMPLAYTIME 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\MPASMPLAYTIME 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\MPASMPLAYTIME PROJECTS\16F628A LED SEQUENCER.ASM 183 : Operand contains unresolvable labels or is too complexClick to expand...
May 8, 2012 #14
tracecom,
DerStrom8 said: ↑
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 thisthread.
tracecomWell-KnownMember
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 relocatablecode, it shouldn't give you the error. I may be wrong, but it's worth a shot.
May 8, 2012 #15
DerStrom8,
tracecom said: ↑
Sorry, please read my edited post. I had relocatable and absolute backwards.
DerStrom8Well-KnownMember
I think I chose relocatable code, but I could be wrong.
May 8, 2012 #16
tracecom,
DerStrom8 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?
tracecomWell-KnownMember
Sorry, please read my edited post. I had relocatable and absolute backwards.
May 8, 2012 #17
DerStrom8,
tracecom said: ↑
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 fromthe circuit in order for it to work.
DerStrom8Well-KnownMember
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 usethose pins (plus others) to connect to LEDs per the schematic. Correct?
May 8, 2012 #18
tracecom,
It works! I have LEDs flashing.
tracecomWell-KnownMember
May 8, 2012 #19
tracecom said: ↑
hi tracecom,
MMcLarenThread StarterActive Member
It works! I have LEDs flashing.
May 8, 2012 #20
vB 3.x - Fluid Contact Us Help Top
Terms and RulesForum software by XenForo™
2 Next >
Previous Thread Next Thread
(You must log in or sign up to reply here.)
MMcLaren,
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
1
Forums ... The Completed Projects Collection