user16682: I have been trying to make a communication with my industrial drive. All I want to do is read a few values of drive, like current, voltage etc.
For that I am using a library:
I don't understand why it's happening. When the same code I have used before and the sketch was uploaded on the board, very well. 
Here's the code from an example:
#include <SimpleModbusMaster.h>

// led to indicate that a communication error is present
#define connection_error_led 13

//////////////////// Port information ///////////////////
#define baud 9600
#define timeout 1000
#define polling 200 // the scan rate

// If the packets internal retry register matches
// the set retry count then communication is stopped
// on that packet. To re-enable the packet you must
// set the "connection" variable to true.
#define retry_count 10 

// used to toggle the receive/transmit pin on the driver
#define TxEnablePin 2 

// This is the easiest way to create new packets
// Add as many as you want. TOTAL_NO_OF_PACKETS
// is automatically updated.
enum
{
  PACKET1,
  PACKET2,
  // leave this last entry
  TOTAL_NO_OF_PACKETS
};

// Create an array of Packets for modbus_update()
Packet packets[TOTAL_NO_OF_PACKETS];

// Create a packetPointer to access each packet
// individually. This is not required you can access
// the array explicitly. E.g. packets[PACKET1].id = 2;
// This does become tedious though...
packetPointer packet1 = &packets[PACKET1];
packetPointer packet2 = &packets[PACKET2];

// The data from the PLC will be stored
// in the regs array
unsigned int regs[9];

void setup()
{
  // read 3 registers starting at address 0
  packet1->id = 2;
  packet1->function = READ_HOLDING_REGISTERS;
  packet1->address = 0;
  packet1->no_of_registers = 3;
  packet1->register_array = regs;

  // write the 9 registers to the PLC starting at address 3
  packet2->id = 2;
  packet2->function = PRESET_MULTIPLE_REGISTERS;
  packet2->address = 3;
  packet2->no_of_registers = 9;
  packet2->register_array = regs;

  // P.S. the register_array entries above can be different arrays

  // Initialize communication settings etc...
  modbus_configure(baud, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS);

  pinMode(connection_error_led, OUTPUT);
}

void loop()
{
  unsigned int connection_status = modbus_update(packets);

  if (connection_status != TOTAL_NO_OF_PACKETS)
  {
    digitalWrite(connection_error_led, HIGH);
    // You could re-enable the connection by:
    //packets[connection_status].connection = true;
  }
  else
    digitalWrite(connection_error_led, LOW);

  // update the array with the counter data
  regs[3] = packet1->requests;
  regs[4] = packet1->successful_requests;
  regs[5] = packet1->total_errors;
  regs[6] = packet2->requests;
  regs[7] = packet2->successful_requests;
  regs[8] = packet2->total_errors; 
}

Also, here is the error I am receiving upon uploading the sketch
This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino Uno"
SimpleModbusMasterExample:110: error: 'packetPointer' does not name a type
SimpleModbusMasterExample:111: error: 'packetPointer' does not name a type
SimpleModbusMasterExample.ino: In function 'void setup()':
SimpleModbusMasterExample:120: error: 'packet1' was not declared in this scope
SimpleModbusMasterExample:127: error: 'packet2' was not declared in this scope
SimpleModbusMasterExample:136: error: invalid conversion from 'int' to 'HardwareSerial*'
SimpleModbusMasterExample:136: error: invalid conversion from 'Packet*' to 'unsigned char'
C:\Users\xyz\Documents\Arduino\libraries\SimpleModbusMasterV2rev2/SimpleModbusMaster.h:143: error: too few arguments to function 'void modbus_configure(HardwareSerial*, long int, unsigned char, long int, long int, unsigned char, unsigned char, Packet*, unsigned int, unsigned int*)'
SimpleModbusMasterExample:136: error: at this point in file
C:\Users\xyz\Documents\Arduino\libraries\SimpleModbusMasterV2rev2/SimpleModbusMaster.h: In function 'void loop()':
C:\Users\xyz\Documents\Arduino\libraries\SimpleModbusMasterV2rev2/SimpleModbusMaster.h:125: error: too many arguments to function 'void modbus_update()'
SimpleModbusMasterExample:143: error: at this point in file
SimpleModbusMasterExample:143: error: void value not ignored as it ought to be
SimpleModbusMasterExample:155: error: 'packet1' was not declared in this scope
SimpleModbusMasterExample:158: error: 'packet2' was not declared in this scope


user19409: The code you are using is the example provided with the SimpleModbusMaster library found on GitHub: https://github.com/angeloc/simplemodbusng
It appears that the SimpleModbusMaster library isn't installed. This can happen if you install a new version of the Arduino IDE.
To install this library:

Go to the link above and download the zip of the code.
Extract the contents and then copy the folder "SimpleModbusMaster".
Paste the folder into the Arduino/libraries folder located on your computer.  (On my computer it is: C:\Program Files (x86)\Arduino\libraries).
Restart the  Arduino IDE. You can go straight to the example code by selecting: File > Examples > SimpleModbusMaster > SimpleModbusMasterExample

This procedure compiled for me with no errors. 

16682: <p>I have been trying to make a communication with my industrial drive. All I want to do is read a few values of drive, like current, voltage etc.
For that I am using a library:</p>

<p>I don't understand why it's happening. When the same code I have used before and the sketch was uploaded on the board, very well. </p>

<p>Here's the code from an example:</p>

<pre><code>#include &lt;SimpleModbusMaster.h&gt;

