CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

pic12f1822 decoding holtec code

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
gl17



Joined: 23 Jul 2013
Posts: 2

View user's profile Send private message

pic12f1822 decoding holtec code
PostPosted: Tue Jul 23, 2013 2:17 pm     Reply with quote

Hi all.
I have a pic12f1822 (with internal RC osc) board with a signal line connected to PIN_A3
I need to decode holtec HT6012 transmitter code.
it looks like so (first 250us "П" pulse is synchro, others are data)


Additional problem - it's a radio channel, and without transmitting it looks so at pin_A3 (sorry haven't good oscilloscope at home) (bottom - transmitter works)


I tried to do it using timer1 directly, like so
Code:

//setup_timer1=1us
//call checkCode after first pulse
unsigned int32 checkCode(void)
{
   unsigned int8 lastState = 0;
   unsigned int8 i;
   unsigned int32 code;
   unsigned int16 timerValue;
   int1 state;
   state = 0;
   putc(0x66);
   while (1) {
      if (get_timer1() > 0x1388) {code = 0xA0000000;break;} // >5ms are passed
      if (input(IN) != state) { //PIN state changed
         timerValue = get_timer1();
         set_timer1(0);
         state = !state;
         i++;
         if ((timerValue > byte_time_low0) & (timerValue < byte_time_low1)) {   
                              // lastState = 0: none, 1: _--250, 2: __-500 ,3: -_250 , 4: --_500
                               // in hex == { 0, 1, z } trinary state of pin
                              // __-__- 1   _--_-- 0   __-_-- z
                                       // == 11, 00, 01 half-bits in transmission (LSB 1st)

            if (state == 1) {       //1: _--250
               if (lastState == 0) {lastState = 1;}
               else {code = 0xA0000000;break;} //bad code
            }
            else { // state == 0    //3: -_250
               if (lastState == 0) {code = 0xA0000000;break;} //bad code
               else {
                  if (lastState == 2) {
                     lastState = 0;
                     code = (code << 1) | 0x01;  //
                  } //good code
                  else {code = 0xA0000000;break;} //bad code
               }
            }            
         }
         else {
            if ((timerValue > byte_time_high0) & (timerValue < byte_time_high1)) {
               if (state == 1) {       //2: __-500
                  if (lastState == 0) {lastState = 2;}
                  else {code = 0xA0000000;break;} //bad code
               }
               else { // state == 0    //4: --_500
                  if (lastState == 0) {code = 0xA0000000;break;} //bad code
                  else {
                     if (lastState == 3) {
                        lastState = 0;
                        code = (code << 1) | 0x00;  //
                     } //good code
                     else {code = 0xA0000000;break;} //bad code
                  }
               }   
            }
            else { // bad byte time
               code = 0xA0000000;break;
            }
         }
      }
   if (i==49) {break;}
   }
   return code; //error if timeout, or error time_packet, or error packet len   
}


it doesn't works, looks like i don't have enough time between pulses.
and i'm feeling i'm doing something really wrong

any ideas how to solve it briefly and elegant ?
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Jul 23, 2013 5:12 pm     Reply with quote

HOLTEC decoder IC interfaced to pic?

these have limiters/ signal cleaner circuit and barrel shiffter.
gl17



Joined: 23 Jul 2013
Posts: 2

View user's profile Send private message

PostPosted: Tue Jul 23, 2013 6:22 pm     Reply with quote

no additional IC's (
signal from RF circuit goes directly at pin
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Jul 23, 2013 7:12 pm     Reply with quote

best of luck with the recovered signal Very Happy Very Happy Very Happy
gpsmikey



Joined: 16 Nov 2010
Posts: 588
Location: Kirkland, WA

View user's profile Send private message

PostPosted: Tue Jul 23, 2013 11:10 pm     Reply with quote

Without a decent front end to recover that signal, I think you are for an exercise in frustration - the old "garbage in - garbage out" applies here with a signal that looks that ratty.

mikey
_________________
mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Jul 24, 2013 8:42 am     Reply with quote

BTW: 40 years of my career has been involved with RF .

and the recovered signal you show looks for all the world like its either :

1- unfiltered direct conversion output, with low signal input
or
2- heterodyne IF system well below limiting
or
3- slight frequency mismatch between TX and your RX

And on second thought , even the Holtec receiver chip will not be of much use with that signal as an input.

Either way , you will find no joy as you attempt reliable data recovery.
Your RF link is way too crappy, and no PIC code is gonna make it right.

you can take it to the bank .
Sad Sad
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group