Welcome to the Beckhoff Knowledge Base

The Knowledge Base will help you to find information about our products.
It has been created from inquiries sent to our support department, and thus contains the most frequently asked questions (FAQ).

The structure of the KB:

The Knowledge Base is divided into the TwinCAT region (software), the hardware region and the application notes region.
You reach the individual pages from the summary of the particular section.

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.
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.

You will also find links in the Beckhoff Automation GmbH Knowledge Base to web pages, some of which are not maintained by Beckhoff Automation GmbH but by third parties. No liability can be accepted by Beckhoff Automation GmbH for the content of these web pages.


TwinCAT

Outline of the entries in TwinCAT
Com
Communication ADS DLL
ADS OCX
Communication with External devices
NC
NC I
PLC
System
System Manager

back to Overview


TwinCAT COM

Date | Article ID. | Article Selection
11/13/2000 | 00110301 | KL6xxx Example Program

back to the TwinCAT Overview


KL6xxx example program

Date: 11/13/2000 Article ID: 00110301

Question:

How do I use the KL6001 terminal under Profibus?

Answer:

General: The example FBs demonstrate the use of the KL6001 terminal under Profibus.

Test set up:

Test software:

Two example blocks have been written, demonstrating the handshaking involved in sending or receiving characters. The characters to be sent/received are stored in two data blocks. A PC with a terminal program (e.g. Term90) is used for check.

Parameterisation of the terminal program: 9600 baud, 8 data bits, 1 stop bit, no parity, RTS/CTS.

Parameterisation of the IM 308 (B/C):

Slot 0: | 177 | 100 I/O
Slot 1: | 177 | 100 I/O

(Other identifications are also possible)

This results in the following relationship between the PLC addresses and the data/control bytes of the RS 232 terminal:

PLC address | Significance for the KL6001
EB 100 | Input data byte 0
EB 101 | Status byte
EB 102 | Input data byte 2
EB 103 | Input data byte 1
AB 100 | Output data bytes 0
AB 101 | Controllbyte
AB 102 | Output data bytes 2
AB 103 | Output data bytes 1


TwinCAT Communication

Outline
ADS DLL ADS OCX External Devices

TwinCAT ADS DLL

Date | Article ID. | Article Selection
06/27/2001 | 01060104 | The ADS DLL application hangs when Windows 2000 is shutdown

TwinCAT OCX

Date | Article ID. | Article Selection
11/09/2000 | 00110705 | ADS-OCX in Delphi Applications V
06/27/2001 | 01060710 | The ADS OCX application hangs when Windows 2000 is shutdown
02/20/2004 | 04020711 | Method AdsSyncReadBoolVarReq does not supply data in Borland Builder 6 applications

TwinCAT Communication- External devices

Date | Article
04/13/2006 | Connecting of the XM3 Card Reader of the Cross Point Company via RS485
06/30/2006 | Connecting TwinCAT with Windows XP Media Center Edition
11/04/2008 | Connecting TwinCAT with Elsner Weather Station
07/14/2009 | Connecting TwinCAT with Thermokon device
11/04/2009 | Connecting TwinCAT with Maestro100Lite Modem
01/22/2013 | Connecting TwinCAT with sACN protocol

You may find further information about external devices and Interfacing Flash via ASP/ASP.NET in the column:
Beckhoff Information System -> TwinCAT -> TwinCAT System -> TwinCAT Connectivity -> TwinCAT ADS Samples.

The documentation about the communication with Crestron can be found under TwinCAT Supplements: TwinCAT Crestron Server


The ADS DLL application hangs when Windows 2000 is shutdown

Date: 27.06.2001 Article ID: 01060104

Question:

If with a AdsDll application running a shutdown of the PC is called, the application hangs and the operating system cannot be shutdown. The error only occurs after an update from NT 4.0 to Windows 2000. Why does the same application under NT 4,0 terminate without error?

Answer:

The shutdown behaviour under Windows 2000 has changed compared with NT 4.0. Applications that build a client-server connection, must break this connection. The ADS DLL provides the AdsPortClose() function for this purpose.. In the event of system shutdown this method must be called from the AdsDll application. In order to detect the initiated shutdown in the application, the Windows message: WM_ENDSESSION must be intercepted and analysed. It is not sufficient, for example, to break the connection in the FormDestroy-Eventhandler since this Eventhandler, e.g. Delphi, is not called in the event of a shutdown.

Other causes can be eliminated in the following manner:

While the application hangs, instigate a router - > cleanup via the TwinCAT system menu in the task bar. This separates all connections to the clients. If the system shuts down, then an existing connection to the TwinCAT router is the cause for the incorrect behaviour.

Example of an implementation in Delphi:

The Eventhandler FormDestroy is then called only if the application has been terminated by the user.

unit DelphiAdsDLLSample1Unit;

interface
uses
  Ads, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, ExtCtrls, ComCtrls;

type
  TForm1 = class(TForm)
.....
   procedure FormDestroy(Sender: TObject);
   private
    { Private-Deklarationen }
    procedure WM_EndSession(var Message: TMessage); message WM_ENDSESSION;
   public
    { Public-Deklarationen }
  end;

var
  Form1         : TForm1;

implementation

{$R *.DFM}
procedure TForm1.WM_EndSession(var Message: TMessage);
begin
    AdsPortClose();
    inherited;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
    AdsPortClose();
end;

.....

Example of an implementation in a dialogue-based VS C++ application

Header:

class CAdsDLLW2KShutdownDlg : public CDialog
{
// Construction
public:
    CAdsDLLW2KShutdownDlg(CWnd* pParent = NULL);	// standard constructor
...
// Implementation
protected:
    ...
    // Generated message map functions
    //{{AFX_MSG(CAdsDLLW2KShutdownDlg)
    ...
    afx_msg void OnEndSession(BOOL bEnding);
    ...
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};
...

cpp-File:

BEGIN_MESSAGE_MAP(CAdsDLLW2KShutdownDlg, CDialog)
    //{{AFX_MSG_MAP(CAdsDLLW2KShutdownDlg)
    ...
    ON_WM_ENDSESSION()
    ...
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

...
void CAdsDLLW2KShutdownDlg::OnEndSession( BOOL bEnding )
{
    AdsPortClose();
    CDialog::OnEndSession( bEnding );
}


ADS-OCX in Delphi Applications V

Date: 11/09/2000 Article ID:00110705

Question:

Can I read a string array from the PLC, or write one into the PLC?

Answer:

No. Only individual string elements can be transferred between the PLC and the ADS-OCX application.


The ADS OCX application hangs when Windows 2000 is shutdown

Date: 27.06.2001 Article ID: 01060710

Question:

If with a AdsOCX application running a shutdown of the PC is called, the application hangs and the operating system cannot be shutdown. The error only occurs after an update from NT 4.0 to Windows 2000. Why does the same application under NT 4,0 terminate without error?

Answer:

The shutdown behaviour under Windows 2000 has changed compared with NT 4.0. Applications that build a client-server connection, must break this connection. The ADS OCX offers the AdsAmsDisconnect() method for this purpose.. In the event of system shutdown this method must be called from the AdsOCX application. In order to detect the initiated shutdown in the application, the Windows message: WM_ENDSESSION must be intercepted and analysed. It is not sufficient, for example, to break the connection in the FormDestroy-Eventhandler since this Eventhandler, e.g. Delphi, is not called in the event of a shutdown.

Other causes can be eliminated in the following manner:

While the application hangs, instigate a router - > cleanup via the TwinCAT system menu in the task bar. This separates all connections to the clients. If the system shuts down, then an existing connection to the TwinCAT router is the cause for the incorrect behaviour.

Example of an implementation in Delphi:

The Eventhandler FormDestroy is then called only if the application has been terminated by the user.

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  OleCtrls, ADSOCXLib_TLB, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    AdsOcx1: TAdsOcx;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
    procedure WM_EndSession(var Message: TMessage); message WM_ENDSESSION;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
procedure TForm1.WM_EndSession(var Message: TMessage);
begin
    AdsOcx1.AdsAmsDisconnect();
    inherited;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    AdsOcx1.AdsAmsServerNetId:=AdsOcx1.AdsAmsClientNetId;
    AdsOcx1.AdsAmsServerPort:=801;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
    AdsOcx1.AdsAmsDisconnect();
end;

Example of an implementation in Visual Basic:

Private Sub Form_Load()
    AdsOcx1.AdsAmsServerNetId = AdsOcx1.AdsAmsClientNetId
    AdsOcx1.AdsAmsServerPort = 801
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Call AdsOcx1.AdsAmsDisconnect
End Sub

Example of an implementation in a dialogue-based VS C++ application

Header:

class CAdsOcxW2KShutdownDlg : public CDialog
{
// Construction
public:
    CAdsOcxW2KShutdownDlg(CWnd* pParent = NULL);	// standard constructor
...
// Implementation
protected:
    ...
    // Generated message map functions
    //{{AFX_MSG(CAdsOcxW2KShutdownDlg)
    ...
    afx_msg void OnEndSession(BOOL bEnding);
    ...
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

cpp-File:

BEGIN_MESSAGE_MAP(CAdsOcxW2KShutdownDlg, CDialog)
    //{{AFX_MSG_MAP(CAdsOcxW2KShutdownDlg)
    ...
    ON_WM_ENDSESSION()
    ...
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

...
void CAdsOcxW2KShutdownDlg::OnEndSession( BOOL bEnding )
{
    m_AdsOcx.AdsAmsDisconnect();
    CDialog::OnEndSession( bEnding );
}


Method AdsSyncReadBoolVarReq does not supply data in Borland Builder 6 applications

Date: 20.02.2004 article ID: 04020711

Question:

In compiled form, the Borland Builder AdsOcx project worked flawlessly under Borland Builder version 5. As one of the parameters for the AdsSyncReadBoolVarReq method, a variable from the pointer to TOLEBOOL was required. After updating to Borland Builder version 6, the same C++ project requires a pointer to short (VARIANT_BOOL* or short*). If the parameter to be transferred is declared as such, the compilation works OK. However, no data are read when method AdsSyncReadBoolVarReq is called up. The error remains if a completely new C++ project is created and the AdsOcx component is re-imported.

Answer:

During the import of the AdsOcx ActiveX component, Borland Builder generates a type library. The function prototypes of the AdsOcx methods in the Borland Builder 6 type library differ from those in Borland Builder 5. When the method is called up, a wrong parameter type is transferred to AdsOcx. The actual method is not called up at all. Communication with the AdsAmsDebugger reveals that no Ads request is sent. Furthermore, no error is generated in the C++ application. At the time of writing this article, we were not aware of an update from Borland that fixes this error.

As a workaround, AdsSyncReadIntegerVarReq may be used. The boolean value that was read is then stored in the short variable. Example:

void __fastcall TForm1::Button2Click(TObject *Sender)
{
   long     hVar = 0;

   WideString  VarName = "MyTask.Inputs.MyInput";
   int AdsErrCode = AdsOcx1->AdsCreateVarHandle(VarName, &hVar);

   if (AdsErrCode == 0)
   {
      short bAsShort = 0;
      AdsErrCode = AdsOcx1->AdsSyncReadIntegerVarReq( hVar, 1, &bAsShort);

      if (AdsErrCode == 0)
         Label2->Caption = bAsShort == 0 ? "FALSE" : "TRUE";
      else
         Label1->Caption = "AdsSyncReadBoolVarReq() error: " + IntToStr(AdsErrCode);

      AdsOcx1->AdsDeleteVarHandle(hVar);
    }
    else
       Label1->Caption = "AdsCreateVarHandle() error: " + IntToStr(AdsErrCode);
}


TwinCAT Kommunikation

Beckhoff Knowledge Base: Communication

TwinCAT Communication- External devices

Date | Article
04/13/2006 | Connecting of the XM3 Card Reader of the Cross Point Company via RS485
06/30/2006 | Connecting TwinCAT with Windows XP Media Center Edition
11/04/2008 | Connecting TwinCAT with Elsner Weather Station
07/14/2009 | Connecting TwinCAT with Thermokon device
11/04/2009 | Connecting TwinCAT with Maestro100Lite Modem

You may find further information about external devices and Interfacing Flash via ASP/ASP.NET in the column:
Beckhoff Information System -> TwinCAT -> TwinCAT System -> TwinCAT Connectivity -> TwinCAT ADS Samples.

The documentation about the communication with Crestron can be found under TwinCAT Supplements: TwinCAT Crestron Server


TwinCAT NC

Date | Article ID. | Article Selection
07/06/2001 | 01070501 | Position offset
11/15/2001 | 01110502 | AX2000-B200 in Torque Control I
11/15/2001 | 01110503 | AX2000-B200 in Torque Control II
11/15/2001 | 01110504 | AX2000-B200 in Torque Control III
12/06/2001 | 01120505 | Software limit switch
07/11/2002 | 02110506 | AX2000 mit zyklischem CANopen Interface
07/22/2003 | 03070507 | AX2000 als Messstrecke
07/22/2003 | 03070508 | Digitale und analoge I/O's am AX2000-B200

back to the TwinCAT Overview


Position offset

Date: 07/06/.2001 Article ID: 01070501

Question:

How can I give a postion offest to an axis, which is permanently active?It does not function by simple describing the fActPosCorrection of the axis interface.

Answer:

The required function is in the Dialog: Axis_ENC / Global / Zero Offset Shifts Position Offset:


AX2000-B200 in Torque Control I

Date: 11/15/2001 Article ID: 01110502

Question:

In which modes can the AX2000-B200 torque interface be used?

Answer:

The maximum current (complies to torque) can, either as the main mode or as a mode aside velocity control (current / torque reduction), be forwarded to the drive.

The value is passed via the cyclical interface and is nominal to a maximum of 3280, which is equal to the maximum current of the amplifier (DIPEAK). The parameterized values for peak current (IPEAK) and rated/nominal current (DICONT) are also acting as limitation here. The actual current limitation can be read back by "m ILIMIT".

Definition of terms:

IPEAK: Peak current of current-controller (motor). IPEAK hast to be lower than DIPEAK
Default: 2 * ICONT;
Range: [ 0 .. 2 * DICONT) ]

ICONT: Current-controller (motor) rated current (also called Irms))
Range: [ 10% of DICONT .. max(DICONT, IPEAK) ]

DIPEAK: Amplifier peak current of drive
Default: 2 * DICONT

DICONT: Amplifier rated current of drive


AX2000-B200 in Torque Control II

Date: 11/15/2001 Article ID: 01110503

Question:

How do I use the AX2000-B200 torque interface as the main mode?

Answer:

