how to set serial protocol parameters to receive DatafromDevice with ARDUINO UNO

Hello to Everyone!

I’m kind of new in working with the Arduino Uno… So I have a problem I can’t solve at my own…

My project is abouth:
I want to receive data from an Inverter via a RS232. I bought a RS232- Serial Adpater with a MAX 323 and connected everything (RX Adapter to TX Arduino, TX Adapter to RX Arduino, GND Adapter to GND Arduino and Vcc Adapter to 5V Arduino). The connector I bought is the following:

http://www.exp-tech.de/Shields/Schnittstelle/Serial-Adapter-RS232-TTL-3-5-5V.html?XTCsid=c94fcabf9a652b7813983b111e22a5bd

The problem I have, is how can I receive the data from my device?

I’ve got the serial protocoll from the device, but I am not sure, how I have to set the frames and headers for the right communication. I atteched the serial protoc to this post…

I figured out, how I have to begin the SerialCommunication:
Serial.begin(38400, SERIAL_8E1),

but don’t know where to set all the other parameters…

THANKS a lot for helping me!

Technical specification - Xtender serial protocol - V1.5.16.pdf (1.5 MB)

but don't know where to set all the other parameters...

Specifically, what "other parameters" are you referring to?

You have something like this ? http://www.studer-inno.com/?cat=sine_wave_inverter-chargers&id=432

Sometimes the RX connects to TX, but sometimes the labels on the adapter are already exchanged. So perhaps you have to connect RX to RX and TX to TX.

When you use the hardware serial port at pin 0 and pin 1, you can no longer use the serial output to the computer (to the serial monitor). So you can't show debug messages, and you never know what is going on in the Arduino.

You can split the serial port into two parts: use the Arduino RX to receive data from the Xtender (if the Xtender is only transmitting), and Arduino TX to transmit data to the computer. Or you can create an extra serial port with SoftwareSerial. http://arduino.cc/en/Reference/SoftwareSerial

Could you try that SoftwareSerial ? If you read data from the Xtender, and send it to the computer, you know what you are receiving. That is a start. After that you can try to recognize the data from the Xtender.

I can’t recieve data from my device (yes it’s an Xtender TM 4000-48).

The code I’m using for trying is:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup()  
{
  // Open serial communications and wait for port to open:
  // Set USART_Configurations: 38400bps, 1start bit, 8bit of data
  // 1 parity bit, even parity, 1 stop bit
  Serial.begin(38400,SERIAL_8E1);

  // set the data rate for the SoftwareSerial port
  mySerial.begin(38400);
  mySerial.println("Hello, world?");
}

void loop() // run over and over
{
  if (mySerial.available())
    Serial.write(mySerial.read());
  if (Serial.available())
    mySerial.write(Serial.read());
}

@PaulS: with parameters I mean:
I have differents Information I want to read out of my device…like batterycurrent, voltageinput etc. Means I have to tell the device, wich objectinformation (object_id) I have to receive from it (see the command_request line, if u just want to talk to the xtender with cmd.exe: >scom.exe --port=COM3 --verbose=3 read_property src_addr=1 dst_addr=101 object_type=1 object_id=3000 property_id=1 format=FLOAT)
So my question is, where can I set all these adresses?

The code I'm using for trying is

So, the SoftwareSerial instance is connected to the XTender?

If so, it is the mySerial (stupid name) instance that you should be setting the bits, parity, etc. for, not the Serial instance.

  mySerial.println("Hello, world?");

Is the XTender really going to understand that, even if you get the communication parameters correct?

So, the SoftwareSerial instance is connected to the XTender?

yes, I connected the Xtender via a rs232 to the arduino

  mySerial.println("Hello, world?");

Is the XTender really going to understand that, even if you get the communication parameters correct?

probably no:)

Maybe I'm not sure, what's the difference between "mySerial" and "Serial". With "mySerial" I can communicate with the Xtender, and with "Serial" I can print data on my monitor? sorry, I'm confused....

