Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Modbus TCP with an arduino MEGA

Modbus TCP with an arduino MEGA 6 years 6 months ago #9279

  • Darkodo
  • Darkodo's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
Hi everyone,

I am trying to connect proview with my arduino MEGA, but I encounter some issues.

On the arduino MEGA, I used the Mudbus library as Modbus server. I have tested my program with the Radzio program (see the screen capture). It fulfilled all my expectations :) .




I have followed Ben's tutorial, and configured my node as described in his video (see the screen capture).
But I can't read or write values on my arduino.





On the console, I have several warnings about the Ge


Console.PNG



What have I done wrong ?


Thank you for your help,

Darkodo
Last Edit: 6 years 6 months ago by Darkodo. Reason: Missing images.
The administrator has disabled public write access.

Modbus TCP with an arduino MEGA 6 years 6 months ago #9280

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3179
  • Thank you received: 502
  • Karma: 133
Hi Darkodo,

You should create a signal objects (Di, Do, Ai) in the plant hierarchy and connect them to the channel objects. Connect by selecting the channel, rightclick on the signal and activate Connect. It's ActualValue in the signal objects that contains the received value that you display in the graph, and the Ge syntax is 'H1-H2-SomeDi.ActualValue##Boolean' or 'H1-H2-SomeAi.ActualValue##Float32'. In the value fields you have to specify a format, for example %6.2f (float with 6 characters and 2 decimals).

/Claes
The administrator has disabled public write access.

Modbus TCP with an arduino MEGA 6 years 5 months ago #9290

  • brew
  • brew's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 108
  • Karma: 0
hello

here are the settings for an arduino project, and it works okay for me

bill

usbMEGAsettings.jpg
The administrator has disabled public write access.

Modbus TCP with an arduino MEGA 6 years 4 months ago #9399

  • Darkodo
  • Darkodo's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
I am sorry for my late answer. Personal life pop-up when I was trying proview.

Thank you Claes ! :)
Now I manage to have the analog values.

I set the representation as you did Brew, but I can't have the digital values.
I saw in Proview the signal set to 0 or 1, but the arduino didn't react at all.

Proviewset2.jpg


Is that a problem with the representation ?
In my arduino sketch, the coil are represented by a boolean variable.

Darkodo
The administrator has disabled public write access.

Modbus TCP with an arduino MEGA 6 years 4 months ago #9400

  • claes
  • claes's Avatar
  • OFFLINE
  • Platinum Boarder
  • Posts: 3179
  • Thank you received: 502
  • Karma: 133
Hi Darkodo,

For Modbus you should use representation Bit16. Note also that Number starts at 0 so Number 9 actually is the tenth coil.

/Claes
The administrator has disabled public write access.

Modbus TCP with an arduino MEGA 6 years 4 months ago #9402

  • Darkodo
  • Darkodo's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
  • Karma: 0
Hi Claes,

I have changed all the representation in bit16 for my digital values.
I have associated in my sketch the pin number to the same coil number (see below).

What I don't understand are :
  • Why I havn't the indicator 13 that blink every 5 seconds.
  • Why my Di7 and Di6 are influenced by the A1 value (If A1 is near 0, Di6 and Di7 are low, if A1 is about 50-60, Di6 and Di7 are High).
In radzio Modbus simulator, I see the coil 13 change from 0 to 1 every 5 seconds. And I don't see the last point in it.

void loop(){
    Mb.Run();
  
  //########### INPUTS ##########################################################
  
  //Analog inputs 0-1023
  Mb.R[0] = analogRead(A0); //3.3V
  Mb.R[1] = analogRead(A1); //Potard (0-5V)

  //Digital inputs
  Mb.C[6] = digitalRead(6);
  Mb.C[7] = digitalRead(7);

  // Blinking of the coil 13
  currentMillis = millis();
    if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    if (Mb.C[13] == 1) {
      Mb.C[13] = 0;
    } else {
      Mb.C[13] = 1;
    }
  }

  //########### OUTPUTS ##########################################################
  
  //Analog outputs 0-255
  //analogWrite(6, Mb.R[6]); //pin ~6 from Mb.R[6]

  //Digital outputs
  digitalWrite(8, Mb.C[8]); 
  digitalWrite(9, Mb.C[9]); 
}
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 7.580 seconds