In main mode, the variable "DriveCtrl0" has be set to value 2, for the digital cyclic torque control (current controller). instead of the usual value 0 for digital cyclic velocity control. The torque setpoint value is assigned through the variable "NominalTorque0" (nominal range). The range for this variable is between -3280 und 3280 digits (equals to ±3280 º ±100 % º ±DIPEAK). The mode switch to main mode applies on-the-fly and is active instantly, doesn't matter whether the drive is enabled or disabled!

0x00001 Byte | "DriveCtrl0" [1] 0: digital speed controller 1: analog speed controller 2: digitaler current controller 3: analog current controller Mode [1] |  | TwinCAT NC Output
0x00062 Byte | "NominalTorque0" [2] Scaling: 3280 = 100% = drive peak current (DIPEAK) | Motorola | TwinCAT NC Output
0x00044 Byte | "NominalTorque" [4] Scaling: 3280 = 100% = drive peak current (DIPEAK) | Motorola | TwinCAT NC Output
0x01062 Byte | "ActualTorque0" [2]: Scaling: 3280 = 100% = drive peak current (DIPEAK) | Motorola | TwinCAT NC Input


AX2000-B200 in Torque Control III

Date: 11/15/2001 Article ID: 01110504

Question:

How do I use the AX2000-B200 torque control aside velocity control?

Answer:

This functionality is only active, if the AX2000 internal parameter DILIM is set to 1. The torque setpoint (current controller) is also preset through the variable "NominalTorque0" (nominal range). The range for this value is between 0 und 3280 digits (equals to 3280 º 100 % º DIPEAK). The maximum current acts as a rated value, therefore only positive values are allowed.

0x002A2 Byte | "CurrentLimiting" [2] Scaling: 3280 = 100% = Amplifier peak current (DIPEAK) | Motorola | TwinCAT NC Output
0x01062 Byte | "ActualTorque0" [2] Scaling: 3280 = 100% = Amplifier peak current (DIPEAK) | Motorola | TwinCAT NC Input


Software limit switch

Date: 12/06/2001 Article-ID: 01120505

Question:

How are the software limit switches entered in the PLC?

Answer:

First of all, the software limit switches should be set in the global parameters of an axis. For each direction there are two parameters, i.e. Enable (BOOL type, default value FALSE) and the value (type LREAL, default value 0.0). Alternatively, the values can also be entered at run-time via the ADS blocks. This would enable the software limit switches to be used only in individual operating modes (see example: SoftschalterADS.pro)

If an attempt is made to place a job outside the specified limits, the System Manager (logger window) will show the following error message:

In the PLC, the function block AXACT (PlcNc.lib) will generate error 0x4461 on the output variable InstanzNamen.ErrID.
If the manual functions of the AXFNS blocks are used, no error message is generated at InstanzNamen.ErrID. The reason is that the NC had initially been accepted the command properly. There is no permanent monitoring via the axis blocks. In this case, the user has to imitate the monitoring of the software limit switches on the PLC. To solve this task, the actual value and the software limit switches of the axis are required (see example).


AX2000 with cyclic CANopen Interface

Date: 11/07/2002 Article-ID: 02110506

Question:

How do I have to configure an AX2000-B510 if the cyclic CANopen interface should be used?

Answer:

An instruction for the configuration can be found under "TwinCAT System Manager - Reference": AX2000-B510

Examples:

PLC and System Manager project data for reading resp. writing of AX2000 CANopen objects.


AX2000 als Messstrecke

Beckhoff Knowledge Base: TwinCAT NC

AX2000 as Measured Length

Date: 07/22/2003 Article-ID: 03070507

Question:

How can I configure a AX2000 as measured length?

Answer:

Assembly : 1 Dig input (light barrier) samples workpiece.
With the positive edge, a trigger is executed and with the negative edge, a trigger is executed.
The digital input is samples with 5µs. The Latch will be stored after 250µs (rule cycle of speed controller).

Configuration: SR600:

TwinCAT:
I/O: activate the variable mapping at AX2000.

Attention:

The old mapping NC- I/O will be deleted.

New mapping of the axis:

This mapping links more variables than the standard mapping:

(left variable mapping, right standard mapping)

Programming on the PLC:

1. Enable pos&neg Latch on the NC

2. pos edge Latch ADSREAD.Port = 501 ADSREAD.Grp = 16#5200 + AxID ADSREAD.Offset = 16#201

3. neg edge Latch ADSREAD.Port = 501 ADSREAD.Grp = 16#5200 + AxID ADSREAD.Offset = 16#202

4. If the Latch occurs, it will be shown in the AxInterface NC_to_PLC. NStateDWord bit 16.

5. Read Latch value from the NC ADSREAD.Port = 501 ADSREAD.Grp = 16#5100 + AxID ADSREAD.Offset = 16#205

Alternative:

Wait until the negative Latch occurred and read the difference between both latch positions.
Read Latch value from the NC ADSREAD.Port = 501 ADSREAD.Grp = 16#5100 + AxID ADSREAD.Offset = 16#208


Digital and analog I/O at AX2000-B200

Date:07/22/2003 Article-ID: 03070507

Question:

How can digital and analog I/Os be configured at the AX2000-B200?

Answer:

The Ax2000 has four digital inputs:

Technical data:

logic | +24V / 7mA designed (PLC compatible)
high level | +12...36V / 7mA
low level | 0...7V / 0 mA
ground | Digital-GND (DGND, Terminal X3/18)

Settings in Drive tool.

The functions can be selected as necessary. If only the digital input should be polled, no function is deposited.

The two digital outputs of the AX2000 can be described via the Lightbus interface (B200).

Technical data:

circuit | DIGITAL-OUT1 and 2 Open-Collector, max. 30V DC, 10mA
ground | Digital-GND (DGND, terminal X3/18)

The outputs can be called from the PLC after the ASCII commands O1Mode & O2Mode are set to 23.

Store EEPROM and reset.

The analog channels in the input range can be used in the drive tool without special settings.

The analog outputs MONITOR1 & MONITOR2 can be called via the DPRAM of the B200, after the ASCII commands ANOut1 and ANOut2 are set to 6.

The resolution of the analog monitor outputs is 1,25mV/dig

The resolution of the analog monitor is 10V/404dig.

Set Ax2000-B200 in the TwinCAT System Manager in the mode "Variables I/O-Mapping". Exisiting connections to the NC axis are broken. The user has to rebuild the connections.

The following variables are available for the digital and analog inputs/outputs in the process image (of the box).


TwinCAT NC I

Date | Article ID. | Article Selection
02/28/2001 | 01020601 | Manage the Interpreter from the PLC

back to the TwinCAT Overview


Manage the interpreter from the PLC

Date: 02/28/2001 Article ID: 01020601

Question:

How is the interpreter managed from the PLC?

Answer:

There´s an example called NCI_Test in the documentation of TwinCAT NCI. The example is described there.

Installing NCI_Test

Note:

You have to install the complete Beckhoff Information System to be able to read this pages.


TwinCAT PLC Control

Date | Article ID. | Article Selection
12/05/2000 | 00120801 | Opening *.pro projects
12/12/2000 | 00120802 | Checking array boundaries
06/12/2001 | 01060804 | BC9000: Communication error when online
06/28/2001 | 01060807 | System Manager and *.pr6 projects
06/28/2001 | 01060808 | BC and *.pro projects
07/06/2001 | 01070809 | Error message: array too large
03/15/2002 | 02030810 | Parameter TwinCAT PLC Library PID
09/11/2002 | 02090811 | TwinCAT Task Interval < 1 ms
02/27/2003 | 03020812 | Remanent Data at CX1000
03/25/2003 | 03030813 | Appending own PLC project HTML documentation to TwinCAT PLC Control help tree
08/18/2003 | 03080814 | POU calls get cut in the lower area of the network view

back to the TwinCAT Overview


Opening *.pro projects

Date: 12/05/2000 Article ID:00120801

Question:

Why is it impossible to open *.pro projects with a doubleclick ( e.g. in the explorer)?

Answer:

It´s possible, that the double inverted commas at %1 are missing:

D:\TwinCAT\Plc\TCatPlcCtrl.exe "%1"

These can be modified as described below.

Afterwards, the projects can be opened with a doubleclick.


Checking array boundaries

Date: 12/12/2000 Article ID:00120802

Question:

How can the array boundaries be checked?

Answer:

The POU CheckBounds checks automatically all array boundaries in the project.


BC9000: Communication error when online

Date: 06/12/2001 Article ID:01060804

Question:

After a period in the online state (logged in via Ethernet/AMS) the message "Communication error - logging out" always occurs.

Answer:

The data traffic is jamming at the Ethernet interface, and data communication is being reduced.
a.) Stop the cyclical data traffic, or lengthen the task time.
b.) Reduce the number of windows open in the online display.
c.) Log in via the serial interface.


System Manager and *.pr6 projects

Date: 06/28/2001 Article ID:01060807

Question:

Why can´t the System Manager read my *.pr6 project?

Answer:

That is correct. A *.pr6 project is made for programming a BCxxx.
If you choose (in PLC Control) the target system type 'BC via AMS' or 'BC serial', the project can be saved as *.pr6 only. see below

If you choose 'PC(i386)' , the System Manager is able to read the project, because the project will be saved as *.pro file. Only these file types can be read from the System Manager.


BC and *.pro projects

Date: 06/28/2001 Article ID:01060808

Question:

Why is is not possible to load my *.pro project into the PLC?

Answer:

That is correct.
The PLC functionality of the Bus terminal controller is not available with *.pro projects.
If you choose (in PLC Control) the target system type 'BC via AMS' or 'BC serial', the project can be saved as *.pr6. A *.pr6 project is made for programming a BCxxx.


Parameter TwinCAT PLC Library PID

Date: 03/15/2002 Article-ID:02030810

Question:

When will the changes at the inputs fKp, fTn, fTv, fTd of the function block of the PID controller become operative?

Answer:

The changes at the input parameters fTn, fTv and fTd will be taken with a rising edge at the bInit-Flag.

Changes at the input parameter fKp on the other hand are taken inside the function block instantaneous.


Task intervals less than 1ms

Beckhoff Knowledge Base: PLC Control

TwinCAT PLC Task Interval < 1ms

Date: 11.09.2002 Article ID:02090811

Question:

How to execute a TwinCAT PLC Task with an interval time less than 1ms?

Answer:

As far as the Fieldbus system supports I/O update times less than 1ms, or no, or just selected I/O variables have to be refreshed at Fieldbus systems with priority controlled telegrams such as Lightbus, PLC tasks can be triggered with intervals less than 1ms.

Step 1: The TwinCAT Base Time has to be adjusted as described under: Real Time Settings

Step 2: At the PLC Configuration, the checkbox "Task cycle times interpreted as ticks" has to be activated.

Step 3: The configuration has to be saved as usual and the TwinCAT System has to be restarted.

Example:

A PLC Task configuration with a setting of "T#1ms", has, after following the above steps and Base Time settings of 333us, a refresh time of 333us.


Remanent Data at a CX1000

Beckhoff Knowledge Base: PLC Control

Remanent Data at CX1000

Date: 27.02.2003 Article-ID: 03020812

Question:

How can remanent (persistent) data be established at a CX1000?

Answer:

Since the CX100x comes already with 8 kbyte NOVRAM, this can be used for saving of data which survives a reboot/restart of the CX. To establish this, the remanent PLC variables have to be declared as ordinary outputs (especially not as VAR PERSISTENT nor VAR RETAIN) , e.g. with AT %Q*. Additionally, inside the System Manager at the NOVRAM-"Device" the checkbox "Auto Init linked PLC Outputs" has to be activated and the new -"save"- PLC variables must be mapped to added NOVRAM outputs (see also: TwinCAT System Manager -> "Generic NOV-RAM").


Appending own PLC project HTML documentation to TwinCAT PLC Control help tree

Date: 03/25/2001 Article ID:03030813

Question:

How can I append own PLC project HTML documentation to TwinCAT PLC Control help tree to call own help topics from PLC Control?

Answer:

It is possible to add up to 5 own CHM-files in the help tree at the same level, but before the TwinCAT PLC Documentation.

The following two steps have to be done:

1. Generate up to 5 new CHM-files with the following names:

TcPlcControlUser1.chm

TcPlcControlUser2.chm

TcPlcControlUser3.chm

TcPlcControlUser4.chm

TcPlcControlUser5.chm

2. Copy the CHM-files in the right TcInfoSys speech file:

\1031 for german

\1033 for english

\1034 for spanish and

\1040 for italian.

The CHM-files which are not available are not shown. Here you can expand the sources for a customer specific CHM-file. These can be modified.

TwinCAT PLC Control hepl with 3 custom specific documents.


POU calls get cut in the lower area of the network view

Date: 08/18/2003 Article ID:03080814

Question:

Why don't FUNCTION and FUNCTION_BLOCK calls display correctly sometimes in graphical programming languages (LD, FBD)?

Answer:

A True-Type font (TTF) resp. true Microsoft font has to be selected at the PLC Control settings for the project. The PLC Control needs a TTF or Microsoft font to rescale the view correctly. For example: You can use Microsoft San Serif but not MS Sans Serif as font at projects with graphical POUs. The font can be changed under:

Project | Options... | Editor

after hitting the Font... button.


TwinCAT System

Date | Article ID. | Article Selection
12/12/2000 | 00121101 | Shutdown NT
12/12/2000 | 00121102 | Retain data with TwinCAT 2.7
12/12/2000 | 00121105 | Realtime settings
06/27/2001 | 01061106 | After shutdown from the PLC the system is shutdown and rebooted
06/28/2001 | 01061107 | Deactivated Bootproject
06/28/2001 | 01061108 | Installation / de-installation of TwinCAT
06/28/2001 | 01061111 | System load
07/13/2001 | 01071113 | System diagnosis
11/29/2001 | 01111114 | Automatic system start-up (Auto Boot) is not executed
12/05/2001 | 01121115 | Real-Time error message during first start
09/11/2002 | 02091119 | Export of System Information
09/13/2002 | 02091120 | Upgrade TwinCAT 2.8
20/09/2002 | 02091121 | TwinCAT Registration on RAID System


Shutdown NT

Date: 12/12/2000 Article ID:00121101

Question:

How is it possible to execute a shutdown of the Windows NT operating system from the PLC?

Answer:

You have to use AdsWriteCtl with

ads state = ADSSTATE_SHUTDOWN =12

and

device state = 0 for Shutdown

or

device state = 1 for Restart.

ShutdownFB

RestartFB

The documentation TwinCAT PLC Library: Utilities provides further information.


Retain data with TwinCAT 2.7

Date: 12/12/2000 Article ID:00121102

Question:

