The more I observe your code and way of thinking, the more I see its briliance.
Thank you again Richard,
Ioannis
The more I observe your code and way of thinking, the more I see its briliance.
Thank you again Richard,
Ioannis
a couple of ways
Code:pulsetrain: index=67 while index while !portb.0 :wend ;wait for hi index=index-1 pauseus 600 ;bit period=3*te ie 3*400=1200uS code.0[index]= ~ portb.0 ;sample @midpoint of bit period while portb.0 :wend ;wait for lo wend
;or with some simple time supervision
Code:fail var bit timer var word ext @timer = TMR1L PRELOAD CON 65535-820 ;@8MHz timer prediv 2 each tick=1uS pulsetrain: index=67 t1con=0 fail=0 while index timer=preload while !portb.0 :wend ;wait for hi t1con=$21 index=index-1 pauseus 600 ;bit period=3*te ie 3*400=1200uS code.0[index]= ~ portb.0 ;sample @midpoint of bit period while portb.0 && !pir1.0 :wend ;wait for lo t1con=0 fail=fail | pir1.0 wend
or sample @50,250,450,650,850 uS past transition to hi
where valid result is
11000 for a 1
11110 for a 0
there are endless methods
Warning I'm not a teacher
My simple thinking lead me to this version ditching the big array:
And then came your masterpiece of coding with TMR1...! Amazing!Code:index=0 pulsetrain: 'now collect 66 pulses ~800/400 ìsec pulsin portb.0,1,temp1 if temp1<55 then main if temp1>170 then main if temp1<130 then code.0[index]=1 else code.0[index]=0 endif index=index+1 if index<66 then pulsetrain
It just needs to be reversed (the code array) I guess. No big deal.
Thanks,
Ioannis
Last edited by Ioannis; - 5th June 2022 at 11:37.
In a noisy environment you can over sample a bit to be sure of data validity, i expect the serial data from a keeloq
chip to be quite clean so a single sample point would suffice
sample @50,250,450,650,850 uS past transition to hi
where valid result is
11000 for a 1
11110 for a 0
Code:sample var bitfail var bit fail=0 pulsetrain: index=67 while index && !fail while !portb.0 :wend pauseus 50 ;50 if !portb.0 then fail = fail | 1 pauseus 200 ;250 if !portb.0 then fail = fail | 1 pauseus 200 ;450 sample=portb.0 pauseus 200 ;650 if portb.0^sample then fail = fail | 1 pauseus 200 ;850 if portb.0 then fail = fail | 1 index=index-1 code.0[index]= !sample wend
Warning I'm not a teacher
In general the data stream on a good signal level is very clean. But when there is no RF signal, the radio module will produce a lot of noise that is converted to random pulses through the data slicer. This creates a lot of bad data and false triggers on a non rolling code systems if digital filtering is not applied. With the keeloq encryption it is safe to assume that such triggers will not happen. The probability to have 66 bits in a correct timing and also in the correct sequence, not mentioning the other safety measures of keeloq like counter etc, is really low if not zero.
When you referred to 5 sampling points I was thinking of timers etc to maintain a fixed sampling point in time...
Your code showed the application of KISS in a fine way!
Thank you for your great ideas,
Ioannis
Last edited by Ioannis; - 5th June 2022 at 21:33.
i would not expect to ever receive a malformed bit from a keeloq serial stream , the data may be useless however.The probability to have 66 bits in a correct timing and also in the correct sequence, not mentioning the other safety measures of keeloq like counter etc, is really low if not zero.
single point sampling should be ok imho
Warning I'm not a teacher
Agree.
Though I have checked various implementations of RF remote controls and many have wide tolerances from the specified timings.
I am very much sure that those chips are bad copies of the original Microchip one. But are out there... If interested, I have many test of original and copy chips with the timings in excel file.
Ioannis
Bookmarks