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] RF-PIC16F877A problem

Status
Not open for further replies.

mturna

Junior Member level 2
Joined
Apr 3, 2011
Messages
20
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,283
Activity points
1,418
Hi everybody!
I have a problem about RF and PIC16F877A.
In my project I'm sending the data from PC via rs232 (and max232 and atx-34 s) and and receive via arx-34 c and send to the pic from RC7/RX (26th) pin of 16f877a.
I can see the tx sends the data and rx receives the data. But the problem is pic16f877a can't process the data. What could be the reason.
PS: I'm sending ascii data like B.
e.g. data1=getchar();
if (data1=='B')
{
output_high(port_d5);
delay_ms(1000);
Output_low(port_d5);
}

Thanks you...
 

Make sure the polarity af the data is correct, ie not inverted.
And the obvious stuff like baud rate, no. of start and stop bits and whether there is parity or not, if your sending a parity bit and the receiver doesnt expect it you'll get a framing error.
Which brings us to something else, check the error register within the pic using a simulator and see if there is an error generated or not.
 

I will check the polarity today. But I'm sure about baud rate and I am sending with a low baud rate (baud rate=300).
I am sending 5 byte AA then 5 byte 00 and finally 5 byte FF. No parity bit.
I used the program on proteus using VMETER. But I can't test RF with proteus.
And I want to ask something else should I use a pass filter or how can I use it?
 

No it's not because of polarity, too.
 

https://obrazki.elektroda.pl/54_1301997336.png

As I said I can't simulate RF on proteus am using VTERM called device to test the code. It sends char and pic gets it. Program works well. But not in real world :).

#include "D:\PIC_FOLDER\rf.h"

#use fast_io(c)
#use fast_io(d)

#define led pin_d3

#use delay(clock=4000000)

#use rs232(baud=300, xmit=PIN_C6, rcv=PIN_C7)

char data1;

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);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);

// TODO: USER CODE!!

set_tris_c(0x80);
set_tris_d(0x00);

output_d(0x00);

data1=getc();
delay_ms(500);
while (true)
{
if(data1=='B')
{
output_high (led);
delay_ms(10000);
output_low(led);
}
else if(data1=='C')
{
output_high (led);
delay_ms(3000);
output_low(led);
delay_ms(3000);
output_high (led);
delay_ms(3000);
output_low(led);
}
}
}

---thanx---
 

try with 9600 baud see if it is not the baud rate problem...
try echoing the received char may be not receiving correctly because if it receive junk character it will go in continuous while loop...


have you set the controller's clock frequency setting despite of having connected an oscillator..?
 

Actually max baud rate for receiver I am already using is 2400.And I am not using any clocks except oscillator one.

---------- Post added at 10:33 ---------- Previous post was at 10:29 ----------

I want to try it with 16f84a too. But even I can't simulate it. Can you help for code.
https://obrazki.elektroda.pl/25_1301999555.png

#include "D:\16f84\rf.h"

#use fast_io(a)
#use fast_io(b)

#define led pin_b3

#use delay(clock=4000000)

#use rs232(baud=300, xmit=PIN_A1, rcv=PIN_A0)

char data1;

void main()
{

setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);

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

output_b(0x00);

data1=getchar();
delay_ms(500);

while (true)
{
if(data1=='B')//forward direction
{
output_high (led);
delay_ms(10000);
output_low(led);
}
else if(data1=='C')
{
output_high (led);
delay_ms(3000);
output_low(led);
delay_ms(3000);
output_high (led);
delay_ms(3000);
output_low(led);
}
}
}
 

i mean to say try some standard value in your case you can use 1200 or 2400..
about the clock i was asking for the simulation only just click on the controller and set the processor frequency setting to 4Mhz....
 

The controller frequency is already 4 Mhz.
By the way I solved the case I asked for 16f84.
Probably I will use 16f84 for RF and send the data from 16f84a to 16f877a.Whole circuit consists of 4 sensors, 4 dc motors and 1 RF and these make 16f877a circuit more complicate.
 

Yes code is working. I'm using RS232 and sending data from PC via tx to PIC16f877a. The problem is rx can't take the data correctly. Maybe I have to use some filters twin t notch.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top