PDA

View Full Version : Help with Pic Delay code mod please



g7jiq
- 22nd March 2009, 10:50
Hi all (again)

I big thanks to all that have help me in the past,
But I have a small problem I hope someone can put me straight with.

Below is my code I have had running for some time with no problems,
What it does is to allow an input to output with a delay on the output when the input is removed,
What I would like to add to this is if the input trigger is longer than say 1 second the output is triggered as before but doesn't have any delay,
If the input has smaller pulses of say less than 1 second the delay is as before.

I hope this makes sense,
Any ideas...?

Many thanks to all ....

************************************************** *************

'G7JIQ MICRO LINK REPEATER
'PIC 12F675
'Internal RC clock
'
' PIC Defines
' -----------
@ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
' System Clock Options (Internal)
@ DEVICE pic12F675, WDT_ON
' Watchdog Timer
@ DEVICE pic12F675, PWRT_ON
' Power-On Timer
@ DEVICE pic12F675, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic12F675, BOD_ON
' Brown-Out Detect
@ DEVICE pic12F675, CPD_OFF
' Data Memory Code Protect
@ DEVICE pic12F675, PROTECT_OFF
' Program Code Protection

'
' Define Hardware
' ---------------
InputTrigger var GPIO.5 ' Input normally HIGH, goes LOW to Trigger
InputReset var GPIO.2 ' Input normally HIGH, goes LOW to RESET
OutputLine var GPIO.0 ' Normally HIGH, goes LOW when triggered
Led var GPIO.1
'
' Define Variables
' ----------------
DelayTick var Byte ' 100mS Tick Counter

'
' Initialise PIC
' --------------
Reset:
TRISIO=%00100100 ' Preset I/O
CMCON=%00000111 ' Disable Comparators
ANSEL=%00000000 ' Disable ADC
DelayTick=0 ' Reset Counter
high OutputLine ' Everything RESET


' pause 4000

' Main Program Loop
' -----------------
Loop:
'
' Test for RESET
' --------------
While InputReset=0 ' Just wait here if RESET
DelayTick=0 ' Reset Counter
high OutputLine ' Reset Output
Wend
'
' Test for Trigger
' ----------------
If InputTrigger=0 then ' Test for Trigger
low OutputLine ' Enable Output
DelayTick=1 ' Arm Counter
'Goto Loop
endif
'
' Timeout Counter
' ---------------
If DelayTick>0 then
DelayTick=DelayTick+1 ' Count Time
Pause 60 ' Waste 100mS
If DelayTick>50 then goto Reset
' 50 = 5 sec
' 100 = 10 sec
' origanly set at 201 Reset at 20 Seconds
endif
Goto Loop

'
End

g7jiq
- 26th March 2009, 00:06
Can anyone please help me with my previous post.
Any takers please...