View previous topic :: View next topic |
Author |
Message |
bjerkely12
Joined: 04 May 2006 Posts: 5
|
RF using bit banging |
Posted: Fri Jun 16, 2006 4:38 pm |
|
|
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
|
|
Posted: Fri Jun 16, 2006 7:50 pm |
|
|
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
|
|
|
Richard Arroyo
Joined: 04 Apr 2006 Posts: 22 Location: Sebastopol, CA
|
|
Posted: Mon Jun 19, 2006 8:23 pm |
|
|
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
|
|
Posted: Sun Mar 01, 2009 12:07 pm |
|
|
#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;
}
} |
|
|
|