Previous in Forum: Three Basic Steps to Avoid Joining a Botnet   Next in Forum: Radiation Hazard Detectors
Close
Close
Close
8 comments
Rate Comments: Nested
Anonymous Poster

Detecting a Missing Pulse Using a PIC16F873A

01/05/2010 4:44 AM

I am relatively new to PIC assembly code and need to monitor a pulse stream on a single port testing a bank of relay contacts, the pulse rate is very slow at about 500ms mark space. All I need to do is monitor the pulse stream to detect any missing pulses and then jump to a failure routine I have already written. I'm guessing this is straight forward and would appreciate a small block of code for me to work on as I am in the dark and have little time.

Thank You,

Craig

Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.

Good Answers:

These comments received enough positive votes to make them "good answers".

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
2
Guru
Technical Fields - Technical Writing - New Member Engineering Fields - Piping Design Engineering - New Member

Join Date: May 2009
Location: Richland, WA, USA
Posts: 21017
Good Answers: 795
#1

Re: Detecting a Missing Pulse Using a PIC16F873A

01/05/2010 4:54 AM

How about this? Set up a timer. Each pulse resets the timer to, say, 600 ms. If the pulses come regularly, the timer always gets reset brfore counting down to zero. If a pulse is missing, the timer bottoms out and triggers your failure subroutine.

__________________
In vino veritas; in cervisia carmen; in aqua E. coli.
Reply Good Answer (Score 2)
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670
#2
In reply to #1

Re: Detecting a Missing Pulse Using a PIC16F873A

01/05/2010 6:29 AM

GA...The timer can even be just a simple dumb delay loop which counts down, every time the pulse is seen it resets the counter to say 255, if the counter gets down to zero all hell breaks loose it sets the alarm.
Del

__________________
health warning: These posts may contain traces of nut.
Reply
Guru

Join Date: Oct 2006
Location: New Jersey U.S.A.
Posts: 1114
Good Answers: 38
#3

Re: Detecting a Missing Pulse Using a PIC16F873A

01/05/2010 8:23 AM

GA Simple and concise. No need for extraneous Bullsh*#.

__________________
The last fight was my fault. My wife asked "What's on the TV?" I said "Dust!"
Reply
Guru

Join Date: Aug 2005
Location: Hemel Hempstead, UK
Posts: 5826
Good Answers: 322
#4

Re: Detecting a Missing Pulse Using a PIC16F873A

01/06/2010 2:58 AM

You might find some useful stuff here too:-

Google search for "watchdog timer PIC"

__________________
If you spend all your time looking for people and things to complain about: trust me, you will find plenty to complain about.
Reply
Guru
Popular Science - Weaponology - New Member Safety - ESD - New Member Hobbies - Fishing - New Member

Join Date: Sep 2006
Location: Near Frankfurt am Main, Germany. 50.390866N, 8.884827E
Posts: 17996
Good Answers: 200
#5

Re: Detecting a Missing Pulse Using a PIC16F873A

01/06/2010 4:52 AM

Look for a retrigerable Monostable circuit on the web, a simple circuit using a 555 is more than enough.

__________________
"What others say about you reveals more about them, than it does you." Anon.
Reply Score 1 for Good Answer
Anonymous Poster
#6
In reply to #5

Re: Detecting a Missing Pulse Using a PIC16F873A

01/08/2010 6:39 AM

I've already designed an analogue circuit using a 556 that then delivers a logic input to the PIC if a pusle is missed but as I have space left I decided to give it a go in code to simplify the circuit, I am a bit of a novice with pic assembly but have something that seems to do the job:

#include <P16F873.inc>

ORG 0x000 ; processor reset vector
clrf PCLATH ; ensure page bits are cleared



COUNT1 equ 20h
COUNT2 equ 21h
COUNT5 equ 24h

main

bsf STATUS,5
movlw 0x03
movwf TRISB
bcf STATUS,5 ;set up portb i/o's

movlw 0x00
movwf PORTB ;clear portb

wait btfss PORTB,0 ;wait for start
goto wait

start movlw 0x03
movwf COUNT3

loop btfsc PORTB,1
goto chkrmton ;go here if portb,1 goes low
call delay3
decfsz COUNT3,1 ;check portb,1 3 counts fail is reaches 0
goto loop


fail bsf PORTB,3
call delay
bcf PORTB,3
call delay
goto fail

chkrmton btfsc PORTB,0 ;if portb,0 is low, pass
goto start
pass bsf PORTB,2
goto pass

delay ;approx .45s @4MHz
movlw 0x06
movwf COUNT5
start3 decfsz COUNT1,1
goto start3
decfsz COUNT2,1
goto start3
decfsz COUNT5,1
goto start3
RETURN

end

This basically looks at portb 0 & 1, portb,0 starts the monitoring on portb,1 if a pulse is missed the delay times out and checks portb,0 and if still hi it jumps to a loop to flash an LED on portb,3. If portb,0 is low it lights an LED to signify no pulses missed.

Any edits to my very basic code graciously accepted

Reply
Guru
Popular Science - Weaponology - New Member United Kingdom - Member - New Member

Join Date: May 2007
Location: Harlow England
Posts: 16512
Good Answers: 670
#7

Re: Detecting a Missing Pulse Using a PIC16F873A

01/08/2010 7:19 AM

I've found your missing pulse...it was lost out in the snow.
I've brought it in, given it a nice hot drink of cocoa and sat it down in front of the fire.
I shall keep it as a family pet.
Del

__________________
health warning: These posts may contain traces of nut.
Reply
Anonymous Poster
#8
In reply to #7

Re: Detecting a Missing Pulse Using a PIC16F873A

01/08/2010 7:29 AM

I'm glad it's gone to a good home.

Reply
Reply to Forum Thread 8 comments

Good Answers:

These comments received enough positive votes to make them "good answers".

"Almost" Good Answers:

Check out these comments that don't yet have enough votes to be "official" good answers and, if you agree with them, vote them!
Copy to Clipboard

Users who posted comments:

Andy Germany (1); Anonymous Poster (2); charsley99 (1); Randall (1); Tornado (1); user-deleted-1105 (2)

Previous in Forum: Three Basic Steps to Avoid Joining a Botnet   Next in Forum: Radiation Hazard Detectors
You might be interested in: Bar Code Scanners, Bar Code Cards, Bar Code Software

Advertisement