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 11th February 2007, 07:18 AM   (permalink)
Default 16f84 asm to 16f628

Dear friends hi!!!!!

Once again i would like your help because i am in a trouble.I have built the circuit below with the lcd version....
http://jap.hu/electronic/combination_lock.html
The problem i have is that i want this circuit to act as a toggle switch.When you press the code,to arm the relay,and when i press it again to disarm.I tried to contact the aythor,but he didn't reply to me.The aythor has to his page,the particular code,but it is used for a pic16f84.What part in the code should i change to convert it to the pic16f628??? i also tried to use the xor operation but as a newbie to microcontrollers world i didn't achived anything..... :-(
I attached the two codes and i would like to tell me if it is circle correct the part that it must be changed to work as a toogle switch....

Sincerely _ab


P.s=sorry for my poor english
Attached Images
File Type: gif asms.GIF (14.5 KB, 61 views)
Attached Files
File Type: zip Files.zip (6.2 KB, 20 views)
_ab is offline  
Reply With Quote
Old 11th February 2007, 09:49 AM   (permalink)
Default

The differences between 16F84 and 16F628 are only tiny, and it was the 'modern' replacement for it last century.

To alter 84 code to 628, you just need to:

1) Alter the fuse settings and heard of the assembly file.

2) Alter the GPR start address.

2) Turn off the analogue comparators.

You can check my tutorials to see what these all look like.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply With Quote
Old 11th February 2007, 10:32 AM   (permalink)
Default

"1) Alter the fuse settings and heard of the assembly file.
2) Alter the GPR start address.
3) Turn off the analogue comparators"

I think that these instructions are changed (aren't they)because already the file works on 16f628 but it has a different output for the relay state.....I don't have the expierience to change these variables.....

What is the Gpr address and what is the correct starting value????
How can i turn off the analogue comparators(and what they do)

Which tutorial from 1 to 10 should i look????

Thanks a lot for your reply!!!!!!
_ab is offline  
Reply With Quote
Old 11th February 2007, 11:06 AM   (permalink)
Default

Quote:
Originally Posted by Nigel Goodwin
The differences between 16F84 and 16F628 are only tiny, and it was the 'modern' replacement for it last century.

To alter 84 code to 628, you just need to:

1) Alter the fuse settings and heard of the assembly file.

2) Alter the GPR start address.

2) Turn off the analogue comparators.

You can check my tutorials to see what these all look like.
5) GPR's start at 20h on the '628 and at 0Ch on the '84.
Mike, K8LH is offline  
Reply With Quote
Old 11th February 2007, 11:53 AM   (permalink)
Default

Quote:
Originally Posted by _ab
What part in the code should i change to convert it to the pic16f628???
You have asked the question badly. It is not about changing from 16F84 to 16F628. The original author had already provided correct source code for the 16F628. It is the function you required not being provided in the F628 source code. So it is a question of modifying the 16F628 source code to include your requirement.

The change required is easily done. See below, change marked with "<<<<<<".

Code:
;**********************************************************************
;                                                                     *
;    Filename:	    cl2.asm                                           *
;    Date:                                                            *
;    File Version:  Combination lock rewritten                        *
;                                                                     *
;    Author:        Peter Jakab <el@jap.hu>                           *
;                   http://jap.hu/electronic/                         *
;**********************************************************************
;..............
;
pulseout				; # operates output

		movf PORTA, W	;get port A into W <<<<<<<<<<
		xorlw 0x04 	;toggle RA2      <<<<<<<<<<
		movwf PORTA




		movlw msg_line
		call lcd_cmdout
		movlw msg_ok
		call lcd_strout

		movlw pulsewidth
		movwf dcnt2

out0		movlw d'200'
		call udelay
		decfsz dcnt2, F
		goto out0

		goto loop
__________________
L.Chung
eblc1388 is offline  
Reply With Quote
Old 11th February 2007, 12:52 PM   (permalink)
Default

