Dado (Customer) asked a question.

Please, by any chance anyone knows if there is an error reference guide for The MODBUS/ETH?

Please,

The MODBUS/ETH communication is working but I keep getting a warning message, which I don understand the meaning. Is by any chance any reference guide for the error/warnings?

Thank you

Dado


  • ADC Community_02 (Automationdirect.com)

    The warning you are referencing is the Base Sync Timeout??

  • Dado (Customer)

    Yes, you are correct.

    I believe you couldn't open the attachment. I attaching the text below.

    Please, this better explains my question.

     

    09:20:03.092 -> Modbus TCP Server and Module I/O Example

    09:20:06.493 -> Slot 1: P1-16ND3

    09:20:06.493 -> Slot 2: P1-15TD2

    09:20:06.493 -> Slot 3: P1-08ADL-2

    09:20:06.493 -> Slot 4: P1-08DAL-1

    09:20:06.493 -> 

    09:20:07.056 -> Done with setup()

    09:20:11.650 -> Client Accept:10.11.0.176

    12:57:46.081 -> Base Sync Timeout

    14:30:59.532 -> Base Sync Timeout

    17:23:03.255 -> Base Sync Timeout

    17:23:24.258 -> Base Sync Timeout

    17:41:27.486 -> Base Sync Timeout

    18:17:58.687 -> Base Sync Timeout

    19:14:39.339 -> Base Sync Timeout

    21:53:46.043 -> Base Sync Timeout

    21:55:38.369 -> Base Sync Timeout

    21:55:38.557 -> Base Sync Timeout

    00:03:14.008 -> Base Sync Timeout

     

    Expand Post
  • Dado (Customer)

    Thank very much

    I am testing it, if works OK, otherwise i will let you know.

    Again

    Thanks

  • Dado (Customer)

    dnjGa,

    I still get the warning message.

     

    16:06:20.224 -> Modbus TCP Server and Module I/O Example

    16:06:23.614 -> Slot 1: P1-16ND3

    16:06:23.614 -> Slot 2: P1-15TD2

    16:06:23.614 -> Slot 3: P1-08ADL-2

    16:06:23.614 -> Slot 4: P1-08DAL-1

    16:06:23.614 -> 

    16:06:24.880 -> Done with setup()

    16:06:24.880 -> P1 Base controller is Active? (1 YES): 1

    16:06:24.880 -> Analog Input 24V Present (0 is OK): 0

    16:06:24.880 -> Analog Output 24V Present (0 is OK): 0

    16:06:27.474 -> Client Accept: 10.11.0.176

    16:06:42.476 -> Base Sync Timeout

     

     

    Thanks

    Dado

    Expand Post
  • FACTS_AdamC (AutomationDirect)

    Can you paste your code? If so please you the code insertion button (< / > below)

    Do you have 24V and USB plugged in at the same time? Is your 24V unstable?

     

    Thanks

    Adam

  • Dado (Customer)

    Adam,

    Thanks for helping.

    • I have used two different 24V PS, same issue. I even got a P1-01AC to replace the Rhino.
    • You can see my base configuration in my code.
    • I have the USB and the 24V at the same time.
    • I also I notice that the Ethernet/Modbus communication start only if after download the program I start the serial communication to verify that the system is working.
    • If I turn the power OFF and then ON the Ethernet/Modbus communication doesn't start.

     

    Would you recommend a Linear PS instead of a switching PS?

     

    Thank you

    Aldo Grossi (Dado)

     

    1. /*
    2.  
    3. Ethernet Modbus TCP Server single connection with P1 IO Modules for use with the P1AM-ETH module.
    4.  
    5. P1AM BASE Configuration:
    6.  
    7. P1-01AC
    8. P1AM-GPIO
    9. P1AM-ETH mac:(0x60, 0x52, 0xD0, 0x06, 0x69, 0xBE), IP: (10,11,0,177)
    10. CPU PIAM-100
    11. P1-16ND3
    12. P1-15TD2
    13. P1-08ADL-2
    14. P1-08DAL-1
    15.  
    16. EA9-RHMI Ethernet built-in port mac: (00:DO:7C:15:24:E6)
    17. Static IP: (10.11.00.176)
    18. Subnet Mask: (255.255.255.0)
    19. Default Gateway:
    20. Preferred DNS Server: (10.11.0.177) OPTIONAL
    21.  
    22. "P1.isBaseActive" functions how the Base Controller can be monitored for a loss of 24V power.
    23.  
    24. */
    25.  
    26. #include <SPI.h>
    27. #include <Ethernet.h>
    28. #include <P1AM.h>
    29. #include <ArduinoRS485.h> // ArduinoModbus depends on the ArduinoRS485 library
    30. #include <ArduinoModbus.h>
    31.  
    32. byte mac[] = { //Use the �Reserved MAC� printed on the right-side label of your P1AM-ETH.
    33.  
    34. 0x60, 0x52, 0xD0, 0x06, 0x69, 0xBE
    35.  
    36. };
    37.  
    38. IPAddress ip(10, 11, 0, 177); //IP Address of the P1AM-ETH module.
    39. boolean MB_C[16]; //Modbus Coil Bits
    40. boolean MB_I[16]; //Modbus Input Bits
    41. int MB_HR[16]; //Modbus Holding Registers
    42. int MB_IR[16]; //Modbus Input Registers
    43. int Slot1_Inputs;
    44. bool heatON=false;
    45. bool coolON=false;
    46. int BTUIn;
    47. int BTULoss;
    48. int TempOuth=819;
    49. int TempOutc=4095;
    50. int period = 10000;
    51. unsigned long time_now = 0;
    52. EthernetServer server(502); //Standard Modbus Port is 502
    53. EthernetClient client;
    54. ModbusTCPServer modbusTCPServer;
    55.  
    56. void setup() {
    57.  
    58. Serial.begin(115200);
    59. while (!Serial){}// wait for serial port to connect.
    60. Serial.println("Modbus TCP Server and Module I/O Example");
    61. while (!P1.init()){} ; //Wait for P1 Modules to Sign on
    62. Ethernet.begin(mac, ip);
    63. server.begin(); // start the server to begin listening
    64.  
    65. if (!modbusTCPServer.begin()) { // start the Modbus TCP server
    66.  
    67. Serial.println("Failed to start Modbus TCP Server!");
    68. while (1); //If it can't be started no need to contine, stay here forever.
    69.  
    70. }
    71.  
    72.  
    73. modbusTCPServer.configureCoils(0x00, 16); //Coils
    74. modbusTCPServer.configureDiscreteInputs(0x00, 16); //Discrete Inputs
    75. modbusTCPServer.configureHoldingRegisters(0x00, 16); //Holding Register Words
    76. modbusTCPServer.configureInputRegisters(0x00, 16); //Input Register Words
    77.  
    78.  
    79. Serial.println("Done with setup()");
    80. Serial.print("P1 Base controller is Active? (1 YES): ");
    81. Serial.println(P1.isBaseActive());
    82. Serial.print("Analog Input 24V Present (0 is OK): ");
    83. Serial.println(P1.check24V(3)); // If returns 0 is OK
    84. Serial.print("Analog Output 24V Present (0 is OK): ");
    85. Serial.println(P1.check24V(4)); // If returns 0 is OK
    86.  
    87. }
    88.  
    89. void loop() {
    90.  
    91. EthernetClient newClient = server.accept(); //listen for incoming clients
    92.  
    93. if (newClient) { //newest connection is always accepted
    94.  
    95. client = newClient;
    96. Serial.print("Client Accept: "); //a new client connected
    97. Serial.println(client.remoteIP());
    98.  
    99. }
    100.  
    101. //if(client.available()){ //if data is available
    102.  
    103. modbusTCPServer.accept(client); //accept that data
    104. modbusTCPServer.poll(); //service any Modbus TCP requests, while client connected
    105.  
    106. // }
    107.  
    108. /* Because I have one client and is always connected I don't need to stop it
    109.  
    110. if(client && !client.connected()){ //Stop any clients which are disconnected
    111. client.stop();
    112.  
    113. Serial.println("Client Stopped"); //the client disconnected
    114.  
    115. }*/
    116.  
    117.  
    118. if(P1.isBaseActive() == false){
    119.  
    120. Serial.println("Re-init() the base modules.");
    121. delay(10);
    122. while (!P1.init()){
    123. Serial.println("Waiting for 24V");
    124. delay(100);
    125.  
    126. }
    127.  
    128. }
    129.  
    130. //Read from P1-16ND3 Digital Input Module and then write into Modbus memory
    131.  
    132. int Slot1_Inputs = P1.readDiscrete(1,0); //Read from P1-16ND3 Input Module
    133. for (int i=0;i<16;i++){
    134.  
    135. MB_I[i]=Slot1_Inputs&(1<<i);
    136.  
    137. }
    138.  
    139. updateInputs(); //Write current state of the Modbus Inputs into MB_I[]
    140.  
    141. //Read from P1-08ADL-2 Analog Input Modules and then write into Modbus memory
    142.  
    143. for(int i=0;i<8;i++){
    144. int inputCounts = P1.readAnalog(3,i+1);
    145.  
    146. MB_IR[i]=inputCounts;
    147.  
    148. }
    149.  
    150. updateInputRegisters(); //Write current state of the Modbus Inputs into MB_IR[]
    151.  
    152. //Read current state of the Modbus Coils into MB_C[] and write to P1-15TD2 Digital Output Module.
    153.  
    154. updateCoils();
    155.  
    156. for (int i=0;i<15;i++){
    157.  
    158. P1.writeDiscrete(MB_C[i],2,i+1);//Data,Slot,Channel ... Channel is one-based.
    159.  
    160. }
    161.  
    162. //Read from P1-08DAL-1 Analog Output Modules and then write into Modbus memory
    163.  
    164. for(int i=0;i<8;i++){
    165.  
    166. updateHoldingRegisters(); //Read current state of the Modbus Registers into MB_HR[]
    167. modbusTCPServer.holdingRegisterWrite(i,MB_HR[i]);
    168.  
    169. P1.writeAnalog(MB_HR[i],4,i+1);
    170.  
    171. }
    172.  
    173. // Temperature simulation
    174.  
    175. if(millis() >= time_now + period){
    176.  
    177. time_now += period;
    178.  
    179. heatON=P1.readDiscrete(1,9);
    180. if(heatON==true){ // Temperature simulation for heating
    181. BTUIn=P1.readAnalog(3,1);
    182. BTULoss=P1.readAnalog(3,4);
    183. if(TempOuth<=4095){
    184. TempOuth=TempOuth+(BTUIn-BTULoss)*85/6553;
    185. P1.writeAnalog(TempOuth,4,1);
    186. Serial.println(TempOuth);
    187.  
    188. }
    189.  
    190. TempOutc=4095;
    191.  
    192. }
    193.  
    194. coolON=P1.readDiscrete(1,10);
    195. if(coolON==true){ // Temperature simulation for cooling
    196. BTUIn=P1.readAnalog(3,2);
    197. BTULoss=P1.readAnalog(3,4);
    198. if(TempOutc>=819){
    199. TempOutc=TempOutc-(BTUIn-BTULoss)*85/6553;
    200. P1.writeAnalog(TempOutc,4,2);
    201. Serial.println(TempOutc);
    202.  
    203. }
    204.  
    205. TempOuth=819;
    206.  
    207. }
    208.  
    209. }
    210.  
    211. }
    212.  
    213. void updateCoils() {//Read the Coil bits from the Modbus Library
    214.  
    215. for (int i=0;i<15;i++){
    216.  
    217. MB_C[i] = modbusTCPServer.coilRead(i);
    218.  
    219. }
    220.  
    221. }
    222.  
    223. void updateInputs() { //Write the Input bits to the Modbus Library
    224.  
    225. for (int i=0;i<16;i++){
    226. modbusTCPServer.discreteInputWrite(i,MB_I[i]);
    227.  
    228. }
    229.  
    230. }
    231.  
    232. void updateHoldingRegisters() {//Read the Holding Register words from the Modbus Library
    233.  
    234. for (int i=0;i<8;i++){
    235.  
    236. MB_HR[i] = modbusTCPServer.holdingRegisterRead(i);
    237.  
    238. }
    239.  
    240. }
    241.  
    242. void updateInputRegisters() { //Write the Input Registers to the Modbus Library
    243.  
    244. for (int i=0;i<8;i++){
    245.  
    246. modbusTCPServer.inputRegisterWrite(i,MB_IR[i]);
    247.  
    248. }
    249.  
    250. }

     

    Expand Post
    • FACTS_AdamC (AutomationDirect)

      Hey Aldo,

       

      Thank you for the additional info. I do not believe it's an issue with your power supply.

       

      A couple things:

      • Could you add this before line 61 (your P1.init() statement). It will set the SPI CS for the ETH before any SPI transaction actually begin.
      1. Ethernet.init(5);
      • At line 59 you have the below statement. This means for code to progress, you have to open a serial connection to the P1AM-100. If you are using the built-in serial monitor in Arduino, you'll have to close that window and re-open it if your device is power cycled or otherwise resets. Reprogramming a board with it open automatically restarts the connection, which may explain the behaviour you're seeing.
      1. while (!Serial){}// wait for serial port to connect.

      Let me know if that helps.

       

      Thanks

      Adam

       

      Expand Post
  • FACTS_KevinC (AutomationDirect)

    Line 59 - while (!Serial){}// wait for serial port to connect - tells the P1AM to wait for the serial monitor to connect before continuing with code execution. You should remove that line if you don't want to require the serial monitor to be open.

     

    Are all your modules signing on correctly? After getting the base timeout error, do you ever see the base re-init?

  • Dado (Customer)

    Adam/Kevin,

     

    Thank you again for your prompt help.

     

    Both Correction were made line 59 and 61.

    Module are signing in correctly and no Reinit after timeout error.

    System start without having the PC connected to the USB after power OFF-ON.

     

    16:22:57.214 -> Slot 1: P1-16ND3

    16:22:57.214 -> Slot 2: P1-15TD2

    16:22:57.214 -> Slot 3: P1-08ADL-2

    16:22:57.214 -> Slot 4: P1-08DAL-1

    16:22:57.214 -> 

    16:22:57.776 -> Done with setup()

    16:22:57.776 -> P1 Base controller is Active? (1 YES): 1

    16:22:57.823 -> Analog Input 24V Present (0 is OK): 0

    16:22:57.823 -> Analog Output 24V Present (0 is OK): 0

    16:23:02.793 -> Client Accept: 10.11.0.176

     

     

    Dado

    Expand Post
10 of 16