What differences does TwinCAT 2.7 have in the way it handles RETAIN data?

Answer:

In all versions prior to 2.7, all variables were always saved in one file. The RETAIN variables were then filtered out during the loading process. There was thus no limit on the RETAIN variables.

In version 2.7, the RETAIN variables are stored in their own region. The size of the region is set under Project/Options/TwinCAT.

In order to make the setting active it may be necessary to first perform the setting, then to save it, and finally to call up the project again.


Realtime settings

Date: 12/12/2000 Article ID:00121105

Question:

What does the display of the CPU time in the NT Task Manager mean?

Answer:

One of the NT Task Manager's functions is to provide the user with a list of the running processes and of the amount of CPU time that they are using. A different interpretation must be given to the display when TwinCAT is running:

The TwinCAT real-time extension makes computing time available to the NT operating system. The NT operating system evaluates this portion as 100% CPU time. The display of the CPU time associated with processes in the NT task manager is thus not related to the CPU time itself, but to the remaining time still available to NT.

Example:

If TwinCAT requires a constant 50% of the CPU's capacity (see the "Realtime Settings"), and an additional process is displayed in the NT Task Manager with 50% "CPU time", it means that this process is actually using 25% of the real CPU time.


After shutdown from the PLC the system is shutdown and rebooted

Date: 27.06.01 Article ID: 01061106

Question:

I instigate a shutdown from the PLC with the help of the NT_Shutdown function block. Under NT 4.0 the PC remains frozen at the dialog "you can switch off the PC". After an update to Windows 2000 the system does actually shutdown, but subsequently reboots.

Answer:

Possibility 1 (recommended!):

The default TwinCAT settings are to perform shutdown with power OFF. You can disable the power OFF function in windows registry. Please add following entry:

"DisableACPIPowerOff" REG_DWORD = 0x00000001 in Registry under: "HKEY_LOCAL_MACHINE\SOFTWARE\Beckhoff\TwinCAT\System"

Possibility 2:

Under Windows 2000 the PC can be switched off using this function. It is however possible only if the main board, the power supply unit, supports this function and the PC has been recognised as being ACPI-capable by the operating system installation. In many cases the PC is not recognised as ACPI-capable, although according to the manufacturer the components fulfil the requirements. The reason for this is that during the Windows 2000 installation in a list is interrogated for the recognised BIOS version. If the recognised BIOS version is not found in the list, then the BIOS is not classified as ACPI-capable. The list TXTSETUP.SIF is in the Windows 2000 installation files. By means of the following procedure the ACPI BIOS is in most cases recognised as such during the installation. Also do not forget to activate the ACPI functions in the BIOS before the Windows 2000 installation.

1. Copy all Windows 2000 installation files on to the hard disk;

2. Remove the write protection from the file TXTSETUP.SIF and open this in Notepad;

3. Look up the following section in the file:

; [ACPIOptions]
; This section lists options that affect the installation of ACPI on x86
;
; ACPIEnable
; 0 - ACPI will be disabled at install time regardless of the BIOS
; 1 - ACPI will be enabled at install time if an ACPI BIOS is present
; 2 - ACPI will be enabled based on the GoodACPIBios list, the NWACL
; and ACPIBiosDate
;
; ACPIBiosDate = mm,dd,yyyy
; Supplies the date that a BIOS must have to be considered good if it is
; not in the GoodACPIBios list. If a BIOS has a date greater than this and
; is not in the NWACL list, then it will be used unless ACPIEnable = 0
;
[ACPIOptions]
ACPIEnable = 2
ACPIBiosDate = 01,01,1999

[NWACL]
FujitsuV66NAS=FujitsuV66NAS
ABitBP6=ABitBP6
ASUSP2B-D=ASUSP2B-D

4. Modify the marked line to:

[ACPIOptions]
ACPIEnable = 1
ACPIBiosDate = 01,01,1999

Thus the BIOS version is no longer looked for in the list.

5. Save the modifications.

6. Call up Setup from the hard disk and reinstall Windows 2000.

Whether the system has been recognised as ACPI-capable can be detected under Settings - > Control Panel - > System - > Hardware - > Device Manager - > Computer.


Deactivated Bootproject

Date: 06/28/2001 Article ID:01061107

Question:

Why is the bootproject by autostart not started?

Answer:

If the bootproject is not started, or the take off is terminated ( e.g the voltage is switched off or there is a crash "Dr. Watson, BlueScreen") the bootproject is de-activated.
The system looks into the registry.

HKEY_Local_Machine / Software / Beckhoff / TwinCAT / System / SysAutoStart must always be 1.
These safety funtions can not switched off, but it is possible to set this value by the surface.
With these settings, the problem of switch off the pc by the NT start can be solved.


Installation/ de-installation of TwinCAT

Date: 06/28/2001 Article ID:01061108

Question:

During the deinstallation of TwinCAT Build 420 and the installation of TwinCAT 450 on Win 2000, the following error occurs:

" There are some files marked for deletion on next reboot. Please reboot first and then install again."

How can this error be removed?

Answer:

In the registry is a key, which has to be deleted:

Under HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager" must be the key "PendingFileRenameOperations".
If there are no Beckhoff components listed, this Key can be deleted.


System load

Beckhoff Knowledge Base: TwinCAT System

Date: 06/28/2001 Article ID: 01061111

Question:

How can I determine approximately the efficiency of the CPU by the TwinCAT System?

Answer:

For TwinCAT can be said:

Cycle time and execution time define the system load!
1K PLC instructions need (execution time) approximately 24 µs on a CPU AMD K6-2 233 MHz and 15µs on a Pentium III 600.

calculation:
execution time/ cycle time *100 = system load (%)

Per axes you have to add approximately 13 µs calculation time ( with Pentium III systems)


System diagnosis

Date: 13.07.2001 Article ID: 01071113

Question:

Is there a system diagnosis ( e.g. what happens if the cycles will be executed in a time cycle longer than the configured one..?)

Answer:

If the cycle time is exceeded the watchdog functions of the Terminals will react ( after 100ms). The way how to react can be set with the KS 2000 software or via TwinCAT. At profibus this is possible via the bus master, too.


Automatic system start-up (Auto Boot) is not executed

Date: 11/29/2001 Article-ID: 01111114

Question:

After an improper start of the operating system (e.g. after a power failure), TwinCAT will no longer automatically start the system during the next NT reboot. How can this be prevented or rectified?

Answer:

From TwinCAT 2.7 build 456, an additional flag can be set in the registry "HKLM\Software\Beckhoff\TwinCAT\System\ DWORD "ForceSysAutoStart", which prevents the auto start flag from being reset and thus the AutoBoot function being interrupted.

During a TwinCAT system start (and only then!) the TwinCAT System Service will set the AutoBoot flag to FALSE, before initialising the real time functions (PLC, NC, IO, etc.). If the system does not boot without fault during this phase, the real time system is not started during the next NT reboot.

However, if the system "survives" the initialisation phase, which is usually the case, the AutoBoot flag is again set to the previously set value, independent of whether initialisation faults have occurred or not.


Real-time system error message during first start

Date: 12/05/2001 Article-ID: 01121115

Question:

The following error message appears during an attempt to start TwinCAT for the first time after the installation on a computer:

How can this fault be rectified?

Answer:

This fault occurs if the affected computer has a multi-processor board, and the multi-processor version of Windows (NT, 2000, XP) is installed.
To correct the fault, you should first of all make backup copies of the system files hal.dll and ntoskrnl.exe. Then copy the files hal.dll and ntoskrnl.exe from a suitable single processor system using the same operating system in the same local language with the same Service Pack than the one on which TwinCAT is running to the appropriate location on your computer. The TwinCAT system can then be started again.

Note:

The corresponding error message has been implemented from TwinCAT 2.7 Build 502. For TwinCAT 2.8, the message will occur from build 708.

Prior to the implementation, the fault caused maximum real time utilisation, without a program being loaded.


Export of System Information

Date: 11.09.2002 Article ID: 02091119

Question:

How to export the PC system information under the operating systems Microsoft Windows NT 4.0 / 2000 / XP?

Answer:

Operating system Microsoft Windows NT

System Information collects and displays your system configuration information. Support technicians require specific information about your computer so they can resolve your system problem. You can use System Information to quickly find the data they need.

To export the PC system information under Microsoft Windows NT 4.0, simply click Start, and then click Run. In the Open box, type msinfo32.exe.

The following dialog appears, where you select File | Save... to export the system information into a text file with the file extension *.txt as shown below.

Note:
If msinfo32.exe can't be executed with Start | Run.. please seach this executable file with Start | Find... | File or Folders... and execute it after it has been found and listed under Name in the Find window!

Operating system Microsoft Windows 2000 Professional

To export the PC system information under Microsoft Windows 2000, you can also simply execute msinfo32.exe by calling it with Start | Run. and typing the file name in the Open box.

At the System Information dialog which appears then, Action | Save As Text File... has to be selected. That opens the dialog for saving this file with a file extension *.txt.

Operating system Microsoft Windows XP Home/Professional

Under Microsoft Windows XP the System Information can also be exported with executing msinfo32.exe within the Open box of Start | Run...

With selecting File | Export..., the text file can to be saved to disk in this case.

For additional information search for the key words "Using System Information" inside the Search box of the Windows XP Help and Support Center.

Operating system Microsoft Windows CE.NET

The System Information of an embedded device running Microsoft Windows CE.NET can be displayed and exported with the help of the Remote Tools.

Further information to be found at the MSDN inside the category: Remote System Information.


Upgrade TwinCAT 2.8

Date: 13.09.2002 article ID: 02091120

Question:

What points require attention when upgrading from TwinCAT 2.7 to TwinCAT 2.8?

Answer:

PLC:

There are certain points which must be observed when changing over the PLC:

  • There are a few new terms that are protected as keywords from Version 2.8. These are:
    • ACTION
    • END_ACTION
    • LINT
    • LWORD
    • ULINT
    • WSTRING

    These terms may no longer be used as variable names in PLC programs.

  • SFC actions may no longer be called from other function blocks. The compiler will generate error code 4350.
  • An SFC action may not be used in multiple, hierarchically different levels. The compiler will generate error code 4368.
  • A CASE instruction with more than one ELSE branch will be detected by the compiler, and rejected with an error (error code 4274).
  • The CFC editor will now strictly check whether an output or a VAR_IN_OUT variable can really be written to. (Error codes 4346 and 4060).
  • The FBD/LD editor will now strictly check whether a VAR_IN_OUT variable can really be written to. (Error code 4060).
  • The ADR operator cannot be applied to bit variables (allocated BOOLs) (error code 4031). The new BITADR operator must be used to obtain the "address" of a bit variable. This returns the number of bits from the beginning of the memory segment. Not, in other words, a physical address.
  • The ADR operator can also not be applied to constants if the "Substitute constants" option has been activated (error code 4035). This option can be activated or deactivated under Project options/Translation options.
  • Version 2.8 objects to incomplete string constants. The string '1$1', for instance, leads to an error (error code 3908). Constants with $ must be two characters long.
  • The possible side-effects of SEL and MUX are pointed out. Warning 1505 is generated. The code in front of the inactive branch will not be executed! This is to be understood as similar to an IF..THEN..ELSE..END_IF structure. Only one branch is computed, depending on the switching variable.
  • There are two new functions for checking whether sub-range types pass out of range at run time:
  • CheckRangeSigned: For all types with arithmetic sign. See PLC Control Documentation.
  • CheckRangeUnsigned: For all types with no arithmetic sign. See PLC Control Documentation.
  • If the constant 0 is used as a divisor, the compiler generates an error message (4034).
  • Following an online change, constants are always initialised to the new value, regardless of whether the "Substitute constants" option is selected or not.
  • Libraries may not contain a block named PLC_PRG. The compiler will generate warning 1900.
  • Programs with parameters are not permitted in an external (C) library. The compiler will generate message 1902.
  • Version 2.8 introduces a range of new system libraries. The old system libraries can continue to be used, but the new ones offer many advantages. These advantages include better encapsulation, easier extension, version management, and automatic dependency generation. The new libraries contain all the blocks that were present in the old libraries. See PLC Control Documentation for more detail.

System Manager:
  • The System Manager no longer reads the PLC project (<Project name>.pro) directly, but the file <Project name>.tpy, which is created during compilation. This XML file contains all the PLC's variables and data structures.
  • The System Manager generates a <Project name>.tpa file if PLC Control contains variables with unspecified addresses (%I*, %Q*). This file is read the next time PLC Control is compiled.


TwinCAT Registration on RAID System

Date: 09/20/2002 Article-ID: 02091121

Question:

How does the TwinCAT Registration on a RAID System react when HDD´s are removed and/or replaced?

Answer:

When installing TwinCAT, the Windows Disk Administrator, which writes an ID (outside the data range) to the HDD, is run. From that ID the TwinCAT System ID is generated, from which the valid registration key is dependent. When a RAID Controller Mirrors a HDD, also areas outside data range -that means also the HDD ID- are copied. Due to that there are no problems with the TwinCAT Registration on RAID Systems.


TwinCAT: System Manager

Date | Article ID. | Article Selection
11/03/2000 | 00110901 | Error: Scanning IEC 61131-3 project
11/03/2000 | 00110902 | BlueScreen by starting the System Manager
11/03/2000 | 00110906 | K-Bus Reset from TwinCAT
11/03/2000 | 00110907 | Diagnosis example BK8x00
11/09/2000 | 00110908 | Adding GSD and EDS boxes
11/10/2000 | 00112102 | Firmware Update at Hilscher cards
12/11/2000 | 00120910 | Siemens S7 315-DP2 as Profibus slave in TwinCAT
06/12/2001 | 01060912 | BC9000: The ErrCounter content is rising
06/12/2001 | 01060913 | BC9000: address of the PLC bus terminals
06/28/2001 | 01060807 | System Manager and *.pr6 projects
07/23/2001 | 01060914 | Terminal configuration GSE / GSG file
12/06/2001 | 01120915 | Maintenance APC / UPS
02/21/2003 | 03020916 | TwinCAT Real-time Ethernet Driver - Installation

back to the TwinCAT Overview


Error: scanning IEC 61131-3 project

Date: 11/03/2000 Article ID: 00110901

Question:

How can I correct the error message: 'Error: scanning IEC61131-3 project'?

Answer:

This error message occurs, if the project is password protected. By the removal of the password protection, the rescan of the project is again possible.

You have to delete the password in TwinCAT PLC Control. The following dialog box opens under 'Project' ->'Options':

You have to delete the password in the category password. It is necessary to rebuild the project under 'Project' -> 'Rebuild all'. After that, the program has to be saved.

