You are on page 1of 18

Member of Matsushita Group

FP PLC OPEN PROTOCOL MEWTOCOL


The programming port of all the FP PLCs support OPEN MEWTOCOL-COM. This is
very useful when you want to monitor PLC values/bits or to set PLC values or bits via
your COMPUTER. You can use any language such as Basic, C, Pascal, Assembler or
even if other suppliers of PLCs can send ASCII strings, they can talk to our PLCs to
exchange data.
* DDE is also available to monitor or set data on MS Excel, Intouch, Intellution or any software applicable to
DDE.

MEWTOCOL format
Master/Slave communication(Half duplex communication)*4
ASCII strings (One frame is up to 118 characters.)*5

19200 bps (or 9600 bps *1 *3 )


8 bit data length (or 7 bit *2 *3 )
1 stop bit fixed *3
*3
Odd parity fixed
*3
Cr (Carriage Return) fixed
*1 Dip switch configurable, located next to programming port for FP1, FPM,
FP3, FP10SH. For FP0 it is software configurable. The default for FP0 is
9600bps.
*2 Configurable in PLC system register through the programming software
(NPST-GR/FPsoft) using the programming port..
*3 Configurable in PLC system register through the programming software
(NPST-GR/FPsoft) using the secondary port.
*4 If you want the PLC to send some alarm signals or any other signals while
the PLC is a slave use the FP3 CCU module when its one to one
communications or FP3 MEWNET-W. When its one to N communication, it
is duplex communications and has MEWTOCOL-DAT which will allow the
PLC to send some command to a master station (computer typically).
*5 If you need to send or receive more than 118 characters in one frame, use
the delimiter so that you can ask the PLC to keep sending the continuous
data. The other way is that you can keep sending 118 character frame
repeatedly as one frame.

MEWTOCOL Capabilities
Here is a list of what this protocol can do.

Read one bit ON/OFF info. (Input, Output, Timer, Counter, Internal relay)
Read 8 mixed bits ON/OFF info. (Input, Output, Timer, Counter, Internal relay)
Read 16 block bits ON/OFF info. (Input, Output, Internal relay)
Read multiple word unit data value (Data, Timer/Counter preset/elapsed value)
Read PLC status (mode, error, version number etc.)
Set one bit ON/OFF (Output, Internal relay)
Set 8 mixed bits ON/OFF (Output, Internal relay)
Set multiple word unit data value (Data, Timer/Counter preset/elapsed value)

April 2, 2004 page 1 NAiS


Member of Matsushita Group

Applicable ports and Modules


FP1 -------- Programming port (RS422)
Secondary port (RS232C), configurable by PLC through software
FPM ------- Programming port (RS232C)
Secondary port (RS232C), configurable by PLC through software
FP3 -------- Programming port (RS422)
FP10SH -- Programming port (RS232C)
Secondary port (RS232C), configurable by PLC through software
FP3/FP10SH modules --Computer Communication Unit(AFP3462) (RS232C)
Computer Communication Net Unit ( AFP3463) (RS485)
Remote Slave Unit (AFP3741, AFP3743) (RS422 port)
MEWNET-H (AFP3700) (RS232C, and through the network)
MEWNET-W (AFP3720) (Through the network)
MEWNET-P (AFP3710) (Through the network)
Modbus Unit (AFP3492, AFP3413) (RS232C, RS485)
Recommended format
RS232C
19200 bps (or 9600 bps *1*3 )
8 bit data length (or 7 bit *2*3 )
1 stop bit fixed *3
Odd parity fixed *3
Cr (Carriage Return) fixed *3

*1 Dip switch selectable, located next to programming port.


*2 Configurable in PLC system register through the programming
software(NPST-GR) using the programming port.
*3 Configurable in PLC system register through the programming
software(NPST-GR) using the secondary port.

April 2, 2004 page 2 NAiS


Member of Matsushita Group

MEWTOCOL Procedure
Computer sends a COMMAND to PLC as an ASCII string. Then the PLC automatically
returns the RESPONSE based on the COMMAND. PLC mode (RUN/PROG )does not
effect the response. Input information shall be returned as all 0 in PROG mode.

