Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Code for detecting a pulse stream using PIC16F84A

Status
Not open for further replies.

adigwe

Junior Member level 1
Joined
Oct 5, 2004
Messages
18
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
129
Hello,

Could any one provide me with code for detecting a pulse stream such as that from a 555 timer in astable mode. Here is something I came up with. A circuit attached to RA0 and RA1 detects movement. If there is no movement the is a stream of pulses at RA0 and RA1. If there is movement, the pulse stream stops. It measures the time taken for the object to move from RA0 to RA1.

Is there a simpler way. I will appreciate the help.


;**Test of signals begins here!!!
TESTBIT BCF PORTA,0
BCF PORTA,1
TESTBIT1 BTFSS PORTA,0
GOTO TESTBIT1
PAUSE1 MOVLW 2 ;delay set(1/200th of a sec) - timer ratio 1:8 - 400Hz.
MOVWF CLKCNT
CLRF INTCON
PAUSE2 BTFSS INTCON,2 ;has a timer time-out been detected?
GOTO PAUSE2 ;no
BCF INTCON,2 ;yes
DECFSZ CLKCNT,F ;dec loop, is it zero?
GOTO PAUSE2 ;no
BTFSC PORTA,0
GOTO PAUSE1 ;no
BCF INTCON,2 ;yes
TIMECLK BTFSS INTCON,2
GOTO TIMECLK
INCREMNT BCF INTCON,2 ;capture time interval btw PORTA 0 and PORTA 1
MOVLW 1 ;increment counters COUNT0, COUNT1
ADDWF COUNT0,F
MOVF STATUS,W
ANDLW 1
ADDWF COUNT1,F ;add Carry to COUNT1
GOTO TESTBIT2 ;Check PORTA bit 1 every INTCON 2 pulse.


TESTBIT2 BTFSS PORTA,1
GOTO TESTBIT2
PAUSE3 MOVLW 2 ;delay set(1/200th of a sec) - timer ratio 1:8 - 400Hz.
MOVWF CLKCNT
CLRF INTCON
PAUSE4 BTFSS INTCON,2 ;has a timer time-out been detected?
GOTO PAUSE4 ;no
BCF INTCON,2 ;yes
DECFSZ CLKCNT,F ;dec loop, is it zero?
GOTO PAUSE4 ;no
BTFSC PORTA,1
GOTO TIMECLK ;no detection 5ms( pulse period) portA,1 has returned high
CALL KMPHR
RETURN
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top