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.

[SOLVED] how send uart data with fsk transmiter in avr???

Status
Not open for further replies.

samna_asadi

Junior Member level 3
Joined
Mar 19, 2011
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,519
hi
recently i`m trying to send some data over another avr uart by fsk transmitter .
when i connect two avr`s by wire it works great , but when i connect them to transmitter and receiver it has so many error`s and works too bad , have to send data 10 or 15 times to send data correctly.
i think maybe it`s because of the uart that is high when its in idle , but i`ve read that it should work.
what`s the problem?? and any way is it possible to connect uart directly to fsk transmitter and get the data correctly in receiver?
 

thanks for your answer.
i tried to pull up both side but still no respond , i still think its because of polarity of uart !! it`s always high.
how can i change the polarity in a simple way , like a npn transistor or somethin??
tnx.
 

Can you specific the make and model of the FSK RF modules you are utilizing in your design?

BigDog
 

How have you cannected FSK transmitter data line to uC? Is it connected to Tx pin of uC? Post your circuit and code. Are you sure the problem is at the transmitter side. What if problem is at receiver side? Have you used serial interrupts to receive data at the receiver side?

and any way is it possible to connect uart directly to fsk transmitter

How have you connected the transmitter? Using RS232? Post datasheet of FSK TX and Rx. It will be using TTL.
 

thanks for giving me your time.
actually it`s a thermometer that turn on or off the air conditioner. it just send the relays situation to the receiver.
the receiver and transmitter are HM-TR in 433mhz. the data pin of the transmitter module is directly connected to the TX pin of the mcu and data pin of the receiver is directly connected to the RX pin of the mcu.
transmitter side is just sending data to mcu by normal UDR=data and reciever is using interrupt.

the partial code of transmitter is like this.


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
//usart init
    UCSRA=0;
    UCSRB=0b00001000;
    UCSRC=0b10000110;
    UBRRH=0;
    UBRRL=207;
.
.
.
.
void send_data(int data)
{
    while ( !( UCSRA & (1<<UDRE)) );
    UDR=255;    // just for identifying the right transmitter
        
    while ( !( UCSRA & (1<<UDRE)) );
    UDR=140;   // just for identifying the right transmitter
        
    while ( !( UCSRA & (1<<UDRE)) );
    UDR=data;
        
    while ( !( UCSRA & (1<<UDRE)) );
    UDR=140;   // just for identifying the right transmitter
    
    
}
 
 
and in the whole code of the receiver side:
 
 
 
#define F_CPU 1000000UL
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#define R_enable PORTD |= 2;
#define R_disable PORTD &= ~2;
#define green_on PORTC |= 4;
#define green_off PORTC &= ~4;
#define yellow_on PORTC |= 16;
#define yellow_off PORTC &= ~16;
 
 
int data,os=0;
void run();
 
int main(void)
{
    DDRD=226;
    DDRC=255;
    DDRB=255;
    PORTC=255;
    PORTB=255;
    PORTD=28;
    
    
    
    UCSRA=0;
    UCSRB=0b10010000;
    UCSRC=0b10000110;
    UBRRH=0;
    UBRRL=25;
    
    green_off;
    yellow_off;
    R_enable;
    
    sei();
    while(1)
            {
 
    }
}
 
ISR(_VECTOR(11))
{
    switch (os)
    {
        case 0:
        {
            if(UDR==255)
            {
                os=1;
                green_on;
            }
            else green_off;
            
            break;
        }
        case 1:
        {
            if(UDR==140)
            {
                os=2;
                yellow_on;
            }
            
            else 
            {
                os=0;
                yellow_off;
            }
            break;
        }
        case 2:
        {
            data=UDR;
            os=3;
            
            break;
        }
        case 3:
        {
            if(UDR==140)
            {
                run();
            }
            os=0;
            break;
        }
        
    }
}
 
void run()
{
    
    PORTD = (PORTD & 31) | (data << 5);
}

 
Last edited by a moderator:

Zip and attach your Project files and Proteus file. I will test it. What AVR are yo using. The only problem I see is that all receiver ports are configured as outputs. Receiver's Rx pin should be configured as input pin. This will solve your problem.
 

here is everything
 

Attachments

  • 1.rar
    111.2 KB · Views: 81

1. Instead of if((PINC & 16)==0 && stat3==2 && stat ==1) use if((PINC & 16)==0 && (stat3==2) && (stat ==1))

2. In receiver code stat is used in if conditions but I don't see any code setting stat to 1.

4. If the if conditions are testing for switch in receiver code it should have debounce delay.

Fix these and try.
 