Now it is possible to rescan the PLC project.


BlueScreen at start-up of the system manager

Date: 11/03/2000 Article ID: 00110902

Question:

How can recovery be made from a BlueScreen at start-up of the system manager?

Answer:

If a BlueScreen appears at the start-up of the system manager, the cause can be found in the settings of the graphic card that is being used. In the case of the ATI graphic card the TRUE COLOR colours must be set to 65536.


K-Bus reset from TwinCAT

Date: 11/03/2000 Article ID: 00110906

Question:

How can the K-Bus be reset from TwinCAT?

Answer:

If the terminal has been unplugged, and the coupler is to start up again after the terminal has been plugged in, 0x80 must be written into Control0 of the BK2000. This will cause the coupler to restart.

Warning:

If the 0x80 remains in Control, auto-reset is always active. Applies from version BE of the BK2000!

You will find further information on this in the application documentation for TwinCAT I/O to ring 3.


Diagnosis example BK8x00

Date: 12/13/2000 Article ID: 00120907

Question:

How can a terminal diagnosis at the BK8x00 be executed under TwinCAT?

Answer:

In order to analyse a terminal diagnosis ( e.g. overflow with one analog terminal ), it is necessary to switch on the diagnosis on the tab 'BK8x00'.

An additional bus terminal input is displayed (DiagState).

Bit 15 displays if error occurs or not

Bit 14 and
Bit 13 and
Bit 12 display extended Diag. code (see terminal documentation)

Bit 11 and
Bit 10 display Diag. code (see terminal documentation)

Bit 9 and
Bit 8 display channel

Bit 7-0 display terminal number.

In order to analyse a clamp diagnosis (e.g. overflow with a similar clamp) in the TwinCAT, it is to be switched on necessarily in the system manager on the record sheet BK8x00 the diagnosis.


Adding GSD and EDS boxes

Date: 11/09/2000 Article ID: 00110908

Question:

How do I add a GSD (GSE), or EDS file into the System Manager?

Answer:

The Profibus and DeviceNet fieldbus systems contain device-specific configuration files which are provided by the hardware manufacturers. These serve to integrate these external devices into any control system that supports that fieldbus. The files are described under Profibus as GSD and under DeviceNet as EDS (Electronic Data Sheet) files.

After selecting Append Box..., depending upon the selected fieldbus system (in this case Profibus), a ‘Generic Profibus Box (GSD)’ item is shown under Miscellaneous.

In the case of DeviceNet you would see ‘General DeviceNet Box (EDS)‘.

With double-click or press on Ok, a Windows file-selection dialog shows available *.gsx files stored in the \TwinCAT\IO\GSD directory.

Press the Open button to integrate the device into the System Manager configuration.

Notice:
The device manufacturers are responsible for the GSD and/or ESD files, i.e. Beckhoff Automation GmbH does not provide GSD/GSE (GSE = GSD files in English) or EDS files for 3rd party devices, nor does it offer any guarantee of their function.

Device description

The specific structure of the GSD/GSE and/or ESD files (specified by the corresponding user organisations (PNO and ODVA respectively) allows the TwinCAT System Manager to read and display device information (manufacturer, device type etc.). This is shown in the right-hand General dialogue for the device selected in the tree.

The dialogue contains the device name, type, manufacturer and GSD/GSE and/or EDS file revision number. The latter can be of particular importance if there is any confusion over currently valid versions.
There is also a "Checkbox" for disabling the device, i.e. if selected, the device will be excluded on the driver side from the current combination of the fieldbus telegram, but can be retained on the hardware side unless the address is assigned to another device.

Compact and Modular Devices

The integrated external devices may be compact or modular. In the case of a compact device, the length of the input and output data transferred by the fieldbus can be pre-set. In the case of a modular device the number of the input and output data bytes of the device can be configured. Further details are given in the documentation TwinCAT System Manager.


Siemens S7 315-DP2 as a Profibus Slave under TwinCAT

Date: 12/11/2000 (05/01) Article ID: 00120910

Question:

How can a CPU 315-DP2 be operated as a slave in the TwinCAT System Manager?

Answer:

Parameterisation of the S7 315-DP2

In order to operate an S7 CPU 315-DP 2 as a slave under TwinCAT, it is first necessary to correctly parameterise the S7 PLC. This requires the S7 CPU to be switched over to slave operation in the Simatic hardware configuration. See picture below

In the tab for Properties - DP-Slave we select the 'Object properties' for the integrated Profibus coupling module in the S7 315-DP2 (marked in blue in the picture).

The 'Network settings' are performed next. It is important to select here the correct profile for the Profibus. The Profibus baud rate will also been set in accordance with this profile. All the devices located on the bus must be considered when choosing this parameter. You reach the tab for 'Network settings' by selecting 'Properties - DP-Slave' -> 'General' -> 'Properties' -> 'Parameters' ->'Properties' -> 'Network settings'.

It is necessary to enter the bus address and to select the subnet on the 'Parameters' tab.

Configuration of the S7 CPU 315-DP2

Finally, it is necessary to configure the CPU. The process image between the slave and Profibus is set up here. The choice between inputs and outputs is made under I/O. Adr... indicates the starting address of the process image. The Diag... entry is made by the system. The last three entries specify the length of the image, the unit and the data consistency. It is advisable to select the consistency in the light of the chosen unit (byte or word), because special functions must be linked into the S7 programme (SFC 14 and 15) if the consistency is greater than two words. The length, unit and consistency must subsequently be set in the TwinCAT System Manager in exactly the same way as here. At the location where the hardware configuration has inputs, the System Manager must later be given have outputs linked, and vice versa.

Settings in the TwinCAT System Manager

First the S7 CPU 315-DP2 must be linked into the System Manager as a GSD file. This GSD file is not included in the TwinCAT installation, and must therefore be placed in an appropriate path.

Once the GSD file has been linked, the CPU 315 will be seen, identified as 1st, 2nd and 3rd. These identifications are provided by the system, and must not be changed. It is also possible to enter the slave address (station no.:) here straight away. It must agree with the address previously set in the Simatic Manager.

It is now possible to enter the inputs and outputs (input and output modules) for the Profibus interface. It is essential to ensure that the length, unit and consistency of the entries are exactly the same as the entries in the hardware configuration. The outputs must be linked here.

The complete System Manager for this example should then look like this:

Finally, it is only now necessary to link the inputs and outputs in the modules with the corresponding task (PLC program).

This completes parameterisation of the S7 CPU 315-DP 2.


BC9000: The ErrCounter content is rising

Date: 06/12/2001 Article ID: 01060912

Question:

The status variable for the BC9000 in the System Manager is counting up. This means that not all the telegrams are still arriving at the Ethernet Bus Terminal Controller, or that they are not being answered.

Answer:

a.) Change the transport layer from TCP/IP to UDP.
b.) Increase the task time for the cyclical data.
c.) Increase the BC9000 background time.
d.) Increase the baud rate from 10 Mbaud to 100 Mbaud.
e.) Try to reduce the bus loading through the use of switches.


BC9000: address of the PLC bus terminals

Date: 06/12/2001 Article ID: 01060913

Question:

You do not know the address at which the Bus Terminals that you have assigned to the local PLC (BC9000) are located. What is the address?

Answer:

Perform your hardware configuration in the System Manager. After you have entered all the Bus Terminals and PLC variables, click with the right mouse button on the BC9000 in the hardware tree, and select the menu item "Export variables info...".

A file is saved, and this file can be inserted in the System Manager under "Project - Import".

ou will have the entry "TwinCAT import" under the global variables, and you will find here all the variables that you have assigned to the BCxxxx.


Terminal configuration / GSE /GSG file

Date: 07/23/2001 Article-ID: 01070914

Question:

I can´t find the Terminal KL1xx2 in the GSE / GSG file!

How can this terminal be configurated?

Answer:

The designations KL1xx2 and KL2002 are not listed in the GSE / GSG file, because these are Beckhoff designations.

The terminal KL1002 has two inputs, so you have to choose 8 bit digital inputs.

For the terminal KL2012 choose 8 bit digital outputs and for the KL1104 16 bit digital inputs, etc.


Maintenance APC / UPS

Date: 12/06/2001 Article-ID: 01120915

Question:

How does the maintenance program of the APC UPS work? When will it be required to change the batteries?

Answer:

The UPS tests the accumulator either after switch on or every 14 days by permanent operation.

If this test fails, the battery replace LED flashs.

The typical service life of the accumulator is 3-6 years, depending on the number of discharge cycles and temperature.


TwinCAT Ethernet Driver - Installation

Date: 21/02/2003 Article-ID: 03020916

Question:

How to install network interface card drivers for Beckhoff Real-Time Ethernet?

Answer:

The Intel 8255x based netword interface card (NIC) should be pluged in and - automatically - detected and installed from Windows XP or even Windows 2000. After that, the driver of the device has to be changed. Open the 'Network Connections' (via Control Panel or 'Properties' of 'My Network Places') and open the 'Properties' of the LAN connection. If more than one NIC is installed, choose the one the real-time Ethernet shall be connected to. Further information about the necessary driver setup steps, see: TwinCAT System Manager | Appendix C: Real-Time Ethernet installation.

Note:

At some systems it has occured that although the Real-time Ethernet driver could be installed, the Beckhoff TcEther protocol couldn't be linked to it since it wasn't available for selction in step 11 of the TwinCAT System Manager | Appendix C: Real-Time Ethernet installation. In that case, you should open the Windows Explorer and open the 'Folder Options...' dialog under the 'Tools' menu. Please select the 'View' tab and activate the 'Show hidden files and folders' under the entry (folder symbol) 'Hidden files and folders'. After that, you can continue with step 11 of Real-time Ethernet installation by clicking on the 'Have disk' button and selecting the Windows\Inf (Windows XP) resp. WinNt\Inf (Windows 2000) folder. The Beckhoff Real-time Ethernet protocol should appear now for selection.


Hardware

Outline of the entries in Hardware
Fieldbusses CANopen
DeviceNet
Profibus
Sercos
Bus Terminal Controller BCxxxx
Control Panel
IPxxxx or Fieldbus Box
KLxxxx or Bus Terminal
NT

back to Overview


Hardware: BCxxxx

Date | Article ID. | Article Selection
07/11/2001 | 01073001 | Retain data are overwritten
07/11/2001 | 01073002 | Dimension Bus Terminal / Bus Coupler
07/11/2001 | 01073003 | BCxxx: clear flash
07/11/2001 | 01073004 | Start-up of the controller
07/11/2001 | 01073005 | LED of the BC3100
06/28/2001 | 01062508 | BC3100 without Profibus-DP
06/28/2001 | 01073006 | Programming BC3100
07/13/2001 | 01073007 | ADR command
12/06/2001 | 01123008 | Errorcode BC3100

back to the Hardware Overview


The retain data are overwritten

Date: 07/11/2001 Article ID:01073001

Question:

The retain data (flags area 0...63) on the BCxxxx are overwritten during the program download.

How can I prevent this?

Answer:

The retain data are always overwritten during a program download. The persistent data survive a dowload only. The length of the persistent data can be set in the table 1 register 18 with the lower 14 bit.

Attention !

The length of the persistent data must be smaller or equal to the length of the retain data.


Dimension Bus Terminal / Bus Coupler

Date: 07/11/2001 Article ID: 01073002

Question:

What is the dimension for Bus Terminals, Bus Couplers and Bus Termional Controllers?

Answer:

The Beckhoff bus terminal system is remarkable for its compact construction and high degree of modularity. When you design the installation you will need to plan for one bus coupler and some number of bus terminals. The dimensions of the bus couplers do not depend on the fieldbus system. The clear dimensions of the bus coupler are not exceeded thanks to the use of fiber-optic cable with the Z1000 connectors.

dimension in mm

The overall width of the construction is the width of the bus coupler, including the bus end terminal, plus the width of the installed bus terminals. The bus terminals are 12 mm or 24 mm (KL5101, KL5121) wide, depending on their function. Depending on the gauge of cables used the overall height of 68 mm may be overstepped by about 5 mm to 10 mm by the cables at the front.


BCxxxx: clear flash

Date: 07/11/2001 Article ID: 01073003

Question:

How can the flash of the BC3100 be deleted?

Answer:

With 'Vendor Configuration'

The factory default settings will be loaded (Boot Project erased), the coupler must be subsequently restarted by initiating a coupler reset.

See Online -> Coupler -> Vendor Configuration:


Start-up of the controller

Date: 07/11/2001 Article ID: 01073004

Question:

How can I recognize the start-up of the controller (1st cycle)?

Answer:

The start -up can not be recognized, because there is no special flag for the first cycle.

That can be implemented however easily.


LED of the BC3100

Date: 07/11/2001 Article ID: 01073005

Question:

What is the importance of the LED on the Bus Terminal Controller BC3100?

Answer:

RUN

The green RUN LED on the controller lights up, if the PLC task runs.

BF

The red BF LED on the controller lights up, if the BC3100 does not participate in the Profibus DP data exchange.

DIA

When downloading the PLC program with the TwinCAT PLC programming environment the program is first stored in the RAM (only). The program will be stored in the flash with the command 'Online -> Create Boot Project'. During this storing, the DIA LED on the controller lights up.

PLC

The PLC LED lights up, if the PLC project runs in the controller.


Programming BC3100

Date: 07/13/2001 Article ID: 01073006

Question:

Is the programming of the BC3xxx with TwinCAT via the profibus interface possible?

Answer:

Yes, the programming is via ADS from a TwinCAT System possible.


ADR command

Date: 07/13/2001 Article ID: 01073007

Question:

What causes the ADR command?

Answer:

The address of the physical memory of a variable is determined with the ADR command.


Error Code BC3100

Date: 12/06/2001 Article-ID: 01123008

Question:

What does it mean, if the "I/O ERR" LED of the BC3100 flashes seven times?

The blinking stopps with a a K-Bus reset, but the Bus Terminals are running incorrect.

Answer:

The PLC cycle of the BC3100 is longer than the "K-Bus Watchdog time".
The "TrigTBusCycle" can be used to trigger an additional terminal bus cycle from the PLC task.

So an error can be avoided by the Watchdog.


Hardware: CANopen

Date | Article ID. | Article Selection
11/03/2000 | 00112101 | Register communication
11/03/2000 | 00110904 | CAN Box Reset
11/10/2000 | 00112102 | Firmware update at Hilscher cards
12/13/2000 | 00122103 | Send command to layer 2

back to the Hardware Overview


Register communication

Date: 11/03/2000 Article ID:00112101

Question:

How does the register communication under CANopen take place?

Answer:

An Example for the SDO access on a terminal. TwinCAT from Version 2.7 Example for BK5120 KL2012 KL6001 KL9010

Here the register 8 of the KL6001 is read, the result must be 6001.


Firmware update at Hilscher cards

Date: 11/10/2000 Article ID: 00112102

Question:

How do I execute an firmware update?

Answer:

The TwinCAT System Manager checks the firmware version of the fieldbus mastercard. An actual version is shown in black. If the colour is red, a firmware update is recommended.

Actual Firmware

Not actual firmware (update recommended)

With the buttom 'Firmware update' the following dialog opens. Choose the file ( e.g. Com.h36 for the CIF30-CAN ).

The product CD contains these files under Unsupported Utilities \ Hilscher Firmware \ ... .

If the firmware update was successfull, you see the following message box.


Send command to layer 2

Date: 12/13/2000 Article ID:00122103

Question:

How can a command 10 bytes long to be sent to layer 2 of a CAN master?

Answer:

With the function block IOF_CAN_Layer2Command

See documentation: TwinCAT PLC Library: IO Functions

Note:

You have to install the complete Beckhoff Information System to be able to read this page.


Hardware Control Panel

Date | Article ID. | Article Selection
03.04.2001 | 01042201 | under preparation

back to the Hardware Overview


Hardware Industrie-PC

Beckhoff Knowledge Base: Hardware Embedded-PC: CX1000

Hardware Embedded PC: CX1000

Date | Article ID. | Article Selection
11/18/2002 | 02113501 | HTTP Server
11/18/2002 | 02113502 | Parallel (Printer) Interface
11/18/2002 | 02113503 | Ethernet/Internet Protocols

back to Hardware Overview


HTTP Server

Date: 11/18/2002 Article ID: 02113501

Question:

Which HTTP server is used by Windows CE.NET and which formats are supported?

Answer:

The HTTP Server supports HTML/DHTML, ASP, SSL and the ISAPI extensions. Java Script is also supported. CGI is not supported (the Windows CE.NET Documentation conatins tips for converting CGI to ISAPI). JavaApplets are not supported, because the CX1000 is delivered without Java VM.


Parallel interface (Printer interface)

Date: 11/18/2002 Article ID: 02113502

Question:

Contains the CX1000 a parallel interface (Printer interface)?

Answer:

No. Printer have to be connected seriel or via USB interface.


Ethernet/Internet Protocols

Date:11/18/2002 Article ID: 02113503

Question:

Which portocols are supported by CX1000?

Answer:

The Protocol HTTP and FTP are supported by all CX1000 modules. The SMTP Protocol is only supported by CX1000 with large memory.

The POP3 Protocol is not supported.

Overview about supported protocols

Supported? | Protocol
CX Module | HTTP | FTP | SMTP
CX1000-0000 | yes | yes | no
CX1000-0010 | yes | yes | no
CX1000-0011 | yes | yes | no
CX1000-0012 | yes | yes | no
CX1000-0100 | yes | yes | no
CX1000-0110 | yes | yes | no
CX1000-0111 | yes | yes | no
CX1000-0112 | yes | yes | no
CX1001-0000 | yes | yes | yes
CX1001-0010 | yes | yes | yes
CX1001-0011 | yes | yes | yes
CX1001-0012 | yes | yes | yes
CX1001-0020 | yes | yes | yes
CX1001-0021 | yes | yes | yes
CX1001-0022 | yes | yes | yes
CX1001-0100 | yes | yes | yes
CX1001-0110 | yes | yes | yes
CX1001-0111 | yes | yes | yes
CX1001-0112 | yes | yes | yes
CX1001-0120 | yes | yes | yes
CX1001-0121 | yes | yes | yes
CX1001-0122 | yes | yes | yes


Hardware DeviceNet

Date | Article ID. | Article Selection
07/25/2001 | 01073301 | Configuring DeviceNet
07/25/2001 | 01073302 | Finding produced (Rx) and consumed (Tx) string lengths
07/25/2001 | 01073303 | String format of Rx String and Tx String
07/25/2001 | 01073304 | Working example to configure BK5200

back to the Hardware Overview


Configuring DeviceNet:

Date: 07/25/2001 Article ID:01073301

Question:

What is the meaning of the electronic data sheet (EDS)?

Answer:

When configuring a DeviceNet node, an electronic data sheet (EDS) is usually provided by the manufacturer of that device to assist in this task. An EDS file is a text file that describes properties of a particular DeviceNet node. It includes the number of bytes that are transmitted to the node (output information) and the number of bytes that are received from the node (input and status information). Since the number of transmit and receive bytes depend on the I/O terminals attached to the BK 5200 coupler, the default transmit and receive sizes are set to 0 in the BK 5200 EDS. For each BK 5200 in the network, you must adjust the transmit and receive sizes to match the data sizes produced and consumed by each node.

Note:

A copy of the EDS file can be found on the web.


Finding produced (Rx) and consumed (Tx) string lengths

Date: 07/25/2001 Article ID:01073302

Question:

How can I calculate the produced and consumed string lengths?

Answer:

The essential parameters that need to be configured correctly before a Beckhoff node may be allocated onto a network are the Tx and Rx string lengths. To calculate the Rx length it is necessary to add the number of input bits each terminal produces for the DeviceNet network divide it by 8 and if a remainder exists add one to the number. The Rx number that is calculated is the number of input bytes the master/controller will receive from the Beckhoff node. But, this is not the total number of bytes the master/controller will receive. It is necessary to add 1 byte for status information that is produced by the coupler. The total number of Rx bytes received by the master/controller is the number of input bytes plus 1 status byte. This is the number used for the Rx value.

The general formula is as follows:

IN1 = number of input bits terminal 1 produces for the DeviceNet network,

IN2 = number of input bits terminal 2 produces for the DeviceNet network, and

INn = number of input bits terminal with n variable produces for DeviceNet network.

Rx (bytes) = (((IN1 + IN2 +..+ INn ) / 8) (+1 if a remainder exists)) + 1 status byte

The Tx value is the number of bytes the master/controller transmits to the Beckhoff coupler. Calculating the Tx value is done by the same method as Rx value with one exception. The Tx value does not contain a status byte.

The following equation may be used in calculating the Tx value:

OUT1 = number of output bits terminal 1 consumes from the DeviceNet network,

OUT2 = number of output bits terminal 2 consumes from the DeviceNet network,

OUTn = number of output bits terminal with n variable consumes from the DeviceNet network.

Tx (bytes) = (((OUT1 + OUT2 +..+ OUTn) /8) (+1 if a remainder exists))

The Tx and Rx values calculated in the above equations will be declared somewhere in the configuration application being used. (i.e. DeviceNet Manager)


String format of Rx String and Tx String

Date: 07/25/2001 Article ID:01073303

Question:

How can I calculate the string format of Rx String and Tx Sring?

Answer:

It is important to know the format of the Rx and Tx strings in order to map the analog and discrete data into desired I/O locations.
When the master/controller receives input information from the Beckhoff DeviceNet coupler, it receives the analog input values starting with the terminal nearest to the communication coupler proceeding to the end terminal. After the master/controller receives the analog data, the discrete data is received. The last byte that is received is the status byte produced by Beckhoff's coupler.
The master/controller must transmit in the same order. The analog data is transmitted starting with the analog output terminal nearest to the BK 5200 coupler.
An easy phrase to remember for the format of the data string is: "Data is produced/consumed left to right with the analog terminals served first." (BK5200 on left side)


Working example to configure BK5200

Date: 07/25/2001 Article ID:01073304

Question:

How can a BK5200 be configured?

Answer:

The follow is an example of a working demo. The Rx an Tx values are calculated and both string formats are shown.

The following is a description of this terminal connection.
(3) KL 1002 (2 channel 24Vdc discrete input terminals)
(1) KL 2002 (2 channel 24Vdc discrete output terminal)
(2) KL 2114 (4 channel 24Vdc discrete output terminals)
(1) KL 1501 (High speed Up/Down counter)
(1) KL 4002 (2 channel 0-10V analog output terminal)
(1) KL 3062 (2 channel 0-10V analog input terminal)
(1) KL 9010 (end terminal)

The following is the calculation of the Rx value:

Rx (bytes) = (((IN1 + IN2 +..+ INn ) / 8) (+1 if a remainder exists)) + 1 status byte

Variable | Terminal | Type | # of produced bits | Analog or Discrete
IN1 | terminal 1 | KL1002 | 2 bits | discrete
IN2 | terminal 2 | KL1002 | 2 bits | dicsrete
IN3 | terminal 3 | KL1002 | 2 bits | discrete
IN4 | terminal 7 | KL1501 | 40 bits | analog
IN5 | terminal 9 | KL3062 | 32 bits | analog

Rx (bytes) = ((((IN1+IN2+IN3+IN4+IN5)/8) +(1 if a remainder exists)) +1status)

((((2+2+2+40+32)/8+(remainder exists so +1)) + 1status)

Rx = 11 bytes

The following is the calculation of the Tx value:

Tx (bytes) =(((OUT1 + OUT2 +...+ OUTn) /8) (+1 if a remainder exists))

Variable | Terminal | Type | # of consumed bits | Analog or Discrete
OUT1 | terminal 4 | KL2002 | 2 bits | discrete
OUT2 | terminal 5 | KL2114 | 4 bits | dicsrete
OUT3 | terminal 6 | KL2114 | 4 bits | discrete
OUT4 | terminal 7 | KL1501 | 40 bits | analog
OUT5 | terminal 8 | KL4002 | 32 bits | analog

Tx (bytes) = ((( OUT1+ OUT2 + OUT3 + OUT4 + OUT5) / 8) + ( 1 if a remainder exists))

(((2 + 4+ 4+ 40 + 31) /8 ) + ( remainder exists so + 1)

Tx = 11 byes

The following is a tabular display of the Rx string:

Byte # | Data information
 | Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0
1 | KL1501
2 | KL1501
3 | KL1501
4 | KL1501
5 | KL150
6 | KL3062 Channel 1 Low byte
7 | KL3062 Channel 1 High Byte
8 | KL3062 Channel 2 Low Byte
9 | KL3062 Channel 2 High Byte
10 | not used | not used | t3c2 | t3c1 | t2c2 | t2c1 | t1c2 | t1c1
11 | not implemented | not implemented | not implemented | not implemented | not implemented | not implemented | not implemented | BK5200 status

t3c1 = terminal 3, channel 1 etc.

The following is a tabular display of the Tx string:

Byte # | Data information
 | Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0
1 | KL1501
2 | KL1501
3 | KL1501
4 | KL1501
5 | KL150
6 | KL4002 Channel 1 Low byte
7 | KL4002 Channel 1 High Byte
8 | KL4002 Channel 2 Low Byte
9 | KL4002 Channel 2 High Byte
10 | t6c2 | t6c1 | t5c4 | t5c3 | t5c2 | t5c1 | t4c2 | t4c1
11 | not used | not used | not used | not used | not used | not used | t6c4 | t6c3


Hardware KLxxxx Overview

Beckhoff Knowledge Base: Hardware IPxxxx

Hardware KLxxxx

Date | Article Id | Article Selection
05/19/2003 | 03053701 | KL6201: Quickstart

back to the Hardware Overview


KL6201: Quickstart

Date: 05/19/2003 Article ID: 03053701

03013701

Question:

How to setup ASi slaves quickly at the KL6201?

Answer:

To set up an ASi network quickly at the KL6201, the following steps are necessary:

  1. Addressing of the ASI nodes and connecting them to the ASi cable (e.g. by connecting them sequentially to the ASi cable and using KS2000 v4 for assigning the appropriate ASi slave address)
  2. Select the process image interface or use the default setting, which means: 12 byte process image interface for slave address 1..11
  3. To enable the ASi commmunication, you have to set bit 3 of CMD nibble to 1

    Example with 12 Byte interface (outputs):

    Byte 0 | Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 | Byte 6 | Byte 7 | Byte 8 | Byte 9 | Byte 10 | Byte 11
    CTRL0 CTRL1 WPara0 WPara1 WPara2 WPara3 CMD
    + Output
    Slave 1     		Output
    Slave
    2+3     		Output
    Slave
    4+5     		Output
    Slave
    6+7     		Output
    Slave
    8+9     		Output
    Slave
    10+11
    0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0x00 | 0xp 8 | 0xpp | 0xpp | 0xpp | 0xpp | 0xpp

    p = Prozess data (outputs) for the correlating ASI slaves

  4. The KL6201 answers after execution of the ASI cycle with its input data (depending on host Fieldbus system, this status info may be delayed one or more cycles until it appears at the host controller)

Hint: A jumper-wire for closing both "Set" inputs is not necessary for process data exchange. During set up process, this is even obstructive, since the KL6201 only exchanges data with those ASi slaves the Bus Terminal found at the time the jumper-wire has been established.

For further information, please refer to KL6201 manual to be located under: http://www.beckhoff.com/english/download/busterm.htm


Hardware NT

Date | Article ID. | Article Selection
11/10/2000 | 00112801 | Shutdown of Windows NT
12/13/2000 | 00122802 | Restart of Windows NT
12/13/2000 | 00122803 | Obtaining the NT system time/date
12/13/2000 | 00122804 | Start a Windows application from the PLC
07/24/2000 | "TwinCAT UPS" | Configuration of UPS Types with different operating systems

back to the Hardware Overview


Shutdown of Windows NT

Date: 11/10/2000 Article ID:00112801

Question:

How can a shutdown of the Windows NT operating system be executed?

Answer:

With the function block NT_Shutdown.

See documentation: TwinCAT PLC Utilities Library

Note:

You have to install the complete Beckhoff Information System to be able to read these pages.


Restart of Windows NT

Date: 12/13/2000 Article ID:00122802

Question:

How can a restart of the Windows NT operating system be executed?

Answer:

With the function block NT_Reboot.

See documentation: TwinCAT PLC Utilities Library

Note:

You have to install the complete Beckhoff Information System to be able to read this pages.


Obtaining the NT system time / date

Date: 12/13/2000 Article ID:00122803

Question:

How can the current NT system time and the date of a TwinCAT System be obtained?

Answer:

With the function block NT_GetTime.

See documentation: TwinCAT PLC Utilities Library

Note:

You have to install the complete Beckhoff Information System to be able to read this pages.


Start a Windows application from the PLC

Date: 12/13/2000 Article ID:00122804

Question:

How can a Windows application be started from the PLC?

Answer:

With the function block NT_StartProcess.

See documentation: TwinCAT PLC Utilities Library

Note:

You have to install the complete Beckhoff Information System to be able to read this pages.


Hardware Profibus

Date | Article ID. | Article Selection
11/03/2000 | 00112501 | Profibus diagnosis
11/03/2000 | 00112502 | FC310x diagnosis example
11/03/2000 | 00112503 | Profibus BK3xxx
11/03/2000 | 00122504 | Profibus DP and MPI via an unshielded wire
12/05/2000 | 00122505 | BK31x0 in the pure Profibus DP
12/11/2000 | 00122506 | Profibus diagnosis on the BC3100 (Profibus status at the slave)
11/09/2000 | 00110909 | GSD (und EDS-) Boxen anfügen
11/13/2000 | 01110301 | KL6xxx example progam
06/25/2001 | 01062507 | Setting the node address
06/25/2001 | 01062508 | BC3100 without Profibus-DP
07/13/2001 | 01073006 | Programming BC3100
07/23/2001 | 01072509 | Diagnose data BK3xxx
07/28/2001 | 01072510 | S7-315 DP2 Profibus interface and special function terminals

back to the Hardware Overview


Profibus diagnosis

Date: 11/03/2000 Article ID:00112501

Question:

How do I execute a diagnosis at the Profibus?

Answer:

With the function block ADSREAD

The following settings of the I/O devices have to be made:

BK3100 with a CP5412

NetID ''
Port 300
Index Group 5001 ( 5000 + ID of the card CP5412, here 1)
Index Offset 16# 0003 0100 (0003 because the station address of the device is 2 in this picture+ 0100 as fix value.)

ID of the card

station address of the Coupler

BK3100 with a FC3100x

Net ID 1 (NetID of the card FC310x, here 1)
Port 200
Index Group 0xF100
Index Offset 2 (station address of the BK3100, here 2)

Net ID of the card

Further information about the funktion block in the in documentation TwinCAT PLC Library: System.


FC310x diagnosis example

Date: 11/03/2000 Article ID:00112502

Question:

How are the diagnosis data with the FC310x under TwinCAT be read and interpreted?

Answer:

See Example program.

Reading the diagnosis data (function block FCxxxxBoxDiag) and interprating of a slave (function block DecodeDpExtDiagData) with a FC310x.


Profibus BK3xxx

Date: 11/03/2000 Article ID: 00112503

Question:

What error is present if the outputs of the couplers flicker?

Answer:

If the outputs of the couplers flicker, the cause of the error can be the trigger of the watchdog.

The coupler and the terminals possess a watchdog (100 ms). If the coupler does not keep a valid telegram for longer than 100ms (possible causes: cycle time of the master too long or bus disturbances) the outputs are reset by the watchdog.

As soon as a telegram arrives once more the coupler is again active (flicker). Any flashing of the LED BF that may occur can be caused by an asynchronous or synchronous mode.


Profibus DP and MPI via an unshielded wire

Date: 12/06/2000 Article ID: 00122504

Question:

Is PROFIBUS DP and MPI via an unshielded wire possible?

Answer:

Unshielded wires with baudrates up to 19.2 kBaud can be used (e.g. using a FSK modem).


BK31x0 in the pure Profibus DP

Date: 12/05/2000 Article ID: 00122505

Question:

How can I operate a BK3100 or BK3110 in the pure Profibus DP?

Answer:

The following changes have to be made in the GSD file:

FMS_supp set zero.

Max_Input_Len = 128

Max_Output_Len = 128

Max_Data_Len = 256

Furthermore the register in the table 100 of the coupler has to be set from 0 to 1.

Note:

The GSD file can be found on our websites.


Profibus diagnosis on the BC3100 (Profibus status at the slave)

Date: 12/06/2000 Article ID: 00122506

Question:

Is a profibus diagnosis on the BC3100 possible?

Answer:

Yes, via the flags area:

MB508:
    Bit 0 	Offline/Passive-Idle
              0 = SPC3 is offline
              1 = SPC3 is passive-Idle

   Bit1 reserved
               Bit2 Diag_Flag
               0 = DP-Master read Diag. buffer
               1 = DP-Master read not Diag. buffer

       Bit3 RAM_Access_Violation
               0 = No Adress Err.
               1 = For adresses > 1536 Byte will be 1024 Byte

       Bit4,5 DP State
               00 = Wait_Prm
               01 = Wait_Cfg
               10 = DATA_EX
               11 = not possible

       Bit6,7 WD State
               00 = Baud_Search
               01 = Baud_Control
               10 = DP_Control
               11 = not possible

MB509:
    Bit0,1 	Baudrate3..0

    Bit2,3 		0000 = 12 MBaud ( SPC3 found Baudrate)
            0001 = 6 MBaud
            0010 = 3 MBaud
            0011 = 1,5 MBaud
            0100 = 500 KBaud
            0101 = 187,5 KBaud
            0110 = 93,75 KBaud
            0111 = 45,45 KBaud
            1000 = 19,2 KBaud
            1001 = 9,6 KBaud

    Bit 4 		SPC3_Release3..0:
    5,6 		Release_Nr.des SPC3
    7 		0000 = Release 0
            rest = not possible

MB510:

Klemmenbus-State:

Bit0 			0 = no Klemmbus Err.
            1 = Klemmbus Err.

Bit1 			0 = no boot Err.
            1 = boot Err.


Setting the node address

Date: 06/25/2001 Article ID: 01062507

Question:

How can the Profibus node address on the control unit of the Simodrive 611UE be set?

Answer:

The setting requires 3 steps:

1.) Set the profibus node address: The current value of the Profibus node address (P0918) is displayed, if you press the "P" key for more than 3 s. These settings can be chanched with the key '+' or '-' . ress the "P" key twice to leave the entry status

2.) Store the address in the FEPROM : Press the key '+' or '-' and the P0652 (takeover in the FEPROM) is displayed. With the key 'P', the parameter can be changed. Make the following settings (key '+'): P0652=1. Wait until P0652=0.

