Arduino as modbus master and slave software

Gadiel Sosa's picture

Offline

Joined: Sep 26, 2020

Replies: 3
Arduino as modbus master and slave software
September 26, 2020 - 8:31am

I am not being able to even compile the code, even though is the exact same code posted in here. I have to be honest and say that I don't really have a extense knowledge about arduino and even less about pragramming, I have only done really basic stuff, but this project is really important because it is for college. If any could help me, I would really appreciate it. Thank you.

Debashis Das's picture

Offline

Joined: Dec 02, 2019

Replies: 117

Can you please provide the error code you are getting while compiling?

Gadiel Sosa's picture

Offline

Joined: Sep 26, 2020

Replies: 3

The error is following one (I copied it from the copy error button from arduino):

 

Arduino:1.8.13 (Windows Store 1.8.42.0) (Windows 10), Tarjeta:"Arduino Uno"

El nombre del sketch ha sido modificado.
Los nombres de Sketch deben empezar con una letra o número, seguido por letras,
números, guiones, puntos y subrayados. La longitud máxima es de 63 caracteres.

 

 

 

 

 

 

 

 

 

 

C:\Users\Gadi\Desktop\School\6to Cuatri\arduino\1er prueba\Save_software_original\Save_software_original.ino: In function 'void setup()':

Save_software_original:46:23: error: no matching function for call to 'ModbusMaster::begin(int, HardwareSerial&)'

   node.begin(1, Serial);            //Slave ID as 1

                       ^

In file included from C:\Users\Gadi\Desktop\School\6to Cuatri\arduino\1er prueba\Save_software_original\Save_software_original.ino:1:0:

C:\Users\Gadi\Documents\Arduino\libraries\ModbusMaster-master/ModbusMaster.h:98:10: note: candidate: void ModbusMaster::begin()

     void begin();

          ^~~~~

C:\Users\Gadi\Documents\Arduino\libraries\ModbusMaster-master/ModbusMaster.h:98:10: note:   candidate expects 0 arguments, 2 provided

C:\Users\Gadi\Documents\Arduino\libraries\ModbusMaster-master/ModbusMaster.h:99:10: note: candidate: void ModbusMaster::begin(uint16_t)

     void begin(uint16_t);

          ^~~~~

C:\Users\Gadi\Documents\Arduino\libraries\ModbusMaster-master/ModbusMaster.h:99:10: note:   candidate expects 1 argument, 2 provided

Save_software_original:47:8: error: 'class ModbusMaster' has no member named 'preTransmission'; did you mean 'beginTransmission'?

   node.preTransmission(preTransmission);         //Callback for configuring RS-485 Transreceiver correctly

        ^~~~~~~~~~~~~~~

        beginTransmission

Save_software_original:48:8: error: 'class ModbusMaster' has no member named 'postTransmission'; did you mean 'beginTransmission'?

   node.postTransmission(postTransmission);

        ^~~~~~~~~~~~~~~~

        beginTransmission

C:\Users\Gadi\Desktop\School\6to Cuatri\arduino\1er prueba\Save_software_original\Save_software_original.ino: In function 'void loop()':

C:\Users\Gadi\Desktop\School\6to Cuatri\arduino\1er prueba\Save_software_original\Save_software_original.ino:55:41: warning: large integer implicitly truncated to unsigned type [-Woverflow]

   node.writeSingleRegister(0x40000,value);        //Writes value to 0x40000 holding register

                                         ^

C:\Users\Gadi\Desktop\School\6to Cuatri\arduino\1er prueba\Save_software_original\Save_software_original.ino:65:39: warning: large integer implicitly truncated to unsigned type [-Woverflow]

     node.writeSingleRegister(0x40001,1);               //Writes 1 to 0x40001 holding register

                                       ^

C:\Users\Gadi\Desktop\School\6to Cuatri\arduino\1er prueba\Save_software_original\Save_software_original.ino:71:39: warning: large integer implicitly truncated to unsigned type [-Woverflow]

     node.writeSingleRegister(0x40001,0);              //Writes 0 to 0x40001 holding register

                                       ^

C:\Users\Gadi\Desktop\School\6to Cuatri\arduino\1er prueba\Save_software_original\Save_software_original.ino:77:39: warning: large integer implicitly truncated to unsigned type [-Woverflow]

     node.writeSingleRegister(0x40002,1);              //Writes 1 to 0x40002 holding register

                                       ^

C:\Users\Gadi\Desktop\School\6to Cuatri\arduino\1er prueba\Save_software_original\Save_software_original.ino:83:39: warning: large integer implicitly truncated to unsigned type [-Woverflow]

     node.writeSingleRegister(0x40002,0);                //Writes 0 to 0x40002 holding register

                                       ^

exit status 1

no matching function for call to 'ModbusMaster::begin(int, HardwareSerial&)'

 

Debashis Das's picture

Offline

Joined: Dec 02, 2019

Replies: 117

Hi again, didi you include the Modbus Master library? you can find the download lnk on the artical also, and there is also instructions how to include it. you can find it in the Programming Arduino Uno as MODBUS Master Section.

Gadiel Sosa's picture

Offline

Joined: Sep 26, 2020

Replies: 3

Yes, I did download it and include it. As you can see in the image, I download the zip file.
I watched the video in detail and I sar the very first line on the code, where the ModbusMaster library is included it doesn´t appear yellow as a normal included library, and this line shoel apper yellow as well: "ModbusMaster node; ", but you can see in the video it doesn´t.
I was using the arduino IDE from microsoft store because the one from the arduino page wouldn´t open, but I uninstalled the microsoft one and made the original work and still the same error.
I saw in the video that the Programmersetting from Tools on arduino IDE was set to AVRISP mkII, and I had it set to default so I change it to the already mentioned one, but still had the same error.
So I think I have download the library in the correct way and I'm not dealing with some missing data that the IDE is not founding from the library, so I have no idea of what my issue is.

Gadiel Sosa's picture

Offline

Joined: Sep 26, 2020

Replies: 3

Is there any other way to talk to each other? I replied to your last reply just an hour after you did it, but my reply was sent to review with the page administrators since then.