Computer(PC) COMMAND1 COMMAND2 .........


PLC REPSONSE1 RESPONSE2

Maximum length of strings


Maximum length of strings is 118 characters excluding check code+terminater.

COMMAND format

RESPONSE format

RESPONSE format on Error

% This is a fixed character. All the previous uncompleted text


strings are ignored when PLC receives % which means
the beginning of the next command. The completion is
recognized by PLC when PLC receives the terminator.

Station Number Two digit decimal number. Default is 01. Configurable


from 01 to 32 in PLC system register by NPST-GR
software. On the network a unique station number must
be set on each station.

#, $, ! Indicates what the string is: COMMAND(#), RESPONSE($)


or ERROR RESPONSE(!).

Command code Refer to each command section.

Text Data Refer to each command section.

Check code (BCC) MEWTOCOL uses BCC (Block check code) made by
performing XOR operation on each strings from % to the
last character of text data.
You can use two asterisks** as a substitute for BCC. It
is recommend to use two asterisks instead of BCC if you
want to ignore it.
PLC response always has BCC but you can ignore it.

Terminator Cr(Carriage Return) is recommended. Default is CR.


Error code Refer to error code section page.

April 2, 2004 page 3 NAiS


Member of Matsushita Group

READ one bit ON/OFF (input, output, timer, counter, internal relay)
COMMAND %01#RCS X 0000 ** Cr
RESPONSE %01$RC 1 BCC Cr

Command is sent to station 01 and the PLC reads X0 (input0). The


RESPONSE shall be returned to the computer with either 1 (ON) or 0
(OFF).

Bit type X(input), Y(output), T(timer), C(counter), R(internal


relay) X (input) can be read only when PLC is in run
mode or you will receive 0 if it is in program mode.
Element Number Always 4 digits. The range is variable. You will get
error code 60 if element number is out of range.
Element numbering method is the same as it is used in
a ladder program.

ERROR %01! error code BCC Cr

Error code is 2 digits in Hex. Refer to error code section page.

Note: In any case a space can not be contained in the command


code.

April 2, 2004 page 4 NAiS


Member of Matsushita Group

READ up to 8 mixed bits ON/OFF (input, output, timer, counter, internal relay)
COMMAND %01#RCP 4 X0010 T0099 R001A Y0005 ** Cr
RESPONSE %01$RC 1011 BCC Cr

Command to be sent to station number 01 and the PLC reads 4 bits of


information: X10 (input 10), T99 (timer 99), R1A (internal relay 1A),
Y5(output5). The RESPONSE shall be returned to computer with either 1
(ON) or 0 (OFF) respectively. In this case, X10 =ON, T99=OFF, R1A=ON,
Y5=ON. From 1 to 8 different mixed bits can be retrieved by one command.

Bit type X(input), Y(output), T(timer), C(counter), R(internal


relay) X (input) can be read only when PLC is in run
mode or you will receive 0 if its in program mode.
Element Number Always 4 digits. The range is variable. You will get
error code 60 if element number is out of range.
Element numbering method is the same as it is used in
a ladder program.

ERROR %01! error code BCC Cr

Refer to error code section page.

Note: In any case a space can not be contained in the command


code.

April 2, 2004 page 5 NAiS


Member of Matsushita Group

READ Word unit (input, output, internal relay, data, timer/counter set/elapsed value)
COMMAND %01#RCC X0000 0004 ** Cr (to read 5 words from WX0 to WX4)
%01#RCC Y0000 0004 ** Cr (to read 5 words from WY0 to WY4)
%01#RCC R0000 0004 ** Cr (to read 5 words from WR0 to WR4)
%01#RCC L0000 0004 ** Cr (to read 5 words from WL0 to WL4*1)

%01#RD D00000 00010 ** Cr (to read 11 words from DT0 to DT10)


*1
%01#RD F00000 00010 ** Cr (to read 11 words from FL0 to FL10 )
*1
%01#RD L00000 00010 ** Cr (to read 11 words from LD0 to LD10 )
Note: Element number must be expressed by 5 digits for this
command.

%01#RS 0005 0008 ** Cr (to read set values of Timer0 to Timer8. *2)
%01#RK 0005 0008 ** Cr (to read elapsed values of Timer0 to Timer8.*2)
*1
These elements are available for the FP3/FP10.
*2
This command is for both timers and counters. Based on the
element number, it is automatically distinguished as either timer
value or counter value.

RESPONSE %01$RC 3412 7856 BC9A F0DE 1234 BCC Cr


WX0 WX1 WX2 WX3 WX4

This response example is for command %01#RCCX00000004. Since the


command tries to read 5 words the PLC responds with 5 words in Hex in the
order of WX0 to WX4 respectively with the upper byte and the lower byte of
the returned information swapped. You have to swap them again to get the
correct information. Also the maximum number of characters in one frame is
118 including BCC and Cr. Therefore the maximum number of words you
can read at one time is 27 words.

WX0 = 1234 (Hex), 0001 0010 0011 0100(Binary), 4660(Decimal)


WX1 = 5678 (Hex), 0101 0110 0111 1000(Binary), 22136(Decimal)
*3
WX2 = 9ABC(Hex), 1001 1010 1011 1100(Binary), -25923(Decimal)
WX3 = DEF0(Hex), 1101 1110 1111 0000(Binary), -8463(Decimal) *3
WX4 = 3412 (Hex), 0011 0100 0001 0010(Binary), 13330(Decimal)
*3
PLC uses 2s compliment. The MSB is the sign bit.

Word type X(input), Y(output), T(timer), C(counter), R(internal


relay). X (input) can be read only when PLC is in run
mode or you will receive 0 if it is in program mode.
Element Number Always 4 digits. The range is variable. You will get an
error code 60 if element number is out of range.
Element numbering method is the same as it is used in
a ladder program.

ERROR %01! error code BCC Cr

Refer to error code section page.

April 2, 2004 page 6 NAiS


Member of Matsushita Group

Note: In any case a space can not be contained in the command


code.

April 2, 2004 page 7 NAiS


Member of Matsushita Group

READ PLC status


COMMAND %01#RT ** Cr

RESPONSE %01$RC 04 29 03 81 00 0000 BCC Cr


PLC type prog size Error flag
Version Operating Mode Error code

PLC type 2 digits


03 FP3 10K program type
04 FP1 C14, C16
05 FP1 C24, C40
13 FP3 16K program type
Version 2 digits(decimal)
Prog size 2 digits(decimal) 2720 steps expressed 03K.
Operating mode 2 digits (Hex)
bit 7 Remote mode Yes (1), No (0)
bit 6 Message exist Yes (1), No (0)
bit 5 Step execution Yes (1), No (0)
bit 4 Output refresh Yes (1), No (0)
bit 3 Break position Yes (1), No (0)
bit 2 Break mode Yes (1), No (0)
bit 1 Test mode Yes (1), No (0)
bit 0 RUN (1), PROG (0)
Error flag 2 digits (Hex)
bit 7 Operation error Yes (1), No (0)
bit 6 Battery error hold Yes (1), No (0)
bit 5 Battery error real time Yes (1), No (0)
bit 4 I/O verify error Yes (1), No (0)
bit 3 Advanced unit error Yes (1), No (0)
bit 2 N/A
bit 1 Power voltage dip Yes (1), No (0)
bit 0 Diagnostic error Yes (1), No (0)
Error code 4 digits (Hex)
The higher byte and the lower byte are swapped.
Refer to FP PLC programming manual for self
diagnostic error.

ERROR %01! error code BCC Cr

Refer to error code section page.

Note: In any case a space can not be contained in the command


code.

April 2, 2004 page 8 NAiS


Member of Matsushita Group

SET one bit ON/OFF (output, internal relay)


COMMAND %01#WCS Y 0000 1 ** Cr
RESPONSE %01$WC BCC Cr

Command sent to station # 01 and the PLC sets Y0 (output0) to ON (1). The
RESPONSE shall be returned to the computer as an acknowledgment.

