Homebuilt underwater robot

 

RS485 communication test

This article describes how to test RS485 communication between ROV Control Unit and PC computer with RS485 to RS232 converter. Test programs are provided to test transmission from 2400bps to 115200bps.

There are 2 programs. The first one is prepared for Windows, the second for Atmega16 chip. Windows program sends random data to ROV Control Unit. Atmega16 sends back all data to desktop computer. If sent and received data is the same communication works properly.

In addition to executable version of programs, there are full source codes available. Atmega16 program is written in BASCOM-AVR, Windows in Microsoft Visual Studio 2005.

Preparation

Download RS485_test_exec.zip file. It consist 2 files:

  1. rs485test.exe – Windows executable (MD5 sum: c80b6b1ddc54ccf96ab98d4b27c7c96e)
  2. RS485ECHO.HEX – Atmega16 binary

First program Atmega16 chip on Control Unit with RS485ECHO.HEX file. Optionally you can compile source code in BASCOM-AVR.

Connect RS485/RS232 converter to Control Unit using 2 wires (1 pair). Be sure to match A and B sockets on converter and Control Unit.
Than connect RS485/RS232 converter to serial port of desktop computer.

Optionally you can connect the second serial port to DB1 of Control Unit to see additional diagnostic messages.

Test procedure

Run command prompt window. For NT/2000/XP run cmd.exe, for other versions of Windows run command.com.
Type rs485test.exe to execute program. If program is not located in you current directory, type full path or change directory.

At the beginning program asks for COM port number to which RS485/RS232 converter is connected. Type 1 for COM1, 2 for COM2, etc and press ENTER.

RS485 test programRS485 test program

If serial port was successfully opened you should see this message:

LED should flash now.
If you do not see this, check connections and run test program again.

Press any key to proceed or ESC to terminate. 

Watch green LED. Blinking LED means that you properly connected converter and you can go to the next step of test. Press ENTER key.

The real test begins. Program will send data to Control Unit and based on data sent back diagnose connection. Test includes all standard transmission speeds from 2400bps up to 115200bps. You can check other speed values by modifying the software.

Testing 2400bps...
        Sent 100 bytes
        Received 100 bytes
        All data ok
2400bps TRANSMISSION OK

Testing 4800bps...
        Sent 100 bytes
        Received 100 bytes
        All data ok
4800bps TRANSMISSION OK

Testing 9600bps...
        Sent 100 bytes
        Received 100 bytes
        All data ok
9600bps TRANSMISSION OK

During test Control Unit sends additional diagnostic messages to DB1 port. It can be useful to check this messages in case of communication problems.

Example output:

***** RS485 TEST PROGRAM *****
$LastChangedDate: 2007-01-14 11:52:24 +0100 (N, 14 sty 2007) $
Waiting for transmission...
Transmission speed: 2400bps
Received: 100 bytes
Data sent back
Waiting for transmission...
Transmission speed: 4800bps
Received: 100 bytes
Data sent back


AttachmentSize
RS485_test_exec.zip35.68 KB
RS485_test_source_code.zip9.97 KB