CLAP CLAP circuit with RELAY OUTPUT

Post here to let others know of a project you're working on.

Moderators: Chuckt, Garth, bitfogav

Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

CLAP CLAP circuit with RELAY OUTPUT

Post by nodoubtman » Thu Aug 02, 2012 3:30 am

hi! this is the asm code for a clap clap circuit, but unfortunaly it turns the relay no after two claps, is it possible to make it for one clap ? and can you provide me the code PLEASE for a single clap, thank you sooo much!!!!
marC:)
;**********************************************************************
; This file is a basic code template for assembly code generation *
; on the PIC10F222. This file contains the basic code *
; building blocks to build upon. *
; *
; Refer to the MPASM User's Guide for additional information on *
; features of the assembler (Document DS33014). *
; *
; Refer to the respective PIC data sheet for additional *
; information on the instruction set. *
; *
;**********************************************************************
; *
; Filename: xxx.asm *
; Date: JULY 17/11 *
; File Version: Rev.A *
; *
; Author: Patrick Mitchell *
; Company: www.engineeringshock.com *
; *
; *
;**********************************************************************
; *
; Files Required: P10F222.INC *
; *
;**********************************************************************
; *
; Notes: *
; *
;**********************************************************************

list p=10F222 ; list directive to define processor
#include <p10F222.inc> ; processor specific variable definitions

__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOFSCS_4MHZ

; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.


;***** VARIABLE DEFINITIONS
TEMP_VAR UDATA
TEMP1 RES 1 ;DELAY REGISTER1
TEMP2 RES 1 ;DELAY REGISTER2
TEMP3 RES 1 ;DELAY REGISTER3
TEMP4 RES 1 ;DELAY REGISTER4
TEMP5 RES 1 ;TIMING REGISTER
TEMP6 RES 1 ;TINING REGISTER


errorlevel -302 ; suppress message 302 from list file

;**********************************************************************
ORG 0xFF ; processor reset vector

; Internal RC calibration value is placed at location 0xFF by Microchip
; as a movlw k, where the k is a literal value.

ORG 0x000 ; coding begins here
movwf OSCCAL ; update register with factory cal value

INITIALIZE
MOVLW B'1000' ; GPIO1=COMPARATOR IN - GPIO0-RELAY ACTIVATE
TRIS GPIO ; INITIALIZE
CLRF ADCON0 ; ADC DISABLE
CLRF GPIO
MOVLW B'00001000'
OPTION
CALL LOOP3
CLRF TEMP5

START:
CLRF GPIO
MOVLW B'01000001' ;analog i/p configuration
MOVWF ADCON0 ;setup GPIO,0 as ADC input
BSF ADCON0,GO ;take an ADC reading

WAITADC:
BTFSC ADCON0,GO ; poll for reading to complete
GOTO WAITADC ; if not done, keep polling
MOVLW B'00000001' ; place 01H in compare register
SUBWF ADRES,C ; compare instruction
BTFSC STATUS,C ; if ADC reading is more than 01H, a clap has been detected
GOTO NEXT ; if clap has been detected, to go NEXT routine
GOTO START ; if not, start from beginning of program


NEXT:
CALL LOOP3 ; delay
GOTO HI
;
;BCF STATUS,C ; clear STATUS flag so that we can use ADC again
;MOVLW 0XFF ; Place FFH in WREG
;MOVWF TEMP3 ; Place FFH into timing register - Will take the following steps up to 255 times (FF Hex)



NEXT2:
CALL LOOP1 ; short delay
BCF STATUS,C
MOVLW B'01000001' ; analog i/p configuration
MOVWF ADCON0 ; setup ADC
BSF ADCON0,GO ; Take an ADC reading

WAITADC2:
BTFSC ADCON0,GO ; poll for ADC reading to complete
GOTO WAITADC2 ; if not complete, poll again
MOVLW B'00000001' ; repeat same steps in earlier programming to look for second clap
SUBWF ADRES,C
BTFSC STATUS,C
GOTO HI ; if second clap is detected, to go step that turns on relay
DECFSZ TEMP3 ; if not, decrement countdown register and compare with 0
GOTO NEXT2 ; if timing register is not 0, repeat ADC reading
GOTO START ; if timing register = 0, restart program from scratch

