Activity Forums Questions & Troubleshooting Software & Firmware Controllino does not receive the data RS485

  • Controllino does not receive the data RS485

     Lukas updated 4 years, 3 months ago 2 Members · 10 Posts
  • todakouma

    Member
    August 10, 2020 at 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:

    // Include Industrial Shields libraries
    #include//// 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:

    #include

    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-base/rs485-modbusrtu/” class=”bbcode_url”>https://www.controllino.biz/knowledge-base/rs485-modbusrtu/ )

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

  • Lukas

    Member
    August 10, 2020 at 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

    Member
    August 10, 2020 at 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

  • Lukas

    Member
    August 10, 2020 at 1:33 pm

    Hello,

    and have you selected the CONTROLLINO variant properly?

    [img]https://i.ibb.co/ftqhCyL/CONTROLLINO-MAXI.jpg[/img]

    Thanks,

    Lukas

  • todakouma

    Member
    August 10, 2020 at 1:54 pm

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

    [img]https://image.noelshack.com/fichiers/2020/33/1/1597067611-image.png[/img]

    Thank you for your reply,

    Todakouma

  • Lukas

    Member
    August 10, 2020 at 2:03 pm

    Hello,

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

    Best regards,

    Lukas

  • todakouma

    Member
    August 10, 2020 at 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

  • Lukas

    Member
    August 10, 2020 at 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

    Member
    August 10, 2020 at 2:38 pm

    It’s working !!!!!!!!!!!!

    Thanks a lot :D

    Todakouma

  • Lukas

    Member
    August 10, 2020 at 2:49 pm

    Great! :)

    You are welcome!

    Lukas

Viewing 1 - 10 of 10 replies

Log in to reply.

Original Post
0 of 0 posts June 2018
Now