![]() |
![]() |
![]() |
|
|
|||||||
| 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) |
|
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 |
|
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) |
|
"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!!!!!! |
|
|
|
|
|
|
(permalink) | |
|
Quote:
|
||
|
|
|
|
|
(permalink) | |
|
Quote:
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 |
||
|
|
|
|
|
(permalink) |
|
Thank you very much for replying me......
I changed the code as you say ,but i have the same results of the circuit..... :-( |
|
|
|
|
|
|
(permalink) | |
|
Quote:
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 |
||
|
|
|
|
|
(permalink) |
|
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 |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Anyway, you can try to replace: Code:
loopx clrf PORTA ; clear output Code:
loopx movlw 0x04 ;<<<<<<<<<
movwf PORTA ;<<<<<<<<<
loop movlw msg_line
__________________
L.Chung |
||
|
|
|
|
|
(permalink) |
|
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. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
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 |
||
|
|
|
|
|
(permalink) | |
|
Quote:
From +5V to RA2 or from RA2 to 0V?
__________________
L.Chung |
||
|
|
|
|
|
(permalink) |
|
Make sure the Relay driver's input is connected to the correct PORT. It was B before, so is it A now?
|
|
|
|
|
|
|
(permalink) | |
|
Quote:
friend donniedj yes it's porta the output in pic16f628 version with the lcd.... |
||
|
|
|
|
|
(permalink) |
|
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.
|
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| 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 |