Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Rf link between 2 pic 16f628 using ART

Status
Not open for further replies.

johney

Newbie level 4
Joined
Nov 20, 2014
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
74
rf link between 2 pic 16f628 using uart

need help for establishing rf link between two 16f628 using 315 mhz rf tx rx module below is the code i am using but coming across the range issue need help to increase the range of the system to atleast 25-30 meters through the walls Thanks

TX code:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
char txt[16];
 char chk;
 char dat,character,strt,data,middle,end,invrte;
 int i=0,ckop=0;
 unsigned int prcnt=0;
 void main() {
 INTCON=0;
 OPTION_REG = 0X8F;
 CMCON=7;
 PORTB=0;
 PORTA=0;
 TRISA=0XFF;
 TRISB = 0XFF;
 TRISB2_BIT=0;
 VRCON=0;
 T1CON=0;
 T2CON=0;
 for(i=0;i<16;i++){txt[i]=' ';}
UART1_Init(1200);
 delay_ms(200);            // Initialize LCD
  while(1){
  asm sleep
 
 
  asm clrwdt;
   asm sleep
 
 
  asm clrwdt;
  TRISB2_BIT=0;
  TRISA1_BIT=0;
  RA1_BIT=0;
  delay_ms(600);
  strt  = 0x0A;
  middle = 0x0B
  end  =0x0C;
  prcnt = PORTB;
  prcnt = (prcnt&0X70);
  switch(prcnt)
  {
  case 0x00:
 if(RB7_BIT==0)
 { data = 'A';
  }
  else
  {
  data = 'E';
  }
  if (UART1_Tx_Idle() == 1)
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(strt);
  UART1_Write(data);
  UART1_Write(middle);
  UART1_Write(end);
  break;
  case 0x10:
 if(RB7_BIT==0)
 { data = 'B';
  }
  else
  {
  data = 'F';
  }
  if (UART1_Tx_Idle() == 1)
   UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(strt);
  UART1_Write(data);
  UART1_Write(middle);
  UART1_Write(end);
  case 0X30:
  if(RB7_BIT==0)
 { sidhad = 'C';
  }
  else
  {
  sidhad = 'G';
  }
   if (UART1_Tx_Idle() == 1)
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(strt);
  UART1_Write(data);
  UART1_Write(middle);
  UART1_Write(end);
  break;
  case 0X70:
  if(RB7_BIT==0)
 { sidhad = 'D';
  }
  else
  {
  sidhad = 'H';
  }
  if (UART1_Tx_Idle() == 1)
    UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(0X55);
  UART1_Write(0XAA);
  UART1_Write(strt);
  UART1_Write(data);
  UART1_Write(middle);
  UART1_Write(end);
  break;
 }
 asm clrwdt;
 SPEN_BIT =0;
 RA1_BIT=0;
 TRISA=0XFF;
 TRISB=0XFF;
 }
 }



RX code:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
char txt[16];
 char chk,ID;
 int i=0,ckop=0;
unsigned long sig;
char data_byte1=0,data_byte2=0,checksum_byte=0,start_byte=0;
char started, count;
char buffer;
  void interrupt(){
     if (PIR1.RCIF) {
         buffer = RCREG;        //read from rcreg register
         if(started){
            count++;
            if(count == 1) txt[count] = buffer;
            if(count == 2) txt[count] = buffer;
            if(count == 3) txt[count] = buffer;
            if(count == 4) {
               txt[4]= buffer;
               started = 0;          //reset started flag
               if(txt[4]==0X0C){    // simple error checking
               RA0_BIT=1;
               delay_ms(10);
               RA0_BIT=0;
                sig=0;
   if(txt[2]=='A')
   {
    RB4_BIT=0;
    RB5_BIT=0;
    RB6_BIT=0;
    RB7_BIT=1;
   }
   else
   {
    if(txt[2]=='E')
    {
    RB4_BIT=0;
    RB5_BIT=0;
    RB6_BIT=0;
    RB7_BIT=0;
    }
    }
   if(txt[2]=='B')
   {
    RB4_BIT=1;
    RB5_BIT=0;
    RB6_BIT=0;
    RB7_BIT=1;
   }
   else{
    if(txt[2]=='F')
    {
    RB4_BIT=1;
    RB5_BIT=0;
    RB6_BIT=0;
    RB7_BIT=0;
    }
    }
   if(txt[2]=='C')
   {
    RB4_BIT=1;
    RB5_BIT=1;
    RB6_BIT=0;
    RB7_BIT=1;
   }
   else
   {
    if(txt[2]=='G')
    {
    RB4_BIT=1;
    RB5_BIT=1;
    RB6_BIT=0;
    RB7_BIT=0;
    }
    }
    if(txt[2]=='D')
   {
    RB4_BIT=1;
    RB5_BIT=1;
    RB6_BIT=1;
    RB7_BIT=1;
   }
   else
   {
    if(txt[2]=='H')
    {
    RB4_BIT=1;
    RB5_BIT=1;
    RB6_BIT=1;
    RB7_BIT=0;
    }
    }
    for(i=0;i<6;i++){txt[i]=' ';}
    buffer=' ';
   asm clrwdt;
    }
    }
         }else{
            if(buffer == 0x0A) {
               started = 1;  //set started flag
               count = 0;
           }
     }
     }
}
 void main() {
 INTCON=0;
 OPTION_REG=0X8F;
 PORTB=0;
 PORTA=0;
 TRISB=0;
 TRISA=0X00;
 CMCON=7;
 VRCON =0;
 TRISB1_bit=1;
 T1CON=0;
 T2CON=0;
 UART1_Init(1200);
 delay_ms(200);
 asm clrwdt;
 INTCON.RCIF=0;
 INTCON.PEIE=1;
 PIE1.RCIE=1;
 INTCON.GIE=1;
 asm clrwdt;
 while(1){
 asm clrwdt;
 RA1_BIT=0;
    }
    }



