Controllino does not receive the data RS485

Stuck? We'll be happy to help!
Post Reply
todakouma
Posts: 5
Joined: Mon Aug 10, 2020 7:25 am

Controllino does not receive the data RS485

Post by todakouma » Mon Aug 10, 2020 7:30 am

Hello,

For a project I have to connect a controllino with a m-duino in RS485, I managed to do the code on the M-Duino, sending and receiving data works but on the controllino just sending works.

The M-duino code:

Code: Select all

// Include Industrial Shields libraries
#include <RS485.h>

//// IMPORTANT: check switches configuration

////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
  // Begin serial port
  Serial.begin(9600);

  // Begin RS485 port
  RS485.begin(38400);
}


void loop() {

  /*
    Envois des données
  */
  String str = "M-Duino";

  for (int i = 0; i < str.length(); ++i) {
    // And send it to the RS-485 port
    RS485.write(str[i]);
    Serial.write(str[i]);
  }


  /*
     Reception des données
  */
  //  if (RS485.available()) {
  //    byte rx = RS485.read();
  //
  //    // Hexadecimal representation
  //    Serial.print("HEX: ");
  //    Serial.print(rx, HEX);
  //
  //    // Decimal representation
  //    Serial.print(", DEC: ");
  //    Serial.println(rx, DEC);
  //  }

  delay(5000);
}
The controllino code:

Code: Select all

#include <SPI.h>

void setup() {
  Serial.begin(9600);
  Serial3.begin(57600);
  Controllino_RS485Init();
}

void loop() {
  RecieveRS485();
  //TestRS485(0);
  delay(1000);
}

void TestRS485 (int mode)
{
  DDRJ = DDRJ | B01100000;
  PORTJ = PORTJ & B10011111;

  switch (mode)
  {
    case 0:
      PORTJ = PORTJ & B10011111;
      PORTJ = PORTJ | B01000000;

      delay (10);
      Serial.println ("Sending test message, expected to return;");
      Serial3.print("Controllino");
      break;

    default:
      Serial.println("Wrong mode!");
      return;
  }
}

void RecieveRS485()
{
  //Serial.println("Recieving RS485.");
    if (Serial3.available())
    {
      // print the new byte:
      Serial.println((char)Serial3.read());
    }
}

char Controllino_RS485Init( void )
{
  pinMode(75, OUTPUT);
  pinMode(76, OUTPUT);
  Controllino_RS485RxEnable();

  return 0;
}


void Controllino_RS485RxEnable( void )
{
  digitalWrite(75, LOW);
  digitalWrite(76, LOW);
  return;
}
I think the error comes from the fact that the pinMode is configured in OUTPUT but on the demo they are too (demo link: https://www.controllino.biz/knowledge-b ... modbusrtu/ )

If you know why I cannot receive the data with the controllino I will listen to you :D

User avatar
Lukas
Posts: 75
Joined: Tue Dec 18, 2018 3:44 pm

Re: Controllino does not receive the data RS485

Post by Lukas » Mon Aug 10, 2020 12:05 pm

Hello,

please, check our latest example code.

You do not need to manipulate with the direction control signals via registers. We already provide API for that.

I am not sure about the M-duino RS485 implementation, but it is always important to wait until the transmission is (physically) finished and then switch to reception.

Best regards,
Lukas

todakouma
Posts: 5
Joined: Mon Aug 10, 2020 7:25 am

Re: Controllino does not receive the data RS485

Post by todakouma » Mon Aug 10, 2020 12:55 pm

Hello,

I copied the code but without success.

I do this because the CONTROLLINO library does not work, I have this error message:
#error Please, select one of the CONTROLLINO variants in Tools->Board

For now the M-Duino is only sending data so there should be no problem :/

Waiting for your reply,
Todakouma

User avatar
Lukas
Posts: 75
Joined: Tue Dec 18, 2018 3:44 pm

Re: Controllino does not receive the data RS485

Post by Lukas » Mon Aug 10, 2020 1:33 pm

Hello,

and have you selected the CONTROLLINO variant properly?

Image

Thanks,
Lukas

todakouma
Posts: 5
Joined: Mon Aug 10, 2020 7:25 am

Re: Controllino does not receive the data RS485

Post by todakouma » Mon Aug 10, 2020 1:54 pm

I don't have the same thing, it shows this to me :/

Image


Thank you for your reply,
Todakouma

User avatar
Lukas
Posts: 75
Joined: Tue Dec 18, 2018 3:44 pm

Re: Controllino does not receive the data RS485

Post by Lukas » Mon Aug 10, 2020 2:03 pm

Hello,

please follow the Instruction Manual, Chapter Software and Initial Startup.

Best regards,
Lukas

todakouma
Posts: 5
Joined: Mon Aug 10, 2020 7:25 am

Re: Controllino does not receive the data RS485

Post by todakouma » Mon Aug 10, 2020 2:06 pm

Ok, it's good the CONTROLLINO library working.
But still the same problem, I do not receive anything with the controllino in RS485

Waiting for your reply,
Todakouma

User avatar
Lukas
Posts: 75
Joined: Tue Dec 18, 2018 3:44 pm

Re: Controllino does not receive the data RS485

Post by Lukas » Mon Aug 10, 2020 2:14 pm

Do you have the same baudrate at both sides? Have you interconnected also the grounds?

May I ask you to share the latest source codes at both sides and also a photo of the wiring?

Thanks!
Lukas

todakouma
Posts: 5
Joined: Mon Aug 10, 2020 7:25 am

Re: Controllino does not receive the data RS485

Post by todakouma » Mon Aug 10, 2020 2:38 pm

It's working !!!!!!!!!!!!

Thanks a lot :D
Todakouma

User avatar
Lukas
Posts: 75
Joined: Tue Dec 18, 2018 3:44 pm

Re: Controllino does not receive the data RS485

Post by Lukas » Mon Aug 10, 2020 2:49 pm

Great! :)

You are welcome!

Lukas

Post Reply