Bit type Y(output), R(internal relay)


ON (1), OFF (0)
If you have the same element, in this case Y0, used as
a coil in the PLC program, even though the ON/OFF
condition is set in PLC, the bit memory shall be
overwritten(updated) by the coil in the PLC program as
soon as its executed. Therefore if you want to turn a
bit ON, make sure the same element is not used as a
coil in your program.
Element Number Always 4 digits. The range is variable. You will get
error code 60 if element number is out of range.
Element numbering method is same as it is used in a
ladder program.

ERROR %01! error code BCC Cr


Refer to error code section page.

Note: In any case a space can not be contained in the command


code.

April 2, 2004 page 9 NAiS


Member of Matsushita Group

SET up to 8 mixed bits ON/OFF (output, internal relay)


COMMAND %01#WCP 3 Y 0002 0 R 001F 1 Y 0000 0 ** Cr
RESPONSE %01$WC BCC Cr

Command sent to station # 01 and the PLC sets 3 bits, Y2 OFF(0), R1F
ON(1), Y0 OFF(0). The RESPONSE shall always be returned to the
computer as an acknowledgment.

Bit type 1 to 8 bits can be set


Y(output), R(internal relay)
ON (1), OFF (0)
If you have the same element, in this case Y0, used as
a coil in the PLC program the bit memory shall be
overwritten(updated) by the coil in the PLC program as
soon as its executed. Therefore if you want to turn a
bit ON, make sure the same element is not used as a
coil in your program.
Element Number Always 4 digits. The range is variable. You will get
error code 60 if element number is out of range.
Element numbering method is same as it is used in a
ladder program.

If error %01! error code BCC Cr


Refer to error code section page.

Note: In any case, space can not be contained in the command


code.

April 2, 2004 page 10 NAiS


Member of Matsushita Group

SET Word unit (output, internal relay, data, timer/counter set/elapsed value)
COMMAND %01#WCC R0000 0002 E803 C800 9CFF ** Cr
start address 1st value 3rd value
end address 2nd value
(to set 3 words from WR0 to WR2)

%01#WD D00100 00103 6400 C800 1027 18FC** Cr


(to set 4 words from DT100 to DT103)
Note: Element number must be expressed by 5 digits for this
command.

%01#WS 0000 0001 6400 1400 ** Cr


(to set 2 set values from Timer0 to Timer1. *2)
%01#WK 0005 0007 0000 3200 5000** Cr
(to set 3 elapsed values from Timer5 to Timer7. *2)
*2
This command is for both timers and counters. Based on the
element number, it is automatically distinguished it is either timer
value or counter value. WS command sends information to SV and
WK command sends information to EV.

Start address First element number in range.


End address Last element number in range.
1st value Value for the first element.
2nd value Value for the second element.
3rd value Value for the third element. In this case, this is the value for the
last element.
All values have to be expressed in Hex format and the higher byte and
the lower byte are reversed. 12 34 -> 34 12(hex)

Maximum length of command is 118 characters. Therefore you can set a


maximum of 25 words, for example DT0 to DT24.

If several PLCs are connected over a network and you want to set the
same value into the same elements in all the stations then use station
number FF. You will not get the response but you can save time.

RESPONSE %01$WC BCC Cr


%01$WD BCC Cr
%01$WS BCC Cr
%01$WK BCC Cr

The response shall be returned as an acknowledgment.

In all commands, values should be all expressed in Hex format. The higher
byte and the lower byte of values are all reversed. If you want to send
1234(hex), you have to send 3412.

WC command In this example, WC command sends 1000, 200, -100 *3


(decimal) to respectively WR0, WR1, WR2. Y(output),
R(internal relay) can be used with this command.

April 2, 2004 page 11 NAiS


Member of Matsushita Group

WD command In this example, WD command sends 100, 200, 10000 and


-1000*3 (decimal) to respectively DT100, DT101, DT102
and DT103. DT(data register), FL(file register), LD(link
data) can be used with this command.
WS command In this example, WS command sends 100 and 200
(decimal) to respectively Timer 0 and Timer 1 set values.
This command can write into SV(set value) of timer and
counter.
WK command In this example, WK command sends 0, 50 and 80
(decimal) to respectively Timer 5, Timer 7 and Timer 8
elapsed values. This command can write into EV(set
value) of timer and counter.

