Hi to everyone i don't know if i need a presentation cause I' ve already done in the italian forum.
So, my problem is that. Now i'm in Stage in portugal and my first job is to communicate between arduino and Modbus.
I've write this code and i think is it true, but if i use a random adress the code print ascii code, if i try the adress of the modbus the modbus print to me a lot of "à".
// Include these libraries for using the RS-485 and Modbus functions
#include <ModbusMaster485.h>
#include <RS485.h>
#include <SPI.h>
// Instantiate ModbusMaster object as slave ID 1
ModbusMaster485 node(10);
// Define one addres for reading
#define address 3204
// Define the number of bytes to read
#define bytesQty 2
void setup() /*the problem is in void setup*/
{
// Power on the USB for viewing data in the serial monitor
Serial.begin(11520);
delay(100);
// Initialize Modbus communication baud rate
node.begin(19200);
// Print start message
Serial.println ("Modbus communication over RS-485");
delay(100);
}
void loop()
{
// This variable will store the result of the communication
// result = 0 : no errors
// result = 1 : error occurred
int result = node.readHoldingRegisters(address, bytesQty);
if (result != 0) {
// If no response from the slave, print an error message
Serial.println("Communication error");
delay(1000);
}
else {
// If all OK
Serial.println("Read value : ");
// Print the read data from the slave
Serial.println(node.getResponseBuffer(0));
delay(1000);
}
Serial.println("\n");
delay(2000);
// Clear the response buffer
node.clearResponseBuffer();
}
Ok, i need to connect my arduino uno to a PM3200 of schneider. The script for what i understand of arduino (i'm not an expert). Is it compilated without any error, the only information at the end are the classic:
"Lo sketch usa 3.496 byte (10%) dello spazio disponibile per i programmi. Il massimo è 32.256 byte.
Le variabili globali usano 533 byte (26%) di memoria dinamica, lasciando altri 1.515 byte liberi per le variabili locali. Il massimo è 2.048 byte."
I've taken the information about the function adress from the fact sheet and the information for the adress of the device in the device menù. So i think that's adress are correct.
But i really don't know why the script doesn't work in the device monitor