+ Reply to Thread
Page 1 of 2
1 2 Last
Results 1 to 15 of 18

Thread: 16f84 asm to 16f628

  1. #1
    _ab
    _ab is offline
    _ab Newbie
    Join Date
    Oct 2005
    Posts
    16

    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
    Attached Files


  2. #2
    Super Moderator Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent Nigel Goodwin Excellent
    Join Date
    Nov 2003
    Location
    Derbyshire, UK
    Posts
    29,759

    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

  3. #3
    _ab
    _ab is offline
    _ab Newbie
    Join Date
    Oct 2005
    Posts
    16

    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!!!!!!

  4. #4
    Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent Mike, K8LH Excellent
    Join Date
    Jan 2005
    Location
    Michigan, USA
    Posts
    2,517

    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.

  5. #5
    eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent
    Join Date
    Jan 2005
    Location
    UK
    Posts
    2,226

    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

  6. #6
    _ab
    _ab is offline
    _ab Newbie
    Join Date
    Oct 2005
    Posts
    16

    Default

    Thank you very much for replying me......
    I changed the code as you say ,but i have the same results of the circuit..... :-(

  7. #7
    eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent
    Join Date
    Jan 2005
    Location
    UK
    Posts
    2,226

    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

  8. #8
    _ab
    _ab is offline
    _ab Newbie
    Join Date
    Oct 2005
    Posts
    16

    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

  9. #9
    eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent
    Join Date
    Jan 2005
    Location
    UK
    Posts
    2,226

    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

  10. #10
    Banned donniedj Bad donniedj Bad
    Join Date
    Jan 2004
    Location
    So Cal
    Posts
    337

    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.

  11. #11
    _ab
    _ab is offline
    _ab Newbie
    Join Date
    Oct 2005
    Posts
    16

    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

  12. #12
    eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent eblc1388 Excellent
    Join Date
    Jan 2005
    Location
    UK
    Posts
    2,226

    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

  13. #13
    Banned donniedj Bad donniedj Bad
    Join Date
    Jan 2004
    Location
    So Cal
    Posts
    337

    Default

    Make sure the Relay driver's input is connected to the correct PORT. It was B before, so is it A now?

  14. #14
    _ab
    _ab is offline
    _ab Newbie
    Join Date
    Oct 2005
    Posts
    16

    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

  15. #15
    Banned donniedj Bad donniedj Bad
    Join Date
    Jan 2004
    Location
    So Cal
    Posts
    337

    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.

+ Reply to Thread
Page 1 of 2
1 2 Last

Similar Threads

  1. 16F628 projects?
    By epilot in forum Micro Controllers
    Replies: 15
    Latest: 16th April 2008, 03:58 AM
  2. 16F84 vs 16F628
    By Nigel Goodwin in forum Micro Controllers
    Replies: 18
    Latest: 24th October 2006, 07:25 PM
  3. code convertion 16F628 -> 16F84
    By patroclus in forum Micro Controllers
    Replies: 6
    Latest: 6th April 2006, 08:35 PM
  4. Proyect Board for 16F84 or 16F628 ???
    By terka in forum Electronic Projects Design/Ideas/Reviews
    Replies: 1
    Latest: 25th January 2005, 01:20 PM
  5. Can JDM program 16F628 ???
    By dy001 in forum Micro Controllers
    Replies: 3
    Latest: 25th September 2003, 03:06 PM

Tags for this Thread