thanks for ur respond.
in line 278 and 378 stat get 1 value.
i was considering the delay that if`s are makin , that`s why i use the lowest baud rate.and plus i have checked the project with wire conected transmitter and receiver gnd and tx to rx , and its working great with no problem.
 

In the reciver code as you are using serial interrupt delay doesn't affect but if you are displaying received data and there is delay function then it might be causing the problem. Explain how your receiver works.


This is your receiver code. where is stat getting value 1? Line 64? In the if conditions I see you are writing some values to PORTD and maybe Rx pin is also being affected by that.


Whare is os getting the value from? You are testing os in switch. cases 0, 1, 2, 3 execute sequentially right? os will be 0 initaially.


In transmitter there are ifs like this if((PINC & 32)==0 && stat==1 && stat3>=1)


If PINC and other similar pins are switches then there will be difficulty executing code inside the if condition.

1. you need debounce delays

2 try to code like this using flags

if((PINC & 32)==0 && stat==1 && stat3>=1)myflag = 1;

if(myflag){ //place all the code in if condition here}





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
/*
 * girande_termometer.cpp
 *
 * Created: 7/21/2013 10:04:55 PM
 *  Author: saman
 */ 
 
#define F_CPU 1000000UL
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#define R_enable PORTD |= 2;
#define R_disable PORTD &= ~2;
#define green_on PORTC |= 4;
#define green_off PORTC &= ~4;
#define yellow_on PORTC |= 16;
#define yellow_off PORTC &= ~16;
 
 
int data,os=0,stat;
void run();
 
int main(void)
{
    DDRD=226;
    DDRC=255;
    DDRB=255;
    PORTC=255;
    PORTB=255;
    PORTD=28;
    
    
    
    UCSRA=0;
    UCSRB=0b10010000;
    UCSRC=0b10000110;
    UBRRH=0;
    UBRRL=25;
    
    green_off;
    yellow_off;
    R_enable;
    
    sei();
    while(1)
    {
        if((PIND & 4)==0 && stat==1)
        {
            stat=0;
            PORTD=((PORTD & 223) | (~PORTD & 32));
        }
        if((PIND & 8)==0 && stat==1)
        {
            stat=0;
            PORTD=((PORTD & 191) | (~PORTD & 64));
        }
        if((PIND & 16)==0 && stat==1)
        {
            stat=0;
            PORTD=((PORTD & 127) | (~PORTD & 128));
        }
        if((PIND & 28)==28)
        {
            stat=1;
        }
//      if((PORTD & 32)==32){yellow_on;}
//      else yellow_off;
//      if((PORTD & 64)==64){green_on;}
//      else green_off;
    }
}
 
ISR(_VECTOR(11))
{
    
    
    switch (os)
    {
        case 0:
        {
            if(UDR==255)
            {
                os=1;
                green_on;
            }
            else green_off;
            
            break;
        }
        case 1:
        {
            if(UDR==140)
            {
                os=2;
                yellow_on;
            }
            
            else 
            {
                os=0;
                yellow_off;
            }
            break;
        }
        case 2:
        {
            data=UDR;
            os=3;
            
            break;
        }
        case 3:
        {
            if(UDR==140)
            {
                run();
            }
            os=0;
            break;
        }
        
    }
}
 
void run()
{
    
    PORTD = (PORTD & 31) | (data << 5);
}

 
Last edited:

well first of all sorry for my last reply i thought u were talking about transmitter code!!
any way , yes stat gets 1 value in line 64. and the keys are working fine any way.
the data that is gonna be send is a 4 byte of data , just 3rd byte is the main data , other bytes are just to make sure the receiver is geting data from my transmitter. and as interrupt is getting the right byte from the usart it adds 1 to os and switch get into the next case.
any way i`m just reminding it`s working well by connecting TX from transmitter to RX from receiver by wire , and relays just work as it should but when i`m trying to send data over wirelessly it just doesn`t work.
 

Pulldown Tx of transmitter and Rx of receiver. Add a 100 nF Capacitor close to VCC and GND pins of Transmitter and receiver RF modules.

Use this code if PORTC of transmitter has buttons. To better help post Schematic or Proteus file.


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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
while(1)
   {
           
      
       if((PINC & 16)==0 && (stat3==2) && (stat ==1))
       {
           _delay(50);
           if((PINC & 16)==0 && (stat3==2) && (stat ==1))
           {
               myflag1 = 1;
               
           }
       }
       
       if(myflag){
           stat=0;
           stat3=0;
           if(rm>=1)
           {
               if(rm==1)
              {
                   if(u[13]>=1)u[13]=0;
                   else
                   u[13]=1;
                   screen(15);
                   send_data();
               }
              
              
               
           }
           else
           
          {
              flash=1;
              if(mode>=1)screen(mode-1);
              mode++;
              if(mode>=12)
              {
                  
                  mode=0;
                  TCCR2=0x05;
                  writeee(200);
                  flash=1;
                  LCDClear();
                  reset_screen();
              }
              else TCCR2=0x03;
              screen(mode-1);
          }
          
          myflag1 = 0;
           
       }
       
       
       if((PINC & 32)==0 && (stat==1) && (stat3>=1))
       {
           _delay_ms(50);
           if((PINC & 32)==0 && (stat==1) && (stat3>=1))
           {
               myflag2 = 1;
               
           }
           
       }
       
       if(myflag2){
           
           stat=0;
           stat3=0;
           if(rm>=1)
           {
              if(rm==1)
                {
                    if(u[13]==1)u[13]=2;
                    else
                    u[13]=1;
                    screen(15);
                    send_data();
                }
                 if(rm==2)
                 {
                     if(u[15]>=3)u[15]=0;
                     else
                     u[15]++;
                     screen(16);
                     
                 }
              
           }
           else
           
           {
               altm=0;
               if(mode==0)
               {
                   
                   u[8]+=10;
                   calc_at();
                   screen(11);
                   if(u[8]>180)
                   {
                       u[8]=0;
                       u[10]=0;
                       screen(12);
                       screen(6);
                       screen(7);
                       LCDWriteStringXY(12,1,"    ");
                   }
                   else
                   {
                       
                       u[10]=1;
                       screen(12);
                       screen(11);
                   }
                   
               }
               else
               {
                   dt_set(2);
                   screen(mode-1);
               }
           }
           
           myflag2 = 0;
           
       }
       
 
       if((PINC & 8)==0 && (stat==1) && (stat3==2))
       {
           _delay_ms(50);
           if((PINC & 8)==0 && (stat==1) && (stat3==2))
           {
                myflag3 = 1;
                
           }
       }
       
       if(myflag3){
           
           stat=0;
           stat3=0;
           if(rm>=1)
           {
               if(rm==1)
               {
                   if(u[14]==1)u[14]=0;
                   else
                   u[14]=1;
                   screen(15);
                   send_data();
               }
               if(rm==2)
               {
                   if(u[15]<=0)u[15]=3;
                   else
                   u[15]--;
                   screen(16);
                  
               }
               
           }
           else
           {
               
               if(mode==0)
               {
                   if(datemode==0)
                   {
                       datemode=1;
                       date_mode(1);
                   }
                   else
                   {
                       datemode=0;
                       date_mode(0);
                   }
                   
               }
               else
               {
                   dt_set(1);
                   screen(mode-1);
               }
               
           }
           
           myflag3 = 0;
       }
       
       
       if((PINC & 4)==0 && (stat==1) && (stat3==2))
       {
           _delay_ms(50);
           if((PINC & 4)==0 && (stat==1) && (stat3==2))
           {
                myflag4 = 1);
           }
       }
       
       if(myflag4){    
           
           stat3=0;
           stat=0;
           if(mode==0)
           
           {
               switch (rm)
               
            {
                case 0:
                {
                    rm=1;
                    screen(15);
                    break;
                }
                
                case 1:
                {
                    rm=2;
                    screen(16);
                    break;
                }
                case 2:
                {
                    rm=0;
                    reset_screen();
                    writeee(15);
                    break;
                }
            }
           }
           else
           {
               if(u[10]==1)u[10]=0;
               else
               u[10]=1;
               
               screen(12);
           }
           
 
       }
       if((PINC & 60) == 60)//if buttons are not pressed
       {
           
           stat=1;
           stat2=0;
       }
       else //if any button is been hold
       {
           led=0;
           
           if(u[9]>=1)led_on();
           
           if(u[9]==0)led_off();
           
       }
       
   }
   
}

 

Pulldown Tx of transmitter and Rx of receiver. Add a 100 nF Capacitor close to VCC and GND pins of Transmitter and receiver RF modules.

Use this code if PORTC of transmitter has buttons. To better help post Schematic or Proteus file.


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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
while(1)
   {
           
      
       if((PINC & 16)==0 && (stat3==2) && (stat ==1))
       {
           _delay(50);
           if((PINC & 16)==0 && (stat3==2) && (stat ==1))
           {
               myflag1 = 1;
               
           }
       }
       
       if(myflag){
           stat=0;
           stat3=0;
           if(rm>=1)
           {
               if(rm==1)
              {
                   if(u[13]>=1)u[13]=0;
                   else
                   u[13]=1;
                   screen(15);
                   send_data();
               }
              
              
               
           }
           else
           
          {
              flash=1;
              if(mode>=1)screen(mode-1);
              mode++;
              if(mode>=12)
              {
                  
                  mode=0;
                  TCCR2=0x05;
                  writeee(200);
                  flash=1;
                  LCDClear();
                  reset_screen();
              }
              else TCCR2=0x03;
              screen(mode-1);
          }
          
          myflag1 = 0;
           
       }
       
       
       if((PINC & 32)==0 && (stat==1) && (stat3>=1))
       {
           _delay_ms(50);
           if((PINC & 32)==0 && (stat==1) && (stat3>=1))
           {
               myflag2 = 1;
               
           }
           
       }
       
       if(myflag2){
           
           stat=0;
           stat3=0;
           if(rm>=1)
           {
              if(rm==1)
                {
                    if(u[13]==1)u[13]=2;
                    else
                    u[13]=1;
                    screen(15);
                    send_data();
                }
                 if(rm==2)
                 {
                     if(u[15]>=3)u[15]=0;
                     else
                     u[15]++;
                     screen(16);
                     
                 }
              
           }
           else
           
           {
               altm=0;
               if(mode==0)
               {
                   
                   u[8]+=10;
                   calc_at();
                   screen(11);
                   if(u[8]>180)
                   {
                       u[8]=0;
                       u[10]=0;
                       screen(12);
                       screen(6);
                       screen(7);
                       LCDWriteStringXY(12,1,"    ");
                   }
                   else
                   {
                       
                       u[10]=1;
                       screen(12);
                       screen(11);
                   }
                   
               }
               else
               {
                   dt_set(2);
                   screen(mode-1);
               }
           }
           
           myflag2 = 0;
           
       }
       
 
       if((PINC & 8)==0 && (stat==1) && (stat3==2))
       {
           _delay_ms(50);
           if((PINC & 8)==0 && (stat==1) && (stat3==2))
           {
                myflag3 = 1;
                
           }
       }
       
       if(myflag3){
           
           stat=0;
           stat3=0;
           if(rm>=1)
           {
               if(rm==1)
               {
                   if(u[14]==1)u[14]=0;
                   else
                   u[14]=1;
                   screen(15);
                   send_data();
               }
               if(rm==2)
               {
                   if(u[15]<=0)u[15]=3;
                   else
                   u[15]--;
                   screen(16);
                  
               }
               
           }
           else
           {
               
               if(mode==0)
               {
                   if(datemode==0)
                   {
                       datemode=1;
                       date_mode(1);
                   }
                   else
                   {
                       datemode=0;
                       date_mode(0);
                   }
                   
               }
               else
               {
                   dt_set(1);
                   screen(mode-1);
               }
               
           }
           
           myflag3 = 0;
       }
       
       
       if((PINC & 4)==0 && (stat==1) && (stat3==2))
       {
           _delay_ms(50);
           if((PINC & 4)==0 && (stat==1) && (stat3==2))
           {
                myflag4 = 1);
           }
       }
       
       if(myflag4){    
           
           stat3=0;
           stat=0;
           if(mode==0)
           
           {
               switch (rm)
               
            {
                case 0:
                {
                    rm=1;
                    screen(15);
                    break;
                }
                
                case 1:
                {
                    rm=2;
                    screen(16);
                    break;
                }
                case 2:
                {
                    rm=0;
                    reset_screen();
                    writeee(15);
                    break;
                }
            }
           }
           else
           {
               if(u[10]==1)u[10]=0;
               else
               u[10]=1;
               
               screen(12);
           }
           
 
       }
       if((PINC & 60) == 60)//if buttons are not pressed
       {
           
           stat=1;
           stat2=0;
       }
       else //if any button is been hold
       {
           led=0;
           
           if(u[9]>=1)led_on();
           
           if(u[9]==0)led_off();
           
       }
       
   }
   
}




its still the same. i have no respond!!
 

Post your circuit. Provide a link for your FSK module.

ISR


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
ISR(_VECTOR(11))
{
    
    
    switch (os)
    {
        case 0:
        {
            if(UDR==255)
            {
                os=1;
                green_on;
            }
            else{
                
                 green_off;
                 os = 0;
            }
            
            break;
        }
        case 1:
        {
            if(UDR==140)
            {
                os=2;
                yellow_on;
            }
            
            else 
            {
                os=0;
                yellow_off;
            }
            break;
        }
        case 2:
        {
            data=UDR;
            os=3;
            
            break;
        }
        case 3:
        {
            if(UDR==140)
            {
                PORTD = (PORTD & 31) | (data << 5);
            }
            os=0;
            break;
        }
        
    }
}




Receiver 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
/*
 * girande_termometer.cpp
 *
 * Created: 7/21/2013 10:04:55 PM
 *  Author: saman
 */ 
 
#define F_CPU 1000000UL
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#define R_enable PORTD |= 2;
#define R_disable PORTD &= ~2;
#define green_on PORTC |= 4;
#define green_off PORTC &= ~4;
#define yellow_on PORTC |= 16;
#define yellow_off PORTC &= ~16;
 
 
 
 
int data,os=0,stat;
unsigned char uart_rd[4], disp, index = 0;
 
