|
|
View previous topic :: View next topic |
Author |
Message |
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
RS485 |
Posted: Tue Dec 27, 2011 8:59 am |
|
|
Dear All,
What is the real difference both on the MAX487 (the chip which handles the RS485 Signal Voltages) and the PIC, with HARDWARE UART and SOFTWARE UART? The enable PIN should be connected to the INT Pin? I am using the 18F252 and I dedicated Interrupt module (INT) only to the MAX487. I do not know if this is good or not? The routine RDA handles a particular operation within the RS485?
Really thanks for your help. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Tue Dec 27, 2011 10:32 am |
|
|
The PIC, has nothing whatsoever to do with RS232, or 485!....
That it does, is a myth, perpetuated by CCS's use of the #USE RS232 nomenclature. The PIC develops and receives asynchronous TTL serial. (technically on chips like the PIC, the 'TTL' bit is also wrong, but the name has stuck). This is a serial data stream, using standard logic switching levels for 1/0, which idles 'high', and goes low to signal. This is what is generated/received by either the hardware UART, or software UART. The ha hardware UART has the ability to send and receive at the same time (full duplex), and to send/receive while the CPU is doing other jobs.
RS485, and RS232, are _signalling voltage standards_. RS232, requires a transmitter that develops between +5v, and +25v for a '1', and between -5v and -25v, for a '0', into a load between 3KR, and 7KR. RS485, is a _differential_ standard requiring two lines, commonly called 'A' and 'B'. A '1' requires B-A, to be more than 200mV. A zero has the voltage reversed. The 'A' pin is meant to be the inverting pin, but 'beware' several of the driver chips name the pins the other way round..... The drivers have to be able to produce a minimum of +/-1.5v on the two lines, with a line impedance of typically 50 to 100R. RS485, only defines the signalling standard, nothing else. You can then use this signalling in a number of ways. With differential signalling, at higher speeds, the pair of lines should be terminated at each end to minimise signal reflections at the ends.
Single pair of wires, no enable - gives simplex (one way) communication between two devices.
Single pair of wires, with enable - allows half duplex (one way at a time) communication between multiple devices (only one transmitting at any one time).
Two pairs of wires no enable - allows full duplex (both ways at the same time) communication between two devices.
Two pairs of wires with enable - allows full duplex communications between multiple devices (only one transmitting at any one time).
In each case, where there is an 'enable' used, the bus has to be setup, so that when no device is driving the lines, the lines move to the 'idle' state (normally done by voltage bias at the terminators), and a device then takes control of the bus by turning it's driver 'on', and signalling as required. Here a 'protocol' is needed to handle how clashes and signalling are handled. This is not part of RS485. Turning the driver 'on' is what the enable pin handles.
The enable pin can be connected to any pin you have available. The enable is an _output_ on the PIC, not an input, so won't generate interrupts.
INT_RDA, has nothing to do with RS485, all it says that a byte has been received by the hardware UART. The byte _can_ be received from an RS485 source, via a chip like the MAX485, but in itself is not to do with the signalling standard.
Best Wishes |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Tue Dec 27, 2011 4:20 pm |
|
|
Does someone have a complete working example of the RS485? I know that there is an example on the compiler ex_rs485.c but I am looking for a very simple program to get started with the RS485 and I will continue step-by-step myself. Really appreciate a program with the basic steps to get started.
Appreciate your support as always. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Tue Dec 27, 2011 6:03 pm |
|
|
One simple way is to have one PIC the master...sends a continuous set of data, the other PIC a slave.
Cut code just like using RS232 with MAX232 chips and test.
When that is working, remove the MAX232 chips, install MAX48 but be sure to wire B-B and A-A as well as the pullup/bias/pulldown resistors.
The MAX1487... datasheet shows these connections.
Only 2 additional wirings are needed. On the 'master' connect the MAX488 RE_ and DE pins together and tie to +5V. On the slave connect them to gnd.
This will force the master to always be enabled to transmit, the slave will only receive.
The program thatwas working for RS232 should work for RS485.
I'd use a baudrate of 9600 for test purposes.
This is a very basic one way test program/hardware system and should work.
From here it's up to you to work on different configurations. Using the CCS #USE RS232( enable=..) option always for the compiler to automatically control the MAX488 enable pins.
There is a TON of info on the Web, make Google your friend ! |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Wed Dec 28, 2011 4:52 pm |
|
|
dear temtronic, thanks for your reply. Actually I started the opertaion by interfaced two PIC16F689 via MAX232 and the operation worked fine. Exchange data and repsond port output according to the data received. On the other hand when I replaced all the interface with the MAX487, nothing was received! I made all the biased resistors and the terminated resistor (120R), but nothing received! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|