Maybe I'm not sure, what's the difference between "mySerial" and "Serial".

You seem to have answered your own question:

With "mySerial" I can communicate with the Xtender, and with "Serial" I can print data on my monitor?

Yes.

sorry, I'm confused....

Then this probably isn't the project for you.

With “mySerial” I can communicate with the Xtender, and with “Serial” I can print data on my monitor?

Yes.

But then I don’t have to set my baudrat etc. for “mySerial”? Cause if I try doing this, i get an ERROR…

still trying to receive data from the xtender:

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup()  
{
  // Open serial communications and wait for port to open:
  // Set USART_Configurations: 38400bps, 1start bit, 8bit of data
  // 1 parity bit, even parity, 1 stop bit
  Serial.begin(38400,SERIAL_8E1);

  // set the data rate for the SoftwareSerial port
  mySerial.begin(38400);
}
void loop(){
   mySerial.print(byte(06));
   delay(30);
  if(mySerial.available()>0){
    Serial.println("Xtender available");
    int c = mySerial.read();
    Serial.println(c);
  }else{
    Serial.println("Xtender not available");
    Serial.println(mySerial.read());
  }
  delay(5000);
}

but I always receive at the monitor:

“Xtender not available
-1”

What is wrong?

   mySerial.print(byte(06));

Why are using octal notation? What is the XTender supposed to do with this value, as a string (whatever it actually turns out to be)? Perhaps the XTender might understand:

mySerial.write(6);
    Serial.println("Xtender not available");
    Serial.println(mySerial.read());

If there is nothing to read, say so, and read anyway. Why?

    Serial.println("Xtender not available");
    Serial.println(mySerial.read());

If there is nothing to read, say so, and read anyway. Why?

the whole code is just for testing if I'm getting any signal from the Xtender. But apparently it doesn't work.

My suggestion why it's not working, is abouth setting the above mentioned parameters... So that the xtender knows, which information of plenty I want to read... but at the moment I still don't know how to do this....

still trying to receive any data from the xtender.

tried to send the following request to the Xtender:

#include <SoftwareSerial.h>

#define rxPin 10
#define txPin 11

SoftwareSerial myXtender(rxPin, txPin); // RX, TX
//Request line 26bytes, Hexadecimal
byte Request[] = {0xAA, 0x00, 0x01000000, 0x65, 0x0A, 0x6F71,0x00,0x01,0x01,0xB80B0000,0x01,0xC590};
 
void setup()  
{
  // define pin modes for tx, rx:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  // Open serial communications and wait for port to open:
  // Set USART_Configurations: 38400bps, 1start bit, 8bit of data
  // 1 parity bit, even parity, 1 stop bit
  Serial.begin(38400,SERIAL_8E1);

  // set the data rate for the SoftwareSerial port
  myXtender.begin(38400);
  
}

void loop(){
  
  //sending the Request to the xtender
  for (int i=0; i<sizeof(Request); i++)
  {
  myXtender.write(Request[i]);
  Serial.println(Request[i]);
  delay(500);
  }
  if(myXtender.available()>0){
    Serial.println("Xtender available");
    int c = myXtender.read();
    Serial.println(c);
  }else{
    Serial.println("Xtender not available");
    Serial.println(myXtender.read());
  }
  delay(1000);
}

but it’s still not working… I can’t receive any data…

probably the way I’m sending the Request is wrong. I want to send 26bytes, like it is written in the seriel protocoll I atteched to my first post.

Still really THANKFUL for any help!!!

Why are you delaying half a second after each byte sent to the device?

PaulS: Why are you delaying half a second after each byte sent to the device?

it was just to see the data I'm sending better at the monitor...

any idea why I can't receive any data?

any idea why I can't receive any data?

No. I don't know what an XTender is, or how you would talk to it. I suspect, though, that 1/2 a second between inputs causes the device to time-out and reset, meaning that it never sees a complete command.