The software is supplied to the user as described in this document. Any risks resulting from its quality or use remain the responsibility of the
user. The user must provide all safety measures protecting against possible maloperation.
We do not take any liability for direct or indirect damage, e.g. profit loss, order loss or any loss regarding business.
2001 Lenze GmbH & Co KG
No part of this documentation may be copied or made available to third parties without the explicit written approval of Lenze GmbH & Co KG.
All information given in this online documentation has been carefully selected and tested for compliance with the hardware and software
described. Nevertheless, discrepancies cannot be ruled out. We do not accept any responsibility or liability for any damage that may occur.
Required corrections will be included in updates of this documentation.
Windows, Windows NT and MS−DOS are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A and/or other countries.
IBM and VGA are registered trademarks of International Business Machines, Inc.
All other brand names are trademarks of the corresponding owners.
This manual contains information about the function library LenzeFpiDrv.lib for the Drive PLC
Developer Studio.
· The function library LenzeFpiDrv.lib contains functions for a freely programmable RS−232C
interface with the 2103 FP interface communication module.
· With the 2103 FP interface communication module the automation interface (AIF) of the
9300 Servo PLC / Drive PLC can be used as freely programmable RS−232C interface for
controlling printers, modems, measuring devices and other components equipped with a
serial RS−232C interface.
Tip!
For installation and technical data of the 2103 FP interface communication module please see the
Mounting Instructions.
1.1.1Conventions used in this Manual
This Manual uses the following conventions to distinguish between different types of information:
Variable identifiers
are shown in the explanatory texts in italics:
· Use byEndChar1 ..."
Tip!
for information about the conventions which are used for variables of Lenze system organization
units, function blocks and functions can be obtained from the appendix of the DDS online
documentation Introduction into IEC1131−3 programming". The conventions ensure universal and
uniform labelling and support the readability of PLC programs.
Functions
can be recognized by the names. They always begin with L_":
· The function L_Rs232Open..."
Program listings
are written in Courier", keywords are printed in bold:
· IF (ReturnValue < 0) THEN..."
l
LenzeFpiDrv.lib EN 1.1
1−1
LenzeFpiDrv.lib function library
Preface and general information
1.1.2Structure of function descriptions
All function descriptions given in this Manual have the same structure:
Headline stating the function and the function identifier
Declaration of the function:
· Data type of the feedback value
· Function identifier
· List of transfer parameters
Short description of the function and its most important features
Function chart including all corresponding variables (transfer parameters
and feedback value)
Table giving information about the transfer parameters:
· Identifier
· Data type
· Possible settings
· Info
Table giving information about the feedback value:
· Data type of the feedback value
· Possible feedback values and their meaning:
Note
If a function cannot be executed properly, a negative feedback value
which is an error number, will be sent.
· Every error number stands for an error reason which is shown under
Meaning".
· If different error numbers (−1, −2, ...) are possible, every error
number is assigned to a certain priority (1, 2, ...) Functions
– The lower the number, the higher the priority,
i. e. 1" stands for highest priority.
– If several error reasons occur at the same time, the error number
with the highest priority will be sent first.
More information about the function
(Notes, tips, application examples, etc.)
1.1.3Pictograms used in this Manual
Use of
pictograms
Warning of
material damage
Other notesTip!
Signal words
Stop!Warns of potential damage to material .
Note!
1.1.4Terminology used
TermIn the following text used for
DDSDrive PLC Developer Studio
FBFunction block
FP interfaceLenze 2103 FP interface communication module
GDCGlobal Drive Control (parameter setting program from Lenze)
Parameter codesCodes for setting the functionality of a function block
SBSystem block
Consequences if disregarded:
Damage of the controller/drive system or its environment
Indicates a tip or note.
.
1−2
LenzeFpiDrv.lib EN 1.1
l
LenzeFpiDrv.lib function library
Preface and general information
1.2Version identifiers of the function library
The version of the function library can be found under the global constant
C_w[Function library name]Version .
Version identifiers as of PLC software version 7.x:
· In the example, "01050000" stands for version "1.05".
Example
value
Version: 01050000
l
LenzeFpiDrv.lib EN 1.1
1−3
LenzeFpiDrv.lib function library
Preface and general information
1−4
LenzeFpiDrv.lib EN 1.1
l
LenzeFpiDrv.lib function library
General information about the RS−232C interface
2General information about the RS−232C interface
RS−232C stands for Recommended Standard−232C, which is an American Standard of the EIA
(Electronic Industries Association). It describes the serial connection between a DTE (Data TerminalEquipment) and a DCE (Data Communications Equipment) and all the electrical and mechanical
features.
· The RS−232C is often also described by the V.24/V.28, which is the international
recommendation of the CCITT (today knows as ITU − International Telecommunication Union).
The V.24 specifies the mechanical features and the V.28 the electrical features.
Although the standard RS−232C only describes the connection between a DTE and a DCE, the
RS−232C interface has been established as standard for serial data transmission over short
distances.
The following chapters inform about the mechanical and electrical features of the RS−232C interface
and the serial data transmission.
2.1Mechanical features
2.1.1Types of plug−in connectors
In general subminiature−D−plug−in connectors in 9 or 25−pole design are used as interface
connectors. They are distinguished as follows:
Master
(e. g. Lenze PLC with FP interface)
9−pole SubD connector (male)
or
25−pole SubD socket (female)
The FP interface requires a connection cable with a 9−pole SubD connector (male).
2.1.2Terminal assignment with a FP interface
9−pole SubD socket for RS−232C interface
PinDesignationInput/outputExplanation
1−−not used
2RxDInputReceive data
3TxDOutputSend data
4DTROutputno function (logic 0")
5GND−Reference potential
6DSRInputno function
7−−not used
8−−not used
9+ 5V−max. output current 50 mA
Slave
9−pole SubD socket (female)
l
LenzeFpiDrv.lib EN 1.1
2−1
LenzeFpiDrv.lib function library
General information about the RS−232C interface
2.2Electrical features
2.2.1Voltage level
The logical states of the individual bits are sent as voltage states via send or receive cables:
Logical stateVoltage levelMin. voltage level − sender*
1−3 ... −15 V−5 V
0+3 ... +15 V+5 V
The achievable distance between two RS−232C devices depends on the cable and baud rate used.
We recommend not to exceed a distance of 15 to 30 meters at a baud rate of 9600 baud.
2.2.2Baud rate/data transmission rate
The baud rate indicates how many bits are transferred per second. This figure together with the other
transmission parameters (number of stop bits/data bits and parity bit) result in the data transmission
rate which is usually indicated in characters per second.
The following table indicates the data transmission rates possible when using a FP interface for a
transmission with 8 data bits, 1 stop bit and even parity.
* With the FP interface every 250 ms a character can be sent, therefore a baud rate higher than 38400 baud cannot be recommended.
Transmission time per character
(ms)
Data transmission rate
(characters/s)
2−2
LenzeFpiDrv.lib EN 1.1
l
LenzeFpiDrv.lib function library
General information about the RS−232C interface
2.3Synchronous/asynchronous transmission mode
Serial data transmission distinguishes between synchronous and asynchronous transmission.
· Synchronous transmission mode:
The data transmission between sender and receiver is synchronised by means of a clock
pulse. Thus the data cannot be send quicker than received and processed by the receiver.
· Asynchronous transmission mode:
The data transmission is not synchronised by means of a clock pulse. The so−called
hand−shake method avoids data loss during the transmission.
The FP interface supports the asynchronous transmission mode only!
2.4Data flow check (handshake)
With asynchronous data transmission the receiver must be able to inform the sender that it is not
ready for processing new or more data. The data flow check is called handshake. There are two
different handshake methods:
· Hardware handshake:
The receiver controls the inputs CTS and/or DSR of the sender with its output DTR and/or RTS
via hardware cables.
– Advantage: transparent data transmission
– Disadvantage: additional cables required for the transmission of the handshake signals.
· Software handshake:
The recipient sends special characters to the sender to control the data flow, e. g. XON/XOFF.
(^ 2−5, ASCII character set)
– Advantage: Only data cables required for data transfer
– Disadvantage: The characters used for controlling the data flow must not be part of the user
data.
The FP interface supports the software handshake only!
2.5Transmission parameters
With a serial, asynchronous data transmission the character to be transmitted is transmitted via the
data cable as bit sequence:
· A bit sequence for a character is always started by a start bit which is send as logic "0".
· The character is then transmitted as sequence of 7 or 8 bits starting with the least significant
bit (LSB).
· The bit sequence for the character can be followed by a parity bit which can be used for
detecting transmission errors.
· The bit sequence is ended by one or 2 stop bits, which are always send as logic "1".
l
LenzeFpiDrv.lib EN 1.1
2−3
LenzeFpiDrv.lib function library
General information about the RS−232C interface
Example: Bit sequence/voltage level for a character to be transmitted
Character:A" (ASCII)
01000001 (bin)
65 (dez)
41 (hex)
Parity*:Even
Stop bits:2
Data bits:7
When using 7 data bits, a parity bit will always be created so that the setting No parity" (byParity = 0) is not admissible!
Character:A" (ASCII)
01000001 (bin)
65 (dez)
41 (hex)
Parity:Even
Stop bits:2
Data bits:8
+3...+15V
Start
−3...−15V
(Neutral level)
+3...+15V
Start
−3...−15V
(Neutral level)
LSB
Bit10Bit20Bit30Bit4
1
0
LSB
Bit10Bit20Bit30Bit4
1
0
0
0
Bit5
MSB1Parity0Stop1Stop
0
Bit50Bit6
MSB0Parity0Stop1Stop
1
2
2
For a successful communication between sender and receiver, the transmission parameters (baud
rate, data bits, parity bit, stop bits) must be set identically for both.
· The transmission parameters of the FP interface are configured using the function
L_Rs232Open.
Parity bit
(^ 3−1)
The parity bit serves as control bit for data transmission, similar to a check sum. We distinguish
between even and odd parities, a parity bit can be deactivated (parity None"):
· Even parity:
The sender transfers 0" as parity bit, if an even number of data bits with valency 1" has been
transferred.
· Odd parity:
The sender transfers 0" as parity bit, if an uneven number of data bits with valency 1" has
been transferred.
· None
No transfer of parity bits.
The parity bit can be used for a "Parity check":
During data transfer the sender determines the parity of the data bits. The parity bit "informs" the
receiver. The receiver calculates the parity of the data bits received and compares the parity with the
parity bit received. It is thus possible to detect transmission error in a bit (1−bit error). It is however
not possible to detect 2−bit errors (two wrong data bits have been transferred), since the parity does
not change.
2−4
LenzeFpiDrv.lib EN 1.1
l
General information about the RS−232C interface
2.6ASCII character set
2.6.1Standard
The following table shows the assignment of the standard ASCII character set (characters 0 − 127):
HEXDECCHARCTRLHEXDECCHARHEXDECCHARHEXDECCHAR
000NUL^@
011SOH^A2133!4165A6197a
022STX^B2234"4266B6298b
033ETX^C2335#4367C6399c
044EOT^D2436$4468D64100d
055ENQ^E2537%4569U65101e
066ACK^F2638&4670F66102f
077BEL^G2739’4771G67103g
088BS^H2840(4872H68104h
099HT^I2941)4973I69105i
0A10LF^J2A42*4A74J6A106j
0B11VT^K2B43+4B75K6B107k
0C12FF^L2C44,4C76L6C108l
0D1313CR^M2D45−4D77M6D109m
0E14SO^N2E46.4E78N6E100n
0F15SI^O2F47/4F79O6F111o
1016DLE^P304805080P70112p
1117DC1^Q314915181Q71113q
1218DC2^R325025282R72114
131319DC3^S335135383S73115s
1420DC4^T345245484T74116t
1521NAK^U355355585a75117amb
1622SYN^V365465686V76118v
1723ETB^W375575787W77119w
1824CAN^X385685888X78120x
1925EM^Y395795989Y79121y
1A26SUB^Z3A58:5A90Z7A122z
1B27ESC ^[3B59;5B91[7B123{
1C28FS ^\3C60<5C92\7C124|
1D29GS ^]3D61=5D93]7D125}
1E30RS ^^3E62>5E94^7E126~
1F31US ^_3F63?5F95_7F127DEL
2032SP4064@6096
LenzeFpiDrv.lib function library
l
LenzeFpiDrv.lib EN 1.1
2−5
LenzeFpiDrv.lib function library
General information about the RS−232C interface
2.6.2Extended, Latin−1
The following table describes the assignment of the extended ASCII character set
(Latin−1, characters 128 − 255):
Addresses within the memory range of the operating system are not permitted with the functions
L_Rs232SendData and L_Rs232ReceiveData !
Problem:
Also the system variable addresses (inputs/outputs) are in the memory
range of the operating system, in the following figure it is the system
variable AIN1_nIn_a:
L_Rs232SendData
wDrvNr
30
AIN1_nIn_a
ADR
pabySendDataMemory
wNumberOfBytes
2
Remedy:
Instead of using a system variable address, use an intermediate
variable address to copy the corresponding system variable value to.
AIN1_nIn_a
nAnalogInput
nAnalogInput
ADR
L_Rs232SendData
wDrvNr
30
pabySendDataMemory
wNumberOfBytes
2
L
LenzeFpiDrv.lib EN 1.1
3−5
LenzeFpiDrv.lib function library
Functions
3.4Send status (L_Rs232GetSendState)
3.4Send status (L_Rs232GetSendState)
INT L_Rs232GetSendState (wDrvNr)
Use this function to find out about the current status of a send order.
L_Rs232GetSendState
wDrvNr
Fig. 3−4Send status (L_Rs232GetSendState)
Transmission parameters
IdentifierData typePossible settingsInfo
wDrvNrWord30AIF interface
Feedback value
Data typeValueMeaningPriority
Integer
−1Wrong driver number ( wDrvNr ) or driver not initialised.−
0All data bytes have been sent, the memory is ready for further orders.
1 ... 32767Number of data bytes to be sent when a send order is active.
wBuffersizeWord2 ... 32767Size of the receive memory in bytes
wNumberOf
ReceiveBytes
wTimeOutWord2 ... 60000Time out time (in ms) for receiving data
byEndChar1Byte0 ... 255Character which defines the end of the data byte to be received.
byEndChar2Byte0 ... 255Character which defines the end of the data byte to be received.
Pointer to Array
of Byte
Word1 ... 32767Number of data bytes to be received
Pointer set onto the address in
the memory where the storage
of the received data bytes is to
start.
The address of a variable (e. g. data array) can be detected using
the address function ADR .
· The memory has a minimum size of two bytes.
· This parameter can be used for checking the end of data
reception (see wControl).
· This parameter can be used for checking the end of data
reception (see wControl).
· This parameter can be used for checking the end of data
reception (see wControl).
· This parameter can be used for checking the end of data
reception (see wControl).
L
LenzeFpiDrv.lib EN 1.1
3−7
LenzeFpiDrv.lib function library
Functions
3.5Receive data (L_Rs232ReceiveData)
IdentifierInfoPossible settingsData type
wControlWordEnd of receiving data after:Checking the end of data reception
Bit 0: wTimeOut
Bit 1: wNumberOfBytes
Bit 2: byEndChar1
Bit 3: byEndChar2
Return value
Data typeValueMeaningPriority
Integer
−6wControl is invalid since reserved bits have been overwritten.6
−5Time out time exceeds its limits (2 ... 60000 ms).5
−4Number of bytes to be received > receive memory (1 ... 32767) or
Number of bytes to be received = 0.
−3Receive memory size exceeds its limits (2 ... 32767).3
−2Pointer of receive memory does not point to PLC−RAM.2
−1Wrong driver number (wDrvNr) or driver not initialised.1
Note: If errors are caused by several problems, the error cause with the highest priority sends back the
corresponding feedback value.
0Receive order successfully transferred to operating system.
0: not active
1: active
0: not active
1: active
0: not active
1: active
0: not active
1: active
Bits 4−15 are reserved for future extensions
4
Receive/send check
The way of how to detect the end of receiving data and whether the unit is read for receiving data can
be configured with beendet wird, kann mit Hilfe von wControl :
Data reception is stopped whenwControlPriority
the memory is full. (This check test is always active.)1
a certain waiting time is over wTimeOut no bytes have been received0000 0000 0000 00012
the number of wNumberOfReceiveBytes bytes have been received0000 0000 0000 001x3
the character byEndChar1 has been received0000 0000 0000 010x4
the character byEndChar2 has been received0000 0000 0000 100x5
the character byEndChar1 and byEndChar2 have been received subsequently0000 0000 0000 110x6
(x: any status)
Example:
wControl = 0x0009
= 0000 0000 0000 100 1
hex
bin
End of receiving data wTimeOut is active
End of receiving data byEndChar2 is active
Caution!
Please ensure that the size of the created memory (e. g. an array) does not fall below value indicated
in wBuffersize since otherwise the check test of the memory limits will not work.
This can result in an impermissible overwriting of the memory and result in errors!
3−8
Receive memory is full
If the receive memory is full and data is sent to be received, the receiving process will be stopped
immediately. By this it is avoided that the memory is overwritten with received data.
LenzeFpiDrv.lib EN 1.1
L
LenzeFpiDrv.lib function library
Functions
3.5Receive data (L_Rs232ReceiveData)
TimeOut
The activation of this function starts a time out timer. The timer will be reset with every byte received.
If the time wTimeOut has expired without receiving data, a TimeOut error will be set and the unit is
no longer ready for receiving data.
NumberOfReceiveBytes
If wNumberOfReceiveBytes bytes have been received, the receiving process will be stopped.
Ending character (byEndChar1/byEndChar2)
With asynchronous data transmission, the data flow is checked by defining a start and an end
character between the sender and receiver. The end character indicates the end of a data package
sent and must be recognised accordingly by the receiver. Sometimes the end character consists of
a character pair.
Use byEndChar1 and byEndChar2 to define these end characters. The receiving process is over
when the defined end character is recognised by the receiver. The end characters are stored in the
receive memory.