Re: finding missing pulses
I'm a bit puzzled by this, but I'm thinking a big state machine and a timer.
The state machine starts after the detection of the 1ms pulse (you could use PulseIn for that). Once you have a negative pulse with a duration of 1ms you go into the state machine. Start a timer checking for the first falling edge. If the falling edge is more than 300us you missed a pulse (tag it as missing), stop the timer and start counting again for the next 300us. If you did not miss a pulse (i.e. you got a falling edge - tag it as present), stop the timer and wait for the next rising edge, start your 300us count once more. Do this until your overall count is 10. At that point you should be ready for the next 1ms pulse. I'm probably all over the place, but this seems reasonable. This does nothing to figure whether any present pulse is a 1 or 0; but you can add that after you get the missing pulse detection part.
Re: finding missing pulses
I would suggest Interrupts on Port B, bit 0. It has Interrupt on edge either high or low, and you control this by bit 6 in Option_Reg.
I'll try a test code to show you how.
Do you have a PIC prefference?
Ioannis
Re: finding missing pulses
try something like this, you need a chip with ioc capability and dt ints
you need to set tmr1 to just exceed a 255 count when a pulse is missing
I use this state engine to decode Manchester code it should just a easily find and identify a missing pulse
rec:
pulsin rx ,0,pt
if pt < t1ms then goto rec ; look for 1ms start pulse
bit_cnt = 0 ; clr bit counter
TMR1H=0 ; clr stopped tmr1
TMR1L=0
SB=RX ;read input pin to set int on change status
T1CON=$31 ; start timer : setup timer to count past 255 when pulse missed ie say 450us = a 255 count
INTCON=$88 ; enable interrupts
IOCA.5=1 ; ioc int
while (bit_cnt < 7 ) and ( flg.0=0) ; receive 8 pulses , adjust to suit
wend
IOCA.5=0 ; ints off timer off
INTCON.0=0
T1CON=$30
; if bit_cnt < 7 then missing pulse = bit_cnt
return
rec_isr:
if TMR1H > 0 then flg.0=1 ; timer count > 255 ie. missing pulse
IF TMR1L > t300us THEN ; discriminate between 300/ 430 us
T1CON=$30
pkt.0[BIt_cnt]=!SB ; save 1 for 430 0 for 300
TMR1H=0 ; clr timer
TMR1L=0
T1CON=$31
bit_cnt = bit_cnt+1 ; inc pulse count
ENDIF
SB=RX ;read port to reset ioc state , helps if noise is a problem
INTCON.0=0
endif
@ INT_RETURN
Re: finding missing pulses
cheers guys , seems a setting the timer is the way to go and triggered by the 1ms low , working with a state machine , the problem i am seeing is the the timed pulse sometimes drift a little , but i hopping not enough over the 7ms to be incorrect. ill try some of the code and see , i am using DT_int14 for the timer's