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

Processing data from a RF module

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







Processing data from a RF module
PostPosted: Tue Jun 06, 2006 3:10 pm     Reply with quote

Whenever the transmitter is not transmitting, I get alot of garbage from my RX module. I'm sending an ascii message and it looks like this

UUU + (manchester encoded byte or 16bit)+UUU.

Is using Kbhit to poll for incoming serial data a good idea in this case? I tried it and it seems to freeze up my pic.

I'm trying to intercept my ascii message, parse it and decode the manchester encoded byte.
danX
Guest







PostPosted: Tue Jun 06, 2006 3:15 pm     Reply with quote

the thing making it hard is all the garbage characters going into the pic. THe pic seems overwhelm or something.

Right now i'm just trying to see if I can intercept the message and prints it to the screen. No decoding is done.

Code:
#include <16F88.h>
#device adc=8
#fuses XT,NOWDT,PROTECT,NOBROWNOUT,PUT,NOMCLR
#use delay (clock=4000000)
#use rs232(baud=14400, xmit=PIN_B5, rcv=PIN_B2)

#define uint8 char
#define uint16 long

uint16 man_encode(uint8 unenc);
uint8 man_decode(uint16 enc);
char string[20];
int receive_error=0;

main()
{
uint16 encoded=0;
uint8 decoded=0;

   while(1)
   {
      if(kbhit()&& (getc()=='U'))
      {
        gets(string);
      }
     
      printf(string);

      output_high(PIN_B4);
      delay_ms(500);
      output_low(PIN_B4);
      delay_ms(500);

   }

}



uint16 man_encode(uint8 unenc) {
   uint8 odd_byte,even_byte,temp;

   odd_byte=unenc&0xAA;
   temp=(~unenc&0xAA)>>1;
   odd_byte=odd_byte|temp;

   even_byte=unenc&0x55;
   temp=(~unenc&0x55)<<1;
   even_byte=even_byte|temp;
   return((uint16)odd_byte<<8)|even_byte;
}

uint8 man_decode(uint16 enc) {
   uint8 odd_byte,even_byte,temp;

   odd_byte=(uint8)(enc>>8);
   if((odd_byte&0xAA)^((~odd_byte&0x55)<<1)) {
      receive_error=1;
      return(0);
   } else odd_byte&=0xAA;
   even_byte=(uint8)enc;
   if((even_byte&0x55)^((~even_byte&0xAA)>>1)) {
      receive_error=1;
      return(0);
   } else even_byte&=0x55;
   receive_error=0;
   return(odd_byte|even_byte);
}
DanX
Guest







PostPosted: Tue Jun 06, 2006 3:17 pm     Reply with quote

My message
UUU + (manchester encoded byte or 16bit)+UUU

does have a '\r' at the end.
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Tue Jun 06, 2006 3:23 pm     Reply with quote

http://www.ccsinfo.com/forum/viewtopic.php?t=23953
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Tue Jun 06, 2006 4:17 pm     Reply with quote

Have you thought about using the RDA interrupt instead of trying to poll for characters inside of main()? That's what the hardware's there for.
DANX
Guest







PostPosted: Tue Jun 06, 2006 4:54 pm     Reply with quote

"forum/viewtopic.php?t=23953"

how can this code work without using manchester encoding? Maybe for expensive modules that doesn't require DC balance?

The module that i'm using require DC balance signal
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Tue Jun 06, 2006 5:07 pm     Reply with quote

DANX wrote:
"forum/viewtopic.php?t=23953"

how can this code work without using manchester encoding? Maybe for expensive modules that doesn't require DC balance?

The module that i'm using require DC balance signal


Try it first. If it doesn't work, then do a pseudo-manchester type of transmission by inserting "U" between each character you send. Discard the "U"s in the receiver.

Long story short: don't try to reinvent the wheel.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Tue Jun 06, 2006 5:14 pm     Reply with quote

Quote:

the thing making it hard is all the garbage characters going into the pic.


http://www.ccsinfo.com/forum/viewtopic.php?t=23886&highlight=manchester
http://www.ccsinfo.com/forum/viewtopic.php?t=24807&highlight=manchester
http://www.ccsinfo.com/forum/viewtopic.php?t=19141&highlight=manchester
http://www.ccsinfo.com/forum/viewtopic.php?t=27090&highlight=


Humberto
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