3.) Power On Reset

To do this, press the "Power On Reset" buttom on the front panel of the module. The Profibus node address set will be active after starting up the system.

Note:

These settings can be made if there are no fault or warning messages displayed.


BC3100 without Profibus-DP

Date: 06/28/2001 Article ID: 01062508

Question:

Is the BC3100 able to act as autarkic system without Profibus DP connection ( e.g. is it possible to go on working with a switched off bus), resp. how can this affect the efficiency of the integrated PLC?

Answer:

The BC3100 can operate as autarkic device. A turning-off of the bus system is non-interacting possible.


Diagnose data BK3xxx

Date: 07/23/2001 Article-ID: 01072509

Question:

The S7-315DP is the profibus master. Some BK3100 with digital and analog I/O´s are connected to it.

How can the diagnose data with the standard function block (FC13) from Siemens be decoded?

Answer:

The sense of the diagnose data is explained in the documentation "Profibus Bus Coupler BK3xxx", see appendix diagnose.

The documentation can be found on our websites.


S7-315 DP2 Profibus interface and special function terminals

Date: 07/28/2001 Article ID: 01072510

Question:

How can the following problem be solved?

The Siemens S7-315 DP2 Profibus interface cannot exchange data with modules maintaining data connections greater than 4 bytes in length in standard configured mode. This creates a problem with some of Beckhoff’s special function modules that exchange standard connection sizes greater than 4 bytes. The solution to this problem is to use special system function controls that allow extended data lengths.

Answer:

Step 1:

In order to implement the necessary controls, the profile of the node needs to be in standard exchange.

Figure 1

Step2:
SFC 14 and SFC 15 must be implement in your CPU code. SFC 14 will control the read process and SFC 15 will control the write process of the special function terminal. In the example below a KL1501 is setup to exchange its extended data length of 5 input bytes (SFC 14) and 5 output bytes (SFC 15).

Figure 2

The following are the descriptions of SFC14 and SFC15 arguments: SFC14: INO = “KL1501_T3_IN_ADD” This location maintains the beginning input address of the module. This is set during the Profibus commissioning phase. (32 hex = 50 =>start location IB50) OUT1 = This address is where the KL1501 data will be reported after this function is called. (MB100 for 5 bytes) RET_VAL = “KL1501_T3_IN_DIA” Memory location were the function diagnostics are stored. SFC15: INO = “KL1501_T3_OUT_ADD” This location maintains the beginning output address of the module. This is set during the Profibus commissioning phase. (32 hex = 50 =>start location QB50) OUT1 = This address is where the KL1501 data will be reported after this function is called. (MB104 for 5 bytes) RET_VAL = “KL1501_T3_OUT_DIA” Memory location were the function diagnostics are stored.

Figure 3 is an example of a KL1501 terminal with the above SFCs utilized.

Figure 3


Hardware Sercos

Date | Article ID. | Article Selection
11/03/2000 | 00110905 | Sercos and the meaning of the phases
12/13/2000 | 00122901 | Communication phase on the Sercos ring
12/13/2000 | 00122902 | Setting of the system parameters
12/13/2000 | 00122903 | Clearing errors from the Sercos Master
12/13/2000 | 00122904 | Phase start-up in the Sercos ring

back to the Hardware Overview


Communication phase on the Sercos ring

Date: 12/13/2000 Article ID:00122901

Question:

How can the current communication phase on the sercos ring be determined?

Answer:

With the function block IOF_SER_GetPhase

See documentation: TwinCAT PLC Library: IO Functions

Note:

You have to install the complete Beckhoff Information System to be able to read this pages.


Setting of the system parameters

Date: 12/13/2000 Article ID:00122902

Question:

How can system parameters in the EEPROM be set appropriately for the application by the controller?

Answer:

With the function block IOF_SER_SaveFlash

See documentation: TwinCAT PLC Library: IO Functions

Note:

You have to install the complete Beckhoff Information System to be able to read this pages.


Clearing errors from the Sercos Master

Date: 12/13/2000 Article ID:00122903

Question:

How can drives errors, diagnostic errors and system errors from a Sercos master be deleted?

Answer:

With the function block IOF_SER_Reset Err

See documentation: TwinCAT PLC Library: IO Functions

Note:

You have to install the complete Beckhoff Information System to be able to read this pages.

Note:

This function does not exist at the Beckhoff master cards FC7501and FC7502 (PCI).


Phase start-up in the Sercos ring

Date: 12/13/2000 Article ID:00122904

Question:

How can the phase start-up in the SERCOS ring be carried out?

Answer:

With the function block IOF_SER_SetPhase

See documentation: TwinCAT PLC Library: IO Functions

Note:

You have to install the complete Beckhoff Information System to be able to read this pages.


Device diagnosis, status word

Date: 12/12/2001 Article-ID:01123401

Question:

What is the structure of the diagnosis status word?

Answer:

Status- word | Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bit 11 | Bit 10 | Bit 9 | Bit 8 | Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0
 | F | Ext. Diag |  |  | Diag |  | Channel |  | Terminal number

Terminal number: supplies the position of the terminal inside the terminal block.
Channel supplies the signal channel
Diag(nosis) supplies the diagnosis code.
Ext(ended) Diag(nosis) supplies the extended diagnosis code.
F(ai)l supplies of an error occurred ( F = 1 ) or has been corrected ( F = 0 ).

Each change of the terminal state (at digital terminals like KL2012), creates a diagnosis (also the change fail 1 -> 0).

The meaning of the diagnosis code depends on the terminal type ( only implemented for digital terminals).


Device diagnosis, Controlword

Beckhoff Knowledge Base: Hardware BKxxxx

Device diagnostics, Controlword

Date: 12/12/2001 Article-ID:01123402

Question:

How is the diagnostics Controlword constructed?

Answer:

Controlword | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
 | -- |  |  |  |  |  |  |  | C | -- | -- | -- | -- | -- | -- | Q

Q(uit) Quits the current diagnostics message.
C(lear) Deletes the content of diagnostics FIFO.

Any modifications detected in the terminal status (for digital terminals such as KL2012) are stored in a FIFO with a size of n (32) words and transferred to the fieldbus via the diagnostics status word (currently supported by Bx20xx, BK40xx, BK5220, Bx7300, Bx9000, CP903x and CPx8xx). Each diagnosis must be acknowledged by the fieldbus via the diagnostic control word before a new diagnosis can be entered in the status word. Both the status word and the control word lie within the process images at fixed defined offsets (bus coupler-dependent).

An error message is not entered a second time in the FIFO until it has been transferred from the diagnostics FIFO.

If a diagnosis is acknowledged via the diagnostic control word, the pending diagnosis will be deleted. As soon as the acknowledgment is withdrawn, any pending new diagnosis will be mapped in the diagnostic status word.


Adjustable Parameters (BK20xx, BC20xx)

Date: 12/12/2001 Article-ID:01123403

Question:

What has to be configured internally at BK2000, BK2020 or BC2000 to activate the extended diagnostics functions?

Answer:

To display status information of digital terminals with confirmation features, the following settings have to be done:

 |  | Description | Default values
Terminal number | 0 |  |
Table number | 0 | Rd/Wr with software write protection |
Register number | 2 | K-bus |
 | 2.0 | Autoreset | 0
 | 2.1 | Device diagnostics | 1
 | 2.2 | Mapping of diagnostics data in the process image | 1


Adjustable Parameters (BK4000)

Date: 12/12/2001 Article-ID:01123404

Question:

What has to be internal configured at a BK4000, to activate the extended diagnostics functions?

Answer:

To display the status information of digital terminals with confirmation features, the following settings have to be done:

 |  | Descriptiuon | Default values
Terminal number | 0 |  |
Table number | 100 | Rd/Wr with software write protection |
Register number | 1 | Fieldbus specific diagnostics message |
 | 1.0 | Set ports "StatErr" if diagnostics occurs | 0


Hardware: BKxxxx

Date | Article-ID. | Article Selection
12/12/2001 | 01123401 | Gerätediagnose, Statuswort
12/12/2001 | 01123402 | Gerätediagnose, Controlwort
12/12/2001 | 01123403 | Einstellbare Parameter (BK20xx, BC20xx)
12/12/2001 | 01123404 | Einstellbare Parameter (BK4000)

back to hardware overview


Hardware Ethernet

Date | Article ID. | Article Selection
17.07.2001 | 01073101 | under preparation

back to the Hardware Overview


Hardware DeviceNet

Beckhoff Knowledge Base: Hardware IPxxxx

Hardware IPxxxx

Date | Article Id | Article Selection

back to the Hardware Overview


Hardware Communication

Date | Article ID. | Article Selection
 | 00112401 | under preparation

back to the Hardware Overview

Further Information about Communication under TwinCAT Communication.


Hardware Industrial PC

Date | Article ID. | Article Selection
 |  | under preparation

back to the Hardware Overview


Hardware RS485/232

Date | Article ID. | Article Selection
 |  | under preparation

back to the Hardware Overview


TwinCAT ADS DLL

