Arduino interface with HMI

Dear All,
I hope you doing fine.

I want to interface the Arduino UNO with Delta HMI through RS232 to communicate in both way either send the binary data to Arduino from HMI and Arduino binary data to HMI. For example, if i press the button from graphical HMI to turn on let's say output # 7 on Arduino then it should turn ON LED and lets say i want to turn on LED or output 7 through hardware push button input #3 to Arduino then i should high the output 7 and same stautus should go to HMI that output 7 is high.

I need your guidance to start this project. I seen many experts here who guiding in very well mananers. expecting the same response from experience people.

Thanks....!

Regards,
King

A bit more detail of what Delta HMI is would probably get you more responses.

I did a quick search out of curiosity and came up with a company called DeltaWW. Presumably you program that panel to generate whatever graphical display you want the user to see.

An UNO only has 1 hardware serial port and that is connected to the on-board serial-USB chip to communicate with the IDE. You can create a software serial port that will support baud rates up to 19200 baud, but you are better off using a MEGA2560 based board that has 4 hardware serial ports (and lots more I/O).

Is this binary data transferred using a known message protocol or are you free to use your own custom data packets?

Hi,

I have delta HMI Model # 103WQ. yes, you searched for the right thing, almost all models have the same mode of communication. it has two options,

  1. RS-232
  2. RS-485

But I prefer to go with RS-232 communication protocol. Actually, i am replacing Arduino with PLC. With PLC programming, i use M0, M1, M2 for input from HMI to PLC and I program accordingly.

But you can say, i can used custom data packet too like below.

Digital Input registers
(10002);
(10003);
Analog input registers
(30001);
(30002);
(30003);

I need your guidance for programming, hardware and communication. I newly shifted from PLC to arduino and i Hope i ll be successful in this transittion.

Regards,

Hi experts,
anyone there to help me please

Thanks in advance.

This is an Arduino support forum. Perhaps your project would get a more helpful response if you were to post it in a forum more suited to PLCs?

I have no idea what this means.

I'm confused. Earlier you indicated you were removing your Arduino and using a PLC instead ... :confused:

Hi,

I am automation engineer and working with PLCs, DCS and SCADA of different brands. I am a good programmer for all these stuff.

Now, I want to use Arduino and interface the HMI (Delta) with it. I think now you are more clear.

Please guide me that which hardware is required to interface HMI with arduino and help me with this way.

I hope you understand and will guide accordingly.

Thanks.....!

Ok, so you are going to use the RS232 interface on your HMI box. You will need an RS232-TTL serial interface module. They look like this:

You need to decide what baud rate your RS232 link will work at. At 19200 baud and below, you should be ok with an UNO and a software serial port. If you want to go higher than 19200 baud, then you should be looking for a MEGA2560 based board that has 4 hardware serial ports.

Thank you for the reply.
Please correct me for the connection between arduino and RS-232 TTL serial interface module.

Arduino UNO RS-232
Rx ---------------> Tx
TX ---------------> Rx
3.3V ---------------> VCC
GND --------------> GND

For HMI, 9600 and 19200 buad rate supported and acceptable.

Can you please sample code to test 1 input from arduino and see output status on HMI and also input from HMI to see output on arduino. ?

I would think that the UNO 5V would go to VCC. I would also advise against trying to use the hardware serial port on 0 & 1. You will need it for loading sketches and serial print as you develop your code.

I would recommend you use AltSoftSerial for your software serial port - I think it uses pins 8 & 9.

You should have a look at the Blink example sketch in the IDE to see how to turn an output pin on and off.

Also search the forums for the "Serial input basics" tutorials as they will show you how to collect incoming serial data.

I don't provide code, but I and others will help you once you have some code for your UNO. I doubt you will get much help with the HMI device here unless somebody has specific experience.

Hi Team,
Please explain this code little bit as i asked query against the comments, i need to understand this in well manners.

secondly, this code is working and i tested with HMI. i need to convert these bits to words. Please guide for this.

#include <ModbusRtu.h>
#define ID   1 

Modbus slave(ID, 0, 0);  // First digit indicates ID number but what is other (ID, 0,0) ?
                        

int8_t state = 0;  // what does it indicates
unsigned long tempus; 

uint16_t au16data[5];  // what does it mean by array 5, is that mean i can use only 5 input outputs?

void setup() {

  configuracionIO();
  
  slave.begin(9600); 
  tempus = millis() + 100;  // what is this purpose.
  digitalWrite(13, HIGH ); 

}

