Once again i would like your help because i am in a trouble.I have built the circuit below with the lcd version.... https://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....
"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)
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
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.....
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.
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
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)
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.
The code that I posted before last changes already worked but your way of connection of LED have given you a false impression that the output is reversed which if you connect it to a NPN transistor+relay will work correctly. If you connect a LED from +5V to RA2, then the pin need to be at 0V for the LED to light. Therefore your LED lights up when the pin is 0V. But 0V on the pin will not turn ON your relay so the relay will be OFF.
Your LED lights when in actual the relay is OFF. Got that now?
Thanks a lot my friend i appreciate what you have done for me!!!!!!!!!!!!As i said i am newbie and i wouldn't have done anything without your help......