Introduction: RS485 Communication Using MAX485 and MSP430 Launchpad
Here we are going to interface a MSP430 Launchpad with a RS485 transceiver chip like MAX485 and communicate with an x86 PC.
Serial(TTL) or RS232 protocol is fine if you are planning to communicate over short distances of a few meters,when you increase the range to a few 100 meters RS232 protocol will become inadequate.
For long distance wired communication you have to use a different protocol called RS485 which can communicate over a kilometer.
In this Instructable we will teach you how to build long distance communication networks using RS485 protocol.
Step 1: Materials Required
For building this Project you will require the following things.
1) Microcontroller (here MSP430 Launchpad with MSP430G2553)
2) MAX485 chip for RS485 Communication
3) 120 Ohm termination Resistor
4) General Purpose PCB or Bread Board
6) RS485 Communication Booster Pack for MSP430 (Optional)
Step 2: RS485 Section
First thing to do is to build the RS485 section using MAX485 chip.
MAX485 chip is available in a 8 Pin DIP package which can be easily mounted on a General Purpose PCB or Bread Board (if you plan on reusing the chip)
You can solder the MAX485 chip to a small piece of General Purpose PCB and bring the pins out to male bergstrip connectors ,so that you can easily connect it with MSP430 Launchpad.
It is preferable to use a IC socket for MAX485 chip since it is easy to swap chip if something goes wrong.
Connect the Pins A and B of MAX485 chip to screw terminals or Terminal Block Connectors.
Connect a 120 ohm termination resistor between the pins A and B.
The Full Circuit Diagram in PDF can be downloaded from here (under Source Code and Circuit Diagram)
Step 3: Interfacing MAX485 With MSP430 Launchpad
After you have completed the RS485 module,
Check the Board for any Solder Bridges before applying power.
Please note that MSP430 operates from a 3 to 3.3 V while MAX485 requires 5V DC.On the Launchpad board there is no 5V output,you can take the 5V output by soldering a wire to the USB connector(use a multimeter to identify the 5V DC pin from ground).As shown in the original article.
The UART pins of MSP430G2553 are connected to the MAX485 chip while Pins P2.0 and P2.1 are used to select the receive and transmit modes of the MAX485.
There is no need to interchange the TX and RX pins.
The UCA0RXD pin of MSP430 is connected to the RO (Receiver Output) pin of MAX485 and
UCA0TXD pin of MSP430 is connected to DO (Driver input) pin of MAX485.
P2.0 is connected to DE (Driver enable) pin of MAX485 which is used to put the chip in Transmit Mode.
P2.1 is connected to ~RE pin (Active Low) of MAX485 which is used to put the chip in Receive mode.
Step 4: Connecting the Microcontroller to Your PC
After you have finished connecting the RS485 section with your Microcontroller (MSP430 Launchpad ) its time to interface the embedded system part (MSP430 + MAX485) with your PC.
Since your embedded system part will be sending data in RS485 protocol, you will require an RS485 to USB converter on your PC side to convert data from RS485 to USB serial.
Here I am using USB2SERIAL for receiving the data from the microcontroller.
Connect the A and B pins of the MAX485 chip (interfaced to MSP430) to the A and B pins of USB2SERIAL as shown in the above figure.
Step 5: USB to RS485 Converter
The USB to RS485 converter uses MAX485 chip to receive the RS485 signals send from MSP430 (Launchpad + MAX485 chip) and converts them to TTL serial which are then send to FT232 USB chip and is then received by the program running on the PC.
The Above figure shows RS485 section and the RS232/RS485 selector switch.Please connect the twisted wire coming from your embedded system part to the screw terminals on USB2SERIAL.
Since USB2SERIAL can do both USB to RS232 conversion and USB to RS485 conversion,Please put the jumpers on CONN1 to RS485 .
You can read the full user manual /datasheet of USB2SERIAL USB to RS485 converter here.
Step 6: Jumper Settings for RS485 Mode
Step 7: Software
This Project uses both embedded software running on the Microcontroller side and PC side software for receiving the character send from MSP430 through RS485 Protocol.
The Microcontroller side code is written in C and compiled on IAR embedded Workbench.
The PC side software is written in C ,C# and Python and can run on Both Linux and Windows.
Step 8: Connections
Photo of the finished Project.
Step 9: Using MSP430 Booster Pack (optional)
In the First Part we build the MAX485 board from scratch on a Protoboard .
The same effect can be achieved by using the MSP430 Motor Control/ RS485 communication Booster Pack
You can use this feature to control multiple motors like in this instructable
Participated in the
Digital Life 101 Challenge