void run();
 
int main(void)
{
    DDRD=226;
    DDRC=255;
    DDRB=255;
    PORTC=255;
    PORTB=255;
    PORTD=28;
        
    UCSRA=0;
    UCSRB=0b10010000;
    UCSRC=0b10000110;
    UBRRH=0;
    UBRRL=25;
    
    green_off;
    yellow_off;
    R_enable;
    
    sei();
    while(1)
    {
        if((PIND & 4)==0 && stat==1)
        {
            stat=0;
            PORTD=((PORTD & 223) | (~PORTD & 32));
        }
        if((PIND & 8)==0 && stat==1)
        {
            stat=0;
            PORTD=((PORTD & 191) | (~PORTD & 64));
        }
        if((PIND & 16)==0 && stat==1)
        {
            stat=0;
            PORTD=((PORTD & 127) | (~PORTD & 128));
        }
        if((PIND & 28)==28)
        {
            stat=1;
        }
//      if((PORTD & 32)==32){yellow_on;}
//      else yellow_off;
//      if((PORTD & 64)==64){green_on;}
//      else green_off;
 
        if(disp){
            
                if((uart_rd[0] == 255)
                {
                    green_on;
                                        
                }
                else{
                    green_off;
                 
                }
                
                if((uart_rd[1] == 140)
                {
                    yellow_on;  
                                                        
                }
                else 
                {               
                    yellow_off;
                }
                
                if((uart_rd[3] == 140)      
                {
                    PORTD = (PORTD & 31) | (uart_rd[2] << 5);                       
                }
                disp = 0;
                                uart_rd[0] = 0;
                                uart_rd[1] = 0;
                                uart_rd[2] = 0;
                                uart_rd[3] = 0;
                                            
        }   
    }
}
 
ISR(_VECTOR(11))
{
    uart_rd[index++] = UDR;
    
    if(index == 4){
        
        index = 0;
        disp = 1;
    }   
}

 
Last edited:

Send the dsn files. You have sent Layout files. The link you provided doesn't have datasheet(s). There is no snubber network for relays. Relays are close to RF module. Change the placement of RF module on your receiver board. Most probably there is EMI between relay and RF receiver module. When you connect through wires you are not experiencing this. To test remove rf module from board and use 15 cm wires to connect receiver module to PCB. If it solves the problem then you have to change the layout of your PCB and place RF module away from power and other electromagnetic devices.

I don't see RF Tx module on Tx board. Use crystal if dealing with UART or precise timing. You have used Internal RC Oscillator of 8 MHz in transmitter.
 
Last edited:

I think you can't simple send data over this RF modules just as UART protocol define. You should use manchester coding etc... If you insist to use UART hardware/protocol, try with first sending several dummy bytes (for example 10 or more same bytes in intervals 10ms) and use it to enter receiver module in "normal working" state. After, you just simple ignore that bytes in your command processing code.
 

Send the dsn files. You have sent Layout files. The link you provided doesn't have datasheet(s). There is no snubber network for relays. Relays are close to RF module. Change the placement of RF module on your receiver board. Most probably there is EMI between relay and RF receiver module. When you connect through wires you are not experiencing this. To test remove rf module from board and use 15 cm wires to connect receiver module to PCB. If it solves the problem then you have to change the layout of your PCB and place RF module away from power and other electromagnetic devices.

I don't see RF Tx module on Tx board. Use crystal if dealing with UART or precise timing. You have used Internal RC Oscillator of 8 MHz in transmitter.

http://www.kosmodrom.com.ua/pdf/HM-R433.pdf
http://www.kosmodrom.com.ua/pdf/HM-T.pdf

i will consider getting relays away from RF , but in testing board that i`ve made i had not install relays on the board.
the RF tx module is between lcd and mcu.
 

Attachments

  • 1.rar
    16.8 KB · Views: 80

well i think at last i`m getting some result. i tried to send some dummy bytes (255) before the main data and mainly tried to lower the data rate to 250 bps and now its working properly.
i`ve not tested this thoroughly , but i think its gonna work.
thanks to anyone who share their knowledges with me.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top