Slow serial communication

Good Morning Community,

I writed two codes for R/T of serial data. Works well, instead it is very slow. :frowning:

Any idea, to increase the speed?

TX-routine:

void telegramm_senden()
{
  Serial.print("Abfrage an Leser: ");
  for (int j = 0; j < 8; j++)
  {
    Serial.print(telegramm[j]);
    Serial.print("-");
  }
  Serial.println();

  digitalWrite (uart_senden, HIGH);
  delay(1);
  Serial1.println(255);
  delay(1);
  //Serial1.write(telegramm,8);
  Serial1.println();
  for (int i = 0; i < 8; i++)
  {
    Serial1.println(telegramm[i]);
    delay(2);
  }
  delay(12);
  digitalWrite (uart_senden, LOW);

  for (int i = 0; i < 8 ; i++) telegramm[i] = 0;
}

RX routine

void telegramm_empfangen ()
{
  while (Serial1.parseInt() != 255)
  {
    zaehler_abbruch++;
    Serial.println("Keine Verbindung");
    if (zaehler_abbruch > 3) break;
  }
  for (int i = 0; i < 8; i++) telegramm[i] = Serial1.parseInt();

  zaehler_abbruch = 0;

  delay(15);

  Serial.print("Antwort von Leser: ");
  for (int j = 0; j < 8; j++)
  {
    Serial.print(telegramm[j]);
    Serial.print("-");
  }
  Serial.println();
}

Try deleting the delays.

Pieter

The delay's are not the problem, there are the solution. I got some timing problems between the recieving data, editing it, and sending it back to the Master.

Here are the main procedure:

  1. MASTER sending data to first SLAVE
  2. SLAVE sending back data to MASTER

This for 15 slaves...

pevloc:
The delay's are not the problem, there are the solution. I got some timing problems between the recieving data, editing it, and sending it back to the Master.

Here are the main procedure:

  1. MASTER sending data to first SLAVE
  2. SLAVE sending back data to MASTER

This for 15 slaves...

Thank that over serial not RS485! how you wired them all up?

Then you have a more fundamental problem. You'll have to design a more appropriate protocol, that doesn't rely on delays to work correctly.

Please post the full code, a schematic, and what kind of messages you want to send.

I suspect the Serial1.parseInt() is the problem because it blocks until it receives a value.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example to illustrate how to extract numbers from the received text.

The technique in the 3rd example will be the most reliable.

You can send data in a compatible format with code like this

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

...R