OFF:
; the following set of routines follow the same programming as the first half of the program, only
; this time, we're looking for two claps that will turn the relay off
MOVLW B'01000001' ;analog i/p configuration
MOVWF ADCON0
BSF ADCON0,GO

WAITADC3:
BTFSC ADCON0,GO
GOTO WAITADC3
MOVLW B'00000001'
SUBWF ADRES,C
BTFSC STATUS,C
GOTO NEXT3
GOTO OFF

NEXT3:
CALL LOOP3
BCF STATUS,C
MOVLW 0XFF
MOVWF TEMP3

NEXT4:
CALL LOOP1
BCF STATUS,C
MOVLW B'01000001' ;analog i/p configuration
MOVWF ADCON0
BSF ADCON0,GO

WAITADC4:
BTFSC ADCON0,GO
GOTO WAITADC4
MOVLW B'00000001'
SUBWF ADRES,C
BTFSC STATUS,C
GOTO LO
DECFSZ TEMP3
GOTO NEXT4
GOTO OFF

HI:
; this routine turns the relay on
BSF GPIO,1
CALL LOOP3
GOTO OFF

LO:
; this routine turns the relay off
BCF GPIO,1
CALL LOOP1
GOTO INITIALIZE ; resets system to start from scratch

; *** LOOP1/2 Routines work together as a short delay routine

LOOP1:
MOVLW 0X00
MOVWF TEMP1
MOVLW 0X02
MOVWF TEMP2

LOOP2:
DECFSZ TEMP1
GOTO LOOP2
DECFSZ TEMP2
GOTO LOOP2
RETURN

; LOOP3/4 work together as a long delay routine

LOOP3:
MOVLW 0X00
MOVWF TEMP1
MOVLW 0X30
MOVWF TEMP2

LOOP4:
DECFSZ TEMP1
GOTO LOOP4
DECFSZ TEMP2
GOTO LOOP4
RETURN

END

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: CLAP CLAP circuit with RELAY OUTPUT

Post by bitfogav » Fri Aug 10, 2012 3:32 am

Why dont you see if you can change the programme yourself? :)

Ill give you a clue, you might want to remove this part of the code from within the code

Code: Select all

NEXT2:
CALL LOOP1 ; short delay
BCF STATUS,C 
MOVLW B'01000001' ; analog i/p configuration 
MOVWF ADCON0 ; setup ADC 
BSF ADCON0,GO ; Take an ADC reading

WAITADC2: 
BTFSC ADCON0,GO ; poll for ADC reading to complete
GOTO WAITADC2 ; if not complete, poll again
MOVLW B'00000001' ; repeat same steps in earlier programming to look for second clap
SUBWF ADRES,C 
BTFSC STATUS,C 
GOTO HI ; if second clap is detected, to go step that turns on relay
DECFSZ TEMP3 ; if not, decrement countdown register and compare with 0
GOTO NEXT2 ; if timing register is not 0, repeat ADC reading
GOTO START ; if timing register = 0, restart program from scratch
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: CLAP CLAP circuit with RELAY OUTPUT

Post by nodoubtman » Thu Aug 16, 2012 4:38 am

bitfogav wrote:Why dont you see if you can change the programme yourself? :)

Ill give you a clue, you might want to remove this part of the code from within the code

Code: Select all

NEXT2:
CALL LOOP1 ; short delay
BCF STATUS,C 
MOVLW B'01000001' ; analog i/p configuration 
MOVWF ADCON0 ; setup ADC 
BSF ADCON0,GO ; Take an ADC reading

WAITADC2: 
BTFSC ADCON0,GO ; poll for ADC reading to complete
GOTO WAITADC2 ; if not complete, poll again
MOVLW B'00000001' ; repeat same steps in earlier programming to look for second clap
SUBWF ADRES,C 
BTFSC STATUS,C 
GOTO HI ; if second clap is detected, to go step that turns on relay
DECFSZ TEMP3 ; if not, decrement countdown register and compare with 0
GOTO NEXT2 ; if timing register is not 0, repeat ADC reading
GOTO START ; if timing register = 0, restart program from scratch
i don't know assembly i will try thank you bigof! :)

marC:)
Last edited by nodoubtman on Thu Aug 16, 2012 5:27 am, edited 1 time in total.

nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: CLAP CLAP circuit with RELAY OUTPUT

