![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) | |
|
Quote:
|
||
|
|
|
|
|
(permalink) |
|
I tried explaining it earlier but maybe i didnt explain it well enough. Let me try again. Originally my thought was to have the PIC control a set of relays via its outputs. The relay board would switch on pattern of lights on the house. Each set of lights, possibly 200-300 lights per relay (120VAC).
It was then suggested that what i wanted would be perfectly suited for the table function. I would have a bunch of patterns stored in the table and have it cycle thru them for a specific duration. I was asking if anyone has any examples in assembly language on how to incorporate tables ? Pete |
|
|
|
|
|
|
(permalink) | |
|
Quote:
|
||
|
|
|
|
|
(permalink) |
|
ok...thanks for the help... I think its time for me to get my hands a bit dirty and try the stuff hardware wise.
I am going to need a programmer and a few PIC chips to start with. I am interested in a ready made programmer, hopefully for under 50$. I saw the pickit2 but i am not sure if thats something good to start with. Suggestions,where to buy ? Also for the PIC chips, i see that they are generally very cheap, i would like to buy a few probably- I will buy a few 16F628A (Whats with the A in the end) anything else ? Anything else i should buy ... THanks pete |
|
|
|
|
|
|
(permalink) | |||
|
Quote:
It workes with MPLAB so you can compile/assemble and program (or debug) from the same UI. Microchip upgrades the software to ensuring that their it works with their new chips. Quote:
Quote:
A few LEDs to use in place of the relays to start with. The relays and transistors to drive them. Use the internal oscillator, 4MHz should be fast enough and it frees up 2 more pins for driving lights. If you need to go faster get a 20MHz resonator. (you could also use a crystal and caps)
__________________
search engine for electronic partsJunebug USB PIC programmer kit., USB Bit Wacker, Homepage The 15 Minute Printed Circuit Board! (+drill time) |
||||
|
|
|
|
|
(permalink) |
|
Any particular place i should buy the stuff from ? Maybe straight from microchip ?
pete |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Mouser carries the Pickit2 and I suspect that Newark does too. Newark has very good prices on PIC processors and most semiconductors. Mouser is better on connectors.
__________________
search engine for electronic partsJunebug USB PIC programmer kit., USB Bit Wacker, Homepage The 15 Minute Printed Circuit Board! (+drill time) |
||
|
|
|
|
|
(permalink) |
|
The PickIt2 comes in different packages, one being the starter kit. I believe the starter kit (DV164120), comes with a card that has a socket for the PIC. If i dont go with the starter kit , are there other socket cards/zif socket cards that would be better ?
pete |
|
|
|
|
|
|
(permalink) | |
|
Quote:
The starter kit comes with the low pin count demo board. Works with chps up to 20 pins. This is an OK choice. For larger PICs ICSP is the way to go anyway. Most often PICs are programed IN CIRCUIT using 3 signal pins plus power and gnd. Serveral different types of connectors are currently being used to do this. The Pickit2 has a 6 pin .1 pitch connector. It looks like it may take a standard header pin setup. Many of the DIY setups including the Inchworm are using a standard 2x5 pin header. Olimex uses a Molex 6 pin. The original ICD2 uses a modular (RJ11 IIRC). When you build your target board you need to provide an ICSP connector that connects to the Pickit2.
__________________
search engine for electronic partsJunebug USB PIC programmer kit., USB Bit Wacker, Homepage The 15 Minute Printed Circuit Board! (+drill time) |
||
|
|
|
|
|
(permalink) |
|
Thanks for the suggestions, i will have the stuff ordered from Newark hopefully by the end of the day today. I think the starter kit should be sufficient. I started working on the code and i have few questions that someone can hopefully answer.
Here is what i have after a few tutorials and some fiddling around. Code:
;PIC Christmas Pattern Lights
;Peter 2007
LIST p=16F628 ;tell assembler what chip we are using
#include "P16F628.inc" ;include the defaults for the chip
__config 0x3D18 ;sets the configuration settings
;(oscillator type etc.)
;Constants
COUNT1 equ 020h ;First counter for our delay loops
Timer1 equ 021h ;Second counter for our delay loops
org 0x0000 ;org sets the origin, 0x0000 for the 16F628,
;this is where the program starts running
movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)
bsf STATUS, RP0 ;select bank 1
movlw b'00000000' ;set PortB all outputs
movwf TRISB
movlw b'00000000'
movwf TRISA ;set PortA all outputs
bcf STATUS, RP0 ;select bank 0
movlw 255 ;First put the value of 85h in the W register
movwf 020h ;Now move it to our 08h register.
movlw 85h ;First put the value of 85h in the W register
movwf 020h ;Now move it to our 08h register.
Main
Pat1 MOVLW 01H ; Set the first bit
MOVWF PORTB ; on Port B.
RLF PORTB,1 ;Pattern to shift Lights left
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTB,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RLF PORTA,1
CALL Delay
RRF PORTA,1 ;Pattern to shift Lights Right
CALL Delay
RRF PORTA,1
CALL Delay
RRF PORTA,1
CALL Delay
RRF PORTA,1
CALL Delay
RRF PORTA,1
CALL Delay
RRF PORTA,1
CALL Delay
RRF PORTA,1
CALL Delay
RRF PORTA,1
CALL Delay
Rpt decfsz Timer1,1 ;This second loop keeps the LED
goto Pat1
goto end
Delay
Loop1 decfsz COUNT1,F ;This second loop keeps the LED
goto Loop1 ;turned off long enough for us to
return
Code:
Clean: Deleting intermediary and output files. Clean: Done. Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p16F628 "christmaslights1.asm" /l"christmaslights1.lst" /e"christmaslights1.err" Message[302] C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 21 : Register in operand not in bank 0. Ensure that bank bits are correct. Message[302] C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 23 : Register in operand not in bank 0. Ensure that bank bits are correct. Warning[202] C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 26 : Argument out of range. Least significant bits used. Error[113] C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 89 : Symbol not previously defined (end) Warning[203] C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 98 : Found opcode in column 1. (return) Warning[205] C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 101 : Found directive in column 1. (end) Error[173] C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM 102 : Source file path exceeds 62 characters (C:\DOCUMENTS AND SETTINGS\PETERBASTA\DESKTOP\PIC\CHRISTMASLIGHTS1.ASM) Halting build on first failure as requested. BUILD FAILED: Thu Jun 21 22:10:35 2007 Thanks pete |
|
|
|
|
|
|
(permalink) |
|
To work with RLF/RRF you need to know about CARRY bit in STATUS register for the time being simple method can do in your main routine like this
Code:
Right movlw 01h movwf PORTB call Delay movlw 02h movwf PORTB call Delay movlw 04h movwf PORTB call Delay movlw 08h movwf PORTB call Delay movlw 10h movwf PORTB call Delay movlw 20h movwf PORTB call Delay movlw 40h movwf PORTB call Delay movlw 80h movwf PORTB call Delay goto Right Code:
Delay decfsz 20h,F goto Delay decfsz 21h,F goto Delay return |
|
|
|
|
|
|
(permalink) |
|
If I remove the lines that store the value 255 in both registers that what would the
decfsz 20h,F command do, how would it react if there is nothing in that register ? Also since the value in that register is being modified by decreasing it how is it supposed to be used again and again if after the first delay run the register is already run down to 0 ? Pete |
|
|
|
|
|
|
(permalink) | ||
|
Quote:
I also strongly advise you don't just use register numbers, use an equ to give it a name at the top of the program - using numbers is just confusing. Quote:
|
|||
|
|
|
|
|
(permalink) |
|
Thanks for all the suggestions, i am currently trying to mess with everything i.e simulations, assembly stuff and transferring things to the chip.
Currently one annoyance is that when simulating things with PIC simulator IDE, things don't move at real time speed. Even when speed is at normal, things move extremely slow. I have to calculate delays and then flash them on the chip to see the time it actually takes ,which is extremely time consuming. Is their a way to have it simulate the program exactly the same way the PIC would ? Thanks pete |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Project: Strobe Light | ElectroMaster | Electronic Projects | 17 | 16th July 2007 03:55 PM |
| PIC to PIC and output on LCD | pouchito | Micro Controllers | 20 | 7th June 2007 08:43 AM |
| max232 and pic data logger mini project | mabauti | General Electronics Chat | 1 | 21st March 2007 10:54 PM |
| need help for senior project | jay_zee | General Electronics Chat | 5 | 17th August 2004 11:46 AM |
| brake light/ turn signal | andrew8485 | Electronic Projects Design/Ideas/Reviews | 13 | 11th November 2003 12:48 AM |