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.

PIC to PIC interfacing by RS485

Status
Not open for further replies.

fuzzzy

Full Member level 3
Joined
Oct 2, 2004
Messages
156
Helped
7
Reputation
14
Reaction score
2
Trophy points
1,298
Location
ITALY
Activity points
1,650
pic rs485

Hi,

I'm trying to connect 2 PIC16f876 by rs485 using SN75176 transceiver. I'd like to use half duplex configuration, so i control RE and DE pins togheter by Port C5 thata is always 0(receiving). It will be set 1 before transimitting and then it returns to 0.
I use pins C6 and C7 to receive and transmit data.

I've some problems in comunication.After a lot of attempt i realized that When one PIC transimts data it seems as it receives what it has transmitted and this will fill in receiving buffer. so the transimitting pic receives the same data it sends. and when the other pic tryes to send data the first pic can't decode data.

I tried all configuration suggested in datasheet to remove bias, with 120 ohm resistors and so on but it's the same. so i should exclude problems on the line.

What will you suggest to try? how can i solve this problem?

thanks!

P.s. I program my PIC using CCS C
 

rs485 pic

It looks like you have the echo problem.
What you should try is to send first a sentence (command) out and during that period of time don't allow anything to be read by the first PIC. After the transmission in one direction is completed wait for the response of the other PIC ..
 
ccs rs485

If you read the datasheets for SN75176 and PIC16f876 you will find that the
receiver of the SN75176 has a minimum VOH of 2.7V and the RC7 pin of the
PIC has minimum VIH of 0.8VDD=4V (in this case).

Obviously the chips are not electrically compatible, so you should start by fixing
this problem.

/Rambo
 

rs485 ccs

The problem is that you don't disable reception on 75176 during transmision. Check the logical levels on RE and DE pins during transmision. Look with an osciloscope at the Rx pin of 75176 during transmision (RE pin at high level). You should have a steady high level on this pin.
 

rs485 with pic

hi fuzzzi,

the "problem" you are seeing is normal with RS485 if you do not disable the receibver as marie65 wrote you will always also receive what you are transmitting :)

As you program in CCS you can search the CCS forum for the keyword RS485 and you will find a lot of useful information even some sourcecode like in this thread:
https://www.ccsinfo.com/forum/viewtopic.php?t=21909&highlight=rs485

hope this helps
 

pic rs485 code

the problem you fixed is what i supposed. I tryed a lot of solution. I have pin RE and DE of sn75176 linked toghrter with pin C5 of PIC. I manually put High pin c5 and after transission or after a fixed time i put manually it down. but the problem is the same, also in #use rs232 there is an option to control this pin automatically also in this case problem is the same!!

when i tryed this configuration an a PIC 16f84A i hadn't this problem!! transission was perfect!! the code is almost the same!
 

pic rs-485

Well, which pin of the 16F84A did you use to receive the data?

/Rambo
 

rs 485 pic

I used B1 to receive and B2 to transimit.
 

rs-485 pic

According to the 16F84A datasheet port B has TTL inputs, i.e. it is compatible
with the SN75176.
This is the problem with the 16F876 - its input pin is not electrically
compatible with the SN75176. The "high" output level of the SN75176 does not reach
the minimum required voltage on pin C7, so the logic level is in the "forbidden"
zone. Also, the receive pin of the SN75176 is put in high-impedance mode when
the receiver is disabled, so pin C7 might be overhearing the transmitting section
of the SN75176.

You might be able to bypass the problem by putting a pull-up resistor (try 1 kΩ or
smaller) on pin C7 of the 16F876.

However, if this design is going to be used in a "mission critical" device I strongly
suggest that you redesign it with compatible chips, or a level-shifter, otherwise
the communication might fail if, for instance, the ambient temperature goes up a
couple of degrees.
What if a patient dies because of this failure? Who will you blame then, Texas Instruments?

My point is: read the datasheet - all of it.

/Rambo
 

ccs c rs485

I agree all what you say about reading datasheet and security. this is a prototype and i can change it. I chose this configuration because of hardware usart of this pic.
evry scheme i've evere seen used this two pins c6 and c7 for serial communication, sometimes interfaced with sn75176 or max 485. so i supposed this was a correct solution.

now i try to see what happens wit a pullup resistor.

thanks for your support
 

pic rs485

Hi, I finally managed it!!! it seems a very stupid thing now!! the problem was to set correctly TRISC. I set TRISC7=1 and all is ok now.
my two pic communicate perfectly without any fault!!
 

rs485 pic16f876

your code is working? do you mind to share it out? I am going to use same communication method with you.

Thanks
 

pic+rs485

fuzzzy said:
Hi, I finally managed it!!! it seems a very stupid thing now!! the problem was to set correctly TRISC. I set TRISC7=1 and all is ok now.
my two pic communicate perfectly without any fault!!
True it is. 90% of the time, it is just those tiny things.
 

rs485 ccs c

funnynypd said:
fuzzzy said:
Hi, I finally managed it!!! it seems a very stupid thing now!! the problem was to set correctly TRISC. I set TRISC7=1 and all is ok now.
my two pic communicate perfectly without any fault!!
True it is. 90% of the time, it is just those tiny things.
I also want the example code
 

Re: pic rs485

fuzzzy said:
Hi, I finally managed it!!! it seems a very stupid thing now!! the problem was to set correctly TRISC. I set TRISC7=1 and all is ok now.
my two pic communicate perfectly without any fault!!
Hi fuzzzy,

I'm also interested in getting familiar with PIC and RS485.
Could you share your code with me, please?

Best regards,
Mike
 

RS232 to RS485.JPGHi Guys,

I have a much simpler method of RS485 Communication. It requires no setting of the RE & DE PINs.
Just connect the RE & DE PINs together and connect them to the Microcontroller TX via simple transistor inverting circuit.
(Only invert the TX signal of the Microcontroller)
Connect the D (PIN 4 of SN75176) to the ground.
Connect the R (PIN 1 of SN75176) directly to the RX of the Microcontroller.

With this circuit you would not have to worry about setting the direction of data, for the RS485 communication.
This will save up both RAM and ROM on the micro controller.

Enjoy !!!
SS
 

Re: pic rs485

Please if you don't mind then share your code.I needed it code urgently because my project is to be submitted on 15th december 2012.

- - - Updated - - -

I m using PIC18F452 as a chip
 

code???
code for what? its simple serial communication!!
 

I know its just simple serial communication but problem is i have never done any work on communication before. i have completed my control unit code and also ballot unit code and now i m struck in communication. i have less than three days to work on it before submission. my supervisor just said that i can show running stimulation on proteus if my hardware is not yet ready to get grades....thats why i was asking for code
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top