Post by nodoubtman » Thu Aug 16, 2012 4:44 am

I guess i will have to remove this part too ?? :
WAITADC3:
BTFSC ADCON0,GO
GOTO WAITADC3
MOVLW B'00000001'
SUBWF ADRES,C
BTFSC STATUS,C
GOTO NEXT3
GOTO OFF

NEXT3:
CALL LOOP3
BCF STATUS,C
MOVLW 0XFF
MOVWF TEMP3

NEXT4:
CALL LOOP1
BCF STATUS,C
MOVLW B'01000001' ;analog i/p configuration
MOVWF ADCON0
BSF ADCON0,GO

WAITADC4:
BTFSC ADCON0,GO
GOTO WAITADC4
MOVLW B'00000001'
SUBWF ADRES,C
BTFSC STATUS,C
GOTO LO
DECFSZ TEMP3
GOTO NEXT4
GOTO OFF

thanks!
marC:)

yes? :)

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: CLAP CLAP circuit with RELAY OUTPUT

Post by bitfogav » Thu Aug 16, 2012 5:08 am

nodoubtman wrote:i don't know assembly i will try thank you brad! :)
marC:)
We all had to start somewhere, Brads assembly tutorials are always a good place to start.
Brads Tutorials

nodoubtman wrote: I guess i will have to remove this part too ?? :
WAITADC3:
BTFSC ADCON0,GO
GOTO WAITADC3
MOVLW B'00000001'
SUBWF ADRES,C
BTFSC STATUS,C
GOTO NEXT3
GOTO OFF

NEXT3:
CALL LOOP3
BCF STATUS,C
MOVLW 0XFF
MOVWF TEMP3

NEXT4:
CALL LOOP1
BCF STATUS,C
MOVLW B'01000001' ;analog i/p configuration
MOVWF ADCON0
BSF ADCON0,GO

WAITADC4:
BTFSC ADCON0,GO
GOTO WAITADC4
MOVLW B'00000001'
SUBWF ADRES,C
BTFSC STATUS,C
GOTO LO
DECFSZ TEMP3
GOTO NEXT4
GOTO OFF

thanks!
marC:)

yes? :)
Yes you can remove that code aswell but you will need to come up with some code to turn off the relay after it has been activated.


Gavin :)
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: CLAP CLAP circuit with RELAY OUTPUT

Post by nodoubtman » Thu Aug 16, 2012 5:23 am

HI:
; this routine turns the relay on
BSF GPIO,1
CALL LOOP2
GOTO OFF

just put LOOP2 instead LOOP3 , is it okay?

LO:
; this routine turns the relay off
BCF GPIO,1
CALL LOOP1
GOTO INITIALIZE ; resets system to start from scratch
----

here's the full code for one single clap :

;**********************************************************************
; This file is a basic code template for assembly code generation *
; on the PIC10F222. This file contains the basic code *
; building blocks to build upon. *
; *
; Refer to the MPASM User's Guide for additional information on *
; features of the assembler (Document DS33014). *
; *
; Refer to the respective PIC data sheet for additional *
; information on the instruction set. *
; *
;**********************************************************************
; *
; Filename: xxx.asm *
; Date: JULY 17/11 *
; File Version: Rev.A *
; *
; Author: Patrick Mitchell *
; Company: http://www.engineeringshock.com *
; *
; *
;**********************************************************************
; *
; Files Required: P10F222.INC *
; *
;**********************************************************************
; *
; Notes: *
; *
;**********************************************************************

list p=10F222 ; list directive to define processor
#include <p10F222.inc> ; processor specific variable definitions

__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOFSCS_4MHZ

; '__CONFIG' directive is used to embed configuration word within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.


;***** VARIABLE DEFINITIONS
TEMP_VAR UDATA
TEMP1 RES 1 ;DELAY REGISTER1
TEMP2 RES 1 ;DELAY REGISTER2
TEMP3 RES 1 ;DELAY REGISTER3
TEMP4 RES 1 ;DELAY REGISTER4
TEMP5 RES 1 ;TIMING REGISTER
TEMP6 RES 1 ;TINING REGISTER



;**********************************************************************
ORG 0xFF ; processor reset vector

; Internal RC calibration value is placed at location 0xFF by Microchip
; as a movlw k, where the k is a literal value.