Thank you very much for replying me......
I changed the code as you say ,but i have the same results of the circuit..... :-(
_ab is offline  
Reply With Quote
Old 11th February 2007, 02:48 PM   (permalink)
Default

Quote:
Originally Posted by _ab
Thank you very much for replying me......
I changed the code as you say ,but i have the same results of the circuit..... :-(
Somewhere else the author reset the output, missed that earlier. Try this:

Code:
warm		movlw 0xf0
		call beep
		call eep_read ; read code from eeprom to ram at cod

loopx	clrf PORTA ; clear output   <<<<<<<<<<< 

loop		movlw msg_line    ;<<<<<<<<<<<<
		call lcd_cmdout
		movlw msg_code
		call lcd_strout
		
		call read ; read code from keyboard into readbuf
		movlw cod
		call compbuf ; compare code in readbuf with code at cod
		bnz loop ; the code is different
__________________
L.Chung
eblc1388 is offline  
Reply With Quote
Old 11th February 2007, 03:31 PM   (permalink)
Default

You are the best my friend!!!!!Thanks a lot for helping me.......!!!!!!!!!
And one last question is it possible,when you first power up the circuit the output to be in the off state instead of the on state that it is now?????

P.s=I wouldn't have done anything without your help..... :-)

Sincerely
_ab is offline  
Reply With Quote
Old 11th February 2007, 04:13 PM   (permalink)
Default

Quote:
Originally Posted by _ab
And one last question is it possible,when you first power up the circuit the output to be in the off state instead of the on state that it is now?????
I don't know why the output is default ON at power up. Could be due to LCD routines.

Anyway, you can try to replace:
Code:
loopx	clrf PORTA ; clear output
with these two instructions:
Code:
loopx   movlw  0x04     ;<<<<<<<<<
        movwf PORTA     ;<<<<<<<<<

loop     movlw msg_line
to see if it works.
__________________
L.Chung
eblc1388 is offline  
Reply With Quote
Old 11th February 2007, 04:19 PM   (permalink)
Default

From what I read from .asm and see in the schematic, I would say that the RELAY output is defaulting to its unenergized state. The BC transistor drivers is not inverted and the PIC code clears PortB on startup. Is this the output to which you are asking?

If the relay in your setup is always closing the contacts between relay pins S and P, you might be using a relay with normally closed (N.C) contacts as opposed to normally open (N.O.) contacts. Or you have a single-pole-double-throw (SPDT) relay and are using the wrong throw pin.

With all the versions of toggling floating around and since I do not trust that experimental toggle (ON/OFF) source, I suggest you perform an absolute test. Remove relay and the transistor from PIC and remove relay from transistor. Verify relay is connected to work as N.O. Reconnect relay to transistor, bias relay base with 5v and verify relay works as N.O. Before connecting relay/transistor to PIC, power on the PIC and monitor RB2 output from power up, which should be low. If its high then the asm code is toggling prematurely. I can see why because dcnt2 is use in multiple places. Just use a dedicated variable for Relay output and toggle it instead of a commonly shared variable.

Last edited by donniedj; 11th February 2007 at 04:52 PM.
donniedj is offline  
Reply With Quote
Old 11th February 2007, 04:53 PM   (permalink)
Default

Quote:
Originally Posted by eblc1388
I don't know why the output is default ON at power up. Could be due to LCD routines.

Anyway, you can try to replace:
Code:
loopx	clrf PORTA ; clear output
with these two instructions:
Code:
loopx   movlw  0x04     ;<<<<<<<<<
        movwf PORTA     ;<<<<<<<<<

loop     movlw msg_line
to see if it works.

I forgot to mention that i have a led right now in the output,instead the relay.(i don't know if that matters...)So It worked!!!!!!!But when i power up the circuit i have a pulse.The led lights for a moment and then it goes to the off state....(it's not much problem)

Thanks all for all you have done for me!!!!!!!!!!!!and especially eblc1388
_ab is offline  
Reply With Quote
Old 11th February 2007, 05:30 PM   (permalink)
Default

Quote:
Originally Posted by _ab
I forgot to mention that i have a led right now in the output,instead the relay.(i don't know if that matters...)So It worked!!!!!!!But when i power up the circuit i have a pulse.The led lights for a moment and then it goes to the off state....(it's not much problem)
It matters a lot. How was the LED connected?

From +5V to RA2 or from RA2 to 0V?
__________________
L.Chung
eblc1388 is offline  
Reply With Quote
Old 11th February 2007, 05:42 PM   (permalink)
Default

Make sure the Relay driver's input is connected to the correct PORT. It was B before, so is it A now?
donniedj is offline  
Reply With Quote
Old 11th February 2007, 09:48 PM   (permalink)
Default

Quote:
Originally Posted by eblc1388
It matters a lot. How was the LED connected?

From +5V to RA2 or from RA2 to 0V?
Why matters can you explain me?????

friend donniedj yes it's porta the output in pic16f628 version with the lcd....
Attached Images
File Type: gif connection.GIF (3.7 KB, 21 views)
_ab is offline  
Reply With Quote
Old 11th February 2007, 10:34 PM   (permalink)
Default

Ok, I see from the attached image that the output is visually inverted. The PIC is not doing the inversion but your connection method is. Turn the led around, connect the resistor to Ground instead of +V, and all will be good for now anyway.
donniedj is offline  
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
16F628 projects? epilot Micro Controllers 15 16th April 2008 03:58 AM
16F84 vs 16F628 Nigel Goodwin Micro Controllers 18 24th October 2006 07:24 PM
code convertion 16F628 -> 16F84 patroclus Micro Controllers 6 6th April 2006 08:34 PM
Proyect Board for 16F84 or 16F628 ??? terka Electronic Projects Design/Ideas/Reviews 1 25th January 2005 01:20 PM
Can JDM program 16F628 ??? dy001 Micro Controllers 3 25th September 2003 03:06 PM



All times are GMT. The time now is 11:24 PM.


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