Stop/ start / change frequency VFD OMRON MX2 with Arduino UNO + RS485 Arduino

Hola !,
Hi !,

lo siento, he leído documentación del foro, en google, pero no consigo poner en marcha/parar/cambiar frecuencia de variador OMRON MX2 a través de Arduino UNO y RS485 arduino.
Sorry, I am reading documentation here, google, but I can't stop/start/change frequency VFD OMRON MX2 with Arduino UNO + RS485 Arduino throught Modbus RTU.

El VFD esta correctamente configurado a priori porque consigo comunicarme con el (stop/start/cambio de frecuencia/sentido) a través del programa Modbus Poll.
VFD is OK configured, it seems, becouse i can start/stop/change frequency and direction with Modbus Poll software.

En la foto se puede ver como tengo las conexiones hardware entre arduino uno y rs485 arduino.
You can download the hardware's photo.

El codigo que utilizo es el siguiente:
This is my sketch:

#include <SoftwareSerial.h>

// RS485 connections
// D8 = DI (TX)
// D9 = DE
// D10 = RE
// D11 = RO (RX)

byte buffer[8];

SoftwareSerial myserial(11,8); // RX, TX Indicando RO y DI

void setup() {

Serial.begin(9600);
pinMode(9,OUTPUT);
digitalWrite(9,LOW);
myserial.begin(9600);

//mensaje

buffer[0]=0x01; // esclavo 1 VDF OMRON MX2
buffer[1]=0x05; // funcion 05 escribe en bobina
buffer[2]=0x00; // direccion de la bobina LSB
buffer[3]=0x00; // direccion de la bobina MSB
buffer[4]=0xFF; // valor a escribir en la bobina LSB
buffer[5]=0x00; // valor a escribir en la bobina MSB
buffer[6]=0x8C; // CRC
buffer[7]=0x3A; // CRC
}

void loop() {

delay(5000);

digitalWrite(9,HIGH);
delay(50);
int bytesSent = myserial.write(buffer,8); // poner en marcha VDF
delay(50);
digitalWrite(9,LOW);

Serial.print("Sent ");
Serial.print(bytesSent);
Serial.println(" bytes");

delay(10000);

}

y también he probado con éste:
and other sketch:

/**

  • Modbus master example 1:
  • The purpose of this example is to query an array of data
  • from an external Modbus slave device.
  • The link media can be USB or RS232.
  • Recommended Modbus slave:
  • diagslave Free Modbus Slave Simulator and Test Tool
  • In a Linux box, run
  • "./diagslave /dev/ttyUSB0 -b 19200 -d 8 -s 1 -p none -m rtu -a 1"
  • This is:
  • serial port /dev/ttyUSB0 at 19200 baud 8N1
  • RTU mode and address @1
    */

#include <ModbusRtu.h>

// data array for modbus network sharing
uint16_t au16data[16];
uint8_t u8state;

/**

  • Modbus object declaration
  • u8id : node id = 0 for master, = 1..247 for slave
  • u8serno : serial port (use 0 for Serial)
  • u8txenpin : 0 for RS-232 and USB-FTDI
  • or any pin number > 1 for RS-485
    */
    Modbus master(0,0,9); // this is master and RS-232 or USB-FTDI, PIN 9 PARA INDICAR QUE TRASMITO

/**

  • This is an structe which contains a query to an slave device
    */
    modbus_t telegram;

unsigned long u32wait;

void setup() {
master.begin( 9600 ); // baud-rate at 19200
master.setTimeOut( 2000 ); // if there is no answer in 2000 ms, roll over
u32wait = millis() + 1000;
u8state = 0;
}

void loop() {
switch( u8state ) {
case 0:
if (millis() > u32wait) u8state++; // wait state
break;
case 1:
telegram.u8id = 1; // slave address
telegram.u8fct = 5; // function code (this one is registers read)
telegram.u16RegAdd = 0; // start address in slave
telegram.u16CoilsNo = 2; // number of elements (coils or registers) to read
//telegram.au16reg = au16data; // pointer to a memory array in the Arduino

// PARA EL VARIADOR OMRON MX1: MODBUS RTU 01 05 00 00 FF 00 -> START
// 01 -> SLAVE (VFD OMRON)
// 05 -> WRITE COIL
// 00 00 -> ADDRESS COIL
// FF 00 -> VALUES TO WRITE IN COIL FOR RUN

telegram.au16reg[0] = 0;
telegram.au16reg[1] = 0;
telegram.au16reg[2] = 0;
telegram.au16reg[3] = 0;
telegram.au16reg[4] = 0;
telegram.au16reg[5] = 0;
telegram.au16reg[6] = 0;
telegram.au16reg[7] = 0;

telegram.au16reg[8] = 1;
telegram.au16reg[9] = 1;
telegram.au16reg[10] = 1;
telegram.au16reg[11] = 1;
telegram.au16reg[12] = 1;
telegram.au16reg[13] = 1;
telegram.au16reg[14] = 1;
telegram.au16reg[15] = 1;

master.query( telegram ); // send query (only once)
delay(3500);

telegram.u8id = 1; // slave address
telegram.u8fct = 6; // function code (this one is registers read)
telegram.u16RegAdd = 1; // start address in slave
telegram.u16CoilsNo = 4; // number of elements (coils or registers) to read
//telegram.au16reg = au16data; // pointer to a memory array in the Arduino
//telegram.au16reg = 0000000111110100;

// PARA EL VARIADOR OMRON MX1: MODBUS RTU 01 06 00 01 01 F4 -> CHANGE FQ
// 01 -> SLAVE (VFD OMRON)
// 06 -> WRITE IN REGISTE
// 00 01 -> REGISTER ADDRESS
// 01 F4 -> VALUE TO WRITE IN THE REGISTER TO CHANGE THE MOTOR FREQUENCY

telegram.au16reg[0] = 0;
telegram.au16reg[1] = 0;
telegram.au16reg[2] = 0;
telegram.au16reg[3] = 0;
telegram.au16reg[4] = 0;
telegram.au16reg[5] = 0;
telegram.au16reg[6] = 0;
telegram.au16reg[7] = 1;

telegram.au16reg[8] = 1;
telegram.au16reg[9] = 1;
telegram.au16reg[10] = 1;
telegram.au16reg[11] = 1;
telegram.au16reg[12] = 0;
telegram.au16reg[13] = 1;
telegram.au16reg[14] = 0;
telegram.au16reg[15] = 0;

master.query( telegram ); // send query (only once)
delay(3500);
telegram.u8id = 1; // slave address
telegram.u8fct = 5; // function code (this one is registers read)
telegram.u16RegAdd = 1; // start address in slave
telegram.u16CoilsNo = 2; // number of elements (coils or registers) to read
//telegram.au16reg = au16data; // pointer to a memory array in the Arduino

// PARA EL VARIADOR OMRON MX1: MODBUS RTU 01 05 00 00 00 00 -> STOP
// 01 -> SLAVE (VFD OMRON)
// 05 -> WRITE COIL
// 00 00 -> COIL'S ADDRESS
// 00 00 -> VALUE TO WRITE FOR STOP

telegram.au16reg[0] = 0;
telegram.au16reg[1] = 0;
telegram.au16reg[2] = 0;
telegram.au16reg[3] = 0;
telegram.au16reg[4] = 0;
telegram.au16reg[5] = 0;
telegram.au16reg[6] = 0;
telegram.au16reg[7] = 0;
telegram.au16reg[8] = 0;
telegram.au16reg[9] = 0;
telegram.au16reg[10] = 0;
telegram.au16reg[11] = 0;
telegram.au16reg[12] = 0;
telegram.au16reg[13] = 0;
telegram.au16reg[14] = 0;
telegram.au16reg[15] = 0;
master.query( telegram ); // send query (only once)
delay(3500);
u8state++;
break;
case 2:
master.poll(); // check incoming messages
if (master.getState() == COM_IDLE) {
u8state = 0;
u32wait = millis() + 100;
}
break;
}
}

Muchas gracias.