hola !,
hi !,
lo siento, leído documentación del foro, en google, pero no consigo poner en marcha/parar/cambiar frecuencia de variador omron mx2 través de arduino uno y rs485 arduino.
sorry, reading documentation here, google, can't stop/start/change frequency vfd omron mx2 arduino uno + rs485 arduino throught modbus rtu.
el vfd esta correctamente configurado priori porque consigo comunicarme con el (stop/start/cambio de frecuencia/sentido) través del programa modbus poll.
vfd ok configured, seems, becouse can start/stop/change frequency , direction modbus poll software.
en la foto se puede ver como tengo las conexiones hardware entre arduino uno y rs485 arduino.
can download hardware's photo.
el codigo que utilizo es el siguiente:
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 escribir en la bobina lsb
buffer[5]=0x00; // valor 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 probado con éste:
, other sketch:
/**
* modbus master example 1:
* purpose of example query array of data
* external modbus slave device.
* link media can usb or rs232.
*
* recommended modbus slave:
* diagslave http://www.modbusdriver.com/diagslave.html
*
* in linux box, run
* "./diagslave /dev/ttyusb0 -b 19200 -d 8 -s 1 -p none -m rtu -a 1"
* is:
* serial port /dev/ttyusb0 @ 19200 baud 8n1
* rtu mode , address @1
*/
#include <modbusrtu.h>
// data array modbus network sharing
uint16_t au16data[16];
uint8_t u8state;
/**
* modbus object declaration
* u8id : node id = 0 master, = 1..247 slave
* u8serno : serial port (use 0 serial)
* u8txenpin : 0 rs-232 , usb-ftdi
* or pin number > 1 rs-485
*/
modbus master(0,0,9); // master , rs-232 or usb-ftdi, pin 9 para indicar que trasmito
/**
* structe contains query slave device
*/
modbus_t telegram;
unsigned long u32wait;
void setup() {
master.begin( 9600 ); // baud-rate @ 19200
master.settimeout( 2000 ); // if there 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 1 registers read)
telegram.u16regadd = 0; // start address in slave
telegram.u16coilsno = 2; // number of elements (coils or registers) read
//telegram.au16reg = au16data; // pointer memory array in 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 write in coil 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 1 registers read)
telegram.u16regadd = 1; // start address in slave
telegram.u16coilsno = 4; // number of elements (coils or registers) read
//telegram.au16reg = au16data; // pointer memory array in 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 write in register change 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 1 registers read)
telegram.u16regadd = 1; // start address in slave
telegram.u16coilsno = 2; // number of elements (coils or registers) read
//telegram.au16reg = au16data; // pointer memory array in 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 write 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.
hi !,
lo siento, leído documentación del foro, en google, pero no consigo poner en marcha/parar/cambiar frecuencia de variador omron mx2 través de arduino uno y rs485 arduino.
sorry, reading documentation here, google, can't stop/start/change frequency vfd omron mx2 arduino uno + rs485 arduino throught modbus rtu.
el vfd esta correctamente configurado priori porque consigo comunicarme con el (stop/start/cambio de frecuencia/sentido) través del programa modbus poll.
vfd ok configured, seems, becouse can start/stop/change frequency , direction modbus poll software.
en la foto se puede ver como tengo las conexiones hardware entre arduino uno y rs485 arduino.
can download hardware's photo.
el codigo que utilizo es el siguiente:
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 escribir en la bobina lsb
buffer[5]=0x00; // valor 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 probado con éste:
, other sketch:
/**
* modbus master example 1:
* purpose of example query array of data
* external modbus slave device.
* link media can usb or rs232.
*
* recommended modbus slave:
* diagslave http://www.modbusdriver.com/diagslave.html
*
* in linux box, run
* "./diagslave /dev/ttyusb0 -b 19200 -d 8 -s 1 -p none -m rtu -a 1"
* is:
* serial port /dev/ttyusb0 @ 19200 baud 8n1
* rtu mode , address @1
*/
#include <modbusrtu.h>
// data array modbus network sharing
uint16_t au16data[16];
uint8_t u8state;
/**
* modbus object declaration
* u8id : node id = 0 master, = 1..247 slave
* u8serno : serial port (use 0 serial)
* u8txenpin : 0 rs-232 , usb-ftdi
* or pin number > 1 rs-485
*/
modbus master(0,0,9); // master , rs-232 or usb-ftdi, pin 9 para indicar que trasmito
/**
* structe contains query slave device
*/
modbus_t telegram;
unsigned long u32wait;
void setup() {
master.begin( 9600 ); // baud-rate @ 19200
master.settimeout( 2000 ); // if there 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 1 registers read)
telegram.u16regadd = 0; // start address in slave
telegram.u16coilsno = 2; // number of elements (coils or registers) read
//telegram.au16reg = au16data; // pointer memory array in 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 write in coil 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 1 registers read)
telegram.u16regadd = 1; // start address in slave
telegram.u16coilsno = 4; // number of elements (coils or registers) read
//telegram.au16reg = au16data; // pointer memory array in 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 write in register change 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 1 registers read)
telegram.u16regadd = 1; // start address in slave
telegram.u16coilsno = 2; // number of elements (coils or registers) read
//telegram.au16reg = au16data; // pointer memory array in 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 write 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.
Arduino Forum > International > Español (Moderators: surbyte, Hector_A) > Stop/ start / change frequency VFD OMRON MX2 with Arduino UNO + RS485 Arduino
arduino
Comments
Post a Comment