// led to indicate that a communication error is present
#define connection_error_led 13

//////////////////// Port information ///////////////////
#define baud 9600
#define timeout 1000
#define polling 200 // the scan rate

// If the packets internal retry register matches
// the set retry count then communication is stopped
// on that packet. To re-enable the packet you must
// set the "connection" variable to true.
#define retry_count 10 

// used to toggle the receive/transmit pin on the driver
#define TxEnablePin 2 

// This is the easiest way to create new packets
// Add as many as you want. TOTAL_NO_OF_PACKETS
// is automatically updated.
enum
{
  PACKET1,
  PACKET2,
  // leave this last entry
  TOTAL_NO_OF_PACKETS
};

// Create an array of Packets for modbus_update()
Packet packets[TOTAL_NO_OF_PACKETS];

// Create a packetPointer to access each packet
// individually. This is not required you can access
// the array explicitly. E.g. packets[PACKET1].id = 2;
// This does become tedious though...
packetPointer packet1 = &amp;packets[PACKET1];
packetPointer packet2 = &amp;packets[PACKET2];

// The data from the PLC will be stored
// in the regs array
unsigned int regs[9];

void setup()
{
  // read 3 registers starting at address 0
  packet1-&gt;id = 2;
  packet1-&gt;function = READ_HOLDING_REGISTERS;
  packet1-&gt;address = 0;
  packet1-&gt;no_of_registers = 3;
  packet1-&gt;register_array = regs;

  // write the 9 registers to the PLC starting at address 3
  packet2-&gt;id = 2;
  packet2-&gt;function = PRESET_MULTIPLE_REGISTERS;
  packet2-&gt;address = 3;
  packet2-&gt;no_of_registers = 9;
  packet2-&gt;register_array = regs;

  // P.S. the register_array entries above can be different arrays

  // Initialize communication settings etc...
  modbus_configure(baud, timeout, polling, retry_count, TxEnablePin, packets, TOTAL_NO_OF_PACKETS);

  pinMode(connection_error_led, OUTPUT);
}

void loop()
{
  unsigned int connection_status = modbus_update(packets);

  if (connection_status != TOTAL_NO_OF_PACKETS)
  {
    digitalWrite(connection_error_led, HIGH);
    // You could re-enable the connection by:
    //packets[connection_status].connection = true;
  }
  else
    digitalWrite(connection_error_led, LOW);

  // update the array with the counter data
  regs[3] = packet1-&gt;requests;
  regs[4] = packet1-&gt;successful_requests;
  regs[5] = packet1-&gt;total_errors;
  regs[6] = packet2-&gt;requests;
  regs[7] = packet2-&gt;successful_requests;
  regs[8] = packet2-&gt;total_errors; 
}
</code></pre>

<p>Also, here is the error I am receiving upon uploading the sketch</p>

<pre><code>This report would have more information with
  "Show verbose output during compilation"
  enabled in File &gt; Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino Uno"
SimpleModbusMasterExample:110: error: 'packetPointer' does not name a type
SimpleModbusMasterExample:111: error: 'packetPointer' does not name a type
SimpleModbusMasterExample.ino: In function 'void setup()':
SimpleModbusMasterExample:120: error: 'packet1' was not declared in this scope
SimpleModbusMasterExample:127: error: 'packet2' was not declared in this scope
SimpleModbusMasterExample:136: error: invalid conversion from 'int' to 'HardwareSerial*'
SimpleModbusMasterExample:136: error: invalid conversion from 'Packet*' to 'unsigned char'
C:\Users\xyz\Documents\Arduino\libraries\SimpleModbusMasterV2rev2/SimpleModbusMaster.h:143: error: too few arguments to function 'void modbus_configure(HardwareSerial*, long int, unsigned char, long int, long int, unsigned char, unsigned char, Packet*, unsigned int, unsigned int*)'
SimpleModbusMasterExample:136: error: at this point in file
C:\Users\xyz\Documents\Arduino\libraries\SimpleModbusMasterV2rev2/SimpleModbusMaster.h: In function 'void loop()':
C:\Users\xyz\Documents\Arduino\libraries\SimpleModbusMasterV2rev2/SimpleModbusMaster.h:125: error: too many arguments to function 'void modbus_update()'
SimpleModbusMasterExample:143: error: at this point in file
SimpleModbusMasterExample:143: error: void value not ignored as it ought to be
SimpleModbusMasterExample:155: error: 'packet1' was not declared in this scope
SimpleModbusMasterExample:158: error: 'packet2' was not declared in this scope
</code></pre>
 19409: <p>The code you are using is the example provided with the SimpleModbusMaster library found on GitHub: <a href="https://github.com/angeloc/simplemodbusng" rel="nofollow">https://github.com/angeloc/simplemodbusng</a></p>

<p>It appears that the SimpleModbusMaster library isn't installed. This can happen if you install a new version of the Arduino IDE.</p>

<p>To install this library:</p>

<ol>
<li>Go to the link above and download the zip of the code.</li>
<li>Extract the contents and then copy the folder "SimpleModbusMaster".</li>
<li>Paste the folder into the Arduino/libraries folder located on your computer.  (On my computer it is: <code>C:\Program Files (x86)\Arduino\libraries</code>).</li>
<li>Restart the  Arduino IDE. You can go straight to the example code by selecting: <code>File &gt; Examples &gt; SimpleModbusMaster &gt; SimpleModbusMasterExample</code></li>
</ol>

<p>This procedure compiled for me with no errors. </p>