*3
PLC uses 2s compliment. The MSB is the sign bit.

Word type WC: Y(output), R(Internal relay), L(link relay)


WD: DT(data register), FL(file register), LD(link data)
WS: SV(set value)
WK: EV(set value)
Y(output), T(timer), C(counter), R(internal relay),
X(input) can be read only when PLC is in run mode or
you will receive 0 if PLC is in program mode.
Element Number Always 4 digits for word number. The range is variable.
You will get error code 60 if element number is out of
range. Element numbering method is same as its
used in a ladder program.

ERROR %01! error code BCC Cr

Refer to error code section page.

Note: In any case a space can not be contained in the command


code.

April 2, 2004 page 12 NAiS


Member of Matsushita Group

Communication update time


Response time is calculated by the formula below:

Response time = (# of command characters + # of response characters) x


(total bit length per character) / baud rate + total idle time + 1 to 2 PLC
scans

(NCOM + NRES) x NBIT


TRES MAX= ---------------------------- + TIDLE + 2 x TSCAN
baud rate

Example
Read data from DT0 to DT9 (10 words).
Command %01#RDD00000 00009 ** Cr = 20 characters
Response %01$RD ???? ???? ???? ???? ???? ???? ???? ???? ???? ???? ** Cr
= 49 characters.
Baud -rate: 19200 bps
Format: 1 start bit, 8 bit data length, 1 stop bit, Odd parity check bit = 11 bits
Scan time: 5.0 ms
Idle time: 0.3 ms between characters.

Response time =
(20+49)charactersx11 bitsx1000/19200bps + 0.3ms x (20 + 49) characters + 5.0 x (1 to 2)scans =
69 x 11 x 1000 /19200 + 0.3 x 69 + 5.0 x (1 to 2) =
759000/19200 + 20.7 + (5 to 10) =
39.5 + 20.7 + (5 to 10) = 65.2 to 70.2ms

Idle time: Idle time is how long it takes to send the next character one after
another.

April 2, 2004 page 13 NAiS


Member of Matsushita Group

BCC calculation
Horizontal parity code to secure the reliability of transmitted data. It is calculated by
performing an XOR operation on each character with the previous result.

Example

%01#RCSX0000 BCC Cr
This is a command to read X0 (input) contact condition.

character ASCII code


% 25 Hex
0 30 Hex 25 XOR 30 => 15
1 31 Hex 15 XOR 31 => 24
# 23 Hex 24 XOR 23 => 07
R 52 Hex :
C 43 Hex :
S 53 Hex :
X 58 Hex :
0 30 Hex :
0 30 Hex :
0 30 Hex :
0 30 Hex :
Result 1D Hex

BCC is, in this case, 1D.

Command should be then.

%01#RCS X0000 1D Cr

Note: In any case a space can not be contained in the command


code.

April 2, 2004 page 14 NAiS


Member of Matsushita Group

ERROR code
An Error code is returned with an exclamation point ! in RESPONSE. The Error code is
expressed in 2 digits in Hexadecimal format.

Basic procedure error


40 BCC error COMMAND strings were not sent from the
computer to PLC correctly or BCC code
attached with a COMMAND sent from the
computer was not correct.

41 Format error COMMAND strings sent from the computer


are missing some characters or some
characters in the COMMAND are not correct.
There might be lower case letters instead of
capital letters or there may not be 5 digits to
describe element start/end address for
RD/WD command.
%01# RDD 0000 0001 **Cr (incorrect)
%01# RDD 00000 00001 **Cr (correct)

%01# rdd 00000 00001 **Cr (incorrect)


%01# RDD 00000 00001 **Cr (correct)

42 NOT support error COMMAND strings you sent from the


computer does not exist. Check that the
COMMAND is spelled correctly. Check all
the characters in Command are written in
capital letters.
%01# RRD 00000 00001 **Cr (incorrect)
%01# RDD 00000 00001 **Cr (correct)

%01# rdD 00000 00001 **Cr (incorrect)


%01# RDD 00000 00001 **Cr (correct)

43 Procedure error Another command was sent from the


computer to the PLC while the PLC was trying
to return the response for the previous
command. Make sure that the program in
the computer waits to send the next command
until either the computer receives a response
for the previous command or it times out (100
to 150 ms recommended).

For more error message refer FP3/FP10SH Computer Communication Unit manual XACG-
M0024.

April 2, 2004 page 15 NAiS


Member of Matsushita Group

Program tips

Faster up date time


Use station number FF to set data for all the PLCs on the CNET
network. You can save time updating data though you will not get an
acknowledgment response. Simply wait 20 ms after you sent the
command to send another command.

For example if there exist a CNET network and an exchange of data


occurs between the computer and the PLCs and this data exchange is
achieved by sending an individual command to each PLC, then this can
virtually take a very long time. If you have 10 stations on the network,
you have to send a command 10 times to read and 10 times to set for a
total of 20 times. Based upon the response time calculation page
assuming the time is 67 ms per command, this becomes 1340 ms (1.34
sec). You can use FF as a station number to send the same data to
all the PLCs on the network. Therefore the total time will be 67 ms x
10 (to read) + 67 ms x 1 (to set) = 737 ms(0.74 sec). In any case, make
sure that the total length of the command to set all of the PLCs is not
longer than 118 characters.

Redundancy
If a PLC on a network is not powered it may corrupt the command from
the computer and you will not receive any response. Make sure your
program sends another command 100 to 150 ms (recommended) after
you sent the previous command. Otherwise even though the other
PLCs are all working, the communication will stop and you will not get
any information from the other working PLCs.

Have your program tell you which station did not respond, this way you can minimize the down
time of your production line.

April 2, 2004 page 16 NAiS


Member of Matsushita Group

Wiring

FP1 programming port to computer


Use AFP15201-US9.
FP1 programming port uses RS422 . Use our smart cable which has a
built in interface circuit in the DB9pin connector.

DB9pin(computer side converted to RS232C )


1. not used 6. not used
2. RD(RX) 7. not used
3. SD(TX) 8. not used
4. not used 9. not used
5. SG

FPM programming port to computer


Use AFC1523-US9.
FP1 programming port uses circular 5pin connector.

DB9pin(computer side RS232C )


1. not used 6. not used
2. RD(RX) 7. not used
3. SD(TX) 8. not used
4. not used 9. not used
5. SG

FP1/M secondary RS232C port (DB9pin) to computer


Use AFP15IBM-US9.
This is standard RS232C. Make sure that pin 5 (CTS) gets the signal
from RTS.
DB9pin(computer side) PLC RS232C DB9pin

April 2, 2004 page 17 NAiS


Member of Matsushita Group

Quick Basic Tip

QBASIC can not use 11 bits. Therefore in order to use o,8,1 format, use the following:

10 OPEN "com1:9600,o,7,1" for randam as #1


20 X%=INP(&H3F8+3)
30 OUT(&H3F8+3), (X% OR 3)

When you want to read volume pot one (DT9040), send the following:

40 A$ = %01#RDD0904009040** + CHR$(13)
50 PRINT #1, A$;

This will take the response from the PLC and puts it into R$.

60 LINE INPUT #1, R$

The response will be, for example, %01$RD6400**+ChR$(13) if the volume pot value is
K100. The value in response is in Hex format and the upper 2 digits and lower 2 digits
are reversed.
K255=Hex 00 64

64 00

To put them into the right order use the following.

70 Receive$ = MID$(R$, 9, 2) + MID$(R$, 7, 2)

To convert from a Hex number to a decimal number, use the following:

80 ReceiveString$= VAL(&H + Receive$)

Now ReceiveString should have decimal number K100.

Now to print on your computer screen


90 LOCATE 10, 10
100 PRINT ReceiveString$

Repeat instructions

110 GOTO 50

April 2, 2004 page 18 NAiS

You might also like