ORG 0x000 ; coding begins here
movwf OSCCAL ; update register with factory cal value

INITIALIZE
MOVLW B'1000' ; GPIO1=COMPARATOR IN - GPIO0-RELAY ACTIVATE
TRIS GPIO ; INITIALIZE
CLRF ADCON0 ; ADC DISABLE
CLRF GPIO
MOVLW B'00001000'
OPTION
CALL LOOP1
CLRF TEMP5

START:
CLRF GPIO
MOVLW B'01000001' ;analog i/p configuration
MOVWF ADCON0 ;setup GPIO,0 as ADC input
BSF ADCON0,GO ;take an ADC reading

WAITADC:
BTFSC ADCON0,GO ; poll for reading to complete
GOTO WAITADC ; if not done, keep polling
MOVLW B'00000001' ; place 01H in compare register
SUBWF ADRES,C ; compare instruction
BTFSC STATUS,C ; if ADC reading is more than 01H, a clap has been detected
GOTO NEXT ; if clap has been detected, to go NEXT routine
GOTO START ; if not, start from beginning of program

NEXT:
CALL LOOP2 ; delay
BCF STATUS,C ; clear STATUS flag so that we can use ADC again
MOVLW 0XFF ; Place FFH in WREG
MOVWF TEMP3 ; Place FFH into timing register - Will take the following steps up to 255 times (FF Hex)

OFF:
; the following set of routines follow the same programming as the first half of the program, only
; this time, we're looking for two claps that will turn the relay off
MOVLW B'01000001' ;analog i/p configuration
MOVWF ADCON0
BSF ADCON0,GO

HI:
; this routine turns the relay on
BSF GPIO,1
CALL LOOP2
GOTO OFF

LO:
; this routine turns the relay off
BCF GPIO,1
CALL LOOP1
GOTO INITIALIZE ; resets system to start from scratch

; *** LOOP1/2 Routines work together as a short delay routine

LOOP1:
MOVLW 0X00
MOVWF TEMP1
MOVLW 0X02
MOVWF TEMP2

LOOP2:
DECFSZ TEMP1
GOTO LOOP2
DECFSZ TEMP2
GOTO LOOP2
RETURN

END

is okay?

thanks!
marC:)

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: CLAP CLAP circuit with RELAY OUTPUT

Post by bitfogav » Thu Aug 16, 2012 6:25 am

This is probably what I would have done.

Code: Select all

	
	list p=10F222 ; list directive to define processor
	#include <p10F222.inc> ; processor specific variable definitions
	
	__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOFSCS_4MHZ
	
	; '__CONFIG' directive is used to embed configuration word within .asm file.
	; The lables following the directive are located in the respective .inc file.
	; See respective data sheet for additional information on configuration word.
	
	errorlevel -302 ; suppress message 302 from list file 

	;***** VARIABLE DEFINITIONS

	cblock 0x09
		counta
		countb
		countc
	endc
	
	
	;**********************************************************************
	ORG 0xFF 		; processor reset vector
	
	; Internal RC calibration value is placed at location 0xFF by Microchip
	; as a movlw k, where the k is a literal value.
	
	ORG 0x000 		; coding begins here
	movwf OSCCAL 	; update register with factory cal value
	
INITIALIZE
	MOVLW B'1000' 	; GPIO1=COMPARATOR IN - GPIO0-RELAY ACTIVATE
	TRIS GPIO 		; INITIALIZE
	CLRF ADCON0 	; ADC DISABLE
	CLRF GPIO
	MOVLW B'00001000'
	OPTION
	NOP
	NOP
	
START: 
	CLRF GPIO
	MOVLW B'01000001' 	; analog i/p configuration 
	MOVWF ADCON0 		; setup GPIO,0 as ADC input
	BSF ADCON0,GO 		; take an ADC reading
	
WAITADC: 
	BTFSC ADCON0,GO 	; poll for reading to complete
	GOTO WAITADC 		; if not done, keep polling 
	MOVLW B'00000001' 	; place 01H in compare register 
	SUBWF ADRES,C 		; compare instruction
	BTFSC STATUS,C 		; if ADC reading is more than 01H, a clap has been detected
	GOTO NEXT 			; if clap has been detected, to go NEXT routine
	GOTO START 			; if not, start from beginning of program
		
