Go Down

Topic: Communication problem using RS232 (Read 1 time) previous topic - next topic

docosama

Aug 29, 2013, 05:44 am Last Edit: Aug 29, 2013, 09:13 am by Coding Badly Reason: 1
hi there

I want to control a UPS device using its Rs232 port via Arduino. I am doing this using MAX3232.

When I connect the UPS directly with my PC and send serial commands using a terminal software, the UPS responds very well. One of the basic command is just a 0x0d character. However, when I send the same command using arduino, the UPS fails to respond. I tested the output of arduino by connecting its DB9 connector to the PC, and found that it sends all commands correctly without any illegal character. The settings on the PC terminal are 2400 baud with data size 8, parity none, handshake off. With these settings, the PC communicates with PC and when connects to the arduino, does the same. However, arduino when connected directly to the UPS, fails.

What could be the other reason that is not coming to my mind here?

Here is the software code programmed in the arduino:

Code: [Select]
#include <SoftwareSerial.h>
SoftwareSerial mySerial(6, 7); // RX, TX
void setup()
{
 // Open serial communications and wait for port to open:
 Serial.begin(9600);
 Serial.println("Starting!");

 mySerial.begin(2400);
 mySerial.write(0x0d);

 delay(1000);
 if (mySerial.isListening()) {
  Serial.println("Port One is listening!");
 }
}

void loop() // run over and over
{
 while (mySerial.available() <= 0) {
   mySerial.write(0x0d);
   Serial.println("Sent");
   delay(5000);
 }

 if (mySerial.available())
 {
   Serial.write(mySerial.read());
 }
 if (Serial.available())
   mySerial.write(Serial.read());

 if (mySerial.overflow()) {
   Serial.println("Overflow ...");
 }
}


Please help .. thanks


Moderator edit: [code] [/code] tags added.

robtillaart

What are the specs of the device? (voltage etc)

did you connect the grounds Arduino/UPS so there is a shared reference?

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

docosama

well, the ground is connected thru DB9 connector and UPS device and Arduino are sharing it ... the connector has 3 pins ... one GND and other is Rx and Tx.
I dont know what voltages the UPS produces on the DB9 connector ..
Should I test the Arduino --> Max3232 output using Loop back method to see if it is sending the right bytes ?


robtillaart

Quote
I dont know what voltages the UPS produces on the DB9 connector ..


do you have a voltmeter, even the cheap 5$ ones are good enough to protect you against overload!
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

docosama

I have a voltmeter :)
I have checked the volts at UPS DB9 connector ... at pin 2 .. its -14.8v, at pin 3 almost zero ...



docosama

well finally I got the success  ... I attached the pin14 and pin13 of Max3232 to pin3 and pin2 of DB9 respectively ... previously they were other way round ... thats the reason the arduino was communicating well with the PC but not with the UPS device ...

all the circuit diagrams listed on the internet are actually designed to communicate Arduino with PC. I was following: http://avrprogrammers.com/doc-max232-arduino.php. My mistake was that the pin connections from Arduino to DB9 were that for PC.

Another problem is that the UPS sends 164 byte data while Arduino is unable to read data beyond 64 bytes ... i think arduino needs some adjustments in the buffer size ...

Thank you everybody for help ..

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:

shortcuts: alt+s submit/post or alt+p preview