Notes on the documentation

This description is only intended for the use of trained specialists in control and automation engineering who are familiar with the applicable national standards.
It is essential that the following notes and explanations are followed when installing and commissioning these components.

The responsible staff must ensure that the application or use of the products described satisfy all the requirements for safety, including all the relevant laws, regulations, guidelines and standards.

Disclaimer

The documentation has been prepared with care. The products described are, however, constantly under development.
For that reason the documentation is not in every case checked for consistency with performance data, standards or other characteristics.
In the event that it contains technical or editorial errors, we retain the right to make alterations at any time and without warning.
No claims for the modification of products that have already been supplied may be made on the basis of the data, diagrams and descriptions in this documentation.

Trademarks

Beckhoff®, TwinCAT®, EtherCAT®, Safety over EtherCAT®, TwinSAFE® and XFC® are registered trademarks of and licensed by Beckhoff Automation GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owners.

Patent Pending

The TwinCAT Technology is covered, including but not limited to the following patent applications and patents:
EP0851348, US6167425 with corresponding applications or registrations in various other countries.

Copyright

© Beckhoff Automation GmbH & Co. KG, Germany.
The reproduction, distribution and utilization of this document as well as the communication of its contents to others without express authorization are prohibited.
Offenders will be held liable for the payment of damages. All rights reserved in the event of the grant of a patent, utility model or design.


Ams Serial Specifcation: Overview

TwinCAT AMS via RS232 Specification

Introduction

The following description reveals the specification for the AMS protocol via RS232. Thereby it´s possible to realise own implementations of AMS via RS232, e.g for other operating systems than windows.

The communication implements via RS232.
The principle operating sequence of the communication is described in the documentation TwinCAT ADS under 'ADS Introduction'.
The specification of the ADS/AMS protocol is described in the documentation under TwinCAT ADS/AMS - Specification'.


AMS Serial Specification: AMS serial packet

TwinCAT AMS via RS232 Specification

AMS serial frame configuration

Data field | Size in bytes | Value range/Default | Description
Magic Cookie | 2 | 0xA501/0xA501 | Id for detecting an AMS serial frame
Transmitter address | 1 | 0..255 / 0 | Address of the sending participant. This value can always be set to 0 for an RS232 communication, since it is a 1 to 1 connection and hence the participants are unique.
Receiver address | 1 | 0..255 / 0..255 | Receiver’s address. This value can always be set to 0 for an RS232 communication, since it is a 1 to 1 connection and hence the participants are unique.
Fragment number | 1 | 0..255 / 0 | Number of the frame sent. Once the number 255 has been sent, it starts again from 0. The receiver checks this number with an internal counter.
User data length | 1 | 0..255 / 0..255 | The max. length of the AMS packet to be sent is 255. If larger AMS packets are to be sent then they have to be fragmented (not published at the moment).
User data | n |  | The AMS packet to be sent.
CRC | 2 | 0..65535 | Frame checksum

An AMS packet can be transferred via RS232 with the help of an AMS serial frame. The actual AMS packet is in the user data field of the frame. The max. length of the AMS packet is limited to 255 bytes. Therefore the max. size of an AMS serial frame is 263 bytes. The fragment number is compared with an internal counter by the receiver. The frame number is simply accepted and not checked when receiving the first AMS frame or in case a timeout is exceeded. The CRC16 algorithm is used for calculating the checksum.

AMS serial acknowledge frame configuration

If an AMS serial frame has been received and the frame is OK (magic cookie OK, CRC OK, correct fragment number etc.), then the receiver has to send an acknowledge frame, to inform the transmitter that the frame has arrived.

Data field | Size in bytes | Value range/Default | Description
Magic Cookie | 2 | 0x5A01/0x5A01 | Id for detecting an AMS serial acknowledge frame
Transmitter address | 1 | 0..255 / 0 | Dedicated address.
Receiver address | 1 | 0..255 / 0..255 | Address of the participant who sent the original frame.
Fragment number | 1 | 0..255 / 0 | Corresponds to the fragment number transmitted by the transmitter.
User data length | 1 | 0/ 0 | Is always 0, since no user data is sent.
CRC | 2 | 0..65535 | Frame checksum