NEXT:
	CALL Delay255 		; delay
	GOTO HI
	
OFF: 
	; the following set of routines follow the same programming as the first half of the program, only
	; this time, we're looking for one clap that will turn the relay off.
	MOVLW B'01000001' 	; analog i/p configuration 
	MOVWF ADCON0 
	BSF ADCON0,GO 
	
WAITADC2: 
	BTFSC ADCON0,GO 	; poll for reading to complete
	GOTO WAITADC2 		; if not done, keep polling 
	MOVLW B'00000001' 	; place 01H in compare register 
	SUBWF ADRES,C 		; compare instruction
	BTFSC STATUS,C 		; if ADC reading is more than 01H, a clap has been detected
	GOTO NEXT2 			; if clap has been detected, to go NEXT2 routine
	GOTO WAITADC2	 	; if not, start from beginning of program 
	
NEXT2:
	CALL Delay255		; delay	
	GOTO LO
	
HI:
	; this routine turns the relay on
	BSF GPIO,1
	CALL Delay255
	GOTO OFF
	
LO:
	; this routine turns the relay off
	BCF GPIO,1
	CALL Delay255
	GOTO INITIALIZE 	; resets system to start from scratch

	
; Delays ============================================================================
Delay255	
		movlw	d'255'		; delay 255 mS
		goto	d0
Delay100	
		movlw	d'100'		; delay 100mS
		goto	d0
Delay50		
		movlw	d'50'		; delay 50mS
		goto	d0
Delay20		
		movlw	d'20'		; delay 20mS
		goto	d0
Delay5		
		movlw	d'05'		; delay 5ms (4 MHz clock)
d0		movwf	counta
d1		movlw	d'199'		; delay 1mS
		movwf	countb
		movlw	d'01'
		movwf	countc
Delay_0
		decfsz	countb, f
		goto	$+2			; skip two clock cycles 
		decfsz	countc, f
		goto	Delay_0

		decfsz	counta, f
		goto	d1			;	once counta and countb have reached zero
		RETLW 0

	END
Heres the Hex file:
clapclap.rar
(274 Bytes) Downloaded 574 times
I have not tested this code but it compiles in MPLAB all ok. And I dont know whether it will support the hardware either!?.
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: CLAP CLAP circuit with RELAY OUTPUT

Post by nodoubtman » Thu Aug 16, 2012 11:44 pm

bitfogav wrote:This is probably what I would have done.

Code: Select all

	
	list p=10F222 ; list directive to define processor
	#include <p10F222.inc> ; processor specific variable definitions
	
	__CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF & _MCPU_OFF & _IOFSCS_4MHZ
	
	; '__CONFIG' directive is used to embed configuration word within .asm file.
	; The lables following the directive are located in the respective .inc file.
	; See respective data sheet for additional information on configuration word.
	
	errorlevel -302 ; suppress message 302 from list file 

	;***** VARIABLE DEFINITIONS

	cblock 0x09
		counta
		countb
		countc
	endc
	
	
	;**********************************************************************
	ORG 0xFF 		; processor reset vector
	
	; Internal RC calibration value is placed at location 0xFF by Microchip
	; as a movlw k, where the k is a literal value.
	
	ORG 0x000 		; coding begins here
	movwf OSCCAL 	; update register with factory cal value
	
INITIALIZE
	MOVLW B'1000' 	; GPIO1=COMPARATOR IN - GPIO0-RELAY ACTIVATE
	TRIS GPIO 		; INITIALIZE
	CLRF ADCON0 	; ADC DISABLE
	CLRF GPIO
	MOVLW B'00001000'
	OPTION
	NOP
	NOP
	
START: 
	CLRF GPIO
	MOVLW B'01000001' 	; analog i/p configuration 
	MOVWF ADCON0 		; setup GPIO,0 as ADC input
	BSF ADCON0,GO 		; take an ADC reading
	
WAITADC: 
	BTFSC ADCON0,GO 	; poll for reading to complete
	GOTO WAITADC 		; if not done, keep polling 
	MOVLW B'00000001' 	; place 01H in compare register 
	SUBWF ADRES,C 		; compare instruction
	BTFSC STATUS,C 		; if ADC reading is more than 01H, a clap has been detected
	GOTO NEXT 			; if clap has been detected, to go NEXT routine
	GOTO START 			; if not, start from beginning of program
		
