Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 18th June 2007, 05:47 AM   (permalink)
Default

Quote:
Originally Posted by amdkicksass
Ok,,,well is there any examples written that display the usage of tables in assembly ?

pete
How many lights do you need? Are they LED's or another 230V AC type ones?
__________________
Gayan

My Website
http://gsmicro.blogspot.com/
Gayan Soyza is offline   Reply With Quote
Old 18th June 2007, 07:19 AM   (permalink)
Default

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
amdkicksass is offline   Reply With Quote
Old 18th June 2007, 07:58 AM   (permalink)
Default

Quote:
Originally Posted by amdkicksass
Ok,,,well is there any examples written that display the usage of tables in assembly ?
Check my tutorials, many of them use tables - for example, the LCD ones, the keypad ones, the LED matrix ones.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 19th June 2007, 06:28 AM   (permalink)
Default

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
amdkicksass is offline   Reply With Quote
Old 19th June 2007, 08:33 AM   (permalink)
3v0
Default

Quote:
Originally Posted by amdkicksass
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 ?
The pickit2 is a very good choice. It can act as either a debugger or programmer. The price is right and I have heard that Microchp is good about replacing broken ones.

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:
Originally Posted by amdkicksass
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 ?
"A" chips are an update of the non "A" chips. Generally runs faster (20MHz instead of 4), internal oscillator, use less power, and newer flash technology. Either would work for you but the newer chips are often less expensive. See this table.

Quote:
Originally Posted by amdkicksass
Anything else i should buy ...
pete
As I said earlier this is an easy build.

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)
3v0 is offline   Reply With Quote
Old 19th June 2007, 11:11 PM   (permalink)
Default

Any particular place i should buy the stuff from ? Maybe straight from microchip ?

pete
amdkicksass is offline   Reply With Quote
Old 20th June 2007, 02:17 AM   (permalink)
3v0
Default

Quote:
Originally Posted by amdkicksass
Any particular place i should buy the stuff from ? Maybe straight from microchip ?

pete
You can order direct from Microchip. But that limits your order to what they have.

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.
3v0 is offline   Reply With Quote
Old 20th June 2007, 07:19 AM   (permalink)
Default

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
amdkicksass is offline   Reply With Quote
Old 20th June 2007, 11:56 AM   (permalink)
3v0
Default

Quote:
Originally Posted by amdkicksass
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 ?
I have been doing some digging. It seems that PicKit2 supports a limited number of PICs. The selection from the 14 bit processors is said to be fair. This may or may not be a problem for you. There is a README somewhere that lists supported processors.

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.
3v0 is offline   Reply With Quote
Old 22nd June 2007, 05:12 AM   (permalink)
Default

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
The first thing that interests me is that the MPLAB software like to complain about much more things in general than other software. For example when i try to build/assemble this code MPLAB it gives me these errors, while assembly thru PIC sim IDE gives no errors.

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
I have been able to get the code to run the PIC sim IDE and after it gets tot he delay subroutine it pretty much hangs and goes into an endless loop, any ideas there.

Thanks
pete
amdkicksass is offline   Reply With Quote
Old 22nd June 2007, 05:31 AM   (permalink)
Default

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
And the delay should like this. Remove the 4 lines that moved 255 to both registers in your program

Code:
Delay	decfsz	20h,F
	goto	Delay
	decfsz	21h,F
	goto	Delay
	return
__________________
Gayan

My Website
http://gsmicro.blogspot.com/
Gayan Soyza is offline   Reply With Quote
Old 23rd June 2007, 11:18 PM   (permalink)
Default

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
amdkicksass is offline   Reply With Quote
Old 24th June 2007, 12:27 PM   (permalink)
Default

Quote:
Originally Posted by amdkicksass
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 ?
It can't have 'nothing' in the register, it can only have a decimal value between 0 and 255 - if it's zero the register will loop round and decrement to 255.

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:

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 ?
See above, decrementing 0 moves to 255.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline   Reply With Quote
Old 9th July 2007, 07:54 PM   (permalink)
Default

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
amdkicksass is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
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



All times are GMT. The time now is 07:50 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.