View previous topic :: View next topic |
Author |
Message |
evaradharaj
Joined: 15 Jan 2009 Posts: 60
|
16f877a microcontroller serial communication with 16f877a |
Posted: Sun Feb 14, 2010 11:10 pm |
|
|
Hi,
I have interfaced the PIC16f877A microcontroller with another PIC16f877a microcontroller. In Proteus simulation it is working fine with putc and getc commands.
But, in real time it is not communicating properly. Means, no character in the receiver or some other.
I think, the problem is with the baud rate. I am using 3.5795MHz crystal oscillator in both microcontrollers.
What is the matching baudrate for that crystals oscillator? If i use 4 MHz as my crystal frequency and what is the standard baud rate? Is there any baudrate calculator for PIC microcontroller?
Thanks and regards,
Varadharaj.E _________________ embedding innovation in engineers |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 14, 2010 11:20 pm |
|
|
You can use the PicBaud program to tell if it's possible to use a desired
baud rate. Download it from this page. Unzip it and put it on your desktop:
http://www.micromagicsystems.com/#/picbaud/4523812801
This web page takes a few seconds to load, and it plays a sound. |
|
|
evaradharaj
Joined: 15 Jan 2009 Posts: 60
|
thanks |
Posted: Mon Feb 15, 2010 4:06 am |
|
|
thank you Sir,
I have downlaoded it and checked it... I have a doubt that if i give 3.5795 MHz to the clock and baud rate is 9000. Then it is showing 3.27% error. Is it acceptable? how many % of error is tolerable for 16f877a.
Once again thanks for the link.. _________________ embedding innovation in engineers |
|
|
Ttelmah Guest
|
|
Posted: Mon Feb 15, 2010 4:43 am |
|
|
Why on earth run at 9000bps?.
However you should have no error at all between your devices. Since both use the same crystal, both will have exactly the same error in the local frequency being generated, and the error _between the devices_ will be zero.
3.27%, is 'upper end' of acceptable error on the link, however would normally be 'acceptable', but you should not have any error at all with just these two devices.
Your problem is from something else.
How are the devices powered?. How is the connection made between them?. Remember that there needs to be a ground connection as well as the signals. How long is the connection?.
Best Wishes |
|
|
evaradharaj
Joined: 15 Jan 2009 Posts: 60
|
Re: PIC to PIC communication |
Posted: Mon Feb 15, 2010 11:52 pm |
|
|
Both are having separate power supplies. Because one is transmitter another one is receiver. The distance between transmitter and receiver is about 1/2 feet.
The same code is working in Proteus. But in real time some different symbol or no character is displaying !!!
Please can you find out what is the problem. _________________ embedding innovation in engineers |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Tue Feb 16, 2010 2:10 pm |
|
|
ignore my post, Ttelmah posted the same before... i didnt see it.
[edit]
"Are you sharing a common ground? Maybe you forgot that since you're using 2 power supplies. Tx and Rx line alone won't cut it" _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
evaradharaj
Joined: 15 Jan 2009 Posts: 60
|
common ground |
Posted: Tue Feb 16, 2010 11:27 pm |
|
|
There is no need of giving common ground.
Because it is a communication link. I tried it with 89c51. It has worked perfectly. No need for common ground.
Now I am trying with wired communication. After that I'll go for wireless. _________________ embedding innovation in engineers |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Thu Feb 18, 2010 4:11 pm |
|
|
You need a common ground.... a ground line.
Check the RS232 standard. Minimun requirement for Tx/RX is 3 cables.... on of them is the GND.
A signal is electricity (voltage) .. and a bit of current... a signal needs to be referenced to something.... thus the common ground....
else the machine receiving or sending... can't tell the diference between high or low.... current won't flow.... signal doesn't get there.
Put a third line... a ground line.... and it will work. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
evaradharaj
Joined: 15 Jan 2009 Posts: 60
|
Common Ground |
Posted: Thu Feb 18, 2010 9:14 pm |
|
|
If it is a wireless communication for about 100 mts.
How can I put the common ground. I tried with 8051 microcontroller without common ground its working fine. _________________ embedding innovation in engineers |
|
|
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Thu Feb 18, 2010 10:52 pm |
|
|
Could post a schematic ?? |
|
|
evaradharaj
Joined: 15 Jan 2009 Posts: 60
|
scematic |
Posted: Fri Feb 19, 2010 12:48 am |
|
|
I will copy that bu tomo _________________ embedding innovation in engineers |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Sun Feb 21, 2010 4:53 pm |
|
|
What wireless link are you using?
Do your pics talk to each other and does the code work when having a
a real wired connection?
Does the link have preset baud rates? you might have a conflict between the pic and the link if your forcing the pic to 9000 and the link is running 9600.
Why not just use a 20mhz crystal and a 9600 baud rate?
I always use that and it never fails. Don't worry to much about the error rate on the signal for now.... just get it working first...stick to standards. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
|