NEXT:
	CALL Delay255 		; delay
	GOTO HI
	
OFF: 
	; the following set of routines follow the same programming as the first half of the program, only
	; this time, we're looking for one clap that will turn the relay off.
	MOVLW B'01000001' 	; analog i/p configuration 
	MOVWF ADCON0 
	BSF ADCON0,GO 
	
WAITADC2: 
	BTFSC ADCON0,GO 	; poll for reading to complete
	GOTO WAITADC2 		; if not done, keep polling 
	MOVLW B'00000001' 	; place 01H in compare register 
	SUBWF ADRES,C 		; compare instruction
	BTFSC STATUS,C 		; if ADC reading is more than 01H, a clap has been detected
	GOTO NEXT2 			; if clap has been detected, to go NEXT2 routine
	GOTO WAITADC2	 	; if not, start from beginning of program 
	
NEXT2:
	CALL Delay255		; delay	
	GOTO LO
	
HI:
	; this routine turns the relay on
	BSF GPIO,1
	CALL Delay255
	GOTO OFF
	
LO:
	; this routine turns the relay off
	BCF GPIO,1
	CALL Delay255
	GOTO INITIALIZE 	; resets system to start from scratch

	
; Delays ============================================================================
Delay255	
		movlw	d'255'		; delay 255 mS
		goto	d0
Delay100	
		movlw	d'100'		; delay 100mS
		goto	d0
Delay50		
		movlw	d'50'		; delay 50mS
		goto	d0
Delay20		
		movlw	d'20'		; delay 20mS
		goto	d0
Delay5		
		movlw	d'05'		; delay 5ms (4 MHz clock)
d0		movwf	counta
d1		movlw	d'199'		; delay 1mS
		movwf	countb
		movlw	d'01'
		movwf	countc
Delay_0
		decfsz	countb, f
		goto	$+2			; skip two clock cycles 
		decfsz	countc, f
		goto	Delay_0

		decfsz	counta, f
		goto	d1			;	once counta and countb have reached zero
		RETLW 0

	END
Heres the Hex file:
clapclap.rar
I have not tested this code but it compiles in MPLAB all ok. And I dont know whether it will support the hardware either!?.
thank you so much! :)
marC:)

nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: CLAP CLAP circuit with RELAY OUTPUT

Post by nodoubtman » Fri Aug 17, 2012 9:38 am

that doesn't seems to work okay, maybe you need the hardware setting :
clapclap.jpg
clapclap.jpg (24.78 KiB) Viewed 18803 times
marC:)



EDITED: by bitfogav*

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: CLAP CLAP circuit with RELAY OUTPUT

Post by bitfogav » Sat Aug 18, 2012 3:35 am

Have you tested your circuit with the two clap programme, Do the circuit work then?.
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: CLAP CLAP circuit with RELAY OUTPUT

Post by nodoubtman » Mon Aug 20, 2012 9:00 am

bitfogav wrote:Have you tested your circuit with the two clap programme, Do the circuit work then?.
yeah his source code works !

but can you modify it for one single clap with this hardware?

thanks!
marC:)

User avatar
bitfogav
Moderator
Moderator
Posts: 915
Joined: Sun Mar 28, 2010 9:03 pm
Location: United Kingdom
Contact:

Re: CLAP CLAP circuit with RELAY OUTPUT

Post by bitfogav » Tue Aug 21, 2012 7:32 am

So when you use the two clap programme then everything works correctly??, what happens when you use my programme? Do anything happen when you clap once?.
If you don't know what Voltage your country is using, you shouldn't be doing electronics ;-)

nodoubtman
Can't get enough of electronics!
Can't get enough of electronics!
Posts: 76
Joined: Wed Jan 25, 2012 2:54 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Re: CLAP CLAP circuit with RELAY OUTPUT

Post by nodoubtman » Wed Aug 22, 2012 4:29 am

bitfogav wrote:So when you use the two clap programme then everything works correctly??, what happens when you use my programme? Do anything happen when you clap once?.
no nothings happens, the led is still on, no reaction of the relay

thanks!
marC:)

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1266: count(): Parameter must be an array or an object that implements Countable

Who is online

Users browsing this forum: No registered users and 7 guests