Sunday, July 15, 2007

Fix to MAnchester Decoding Receive Routines of tb 045 from microchip (keeloq)

Hi! So, i am here again! (link to second part of the FIX HERE)
I will try write in english, but cannot garante clear typing.
I am working on manchester receiver and transmiter for portable remote control, based in the manchester decoder system for keeloq system. The manchester decoder routines is shared by the microchip, and has been seen made by Lucio Di Jasio.
In order to use the receiver I has build a software for transmiter manchester code. Afther much debug, it work fine and make-me learn alot about michochip assembler!
The receiver code was very powerfull, but since make it work with my routines have found some strangers things happening.
I send a burst of 90~100 bits every key press, with transmiter codes, and key being pressed. But some times the receiver dont recognize even clean code sequences. Read the some time as 1 each 15 pressed of key.
The code is transmited, but the receiver dont recognize.
In order to make the debug of transmited data, I use SoundCard as "osciloscope", since I send just 2500bps in AM. Work very fine just for this purpose.
And the data that is seen in capture program not lies; is always right, but the receiver reject the data sometimes.
Too look where is the mistake, I use some nice thicks.
First, to you understand you have that understand that decoding manchester data (as presented in TB045 for keeloq system) is based in a state machine implemented in software driven by interrupt routines.
The state machine are a "4 state" machine, that dictates how the data are recognized and received. You should read the microchip documentation in order to understand all the states, I will not tell nothing about its.
The important is, i put BSF e BCF in each state to FLAG pins outside the PIC.
Just for know, the state 0(zero) reset all other states, and restart the receiver for complete new burst. So i reset all states in the state 0. In state 1 I BSF PIN1, and so in same manner to other states. So i can see where is happening the lost of data when the system not recognize some busrt!
Is my first time with PICs, and pic assembler language, just 3 weeks working over this great pice of silicon, and feel like powerfull tool for small programming tasks.

Above the data in right maner, without any error. The top graph represent the send data, and the lower the response of one of states of keeloq receiver. In this case, the receiver and states work in a very nice way. Receive all data, without troubles.
In next post i will put the response of others states in normal way, and what happen when it lost data.
This new post bring the fix to live, if someone have interest.

3 comments:

Sander Schutten said...

Hi FF,

for my home automation project based on the Arduino platform i'm trying to correctly manchester decode a signal sent by my car key. I am able to receive and recognize a constant pulsetrain consisting of 88bits. I am also already able to differentiate the different carkeys (main and a spare key) and a lock/unlock flag.
I hope to get into contact with you as you are state in your post the Keeloq pulsetrain should be 90bits. I want to verify my decoding code.

thanks, Sander (The Netherlands)

amfs said...

Hi Sander,
would you share your arduino based KeeLoq manchester decoder ? I´m would like to inteface my arduino to Microchip (un)secure tx chip...

amunisfz@gmail.com

chico said...

Sorry my delay to aswer your questions. If you still have some doubt about keyloq that i can help, tell-me.
FF.(hernandi)