CODE IS WORKING PRETTY WELL O HARDWARE BUT RANGE IS THE MAIN ISSUE GETTING RANGE ONLY UPTO 15-20 FEET THROUGH WALLS CROSS THT NOT WORKING KINDLY HELP ME OUT NEED TO COMPLETE IT ASAP.
 
Last edited by a moderator:

Re: rf link between 2 pic 16f628 using uart

Code will not increase the range significantly. You can try implementing a "resend until it gets through" algorithm but the difference it makes may only be a few cm.

You need more RF power or better still, a good antenna. You haven't given us any idea of the transmitter or receiver though so it's difficult to suggest how you can improve them.

Brian.
 

Re: rf link between 2 pic 16f628 using uart

I am using syn115 for transmitter and syn480 as receiver works on ask
 

Re: rf link between 2 pic 16f628 using uart

ASK costs little but isn't the best method for reliable data because it is prone to interference, especially in the '0' bits where the receiver hears nothing but noise.

However, the solution to your problem seems to be that the signal is just too weak. What kind of antenna are you using on the modules at the moment?

Brian.
 

Re: rf link between 2 pic 16f628 using uart

I am using a 1/4 wavelength whip Antena and when I am using same module with same Antena with ht12e and ht12d I am getting the desired range
 

Re: rf link between 2 pic 16f628 using uart

when I am using same module with same Antena with ht12e and ht12d I am getting the desired range
Sounds plausible when looking at your code.

UART transmission with cheap ASK modules is a serial topic at Edaboard. You'll find many previous threads discussing the same problem.

Short answer, the method used in your code is unreliable for two reasons:

- Sending 8-Bit data through UART without recoding. You need an encoding method that achieves a DC-balanced bit stream, Manchester encoding is mostly used. A kind of pseudo Manchester encoding sending one data byte in two UART bytes is used in some cases, but it's not the same as real Manchester encoding due to the UART start/stop framing.

- Not synchronizing received data on a bit level. That's not possible when using the UART receiver.

There are RF transmission libraries using software Manchester encoding, e.g. for Arduino. Mikro-C also has it.
 

Re: rf link between 2 pic 16f628 using uart

I have tried mikroc Manchester example but it only works with wired connection even I tried to send preamp bits but with no success on rf link
 

Re: rf link between 2 pic 16f628 using uart

I must confess that I don't use mikro C and can't confirm correct operation of their Manchester library. There might be other problems like wrong polarity of the Tx signal.
 

Re: rf link between 2 pic 16f628 using uart

http://www.winpicprog.co.uk/pic_tutorial12.htm have used the Manchester code in the example but have to send the packet at least 20 times before my mcu sleeps to get a good desired range and reliability of receiving the data in 1st to 3rd cycle. But I need the data to be received in 2nd cycle in worst case scenario kindly help what can be done.
 

Re: rf link between 2 pic 16f628 using uart

Unfortunately I don't know what the problem is. You need to debug the receive process to determine where it exactly fails.
 

Re: rf link between 2 pic 16f628 using uart

The FSK or QPSK signal to get rid of low dampping delay of signal and Do you try connect to Chip ? , re-code C language above to make Data Bank (Support Option for stable)
 

Re: rf link between 2 pic 16f628 using uart

The FSK or QPSK signal to get rid of low dampping delay of signal and Do you try connect to Chip ? , re-code C language above to make Data Bank (Support Option for stable)
These are ASK (on/off carrier) devices, it isn't possible to use FSK or QPSK using them.

Brian.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top