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 support@ccsinfo.com

RF using bit banging

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



Joined: 04 May 2006
Posts: 5

View user's profile Send private message

RF using bit banging
PostPosted: Fri Jun 16, 2006 4:38 pm     Reply with quote

I'm trying to send data over RF link and I have to use D0 pin of a PIC16F877.

So can you help me on RF data transmit/receive code using bit banging technique.

Regards,
Richard Arroyo



Joined: 04 Apr 2006
Posts: 22
Location: Sebastopol, CA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Jun 16, 2006 7:50 pm     Reply with quote

You could generate a square wave 1.6< Mhz with the 5 mips the 877 provides running @ 20mhz. The signal would then have to be put trough an Lc
filter and an impedance matching network to get a nice sine wave with only a few mw of power. Receiving with no RF amp and filter won't work too well on a logic port. Also, a big antenna is needed at those LW AM radio frequencies unlike 2.5Ghz. The program would have to be done in assembly and in the end you would end up with way less than 1.6mhz. The BRA instruction takes 2 cycles and I think the bit toggle instruction is one cycle.

Are you trying to interface with RF hardware because that would make more since?
_________________
RAA
bjerkely12



Joined: 04 May 2006
Posts: 5

View user's profile Send private message

PostPosted: Sat Jun 17, 2006 8:59 am     Reply with quote

I'm using ATX-34 and ARX-34 modules from UDEA electronics:

http://www.udea.com.tr/Turkce/Urunler/RF_Moduller/RF_Receivers.htm
http://www.udea.com.tr/Turkce/Urunler/RF_Moduller/RF_Transmitters.htm

I need an algorithm on bit-banging, for example how can I set baudrate to 1200 and how to check for Preamble etc...
Richard Arroyo



Joined: 04 Apr 2006
Posts: 22
Location: Sebastopol, CA

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Jun 19, 2006 8:23 pm     Reply with quote

Ah, I see. Only 2400 baud max on those little things and no Vr. : )
The modules appear to operate in plane old ASK with no signal processing.
Well, since they didn't specify what type of serial coding to go after
the preamble buzz you could go with the built in serial routine which the CCS compiler provides. The preamble buzz isn't entirely necessary but may provide better data synch under pos conditions. Keep in mind that unless you use the 877's serial hardware or a port with an interrupt the port has to be polled much faster than the baud rate to avoid data loss. Also, you would want a timeout count. Now if you wish to use the preamble buzz I could bang out some small code that would receive and synch if I can get some free time soon.
_________________
RAA
serkan



Joined: 07 Jul 2006
Posts: 1

View user's profile Send private message

PostPosted: Sun Mar 01, 2009 12:07 pm     Reply with quote

#define data_in PIN_B0
#define veri_hatali PIN_A1
#define veri_dogru PIN_A2


void fivebit0();
void fivebit1();
void data_read();

int16 plus0=0;

void main()
{

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);

// TODO: USER CODE!!
set_tris_b(0xff);
set_tris_a(0x00);

while(1)
fivebit0();

}

void fivebit0(){

while(1){
if(input(data_in)==0){
for(;;){
delay_us(10);
plus0++;
if(plus0>=600){
while(input(data_in==0));
fivebit1();
return;
}
if(input(data_in)==1)
break;
}
plus0=0;
}
}
}

void fivebit1(){
int16 plus1=0;

while(1){
if(input(data_in)==1){
for(;;){
delay_us(10);
plus1++;
if(plus1>=600){
while(input(data_in)==1);
data_read();
return;
}
if(input(data_in)==0){
plus0=0;
plus1=0;
return;
}
}
}
}
}

void data_read(){
unsigned char data=0x00;
int say=0;

while(say<=7){
if(input(data_in)==1)
bit_set(data,0);
else
bit_clear(data,0);
if(say==7)
break;
say++;
data=data<<1;
delay_us(410);
}

if(data==0x42){
output_high(veri_dogru);
delay_ms(1000);
output_low(veri_dogru);
return;
}
else{
output_high(veri_hatali);
delay_ms(1000);
output_low(veri_hatali);
data=0;
say=0;
return;
}
}
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