void loop() {
  // poll messages
  // blink led pin on each valid message
  state = slave.poll( au16data, 5 );  what os this poll message?  what does it mean by 5?

// what is this state 4 mean
  if (state > 4) { 
    tempus = millis() + 50; 
    digitalWrite(13, HIGH);
  }
  if (millis() > tempus) 

digitalWrite(13, LOW ); 
    
  MapeoIOmodbus();
} 

void configuracionIO() {
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);
  pinMode(8, INPUT);
  pinMode(9, INPUT);
  pinMode(10, INPUT);
  pinMode(11, INPUT);
  pinMode(12, INPUT);
 // pinMode(13, INPUT);

  digitalWrite(2, LOW );
  digitalWrite(3, LOW );
  digitalWrite(4, LOW );
  digitalWrite(5, LOW );
  
 // analogWrite(10, 0 ); //PWM 0%
  //analogWrite(11, 0 ); //PWM 0%
}

/*********************************************************
Enlaza la tabla de registros con los pines
Bind register table to pins
*********************************************************/
void MapeoIOmodbus() {

  // digital outputs -> au16data[0]
  // Lee los bits de la variable cero y los pone en las salidas digitales
  //Reads the bits of the zero variable and puts them on the digital outputs
  
  digitalWrite( 2, bitRead( au16data[0], 0 )); //Lee el bit 0 de la variable au16data[0] y lo pone en el pin 2 de Arduino
  digitalWrite( 3, bitRead( au16data[0], 1 )); //Read bit 0 from variable au16data[0] and put it on pin 2 of Arduino
  digitalWrite( 4, bitRead( au16data[0], 2 ));
  digitalWrite( 5, bitRead( au16data[0], 3 ));

  
  
  // digital inputs -> au16data[1]
  // Lee las entradas digitales y las guarda en bits de la primera variable del vector
  // (es lo mismo que hacer una máscara)
  bitWrite( au16data[1], 0, digitalRead( 6 )); //Lee el pin 6 del Arduino y lo guarda en el bit 0 de la variable au16data[0]
  bitWrite( au16data[1], 1, digitalRead( 7 )); // Read pin 6 from the Arduino and store it in bit 0 of the variable au16data[0]
  bitWrite( au16data[1], 2, digitalRead( 8 ));
  bitWrite( au16data[1], 3, digitalRead( 9 ));
  bitWrite( au16data[1], 4, digitalRead( 10 )); //Lee el pin 6 del Arduino y lo guarda en el bit 0 de la variable au16data[0]
  bitWrite( au16data[1], 5, digitalRead( 11 )); // Read pin 6 from the Arduino and store it in bit 0 of the variable au16data[0]
  bitWrite( au16data[1], 6, digitalRead( 12));
  //bitWrite( au16data[1], 7, digitalRead( 13));

  // Cambia el valor del PWM
  //analogWrite( 10, au16data[2] ); //El valor de au16data[2] se escribe en la salida de PWM del pin 10 de Arduino. (siendo 0=0% y 255=100%)
  //analogWrite( 11, au16data[3] );

  // Lee las entradaa analógica (ADC)
  au16data[4] = analogRead( 0 ); //El valor analógico leido en el pin A0 se guarda en au16data[4]. (siendo 0=0v y 1023=5v)
}

It helps if you tell us which Modbus library you are using. Is it this one?

If so, a quick look at the source on github would reveal this line, which I think relates to your 1st query:

Modbus(uint8_t u8id, Stream& port, uint8_t u8txenpin =0);

If you scroll further down the source file, you will see these comments:

/**
 * @brief
 * Constructor for a Master/Slave.
 *
 * For hardware serial through USB/RS232C/RS485 set port to Serial, Serial1,
 * Serial2, or Serial3. (Numbered hardware serial ports are only available on
 * some boards.)
 *
 * For software serial through RS232C/RS485 set port to a SoftwareSerial object
 * that you have already constructed.
 *
 * ModbusRtu needs a pin for flow control only for RS485 mode. Pins 0 and 1
 * cannot be used.
 *
 * First call begin() on your serial port, and then start up ModbusRtu by
 * calling start(). You can choose the line speed and other port parameters
 * by passing the appropriate values to the port's begin() function.
 *
 * @param u8id   node address 0=master, 1..247=slave
 * @param port   serial port used
 * @param u8txenpin pin for txen RS-485 (=0 means USB/RS232C mode)
 * @ingroup setup
 */
Modbus::Modbus(uint8_t u8id, Stream& port, uint8_t u8txenpin)

Look further down the source and you will find the details of the poll() function too.

Did you look at the examples - probably the one called RS485_slave?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.