Date | Article ID. | Article Selection
06/27/2001 | 01060104 | The ADS DLL application hangs when Windows 2000 is shutdown

back to the TwinCAT Overview


ADS-OCX in Delphi Applications I

Date: 11/09/2000 Article ID:00110701

Question:

Which ADS-OCX methods, properties and events cannot be used in Delphi?

Answer:

The following properties, methods and events cause errors in Delphi applications, and must not be used. As can be seen in the table, either the latest version of Delphi should be used, or certain functionalities must be omitted. There are a variety of a updates for the Delphi versions listed, and these may correct certain errors.

 | Error descriptions | Workaround | Delphi version
Properties |  |  | 3.0 | 4.0 | 5.0 | 6.0
AdsClientType | There is a memory leak when accessing this property.Memory space for the return string is not correctly allocated. | n/a | Bug | ? | Fixed |
AdsClientAdsState | There is a memory leak when accessing this property.Memory space for the return string is not correctly allocated. | n/a | Bug | ? | Fixed |
AdsClientAdsControl | There is a memory leak when accessing this property.Memory space for the return string is not correctly allocated. | n/a | Bug | ? | Fixed |
AdsServerAdsControl | There is a memory leak when accessing this property.Memory space for the return string is not correctly allocated. | n/a | Bug | ? | Fixed |
AdsServerAdsState | There is a memory leak when accessing this property.Memory space for the return string is not correctly allocated. | n/a | Bug | ? | Fixed |
AdsServerType | There is a memory leak when accessing this property.Memory space for the return string is not correctly allocated. | n/a | Bug | ? | Fixed |
AdsServerLastMessage | There is a memory leak when accessing this property.Memory space for the return string is not correctly allocated. | n/a | Bug | ? | Fixed |
AdsAmsClientNetId | There is a memory leak when accessing this property.Memory space for the return string is not correctly allocated. | n/a | Bug | ? | Fixed |
AdsAmsServerNetId | There is a memory leak when accessing this property.Memory space for the return string is not correctly allocated. | n/a | Bug | ? | Fixed |
Methods |  |  |  |  |  |
All AdsOcx methds | All functions (ADSOCXLib_TLB) returns undefined return values. | Please install Delphi 6 Update Pack 2 |  |  | no Bug | Bug
AdsSyncReadReq | These methods allow variables of any type to be transferred to the PLC or to be read from the PLC. The OleVariant parameters, however, are passed by value and not by reference by the AdsSyncReadReq method. This means that the method cannot alter the value of the data parameter during the call. Although it is true that the PLC variables are copied into a corresponding OleVariant variable during the call, that variable is only a copy of the actual variable from the current parameter list. The method prototypes for the ADS-OCX are generated automatically by the Delphi development environment when the ADS-OCX is linked, and cannot be modified. | Use the "released" methods to have synchronous access the PLC variables (e.g. AdsSyncReadIntegerReq() etc. ). | Bug | ? | Bug |
AdsSyncWriteReq
AdsReadVarConnectEx | Similarly to the process for the AdsSync methods, the OleVariant parameters in the event functions are passed by value and not by reference. | Use the AdsReadVarConnectEx2 method. | Bug | ? | Bug |
Events |  |  |  |  |  |
AdsReadConnectUpdateEx | An access violation is generated when the event function is called. | Use the AdsReadConnectUpdateEx2 event function. | Bug | ? | Bug |


ADS-OCX in Delphi Applications II

Date: 11/09/2000 Article ID:00110702

Question:

How can I open the properties page?

Answer:

The properties page is opened under Delphi as follows:

procedure TForm1.ShowPropertyButtonClick(Sender: TObject);
begin
    AdsOcx1.BrowseProperties();
end;


ADS-OCX in Delphi Applications III

Date: 11/09/2000 Article ID: 00110703

Question:

How can I write an array into the PLC, or read one out the PLC?

Answer:

Use the "released" methods for particular data types. If you want, for example, to read an array in the PLC of type INT, then the following methods may be used, depending on the access type:

AdsSyncReadIntegerVarReq( hVar : Integer, length : Integer, var pData : Smallint )

AdsSyncReadIntegerReq( indexGroup : Integer, indexOffset : Integer, length : Integer, var pData : Smallint )

AdsSyncWriteIntegerVarReq(hVar : Integer, length : Integer, var pData : Smallint )

AdsSyncWriteIntegerReq( indexGroup : Integer, indexOffset : Integer, length : Integer, var pData : Smallint )

AdsReadIntegerReq( nInvokeId : Integer, nIndexGroup : Integer, nIndexOffset : Integer, cbLength : Integer )

AdsWriteIntegerReq( nInvokeId : Integer, nIndexGroup : Integer, nIndexOffset : Integer, cbLength : Integer, var pData : Smallint )

String arrays cannot be accessed in this way. The length of the data that is to be read or written may be found from the number of elements that are to be read or written, multiplied by the byte-size of each element. This length must be passed in the length or cbLength parameters. The parameter pData is used to pass the first element of the Delphi array.

Example:

PROGRAM MAIN
VAR
    varIntArray :ARRAY[1..9] OF INT:=9(1);
END_VAR

Delphi program:

Reading an array from the PLC:

procedure TForm1.SyncReadArrayVarButtonClick(Sender: TObject);
var i, hVar, AdsResult:integer;
    varIntArray       : ARRAY[1..9] OF Smallint;
begin
    AdsResult := AdsOcx1.AdsCreateVarHandle( 'MAIN.VARINTARRAY', hVar );
    if AdsResult = 0 then
    begin
        AdsResult := AdsOcx1.AdsSyncReadIntegerVarReq( hVar, sizeof(varIntArray), varIntArray[1] );
        if AdsResult = 0 then
        begin
            ListBox1.Clear();
            for i:=1 to 9 do
                ListBox1.Items.Add( Format('varIntArray[%d] = %d', [i, varIntArray[i]] ) );
        end
        else Label1.Caption := Format('AdsSyncReadIntegerVarReq error:%d', [AdsResult] );
        AdsOcx1.AdsDeleteVarHandle( hVar );
    end
    else Label1.Caption := Format('AdsCreateVarHandle error:%d', [AdsResult] );
end;

Writing an array into the PLC:

procedure TForm1.SyncWriteArrayVarButtonClick(Sender: TObject);
var i, hVar, AdsResult:integer;
    varIntArray       : ARRAY[1..9] OF Smallint;
begin
    for i:=1 to 9 do
        varIntArray[i] := i;

    AdsResult := AdsOcx1.AdsCreateVarHandle( 'MAIN.VARINTARRAY', hVar );
    if AdsResult = 0 then
    begin
        AdsResult := AdsOcx1.AdsSyncWriteIntegerVarReq( hVar, sizeof(varIntArray), varIntArray[1] );
        if AdsResult > 0 then
            Label1.Caption := Format('AdsSyncWriteIntegerVarReq error:%d', [AdsResult] );
        AdsOcx1.AdsDeleteVarHandle( hVar );
    end
    else Label1.Caption := Format('AdsCreateVarHandle error:%d', [AdsResult] );
end;


ADS-OCX in Delphi Applications IV

Date: 11/09/2000 Article ID:00110704

Question:

How can I write a string into the PLC, or read one out the PLC?

Answer:

The actual length of a PLC string can be determined using the PLC operator SIZEOF. Within the PLC the strings are terminated with a null, and the actual string length is calculated from the defined length plus 1. If no length is given when the string is defined, then a string has an actual length of 81 characters, including the final null.

Example:

PROGRAM MAIN
VAR
    strColor 		:STRING(10)	:='Blue';
    strState 		:STRING(20)	:='STOP';
    strMessage 	:STRING		:='TwinCAT ADS-OCX';
END_VAR

strColor has a length of 11 characters;

strState has a length of 21 characters;

strMessage has a length of 81 characters;

Delphi program:

Reading a string from the PLC:

procedure TForm1.ReadStringButtonClick(Sender: TObject);
var hVar        : Integer;
    varString   : WideString;
    AdsResult   : Integer;
begin
    SetLength( varString, 7 );
    AdsResult := AdsOcx1.AdsCreateVarHandle( 'MAIN.STRMESSAGE', hVar );
    if AdsResult = 0 then
    begin
        AdsResult := AdsOcx1.AdsSyncReadStringVarReq( hVar, Length(varString)*2, varString );
        if AdsResult = 0 then
            Edit1.Text := varString
        else Label1.Caption := Format('AdsSyncReadStringVarReq error:%d', [AdsResult] );
        AdsOcx1.AdsDeleteVarHandle( hVar );
    end
    else Label1.Caption := Format('AdsCreateVarHandle error:%d', [AdsResult] );
end;

In the example above, seven characters of a PLC string were read in Delphi. The dynamic string types have a length of zero immediately after initialisation. The Delphi string variable must first be allocated the correct length if the ADS-OCX is to be able to copy the PLC string into the Delphi string variable. In Delphi, a WideString variable requires two bytes for each character. The length function returns the number of allocated characters in the string. The Length parameter in the method call, however, requires the length in bytes, and the length determined by the length function is therefore doubled.

Writing a string into the PLC:

procedure TForm1.WriteStringButtonClick(Sender: TObject);
var hVar        : Integer;
    varString   : WideString;
    AdsResult   : Integer;
begin
    varString:=Edit1.Text;
    AdsResult := AdsOcx1.AdsCreateVarHandle( 'MAIN.STRMESSAGE', hVar );
    if AdsResult = 0 then
    begin
        AdsResult := AdsOcx1.AdsSyncWriteStringVarReq( hVar, Length(varString)*2, varString );
        if AdsResult > 0 then
            Label1.Caption := Format('AdsSyncWriteStringVarReq error:%d', [AdsResult] );
        AdsOcx1.AdsDeleteVarHandle( hVar );
    end
    else Label1.Caption := Format('AdsCreateVarHandle error:%d', [AdsResult] );
end;


ADS-OCX in Delphi Applications VI

Date: 11/09/2000 Article ID:00110702

Question:

Do I have to fetch the handle for the PLC variable every time?

Answer:

No. All the required handles can be fetched once at the start of the application, and released again when the application is closed. Continuously requesting and releasing handles places unnecessary loading on the system.

Handles that have already been requested become invalid when TwinCAT is restarted, and must be requested again. The same applies after 'Rebuild All' in the PLC. 'Rebuild All' causes a complete new program to be loaded into the runtime system, so that any handles that have already been requested are invalid, and are automatically released by TwinCAT. The handles that are no longer required must always be released. This can, however, only be done if the TwinCAT system is still running. If the TwinCAT system has already stopped, then all the handles are automatically released.

Connect with the first runtime system on the local PC and fetch the handle of the PLC variables:

procedure TForm1.FormCreate(Sender: TObject);
begin
    AdsOcx1.AdsAmsServerNetId := AdsOcx1.AdsAmsClientNetId;
    AdsOcx1.AdsAmsServerPort := 801;
    AdsOcx1.AdsCreateVarHandle( 'MAIN.VARINTARRAY', hVar );
end;

Release the handle when the application is closed:

procedure TForm1.FormDestroy(Sender: TObject);
begin
    AdsOcx1.AdsDeleteVarHandle( hVar );
end;


ADS-OCX in Delphi Applications VII

Date: 09.04.2001 Article ID:01040707

Question:

Following a program error, it is not possible to reset the application from the development environment. What can be done about this?

Answer:

Following a program error it is often not possible to use the usual "Start->Program Reset" operating function. The following message is given by the debugger:

The cause of this is that using the ADS-OCX generates a client-server connection to the TwinCAT router, and this must be closed when the application stops. The Delphi application cannot be closed using the "Program Reset" menu command, because at this point there is a connection to the TwinCAT router. Their connection is generated in the application through the assignment of the AdsAmsNetId and the port number.

The following methods may be used to close the application without having to restart the computer:

  • First confirm the runtime error with OK, then stop the TwinCAT system via the task bar, and then reset the Delphi application. This causes existing connections to the clients to be closed. The disadvantage is that the TwinCAT system and the PLC must then be restarted;
  • First confirm the runtime error with OK, then call the Router Cleanup via the task bar, and then reset the Delphi application;
  • Make use of exception handling. The AdsAmsDisconnect() can be used to explicitly close the connection to the router;
        try
        n:=8; Switch[n].Tag:=0; // This index is not allowed
    except
        on EAccessViolation do
        begin
            AdsOcxSPS.AdsAmsDisconnect();
            Application.Terminate();
        end;
    end;


ADS-OCX in Delphi Applications VIII

Date: 09.04.2001 Article ID: 01040708

Question:

I would like to read a number of boolean variables into a Delphi array with one access, but only the first element is ever returned.

Answer:

Multiple boolean PLC variables can be read into Delphi applications with one access, provided the variables are stored at addresses that are sequentially located in the memory. It is, however, important that the first variable is located at a byte address:

varBoolean AT%MB6 : ARRAY[1..4] OF BOOL;

Delphi Application

procedure TForm1.Button3Click(Sender: TObject);
var 	i, hVar, AdsResult:integer;
    varBoolArray : ARRAY[1..4] OF WordBool;
begin
    AdsResult := AdsOcx1.AdsCreateVarHandle( 'MAIN.VARBOOLEAN', hVar );
    if AdsResult = 0 then
    begin
        AdsResult := AdsOcx1.AdsSyncReadBoolVarReq( hVar, sizeof(varBoolArray), varBoolArray[1] );
        if AdsResult = 0 then
        begin
            ListBox1.Clear();
            for i:=1 to 4 do
            ListBox1.Items.Add( Format('varBoolArray[%d] = %d', [i, Ord(varBoolArray[i])] ) );
        end
        else Label1.Caption := Format('AdsSyncReadBooleanVarReq error:%d', [AdsResult] );
    end;
end;


Installing the ADS OCX

Date: 09.04.2001 Article ID: 01040709

Question:

Can I install the ADS OCX without rebooting the computer?

Answer:

The ADS OCX can be installed with Regsvr32. The path to the file that is to be registered must be stated.

It is not necessary to reboot the computer.


TwinCAT OCX

Date | Article ID. | Article Selection
11/09/2000 | 00110705 | ADS-OCX in Delphi Applications V
06/27/2001 | 01060710 | The ADS OCX application hangs when Windows 2000 is shutdown
02/20/2004 | 04020711 | Method AdsSyncReadBoolVarReq does not supply data in Borland Builder 6 applications

back to the TwinCAT Overview


Memory requirement TON, TOP

Beckhoff Knowledge Base: PLC Control

Memory requirement TON, TOF

Date: 06/11/2001 Article ID: 01060803

Question:

How large is the memory requirement of the function TON or TOP under TwinCAT?

Answer:

The function TON or TOP requires 15 byte data.


BC9000: Data memory too small

Date: 06/12/2001 Article ID:01060805

Question:

During translation you receive the message that your data memory is not large enough. How can the data memory be increased?

Answer:

You can increase this in PLC Control, under the menu item "Project -Options - Bus Controller", where you push the slider to the left, or where you activate the "Large model".


BC9000: Program memory too small

Date: 06/12/2001 Article ID:01060806

Question:

During translation you receive the message that your program memory is not large enough. How can the program memory be increased?

Answer:

You can increase this in PLC Control, under the menu item "Project -Options - Bus Controller", where you push the slider to the right, or where you activate the "Large model".


Error message: array too large

Date: 06.07.2001 Article ID:01070809

Question:

How can I define an array larger than 1 MB?

The following errors occurs after compilation:

The global Variables need too much storage.

Answer:

You have to increase the value "data"' under "Project" --> "Options" --> "TwinCAT".

Afterwards you have to save the project, close and reopen. Then the array will be compiled accurate

The problem with close and reopen wiil be removed in the TwinCAT Version > TwinCAT 2.7 Build 459


Automatic logging into Windows NT

Date: 12/12/2000 Article ID:00121103

Question:

How can I log into Windows NT automatically?

Answer:

Automatic logging in (Auto Logon) under Windows NT can be set via the configuration of the TwinCAT system properties.

An appropriate change must be made on the 'System' tab of the 'TwinCAT System Properties' for this purpose.

Settings:

You open this tab by clicking with the mouse on the TwinCAT Real-time Server, and activate the Properties menu.

The following window then opens:

Here you select 'Enable Auto Logon' and enter your user name and your password. Windows NT accepts this setting once you confirm with 'OK'. If you do not enter a password at this stage, the automatic login will only function once (this is a property of Windows NT).

Cancelling automatic logging in:

In order to stop automatic logging in although the setting has been made, it is necessary to hold the shift key pressed during the login. This interrupts the Auto Logon, and you can then log into Windows NT in the usual way.


Starting TwinCAT without mouse

Date: 12/05/2000 Article ID:00121104

Question:

How can I start the TwinCAT System Manager or the TwinCAT PLC Control without using a mouse?

Answer:

With Alt and ( [NUM] + ) the TwinCAT real-time server can be started.


TwinCAT and Windows NT

Date: 06.03.2002 article ID: 02031116

Question:

How does Windows NT deal with the various priorities and execution times involved in task execution?

Answer:

The following diagram illustrates an example of execution times.

Task 1, which has higher priority, is run in every cycle. The remaining time available for task execution is used by Task 2 (which has lower priority). The execution time for Windows NT remains a constant 50% in each cycle.


TwinCAT and Windows NT

Date: 06.03.2002 article ID: 02031117

Question:

How are task execution, and the execution time, handled under Windows NT?

Answer:

The following diagram illustrates an example of execution times.

The execution time for NT starts when task execution has finished, but at the latest halfway through the available period (50%). If execution of the task needs more time than the 50% that has been set, it is interrupted to give time to Windows NT, and completed in the following cycle. If no task is being run in any particular cycle, Windows NT can use 100% of the available computing time.


TwinCAT and Real-time

Date: 03/15/2002 Article-ID: 02031118

Question:

Can TwinCAT be used without executed real-time? Which restrictions will arise from that?

Answer:

TwinCAT can be used without executed real-time.

After successfull installation of TwinCAT, the base time in real-time settings in the System Manager has to be set to none.

Thereby the real-time will not be executed.

Implementations which don´t need real-time, work as usual (AMS Router, TwinCAT Scope, ADS OCX, ...)

Restricitions:

Real-time tasks, like PLC tasks, software tasks and I/O tasks (Profibus, DeviceNet, Sercos or Lightbus) can not be executed.


CAN Box Reset

Date: 11/03/2000 Article ID: 00110904

Question:

How can I execute a CAN Box reset?

Answer:

CAN box Reset takes place in 8 steps.

1. Step:

At first, you have to add the box. Open the dialog box under the device (here FC510x, CANopen Master, PCI).

2. Step:

Choose 'CANopenNode' in the diaolg 'Insert device'.

3. Step:

The box has 2 inputs and outputs. You have to delete TxPDO1, TxPDO2 and RxPDO1.

4. Step:

The apporpriately tab must have the following settings:

5. Step:

At the output RxPDO1 tab, the COB ID must be set to zero.

6. Step:

When you open the dialog box under RxPDO 1 'outputs' , you can insert further variables.

7. Step:

The appropriately tab must have the following settings:

8. Step:

Mapping

This is the appropriately representation.

Thus CAN box RESET is terminated.


SERCOS and the meaning of the phases

Date: 11/03/2000 Article ID: 00110905

Question:

What do the individual phases mean during the initialisation between master and drive?

Answer:

SERCOS is based on optical fibre technology (OFT) and has a very deterministic time-wise performance. In order to achieve this time-wise performance, parameters are exchanged during the initialisation in several phases between master and drive. The meanings of the individual phases are presented in the following table.

Phase | Description
0 | - In this phase a check is made whether the optical fibre ring is physically closed
1 | - The addresses of the drives in the ring are checked for clarity. Here each drive must acknowledge the receipt of a telegram addressed to it.
2 | - Each drive enters into acyclic data exchange with the master. The times for the time slot calculation that are held in the drive are interrogated - The master calculates the time slots and writes the specific values back into the respective drive - If Startup parameters are indicated, these are now written down into the drive
3 | - The calculated timing is active from now on - Process data are not yet active / valid
4 | - Process data are valid from now on - Via Ctrl/Stat bits the drive can now be placed in control - The initialisation is complete

Further information concerning SERCOS under TwinCAT can be found in: TwinCAT System Manager - Reference.


Settings of the BC2000

Date: 12/11/2000 Article ID: 00120909

Question:

How can I merge the BC2000 in the TwinCAT system manager?

Answer:

basic properties:

The basic properties of the bus terminal controller are handled in the system manager. The terminals of the bus terminal controller can be assigned directly to the Lightbus master or to the BC2000. Terminals that are assigned directly to the BC2000 are displayed in the system manger with "PLC", and are not visible to the master. A further distinction between "Complex" and "Compact" is also made in the analogue terminals.

Complex: complete representation of the analogue terminals with control/status, 4 bytes input/output per channel

Compact: user data only, 2 bytes per channel

The terminals that are assigned to the master are invisible to the bus terminal controller. If it is desired to make a terminal visible to both systems, the terminal must first be assigned to the BC2000, and then the data from the terminal are transmitted to the master via the PLC variables.

The settings for the PLC in the bus terminal controller are found under the "PLC" tab. All the basic settings that control the properties of the PLC in the BC2000 are handled there.

PLC Cycle Time

The PLC cycle time determines the program's repetition frequency. This time is not deterministic. This means that when the program in the bus terminal controller needs more time, the PLC cycle time rises. If the program needs less than the cycle time, it is repeated at intervals of the set cycle time.The processing of the Lightbus and the serial interfaces is executed in the background time. This should be set to approx. 20 % of the PLC cycle time.

The "mean cycle time" is measured in order to optimise the system. You will find this item in PLC Control under Online\Coupler. About 20% - 30% is added to this, and the result entered as the PLC cycle time. The background time is then set to 20% of the PLC cycle time.

PLC cycle time = mean cycle time + 20% = 10 ms + 20% = 12 ms
Background time = PLC cycle time * 0,2 = 12 ms * 0,2 = 2,4 ms " 2 ms

Mean cycle time

The measured cycle time also includes that required for the terminal bus update. This results in a connection between the number of terminals that are inserted and the cycle time. Before initiating the program, the bus terminal controller executes a terminal bus update, in order to interrogate the inputs. After the program has been executed, the BC2000 carries out another terminal bus update, in order to write the current outputs. The background time follows this. The cycle time can also be shortened, if the terminal bus update is carried out simultaneously for inputs and outputs (see Terminal Bus Update).

PLC Variables

PLC variables are variables that are situated in the BC2000 from addresses %IB128 and %QB128. This offset can be shifted. These addresses are not assigned to any terminal, so that signals or data can be transmitted to or received from the master via the PLC variables.

Remanent Variables

Retained or remanent variables are data that retain their value when voltage is not present. In PLC Control this data is placed in the allocated flags area. Following the default setting, this means that all the variables from %MB0 - %MB63 are RETAIN data. The maximum setting is 512 bytes

Terminal Bus (K-Bus) Update

Double Cycle: Terminal bus inputs before the PLC cycleTerminal bus outputs after the PLC cycle

Before PLC: Terminal bus inputs and outputs before the PLC cycle

After PLC: Terminal bus inputs and outputs after the PLC cycle

Program download via the fibre optic ring

TwinCAT offers a facility for transferring the program to the BC2000 over the optical fibre ring. To do this, string communication and the Ams/Ads must be activated in the system manager under the ADS/AMS tab. The TwinCAT system is started after the configuration has been saved. Now the BC2000 target system can be selected in PLC Control.

Selection of the target platform

When TwinCAT PLC Control is restarted, the program asks for the target platform, i.e. the device on which the user will want his program to run. TwinCAT offers two target platforms, the PC as a controller and the BC2000 coupler. For the program transfer with the bus terminal controller there are again two possibilities. "AMS" is for communication over the fieldbus, while the "serial" communication takes place via the PC's serial interface and the BC2000 programming interface.

Selection of the target system

Once the program has been written, the target system is selected under the "Online" symbol bar. In this example, the C1220 with the Box1 and the Run-Time1 of the bus terminal controller.

Program download via the RS232 interface

Every bus terminal controller offers the possibility of being programmed via the PC's RS232 interface. This can be implemented with the aid of a special cable. For this purpose, the serial interface is selected in PLC Control.

Communication parameters

The settings for the serial interface, port number, baud rate etc. are found under Online/Communication parameters in PLC Control.The bus terminal controller requires the following setting:

Baud rate: 19200

Stop bits: 1

Parity: even


Settings of the BC3100

Date: 05/22/2001 Article ID: 01050911

Question:

How can I merge the BC3100 in the TwinCAT system manager?

Answer:

basic properties:

The basic properties of the bus terminal controller are handled in the system manager. The terminals of the bus terminal controller can be assigned directly to the Lightbus master or to the BC3100. Terminals that are assigned directly to the BC3100 are displayed in the system manger with "PLC", and are not visible to the master. A further distinction between "Complex" and "Compact" is also made in the analogue terminals.

Complex: complete representation of the analogue terminals with control/status, 4 bytes input/output per channel

Compact: user data only, 2 bytes per channel

The terminals that are assigned to the master are invisible to the bus terminal controller. If it is desired to make a terminal visible to both systems, the terminal must first be assigned to the BC3100, and then the data from the terminal are transmitted to the master via the PLC variables.

If you merge the PLC variables, the following dialog opens. It determines the start address.

The settings for the PLC in the bus terminal controller are found under the "PLC" tab. All the basic settings that control the properties of the PLC in the BC3100 are handled there.

PLC Cycle Time

The PLC cycle time determines the program's repetition frequency. This time is not deterministic. This means that when the program in the bus terminal controller needs more time, the PLC cycle time rises. If the program needs less than the cycle time, it is repeated at intervals of the set cycle time.The processing of the Lightbus and the serial interfaces is executed in the background time. This should be set to approx. 20 % of the PLC cycle time.

The "mean cycle time" is measured in order to optimise the system. You will find this item in PLC Control under Online\Coupler. About 20% - 30% is added to this, and the result entered as the PLC cycle time. The background time is then set to 20% of the PLC cycle time.

PLC cycle time = mean cycle time + 20% = 10 ms + 20% = 12 ms
Background time = PLC cycle time * 0,2 = 12 ms * 0,2 = 2,4 ms " 2 ms

Mean cycle time

The measured cycle time also includes that required for the terminal bus update. This results in a connection between the number of terminals that are inserted and the cycle time. Before initiating the program, the bus terminal controller executes a terminal bus update, in order to interrogate the inputs. After the program has been executed, the BC3100 carries out another terminal bus update, in order to write the current outputs. The background time follows this. The cycle time can also be shortened, if the terminal bus update is carried out simultaneously for inputs and outputs (see Terminal Bus Update).

PLC Variables

PLC variables are variables that are situated in the BC3100 from addresses %IB128 and %QB128. This offset can be shifted. These addresses are not assigned to any terminal, so that signals or data can be transmitted to or received from the master via the PLC variables.

Remanent Variables

Retained or remanent variables are data that retain their value when voltage is not present. In PLC Control this data is placed in the allocated flags area. Following the default setting, this means that all the variables from %MB0 - %MB63 are RETAIN data. The maximum setting is 512 bytes

Terminal Bus (K-Bus) Update

Double Cycle: Terminal bus inputs before the PLC cycleTerminal bus outputs after the PLC cycle

Before PLC: Terminal bus inputs and outputs before the PLC cycle

After PLC: Terminal bus inputs and outputs after the PLC cycle

Program download via the fibre optic ring

TwinCAT offers a facility for transferring the program to the BC3100 over the optical fibre ring. To do this, string communication and the Ams/Ads must be activated in the system manager under the ADS/AMS tab. The TwinCAT system is started after the configuration has been saved. Now the BC3100 target system can be selected in PLC Control.

Thus the PLC tab changes as follows:

If the program is larger, AMS Response during download must be selected.

After saving the configuration you can start the TwinCAT System. In the PLC Control it´s now possible to select the target system of the BC3100.

Selection of the target platform

When TwinCAT PLC Control is restarted, the program asks for the target platform, i.e. the device on which the user will want his program to run. TwinCAT offers two target platforms, the PC as a controller and the BC3100 coupler. For the program transfer with the bus terminal controller there are again two possibilities. "AMS" is for communication over the fieldbus, while the "serial" communication takes place via the PC's serial interface and the BC3100 programming interface. (Zu öffnen unter dem Karteireiter Resourcen -> Steuerungskonfiguration)

Selection of the target system

Once the program has been written, the target system is selected under the "Online" symbol bar. In this example, the FC310x with the Box1 and the Run-Time1 of the bus terminal controller.

Program download via the RS232 interface

Every bus terminal controller offers the possibility of being programmed via the PC's RS232 interface. This can be implemented with the aid of a special cable. For this purpose, the serial interface is selected in PLC Control

Communication parameters

The settings for the serial interface, port number, baud rate etc. are found under Online/Communication parameters in PLC Control. The bus terminal controller requires the following setting:

Baud rate: 19200

Stop bits: 1

Parity: even