AMS serial reset frame configuration

In case the transmitter does not receive a valid acknowledgement after multiple transmission, then a reset frame is sent. In this way the receiver is informed that a new communication is running and the receiver then accepts the fragment number during the next AMS-Frame, without carrying out a check.

Data field | Size in bytes | Value range/Default | Description
Magic Cookie | 2 | 0xA503 / 0xA503 | Id for detecting an AMS serial reset frame
Transmitter address | 1 | 0..255 / 0 | Transmitter address.
Receiver address | 1 | 0..255 / 0..255 | Receiver’s address.
Fragment number | 1 | 0/0 | Is always 0.
User data length | 1 | 0/ 0 | Is always 0, since no user data is sent.
CRC | 2 | 0..65535 | Frame checksum


AMS Serial Specification: Serial Communication

TwinCAT AMS via RS232 Specification

Serial communication process

The transmitter carries out the following steps:

  • Application sends AMS command
  • If the AMS command is greater than 255 bytes, an error is sent to the application.
  • An AMS serial frame is allocated and the AMS command is copied into the user data field. The user data length field is set to the size of the AMS command.
  • The frame is sent via the serial interface and acknowledgement is waited for.
  • In case the transmitter does not receive a valid acknowledgement after multiple transmission, then a reset frame is sent.

The receiver carries out the following steps:

  • The serial interface is exported
  • In case data is received:
    • Check the magic cookies
    • Check the CRC
    • Check whether the fragment number agrees with the internal counter. If this is the first received frame, or if no more frames are received after a certain time, then the frame number is simply accepted and not checked.
    • If a valid frame has been received:
      • Send an acknowledgement to the transmitter
      • Forward user data ( AMS telegram) to the application

Since ADS is only a higher-level protocol from AMS, the same is also valid for the sending of ADS-commands. The ADS command is in the data range of the AMS commands, that can then be sent via the serial interface.


AMS Serial Specification: Serial AMS packet

TwinCAT AMS via RS232 Specification

Example

Terminal --> PLC : Request of 2 bytre data

Magic Cookie 01h/A5h
Sender 00h
Empfaenger 00h
Fragmentnummer 06h
Datenlaenge 2Ch
NetID Empfaenger C0h/A8h/64h/AEh/01h/01h
Port Nummer 21h/03h
NetID Sender C0h/A8h/64h/9Ch/01h/01h
Portnummer 01h/80h
Kommando lesen 02h/00h
Status 04h/00h
Anzahl Datenbyte 0Ch/00h/00h/00h/
Fehlercode 00h/00h/00h/00h
InvokeID 07h/00h/00h/00h
Index Gruppe 05h/F0h/00h/00h
Index Offset 04h/00h/00h/9Dh
Anzahl Byte 02h/00h/00h/00h
Checksumme xxh/xxh/

PLC --> Terminal : Acknowledge:

Magic Cookie 01h/5Ah
Sender 00h
Empfaenger 00h
Fragmentnummer 06h
Datenlaenge 00h
Checksumme 67h/5Ah

PLC sends data:

Magic Cookie 01h/A5h
Sender 00h
Empfaenger 00h
Fragmentnummer ECh
Anzahl Daten 2Ah
NetID Empfaenger C0h/A8h/64h/9Ch/01h/01h
Portnummer 01h/80h
NetID Sender C0h/A8h/64h/AEh/01h/01h
Portnummer 21h/03h
Response Lesen 02h/00h
Status 05h/00h
Anzahl Daten 0Ah/00h/00h/00h
Fehlercode 00h/00h/00h/00h
InvokeID 07h/00h/00h/00h
Ergebnis 00h/00h/00h/00h
Anzahl Daten 02h/00h/00h/00h
Daten AFh/27h
Checksumme 04h/A9h/

Terminal --> PLC : Acknowledge: