Arduino writing Mewtocol Protocol from PLC’S Panasonic

Thanks to the request of one of my subscribers I have created this tutorial, which will be written in a Panasonic PLC (Nais) of the FPX Series Family. These PLCs are very practical and a high percentage of machines have it as a unit control.

On this occasion I will use an Arduino MEGA 2560 R3 and a converter MAX232 (RS232) to write to DT records of the PLC, since in the network are the manuals of Mewtocol Protocol of panasonic that is used by PLC’S, HMI Screens, Inverters, Servo Drives Among other industrial devices.





The Arduino will communicate through the Toolport, the PLC’s programming port that supports the configuration as Master-slave Mew-Computer-Link and general purpose (Scanners, bar code readers).

The Mewtocol protocol has similarities to Modbus, although the Mewtocol mixes Hexadecimal and Ascii in its frames, with 2 usb serial converters, 1 PLC and a panasonic screen, I take the task of spying physically the plot, understand it and replicate it in Arduino IDE.

Realterm

Realterm

We have only implemented a part of Mewtocol, specifically [WD]write data area frames that write to only write DT, LD, and FL records, write only.

Description of Frame Mewtocol

This frame allows to write in the registers:

  • DT Data Registers
  • LD Link Data Registers
  • FL File Registers

Frame-Mewtocol

Arduino IDE

Funcion addcero

This function concatenates a series of zeros to the left “0000” to an input variable according to the maximum size that output is required and the output returns. Input parameters String (Variable to concatenate) int size or number of zeros maximum to add.

Example: addcero (“10”, 5) returns “10” + “000”.

WD_Mewtocol Function

The main function is WD_Mewtocol that generates and sends the frame mewtocol, this function requires 2 input parameters:

String Register address, example “DT100”.
Int 16 bit value to be written to the “DT100”.

Header

Indicates the start of the frame and indicates the type of record on which to write:

Example:% EE # WD “+ Datacode (D or L or F).

Type of Registration and Address of Registry

Separate the address of the record type and concatenate zeros.

Example: “DT”, “1000”,

Conversion of int value, Hex to Ascii

The value to send requires a process to add to the frame.

  1. We must separate the high and low layer from the value we use the functions highByte and lowByte.
  2. Convert both records from hex to String.
  3. Convert to Shift.
  4. Fill with zeros to the left addcero function.

Full Frame Concatenation

Calculate BCC

BCC (Block Verification Code)
– The BCC is a code that performs horizontal parity error checking to
Improve the reliability of the data being sent.
– The BCC uses an exclusive OR from the header (%) to the final character of the
Text and converts the 8-bit data into a 2-character ASCII code.

BCC-Mewtocol

BCC at Arduino

We take the whole frame, and with the getBytes function we move it to a byte array and the for loop makes an exclusive or with the records and the BCC result we convert it to String and concatenate it to the end of the frame, if the BCC is Wrong the panasonic PLC will discard the frame automatically.

Send Frame

Finally we send the plot through the SerialPort1 and concatenate only CR.

PLC Response Confirmation

After sending the frame, the PLC sends a frame response, indicating if it is correct to send something similar to this “% EE $ WD12” and in frame error “% EE! 4202”.

Full Code

Note: Download code from Github link in bottom:

Components and materials required for testing





Mounting

Arduino_PLC_Panasonic

Conclusions

In this case this frame has been created for a Panasonic PLC but with the skill 2 serial converters and the device in question and the documentation can generate the communication frame for any brand device either PLC or HMI.

Take into account WD_Mewtocol function, it works correctly, but it is still in test, but in case of finding some error.

The function only allows writing in registers. To read registers a new frame must be created that requests data from a specific register and the PLC will send the answer that must be interpreted in arduino.

With this example you will be able to write to any DT registers mainly from the Panasonic Fpx, FP0, FP0R, FP2, FP2SH and FPSigma PLC families among other existing families.

Currently Mew is being created for Arduino or ESP8266.

Easily this example that only writes in DT’S can be modified for writing other registers such as Relay R, and Y Outputs, WR and WY.

References

Downloads

Arduino IDE Code Arduino-Mewtocol-WriteArea

 





You may also like...

1 Response

  1. lokeshvankudoth says:

    I was trying to communicate an digital energy meter with Panasonic AFPXC14R PLC using modbus rtu protocol but i’m unable to read the values into the plc.When i used an open software MODBUSPOLL for reading the values of meter i could read the values.But i’m unable to read values into the plc.The address of the energy meter are 40108,40109. Could you please help me with the programming to read the values into plc..

Leave a Reply