RS-485 's Introducción
Lectura previa
Requirements for working with RS-485
RS-485 en M-Duino
RS-485 en Ardbox
ForPara la familia Ardbox tenemos dos subfamilias. En ésta, tenemos que elegir entre RS-485 y RS-232 utilizando los interruptores y puentes como mostramos en la siguiente imagen:
Hardware
The first thing we need to do is to be sure that the industrial Arduino PLC is supplied with 12-24Vdc.
Los pines del PLC que tenemos que utilizar para la comunicación RS-485.
Después de llevar a cabo la configuración de hardware, necesitamos continuar con la configuración de software y saber cómo utilizarla. Para empezar con este proceso, es necesario incluir la librería de RS485.h, la cual está incorporada con nuestras
Boards. Después de esto, en la función de setup, por favor tenga cuidado en realizar la correcta implementación de su comunicación.
#incluir <RS485.h>
Para comprobar la activación de RS-485 solo tienes que utilizar el monitor serie del Arduino IDE usando la oración correcta dentro de la función setup ().
Serial.begin(9600);
También es importante implementar la inicialización en la función setup().
RS485.begin(38400);
IMPORTANTE: COMPRUEBA LA VELOCIDAD DE TRANSMISIÓN DE LOS DISPOSITIVOS PLC-PORTÁTIL Y PLC.
Un ejemplo básico de escritura en el RS-485:
// Include Industrial Shields libraries
#include <RS485.h>
//// IMPORTANT: check switches configuration
////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
// Begin serial port
Serial.begin(9600);
// Begin RS485 port
RS485.begin(38400);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
// Wait bytes in the serial port
if (Serial.available()) {
byte tx = Serial.read();
// Echo the byte to the serial port again
Serial.write(tx);
// And send it to the RS-485 port
RS485.write(tx);
}
}
// And send it to the RS-485 port
RS485.write(tx);
}
}
Un ejemplo básico de lectura del RS-485:
// Include Industrial Shields libraries
#include <RS485.h>
//// IMPORTANT: check switches configuration
////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
// Begin serial port
Serial.begin(9600);
// Begin RS485 port
RS485.begin(38400);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
// Print received byte when available
if (RS485.available()) {
byte rx = RS485.read();
// Hexadecimal representation
Serial.print("HEX: ");
Serial.print(rx, HEX);
// Decimal representation
Serial.print(", DEC: ");
Serial.println(rx, DEC);
}
}
Ejemplo básico de RS-485 Full Duplex:
Antes de iniciar la prueba, conecta A, B (receptores) a los Y, Z (transmisores).
Conceptos básicos sobre RS485 de un PLC industrial