Elatec TWN3M1 RFID Tag Reader User Manual TH TWN3 104

Elatec GmbH RFID Tag Reader TH TWN3 104

User Manual

Download: Elatec TWN3M1 RFID Tag Reader User Manual TH TWN3 104
Mirror Download [FCC.gov]Elatec TWN3M1 RFID Tag Reader User Manual TH TWN3 104
Document ID1040107
Application IDl+5zcf9eKomPfQdWKMsgig==
Document DescriptionUser Manual
Short Term ConfidentialNo
Permanent ConfidentialNo
SupercedeNo
Document TypeUser Manual
Display FormatAdobe Acrobat PDF - pdf
Filesize51.16kB (639526 bits)
Date Submitted2008-12-05 00:00:00
Date Available2008-12-05 00:00:00
Creation Date2008-11-04 10:50:34
Producing SoftwareAFPL Ghostscript 8.13
Document Lastmod2008-11-04 10:50:34
Document TitleTH_TWN3_104.doc
Document CreatorPDF-WRITER 1.0.010 (c) by Dirk Paehl Freeware

Transponder Reader
TWN3
Technical Manual
Rev. 1.04
Elatec GmbH
Content
1.
Introduction..................................................................................................................... 4
2.
Functional Overview....................................................................................................... 4
3.
Modes of Operation......................................................................................................... 5
3.1
USB-Device .............................................................................................................................. 6
3.1.1
3.1.2
3.2
V24-Device............................................................................................................................... 6
3.2.1
3.2.2
4.
Keyboard Emulation (USB HID Device).........................................................................................6
Emulating a Virtual Serial Port ........................................................................................................6
Serial Communication Parameters ...................................................................................................6
Pin Assignment ................................................................................................................................7
Installation ...................................................................................................................... 7
4.1
V24-Device............................................................................................................................... 7
4.2
USB-Device (Keyboard Emulation) ...................................................................................... 7
4.3
USB-Device (Virtual Serial Port) .......................................................................................... 8
5.
Configuration ................................................................................................................ 10
5.1
Starting Configuration Mode .............................................................................................. 10
5.2
Writing Configuration to a TWN3 Device ......................................................................... 11
5.3
Resuming Normal Operation............................................................................................... 12
5.4
Selecting Mode of Operation ............................................................................................... 13
5.5
Setting Up the Keyboard Emulation................................................................................... 14
5.5.1
5.5.2
Table of Scan Codes ......................................................................................................................14
Key Repeat Rate ............................................................................................................................15
5.6
Installing Scripts ................................................................................................................... 16
5.7
Miscellaneous Settings.......................................................................................................... 17
5.8
Updating the Firmware........................................................................................................ 18
5.9
Export and Import of Configurations................................................................................. 19
5.10
6.
Installing USB-Drivers for Configuration ...................................................................... 20
Transparent Mode......................................................................................................... 21
6.1
7.
HID Prox Transparent Protocol.......................................................................................... 22
Scripting ........................................................................................................................ 22
7.1
Language Description........................................................................................................... 22
7.1.1
Source Code...................................................................................................................................22
7.1.2
Comments ......................................................................................................................................23
7.1.3
Case Sensitivity..............................................................................................................................23
7.1.4
Preprocessor Directives .................................................................................................................23
7.1.4.1 #include Directive......................................................................................................................23
7.1.5
Functions........................................................................................................................................23
7.1.5.1 Return Values.............................................................................................................................23
7.1.5.2 Arguments..................................................................................................................................24
7.1.5.3 System Functions .......................................................................................................................24
7.1.5.4 Function main ............................................................................................................................24
7.1.6
Statements......................................................................................................................................24
7.1.6.1 if Statement ................................................................................................................................24
7.1.6.2 if else Statement .........................................................................................................................25
7.1.6.3 while Statement..........................................................................................................................25
Page 2 of 44
Elatec GmbH
7.1.6.4 do while Statement.....................................................................................................................25
7.1.6.5 for Statement..............................................................................................................................25
7.1.6.6 switch Statement ........................................................................................................................25
7.1.6.7 break Statement..........................................................................................................................26
7.1.6.8 continue Statement.....................................................................................................................26
7.1.6.9 return Statement .........................................................................................................................26
7.1.6.10
goto Statement .......................................................................................................................26
7.1.6.11
Labels.....................................................................................................................................26
7.1.6.12
Empty Statement ....................................................................................................................27
7.1.7
Storage Types ................................................................................................................................27
7.1.8
Storage Classes ..............................................................................................................................27
7.1.8.1 const...........................................................................................................................................27
7.1.8.2 secret ..........................................................................................................................................27
7.1.9
Operators .......................................................................................................................................28
7.2
Runtime Environment.......................................................................................................... 29
7.2.1
Include File ....................................................................................................................................29
7.2.2
Basic Definitions............................................................................................................................29
7.2.3
Bit Fields........................................................................................................................................29
7.2.4
Startup Condition...........................................................................................................................29
7.2.5
System Function Calls....................................................................................................................30
7.2.5.1 Transponder Operations.............................................................................................................30
7.2.5.1.1 Generally Available Transponder Operations .....................................................................31
7.2.5.1.2 Multi125-Specific Transponder Operations........................................................................32
7.2.5.1.3 Mifare Specific Transponder Operations ............................................................................33
7.2.5.1.4 Legic Specific Operations ...................................................................................................33
7.2.5.2 Functions for Host Communication ...........................................................................................34
7.2.5.3 Accessing LEDs.........................................................................................................................36
7.2.5.4 Accessing the Beeper .................................................................................................................37
7.2.5.5 Bit Operations ............................................................................................................................37
7.2.5.6 Byte Operations .........................................................................................................................39
7.2.5.7 Timer Operations .......................................................................................................................40
7.2.5.8 Retrieving System Information ..................................................................................................41
7.2.5.9 Miscellaneous ............................................................................................................................41
8.
Technical Data .............................................................................................................. 42
9.
Regulatory Information ................................................................................................ 42
9.1
CE Declaration of Conformity ............................................................................................ 42
9.2
FCC Statement...................................................................................................................... 43
9.3
CI (Canada Industry) Statement......................................................................................... 43
10.
Trademarks.................................................................................................................... 44
Page 3 of 44
Elatec GmbH
1. Introduction
This document is the reference guide for the transponder reader family TWN3.
Note:
In order to use the functionality, which is described in this document, your TWN3 reader needs
a firmware version V4.00 or above. The latest version of the firmware is part of the developer
pack. Please revere to section “Updating the Firmware”, if you would like to update the
firmware.
2. Functional Overview
Here is a block diagram of the basic functional components of a TWN3 transponder reader:
Page 4 of 44
Elatec GmbH
Let’s take a more detailed view:
The diagram below is showing the functional units and how they can be configured:
TWNConfig
USB
Keyboard
Emulation
Scancode
Translation
Table
TWNConfig
TWNConfig
TWNConfig
TWN3
Device Type
Multi125
Selected by
Cable
Scripting
Engine
Mifare
USB Virtual
COM Port
HID Prox
Transparent
Communication
V24Interface
HID iClass
Command
for Config
Mode
Config
Mode
Legic
3. Modes of Operation
The transponder reader TWN3 can be ordered in several hardware configurations:
•
Support for the specific transponder family (Multi125, Mifare, HID Prox, HID iClass, Legic)
•
Physical type of connection (type of cable) to the host computer (USB or V24 (DSUB25,
DSUB9, PS/2))
Many other configurations can be done by the system integrator:
•
Type of USB mode (USB devices only)
•
Behavior of keyboard emulation
•
Scripting mode
Page 5 of 44
Elatec GmbH
3.1 USB-Device
A TWN3 USB reader is capable of supporting several modes of operation.
3.1.1 Keyboard Emulation (USB HID Device)
This is the default mode for USB devices. No drivers are required for running the device in a typical
environment like Windows XP or Linux. Any output from the TWN3 transponder reader to the host is
sent like keyboard input from a user. Therefore, any characters are displayed at the current position of
the cursor on the screen of the computer.
Please be aware, that the communication between TWN3 device and host computer is unidirectional.
This means, there is no possibility to send data from the host to the TWN3 device. In situations where
this is required, we recommend the emulation of a serial port.
3.1.2 Emulating a Virtual Serial Port
Optionally, a USB device can be configured to emulate a virtual serial port. This mode of operation is to
be preferred, if a direct communication between application and TWN3 transponder reader is required.
This mode also enables a bidirectional communication between .
The communication protocol is identical to the version of TWN3 reader with a physical V24 interface.
3.2 V24-Device
3.2.1 Serial Communication Parameters
Parameter
Baudrate
9600 Baud
Databits
Parity
Stopbits
(1)
Value
None(1)
Handshake
None
Connector
DSUB25 or DSUB9 or PS/2
TWN3 Multi125 in transparent mode is using even parity, which is the native setup for the T4
transponder reader family.
Page 6 of 44
Elatec GmbH
3.2.2 Pin Assignment
Following pin assignment for the DSUB25 plug:
Pin
Signal
RxD from host
TxD to host
Signal ground
24
5V power supply from the host
Following pin assignment for the DSUB9 plug:
Pin
Signal
RxD from host
TxD to host
Signal ground
5V power supply from the host
Following pin assignment for the PS/2 plug:
Pin
Signal
RxD from host
TxD to host
Signal ground
5V power supply from the host
4. Installation
4.1 V24-Device
Installing a TWN3 reader with a serial port requires an additional power supply, which is not standard
for usual PCs. On the other hand, many devices do supply the 5V on a rarely used pin of the serial
connector. Please contact Elatec for a specific solution for you.
The installation of the reader is as simple as connecting a USB device to a host.
4.2 USB-Device (Keyboard Emulation)
Installing a TWN3 reader emulating a keyboard is rather simple due to the fact, that drivers come with
the operating system. Therefore, the device simply can be connected to the host computer and can be
immediately used.
Page 7 of 44
Elatec GmbH
4.3 USB-Device (Virtual Serial Port)
In order to install a TWN3 reader, which emulates a virtual serial port under Windows XP, keep the
drivers nearby and follow these steps:
•
Plug in the TWN3 reader into your host computer. The following screen should appear (in your
native language)
Select to install the software from a specific source.
•
The following screen should appear:
Select the directory, where the drivers reside and click continue. The drivers will be installed
now.
•
After installation, the following screen should appear:
Page 8 of 44
Elatec GmbH
The installation is now completed. In order to find the serial communication port, which is emulated by
the TWN3 transponder reader, you may take a look into the device manager:
In this example, we find the TWN3 reader at COM7.
Depending on the further configuration of the device, you may now test the TWN3 transponder reader
with a normal terminal program.
Page 9 of 44
Elatec GmbH
5. Configuration
In order to configure a TWN3 transponder reader, the program TWNConfig.exe is required.
Configuration is supported under Windows XP or Windows Vista. During configuration, a TWN3
transponder reader is switched into configuration mode. In this mode the entire setup of the device can
be done. Configuration is possible both for V24 and USB devices.
Note:
Please do not connect more than one TWN3 device at a time to your computer during the usage
of TWNConfig. This ensures the knowledge about the TWN3 device which is actually to be
configured.
5.1 Starting Configuration Mode
Assuming, that the TWN3 transponder reader is already connected to the host computer, start the
program TWNConfig.exe. The following screen will appear:
Depending on the physical interface of the TWN3 transponder reader, choose the appropriate port in
the top left combo box. Click the “Connect”-button.
Page 10 of 44
Elatec GmbH
TWNConfig is searching and connecting to a TWN3 device. You are now ready to do the required
configurations on the device.
Note:
If you are configuring a USB device the first time, you have to install the appropriate
configuration drivers. Please refer to “Installing USB-Drivers for Configuration”.
5.2 Writing Configuration to a TWN3 Device
Once a configuration has been set up completely (either via importing a configuration or manually via
the tab folders), the configuration can be written back to the TWN3 device. This will save the
configuration permanently in the TWN3 device. In order to do that, click the button “Write Config”.
Page 11 of 44
Elatec GmbH
5.3 Resuming Normal Operation
In order to leave configuration mode of the TWN3 device and resume to normal operation click the
“Restart” button.
Note:
Disconnecting the device from the host or a power cycle will not leave configuration mode.
Page 12 of 44
Elatec GmbH
5.4 Selecting Mode of Operation
In the tab folder “Mode of Operation” you select the basic mode in which the TWN3 device operates.
This setup is used both for USB and V24 devices:
Mode
USB Device
V24 Device
Intelligent Virtual COM Port:
Run a script on the TWN3 device
(“intelligent”) and emulate a COM port
Intelligent Operation:
Run a script on the TWN3 device
(“intelligent”)
Intelligent Keyboard Emulation:
Run a script on the TWN3 device
(“intelligent”) and emulate a keyboard
Intelligent Operation:
Identical to V24 Mode 1
Transparent Virtual COM Port:
Establish a direct link between the virtual
COM port and the internal transponder
reading module.
Transparent Operation
Establish a direct link between the serial
port and the internal transponder reading
module.
Page 13 of 44
Elatec GmbH
5.5 Setting Up the Keyboard Emulation
5.5.1 Table of Scan Codes
This tab folder enables you to change the scan codes of the keyboard emulation, which are sent to the
host for a specific character. The default setup of the device already contains the mainly used
characters ‘0’ – ‘9’, ‘A’ – ‘F’ and the carriage return. This enable the reader to send any hex number
and an ENTER to the host computer.
There are some reasons, why you may want to change the existing setup:
•
You need a setup for a specific country, where the key layout of a keyboard is different from
the default one.
•
You need some additional keys in order to achieve your specific format to be sent to the host.
This might be an additional space or a tab instead of return.
Page 14 of 44
Elatec GmbH
In order to do this, you may double-click on an existing entry in the table or specify a new entry by
pressing the “Add”-button. In the following dialog you now are able to select the appropriate keys.
Please keep in mind, that the keyboard keys are to be specified in relation to a standard U.S. QUERTY
keyboard, which is shown below:
Source: www.wikipedia.org
Note:
A maximum of 48 entries in the scan code table are possible.
5.5.2 Key Repeat Rate
You may fine adjust the rate, with which key strokes are sent to the host. This repeat rate is given in
multiples of milliseconds.
Page 15 of 44
Elatec GmbH
5.6 Installing Scripts
In order to install a script on a TWN3 device, perform following actions:
•
Select a script file (extension “.twn.c”) by clicking the button “Select Script”.
•
Click the “Compile Script”. This will start the script compiler.
•
If there is an error detected in the script, the line number and type of error will be displayed.
•
If the compilation is successful, following screen will appear:
The compiled script is now part of the configuration within TWNConfig. Some additional information is
displayed on how much storage space is occupied by this script. Up to now, the script has not been
saved to the TWN3 device.
Page 16 of 44
Elatec GmbH
5.7 Miscellaneous Settings
Within the tab folder “Misc”, there is only one setting, which influences the behavior on how a carriage
return is transferred to the PC.
The reason for this is that in keyboard emulation, it makes no sense to send a line feed to the host
computer (in fact, there is no key on a keyboard, which does “line feed”). On the other hand, sending a
line feed after a carriage return might appear quite normal in a terminal session via serial interface.
The default value is off.
Conclusions:
•
A line feed will only be appended if:
This options is selected
The device is in intelligent mode (“running a script”)
The device is connected via V24 interface or via USB and emulating a virtual serial
port.
•
This setting has no influence on any keyboard emulation.
•
This setting has no influence in transparent communication.
Page 17 of 44
Elatec GmbH
5.8 Updating the Firmware
In order to update the firmware of a TWN3 device select tab folder “Firmware”.
After any successful connection to a TWN3 device, the current directory will be searched for firmware
images, which are compatible to the connected device. In order to re-program the firmware of a TWN3
device, click the “Program”-button. After successful programming, the following screen should be
displayed:
Notes:
•
If programming fails for any reason (blackout or whatever), it is possible to restart the
programming process. The TWN3 device can only be brought back to normal operation
after successful programming of the firmware.
•
If somebody instructed you to reprogram many dozens of TWN3 devices, you might be
interested in directly restarting the TWN3 reader after successful reprogramming. On
the other hand you may find it boring to answer the same question all the time, if you
are really sure about reprogramming. In these cases, please check the appropriate
boxes in the dialog.
Page 18 of 44
Elatec GmbH
5.9 Export and Import of Configurations
Once a device has been configured completely, this configuration can be exported to a file. This makes
it much easier to setup many TWN3 devices in the same way:
Note:
•
It is not possible to read the secret area from a TWN3 device. To save a configuration
including their secrets, you have to compile the appropriate script, which defines these
secrets. After successful compilation of this script you are able to export the
configuration including script and secrets.
•
Be aware, that the configuration file also contains the secrets now so this file should be
handled as carefully as the source code of the script.
Page 19 of 44
Elatec GmbH
5.10 Installing USB-Drivers for Configuration
If the USB TWN3 reader is configured the first time, USB drivers for the configuration mode have to be
installed. Here are the steps to do so:
•
Once you have clicked the “Connect”-button within TWNConfig.exe the first time, the following
screen will appear:
Select to install the software from a specific source.
•
The following screen should appear:
Select the directory, where the drivers reside and click continue. The drivers will be installed
now.
•
After installation, the following screen should appear:
Page 20 of 44
Elatec GmbH
You are now ready to configure the TWN3 reader.
Please Note:
If the TWN3 reader is plugged into a different USB port of the host computer, this installation
procedure has to be repeated.
6. Transparent Mode
Once a TWN3 device has been turned into transparent mode, a direct link will be established between
the serial interface (V24 or virtual USB), and the reading module. The direct communication with a
transponder reader module is not compatible to each other and requires the knowledge of the specific
communication protocol. Please see the following documents for related information:
TWN3 Type
Multi125
Mifare
HID Prox
Document
T4T5Handbook x.xx.pdf
TH_Mifare_x.xx.pdf
This Document
HID iClass
Please contact Elatec GmbH
Legic
Please contact Elatec GmbH
Page 21 of 44
Elatec GmbH
6.1 HID Prox Transparent Protocol
Due to the nature of the HID Prox transponder, which is read only, the raw data, which will be returned
by a successful read, is directly described in this document:
If a transponder is read, a ASCII string is sent which is terminated by ‘\r’;
The first character represents the number of valid bits, the remaining bytes do contain these bits.
Example:
Data sent by the reader:
0x1A 0x80 0x80 0x01 0xC0 ‘\r’
Meaning:
The first contains 0x1A, which means the following ID contains 26 bits.
The remaining four bytes contain 32 bits, but only the first 26 bits are valid.
The ID data in hexadecimal notation:
0x80 0x80 0x01 0xC0
In binary notation this leads to
Byte 1
Byte 2
Byte 3
Byte 4
1000 0000 1000 0000 0000 0001 11(00 0000)
Please note, that the unused bits are the lowest significant bits of the last bytes.
7. Scripting
7.1 Language Description
The scripting language for TWN3 readers is a simplified version of the language C. The main
differences are:
•
There is one data type available, which is a byte. A byte is an unsigned integer with a size of
8 bits.
•
There are no pointers available. Instead, there is a reference operator, which is showing some
similarity to the language C++.
7.1.1 Source Code
The source for a TWN3 script is given as a text file. Due to closeness to the language C, the extension
should be “.c”. Doing so will give the advantage of a working syntax highlighting in many programming
editors. In order to distinguish normal C-code from TWN3 scripting code it is furthermore
recommended to expand the extension to “.twn.c”. This is also the default extension which is used
by the configuration tool TWNConfig. The preferred extension for include files is “.twn.h”.
A TWN3 script is one file of source. It is possible to include additional source files via a directive to the
preprocessor.
Page 22 of 44
Elatec GmbH
7.1.2 Comments
In order to place a comment within the source code, two slashes are used. The remaining content of
the line will be ignored by the compiler.
7.1.3 Case Sensitivity
The TWN3 script language is sensitive to upper and lower case. Examples:
byte a;
// Valid
Byte a;
// Invalid
byte Byte; // Valid(!)
7.1.4 Preprocessor Directives
The preprocessor is removing comments from the source code and processing the preprocessor
directives. Currently, there is one directive available.
7.1.4.1 #include Directive
Include another source file and treat it as a part of the compiled source. There are two possibilities:
#include 
Include the given file, which is located relative to the directory, where TWNConfig.exe resides.
#include “mydefs.twn.h”
Include the given file, which is located relative to the current directory
7.1.5 Functions
Functions may be defined (“prototype”) in order to resolve forward references, or declared directly.
The prototype of a function has the following form:
(byte | void) identifier([list of arguments]);
The declaration of a function has the following form:
(byte | void) identifier([list of arguments])
function body
The function body is a block of statements.
7.1.5.1 Return Values
A function either has a return value (byte) or not (void). Following form is required to return a value:
return expression;
Page 23 of 44
Elatec GmbH
7.1.5.2 Arguments
If a function has no arguments, the list of arguments has to be left empty (do not write void).
In order to declare arguments, write the list of arguments separated by commas. Arguments are
passed by value or by reference. In order to pass an argument by reference instead of value, insert the
‘&’ before the identifier of argument. Here are some examples of valid function prototypes:
void Func1();
void Func2(byte i);
// No arguments
// A single argument,
// which is passed by value
void Func3(byte in, byte &out); // Two arguments, where in is passed by
// value and out is passed by reference
7.1.5.3 System Functions
A system function can only be declared as prototype. Following form:
(byte | void) identifier([list of arguments]) system number;
The list of available system functions is contained in the file sys.twn.h. For the script programmer there
is normally no need to declare system functions on his own.
7.1.5.4 Function main
A TWN3 script always needs the function main to be implemented. The prototype for the function main
is:
void main();
After internal initialization, the TWN3 reader will start execution of the script by calling this function
main.
7.1.6 Statements
A single statement has the form
[expression];
This means, a statement is a (optional) expression followed by a semicolon. If only a semicolon without
an expression is specified, it is called an empty statement. Statements can be enclosed by braces to
build a block of statements. A block statement can be used wherever a single statement can be used.
7.1.6.1 if Statement
An if statement has the form:
if (expression) statement
Statement is executed only if the result of expression is not equal to zero.
Page 24 of 44
Elatec GmbH
7.1.6.2 if else Statement
An if else statement has the form:
if (expression) statement1 else statement2
Statement1 is executed only, if the result of expression is not equal to zero. Otherwise, statement2 is
executed.
7.1.6.3 while Statement
A while statement has the form:
while (expression) statement
Statement is executed, as long as the result of expression is not equal to zero.
7.1.6.4 do while Statement
A do while statement has the form:
do statement while (expression);
Statement is executed, until the result of expression is equal to zero.
7.1.6.5 for Statement
A for statement has the form:
for ([expression1]; [expression2]; [expression3] statement
As first step, expression1 is evaluated. As long as expression2 is not equal to zero, statement is
executed. After execution of statement, expression3 is evaluated. Therefore, a for statement can be
rewritten as while statement with exactly the same behavior:
expression1;
while (expression2)
statement
expression3;
7.1.6.6 switch Statement
A switch statement has the form:
switch (expression)
[case constant expression: [case statement]]
[default: [default statement]]
The script is evaluating expression. Depending on the result of the expression the appropriate case is
executed. If there is no appropriate case, the default case is executed. If there is no default label,
execution is continued after the switch statement.
Page 25 of 44
Elatec GmbH
7.1.6.7 break Statement
Form:
break;
The break statement can be used in while, do/while, for and switch statements (loop or switch
statements).
In a loop statement, control is passed directly to the next statement outside of the loop. In a switch
statement, control is passed directly to the next statement outside of the switch body.
7.1.6.8 continue Statement
Form:
continue;
The continue statement can be used in while, do/while and for statements (loop statements). It directly
passes execution to the loop continuation portion of the loop statement.
7.1.6.9 return Statement
Two forms are possible:
Functions, which do not return a value:
return;
The execution of the current function is stopped. Execution is continued in the calling function.
Functions which return a value:
return expression;
Expression is evaluated, execution is stopped, the result of the expression is passed to the calling
function, execution is continued in the calling function.
7.1.6.10 goto Statement
Form:
goto label;
The goto statement directly passes execution to the position within a function, where the label
statement has been defined.
7.1.6.11 Labels
A label has the form:
identifier: statement
They may appear on any position within a function body. A label is used as destination for a goto
statement.
Page 26 of 44
Elatec GmbH
7.1.6.12 Empty Statement
A statement, which is doing nothing is the semicolon. Example:
for (i=0; i<10; i+=1)
// Waste some time and do ten times nothing
7.1.7 Storage Types
In the TWN3 scripting language, there is only one type of storage defined, which is the byte. A byte is
an unsigned integer with a size of 8 bits.
7.1.8 Storage Classes
There are following storage classes available: Standard, const and secret. Without using any modifier,
the standard storage is used. A variable, which is declared in the standard storage class, is allocated in
the normal data segment.
Examples:
byte i;
byte a[15];
// A single integer
// An array of 15 bytes
7.1.8.1 const
An identifier, which is declared as const can be used for calculations at compile time. There is no
physical memory occupied during runtime. Typically, you would use a const for defining constants,
which are used throughout a script for easier understanding and adaptation for different purposes.
Example:
const byte c = 15;
7.1.8.2 secret
The secret data space is a read-only segment. The content of this segment is written once during
programming the script into the TWN3 transponder reader. Furthermore, this segment can not be read
directly by the script itself. Therefore, there is no way to simply read the content of this memory and
send it to the host. There are only a few system functions, which take the content of this segment as
input. Typically, the secret data space is used for keys, which are necessary for authentication to a
transponder. Examples:
// Some well known factory
secret byte MifareKeyFF[6]
secret byte MifareKeyAA[6]
secret byte MifareKeyBB[6]
secret byte Hitag2Key[4]
secret byte EM4050Key[4]
default keys for transponders
= { 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF };
= { 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5 };
= { 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5 };
= { 'M','I','K','R' };
= { 0x00,0x00,0x00,0x00 };
Page 27 of 44
Elatec GmbH
7.1.9 Operators
Following operators are available:
Operator
Meaning
Example
()
Parenthesis
A = B * (C + D)
[]
Brackets
A = B[C]
Logical Not
A = !B
Bitwise Complement
A = ~B
Unary Minus
A = -B
Unary Plus
A = +B
Multiplication
A = B * C
Division
A = B / C
Modulus
A = B % C
Add
A = B + C
Subtract
A = B – C
<<
Shift Left
A = B << C
>>
Shift Right
A = B >> C
Lower
A = B < C
<=
Lower or Equal
A = B <= C
Greater
A = B > C
>=
Greater or Equal
A = B >= C
==
Equal
A = B == C
!=
Not Equal
A = B!= C
Binary And
A = B & C
Binary Exclusive Or
A = B ^ C
Binary Or
A = B | C
&&
Logical And
A = B && C
||
Logical Or
A = B || C
Assignment
A = B
+=
Addition/ Assignment
A += B
-=
Subtraction/ Assignment
A -= B
*=
Multiplication/ Assignment
A *= B
/=
Division/ Assignment
A /= B
%=
Modulus/ Assignment
A %= B
|=
Bitwise Or/ Assignment
A |= B
&=
Bitwise And/ Assignment
A &= B
^=
Bitwise Exclusive Or
A ^= B
<<=
Shift Left/ Assignment
A <<= B
>>=
Shift Right/ Assignment
A >>= B
Page 28 of 44
Elatec GmbH
7.2 Runtime Environment
7.2.1 Include File
The file sys.twn.h declares all constants and system function prototypes, which are necessary for
accessing the TWN3 transponder reader functionality. It is strongly recommended to include this file in
any TWN3 script:
#include 
7.2.2 Basic Definitions
In order to handle boolean operations in a more natural way, there are two constants defined:
const byte FALSE = 0;
const byte TRUE = 1;
System functions, which only return 0 or 1 in order to signal successful operation, are described to
return FALSE or TRUE for better readability.
7.2.3 Bit Fields
Many system functions operate on an array of bytes, where a count of bits is and/or a start bit is
specified. The table shows, how the bits are enumerated within the array of bytes:
Byte Index
Bit Index
10 11
12
13
14
15 16 17
18
19 20
21
22 23
Functions, which only specify a bitcount, operate on bits 0 to bitcount-1.
Functions, which specify a startbit and bitcount, operate on bits startbit to startbit+bitcount-1.
Please note, that both the most significant bits and the most significant bytes are still oriented to the left
side of the bit field.
7.2.4 Startup Condition
Following conditions are met, before a TWN3 script is started:
•
The entire variable data space is preset to 0.
•
All timers are stopped.
•
The LEDs are turned off.
•
The volume of the beeper is set to minimum level but not turned off (volume 1).
•
The communication with the transponder reading module is restarted.
Page 29 of 44
Elatec GmbH
7.2.5 System Function Calls
7.2.5.1 Transponder Operations
Following constants are defined for the various types of transponders which can be read by the family
of TWN3 transponder readers:
TWN3 Type
Transponder Types
Multi125
TAGTYPE_EM4102
TAGTYPE_HITAG1S
TAGTYPE_HITAG2
TAGTYPE_EM4150
TAGTYPE_ISOFDX
Mifare
TAGTYPE_MIFARE
HID Prox
TAGTYPE_HIDPROX
HID iClass
TAGTYPE_HIDICLASS
Legic
TAGTYPE_LEGIC
TAGTYPE_MIFARE
TAGTYPE_ISO15693
Page 30 of 44
Elatec GmbH
7.2.5.1.1 Generally Available Transponder Operations
byte TagSearch(byte &IDData, byte &IDBitCnt, byte &TagType)
Search a transponder. This function behaves similar on different types of transponder readers, but not
identical.
Parameter:
byte &IDData
byte &IDBitCnt
Reference to a bit field (in fact an array of bytes), which receives the ID
data.
Number of valid bits(!), the ID consists of.
byte &TagType
Type of tag, which has been found.
Return:
If a transponder has been found, the return value is TRUE, otherwise it is
FALSE.
The following table shows, how data is stored in the given array of bytes:
Maximum length
of ID (bits)
Maximum length
of ID (bytes)
IDBitCnt is always
a multiple of 8 bits
Multi125
64
Yes
Mifare
56
Yes
HID Prox
128
16
No
HID iClass
128
16
Yes
Legic
128
16
Yes
If IDBitCnt is a multiple of 8 bits, then the number of involved bytes simply can be calculated by
following formula:
IDByteCnt = IDBitCnt/8;
If IDBitCnt is not a multiple of 8 bits, then the number of involved bytes can be calculated by a
somewhat more complicated formula:
IDByteCnt = (IDBitCnt+7)/8;
The second formula can be used in general but occupies somewhat more program space.
byte TagRead(byte Address, byte ByteCnt, byte &Data)
Read data from a selected transponder.
Parameters:
byte Address
The address within the address space of the transponder.
byte ByteCnt
Number of bytes to read.
byte &Data
Reference to an array of bytes, where the read data will be stored.
Return:
If the operation was successful, the return value is TRUE, otherwise it is
FALSE.
Page 31 of 44
Elatec GmbH
byte TagWrite(byte Address, byte ByteCnt, byte &Data)
Write data to a selected transponder.
Parameters:
byte Address
The address within the address space of the transponder.
byte ByteCnt
Number of bytes to write.
byte &Data
Reference to an array of bytes to be written.
Return:
If the operation was successful, the return value is TRUE, otherwise it is
FALSE.
7.2.5.1.2 Multi125-Specific Transponder Operations
byte Multi125SearchLogin(byte &IDData, byte &IDBitCnt,
byte &TagType, byte &Secret)
Perform a search for transponders and login to Hitag2 or EM4150 transponders if applicable. This
function behaves similar to the function TagSearch except the fact, that it also tries to perform a login
with the given key information.
Parameters:
byte &IDData
byte &IDBitCnt
Reference to a bit field (in fact an array of bytes), which receives the ID
data.
Number of valid bits(!), the ID consists of.
byte &TagType
Type of tag, which has been found.
byte &Secret
Reference to an array of bytes, which must contain four bytes. These
bytes represent the key for the login process.
If the operation was successful, the return value is TRUE, otherwise it is
FALSE.
Return:
byte Multi125Generic(byte &TXData, byte TXCount, byte &RXData,
byte &RXCount, byte MaxRXCount, byte Timeout)
Send a specific command to the built in module of a Multi125 reader.
Parameters:
byte &TXData
byte TXCount
Reference to an array of bytes which contains the command to be sent
to the module.
Count of bytes in the specified array of bytes to be sent.
byte &RXCount
Reference to an array of bytes (receive buffer) which receives the
answer from the module.
Count of bytes, which have been received.
byte MaxRXCount
The size of the receive buffer.
byte Timeout
Timeout time in multiples of 100 milliseconds.
Return:
If the operation was successful, the return value is TRUE, otherwise it is
FALSE.
byte &RXData
Please note, that both TXData and RXData do contain a telegram without length, address and BCC.
Page 32 of 44
Elatec GmbH
7.2.5.1.3 Mifare Specific Transponder Operations
byte MifareLogin(byte &Secret, byte KeyType, byte Sector)
In order to do any operations on a sector of a Mifare transponder, a login has to be performed.
Parameters:
byte &Secret
byte KeyType
Reference to a array of bytes, which has to contain six bytes. These
bytes represent the key for the login process.
Specifies, with which key the operation has to be performed. This is one
of the defined constants KEYA or KEYB.
byte Sector
Specifies the sector for the login.
Return:
If the operation was successful, the return value is TRUE, otherwise it is
FALSE.
7.2.5.1.4 Legic Specific Operations
byte LegicGeneric(byte &TXData, byte TXCount, byte &RXData,
byte &RXCount, byte MaxRXCount, byte Timeout)
Send a specific command to the built in module of a Legic reader.
Parameters:
byte &TXData
byte TXCount
Reference to an array of bytes which contains the command to be sent
to the module.
Count of bytes in the specified array of bytes to be sent.
byte &RXCount
Reference to an array of bytes (receive buffer) which receives the
answer from the module.
Count of bytes, which have been received.
byte MaxRXCount
The size of the receive buffer.
byte Timeout
Timeout time in multiples of 100 milliseconds.
Return:
If the operation was successful, the return value is TRUE, otherwise it is
FALSE.
byte &RXData
Please note, that TXData and RXData do contain a telegram without length byte and LRC or CRC.
This information is calculated by the firmware of the TWN3 reader.
Page 33 of 44
Elatec GmbH
7.2.5.2 Functions for Host Communication
void HostSendVersion()
Send version information of the firmware to the host. This information is sent without a carriage return.
Therefore, it is possible to append some more information, i.e. the version of the script, which is
currently executed.
Parameter:
Return:
None
None.
Example:
HostSendVersion();
HostSendChar(‘.’);
HostSendChar(‘0’);
HostSendChar(‘2’);
HostSendChar(‘\r’);
// Send the firmware version
// Send another separator
// Send version of this small example
This will send following string to the host. The string may vary with the actual firmware of the
transponder reader.
ELA GM4.01.02
void HostSendChar(byte Char)
Send a single character to the host.
Parameter:
byte Char
Char represents the ASCII value of the character to be sent to the host.
Return:
None.
Page 34 of 44
Elatec GmbH
void HostSendHex(byte &Data, byte BitCnt, byte Width)
Convert a number, which is given as a bit field into hexadecimal ASCII format, and send it to the host.
Letters are sent in upper case.
Parameters:
byte &Data
byte BitCnt
byte Width
Return:
A reference to an array of bytes, which contains the bit field
The number of bits, which are valid within the array of bytes. A
maximum of 128 bits can be converted.
Specifies the number of digits, the output should contain. If width is 0,
then at least 1 digit is sent. If Width is greater than the actual width of
the number to be converted, then the number is preceded by zeros.
None.
Example:
byte ID[2];
ID[0] = 0x12;
ID[1] = 0x34;
HostSendHex(ID,16,0);
HostSendHex(ID,8,5);
HostSendHex(ID,13,5);
// Result is 1234
// Result is 00012
// Result is 00246
void HostSendDec(byte &Data, byte BitCnt, byte Width)
Convert a number, which is given as a bit field into decimal ASCII format, and send it to the host.
Parameters:
byte &Data
byte BitCnt
byte Width
Return:
A reference to an array of bytes, which contains the bit field
The number of bits, which are valid within the array of bytes. A
maximum of 128 bits can be converted.
Specifies the number of digits, the output should contain. If width is 0,
then at least 1 digit is sent. If Width is greater than the actual width of
the number to be converted, then the number is preceded by zeros.
None.
Example:
byte ID[2];
ID[0] = 0x12;
ID[1] = 0x34;
HostSendDec(ID,16,0);
HostSendDec(ID,8,5);
HostSendDec(ID,13,5);
// Result is 4660
// Result is 00018
// Result is 00582
Page 35 of 44
Elatec GmbH
byte HostTestCmd(byte &Cmd, byte &CmdLen, byte MaxCmdLen)
This command implements a generic method for receiving an array of bytes from the host. This
enables the programmer to implement a simple interface, which executes commands sent from the
host to the reader. A host command is any sequence of ASCII characters which is terminated by ‘\r’.
The character ‘\n’ can be sent optionally but is ignored by the reader.
Parameters:
byte &Cmd
byte &CmdLen
byte MaxCmdLen
Return:
A reference to an array of bytes, which contains the received ASCII data
from the host (without the ‘\r’).
The number of bytes, which have been received from the host. Even a
command of the length 0 can be received.
This value specifies the maximum number of bytes the array of bytes
Cmd can hold.
If a command has been received from the host, the return value is
TRUE, otherwise it is FALSE.
7.2.5.3 Accessing LEDs
void LEDSet(byte LEDs, byte Status)
Set the state of the red and/or the green LED.
Parameters:
byte LEDs
byte Status
Return:
Binary or of the LEDs to be switched. The green LED is represented by
the constant GREEN, the red LED is represented by the constant RED.
The new status for the LEDs specified by LEDs. It may be either one of
the following constants:
OFF:
Turn off
ON:
Turn on
BLINK:
Blink
TOGGLE:
Toggle on/off state. This has no
influence on a blinking LED
None.
Examples:
LEDSet(GREEN | RED,ON);
LEDSet(GREEN,BLINK);
// Turn on both green and red LED
// Let the green LED blink
byte LEDGet(byte LED)
Get the current status of a LED. Only the status of one LED can be retrieved at a time.
Parameter:
byte LED
Return:
Specifies either the value for the green (constant GREEN) or the red
(constant RED) LED.
The current status of the LED specified by LED.
OFF:
The LED is off
ON:
The LED is on
BLINK:
The LED is blinking
Page 36 of 44
Elatec GmbH
7.2.5.4 Accessing the Beeper
void SetVolume(byte Volume)
Set the volume of the beeper.
Parameter:
byte Volume
A value between 0 (beeper turned off) and 4 (maximum volume).
Return:
None.
void Beep(byte Type)
Sound some type of beep.
Parameter:
byte Type
Return:
Four types of beeps are defined by constants:
BEEPLOW:
A beep at lower frequency
BEEPHIGH:
A beep at higher frequency
BEEPSUCCESS:
A low-high sequence, which is
intended to signal a successful operation.
BEEPFAILED:
A high-low sequence, which is
intended to signal an operation which has
not been successful.
None.
7.2.5.5 Bit Operations
byte CompBits(byte &Data1, byte &Data2,byte BitCount)
Compare two bit sets.
Parameters:
byte &Data1
Reference to an array of bytes which represent a bit field
byte &Data2
Reference to an array of bytes which represent a bit field
byte BitCount
Number of bits (beginning from bit index 0) to be compared.
Return:
TRUE:
FALSE:
The two bit fields are identical.
The two bit fields are not identical
Page 37 of 44
Elatec GmbH
void CopyBits(byte &DestBits, byte StartDestBit, byte &SourceBits,
byte StartSourceBit, byte BitCount)
Copy bits from a source to a destination. Source and destination may be identical and the source
section may overlap the destination. Depending on that, the correct method for copying will be chosen.
Parameters:
byte &DestBits
byte StartDestBit
Reference to an array of bytes which represent a bit field which is the
destination of the copy operation.
First bit within the destination bit field where the bits are copied to.
byte StartSourceBits
Reference to an array of bytes which represents a bit field which is the
source of the copy operation
First bit within the source bit field where the bits are copied from.
byte BitCount
Number of bits to be copied.
Return:
None.
byte &SourceBits
void FillBits(byte &Dest, byte StartBit, byte Value, byte BitCount)
Fill bits within a given bit field with either 0 or 1.
Parameters:
byte &Dest
byte StartBit
Reference to an array of bytes which represent a bit field which is the
destination for the operation.
First bit within the bit field where the bits are filled.
byte Value
The bit value which is either 0 or 1.
byte BitCount
Number of bits to be filled.
Return:
None.
void SwapBits(byte &Data, byte StartBit, byte BitCount)
Swap the order of bits within a bit field.
Parameters:
byte &Data
byte StartBit
Reference to an array of bytes which represent a bit field which is the
destination for the operation.
First bit within the bit field where bits are swapped.
byte BitCount
Number of bits to be swapped.
Return:
None.
Page 38 of 44
Elatec GmbH
7.2.5.6 Byte Operations
byte CompBytes(byte &Data1,byte &Data2,byte ByteCount)
Compare two byte arrays.
Parameters:
byte &Data1
Reference to an array of bytes.
byte &Data2
Reference to an array of bytes.
byte ByteCount
Number of bytes (beginning from index 0) to be compared.
Return:
TRUE:
The two arrays are identical.
FALSE: The two arrays are not identical
void CopyBytes(byte &DestBytes, byte &SourceBytes, byte ByteCount)
Copy bytes from a source to a destination. Source and destination may be identical and the source
section may overlap the destination. Depending on that, the correct method for copying will be chosen.
Parameters:
byte &DestBytes
byte &SourceBytes
Reference to an array of bytes which is the destination of the copy
operation.
Reference to an array of bytes which is the source of the copy operation
byte ByteCount
Number of bytes to be copied.
Return:
None.
void FillBytes(byte &Dest, byte Value, byte ByteCount)
Fill bytes within a given array with a value.
Parameters:
byte &Dest
Reference to an array of bytes which is the destination for the operation.
byte Value
The byte value with which the array will be filled.
byte ByteCount
Number of bytes to be filled.
Return:
None.
void SwapBytes(byte &Data, byte ByteCount)
Swap the order of bytes within an array.
Parameters:
byte &Data
Reference to an array of bytes which is the destination for the operation.
byte ByteCount
Number of bytes to be swapped.
Return:
None.
Page 39 of 44
Elatec GmbH
byte ScanHex(byte &Data, byte ByteCnt)
Convert an array of bytes containing ASCII characters which represent hexadecimal numbers into their
binary representation. The conversion is done in place. This means that after successful conversion,
number of valid is half of the given count of ASCII characters (two hex digits represent one binary
byte).
Parameters:
byte &Data
Reference to an array of bytes which is the destination for the operation.
byte ByteCount
Number of (ASCII-) bytes to be converted.
Return:
Number of successful converted bytes.
7.2.5.7 Timer Operations
void StartTimer(byte ID, byte Time)
Start a timer. After the specified time, the timer goes into the timed-out state, which can be tested by
the function TestTimer. A timer is running in real time in the background. This means, that even if other
tasks are performed by the script, the time till time-out is still kept correctly. The timed-out state is
reached only one time.
Parameters:
byte ID
The ID of a timer which maybe one of the four available timer 0 to 3.
byte Time
The timeout values specified in multiples of 100 milliseconds.
Return:
None.
void StopTimer(byte ID)
Stop a timer. This will prevent a started timer going into timed-out state. It is possible to stop a timer,
which never has been started or stop an already stopped timer.
Parameter:
byte ID
The ID of the timer to be stopped in the range of 0 to 3.
Return:
None.
byte TestTimer(byte ID)
Test, if a timer has reached the timed-out state. The timed-out state can only be detected once. After
that, the timer is stopped.
Parameter:
byte ID
Return:
The ID of the timer to be tested.
TRUE:
Timed-out state has been reached.
FALSE: Timer is still running or stopped.
Page 40 of 44
Elatec GmbH
7.2.5.8 Retrieving System Information
byte GetConnection()
Retrieve the physical type of connection (V24 or USB).
Parameter:
Return:
None.
Either one of the defined constants:
V24:
The TWN3 reader is connected via a V24 cable to
the host.
USB:
The TWN3 reader is connected via a USB cable to
the host
byte GetUSBMode()
Retrieve the information if the TWN3 reader is emulating a keyboard or if it is emulating a virtual COM
port.
Parameter:
Return:
None.
Either one of the defined constants:
USBVCOM:
The TWN3 reader is emulating a virtual COM port.
USBHID:
The TWN3 reader is emulating a keyboard.
byte GetDeviceType()
Retrieve the information, which family of transponders this device supports.
Parameter:
Return:
None.
Either one of the defined constants:
DEVTYPE_MULTI125:
Multi125
DEVTYPE_MIFARE:
Mifare
DEVTYPE_HIDPROX:
HID Prox
DEVTYPE_LEGICPRIME:
Legic Prime (obsolete)
DEVTYPE_HIDICLASS:
HID iClass
DEVTYPE_LEGICADVANT:
Legic
7.2.5.9 Miscellaneous
void Reset()
Restart the execution of the script.
Parameter:
Return:
None.
None.
Page 41 of 44
Elatec GmbH
8. Technical Data
HID Prox
Multi125
125 kHz
Frequency
Legic
13,56 MHz
88mm x 56mm x 18mm
Dimensions
5V via communication cable
Power Supply
140mA
220mA
120mA
220mA
280mA
0°C up to +50°C
Temperature
Range
Aircoil
Antenna
PCB Aircoil
up to 10cm depending on transponder
Read-/WriteDistance
Supported
Transponders
HID iClass
Material ABS, color black or white
Housing
Supply Current
Mifare
HID PROX
EM410x,
HITAG-1,
HITAG-2,
HITAG-S,
EM4150,
T5567, Q5
Mifare
Ultralight,
Mifare 1k,
Mifare 4k
Mifare DESfire
HID iClass
Legic Prime,
Legic Advant
ISO14443
ISO15693
9. Regulatory Information
9.1 CE Declaration of Conformity
Elatec declares under his responsibility that these products are conform with the following standards:
•
ETSI EN 300330-1 V1.3.1 / ETSI EN 300330-2: V1.3.1
•
ETSI EN 301489-1: V1.6.1 / ETSI EN 301489-3: V1.4.1
•
DIN EN 55022: 2007-04 class B / DIN EN 55024: 2003-10
•
DIN EN 50371:2001-11
Page 42 of 44
Elatec GmbH
9.2 FCC Statement
This device complies with Part 15 of the FCC rules. Operation is
subject to the following two conditions: (1) this device may not cause
harmful interference, and (2) this device must accept any interference
received, including interference that may cause undesired operation.
Section 15.21 Information to user
Changes or modifications not expressly approved by the party
responsible for compliance could void the user's authority to operate
the equipment
Section 15.105 (b)
Note: This equipment has been tested and found to comply with the
limits for a Class B digital device, pursuant to part 15 of the FCC
Rules. These limits are designed to provide reasonable protection
against harmful interference in a residential installation. This
equipment generates, uses and can radiate radio frequency energy
and, if not installed and used in accordance with the instructions, may
cause harmful interference to radio communications. However, there
is no guarantee that interference will not occur in a particular
installation.
If this equipment does cause harmful interference to radio or television
reception, which can be determined by turning the equipment off and
on, the user is encouraged to try to correct the interference by one or
more of the following measures:
•
Reorient or relocate the receiving antenna.
•
Increase the separation between the equipment and receiver.
•
Connect the equipment into an outlet on a circuit different from
that to which the receiver is connected.
•
Consult the dealer or an experienced radio/TV technician for help.
9.3 CI (Canada Industry) Statement
This Class B digital apparatus complies with Canadian ICES-003.
Cet appareil numérique de la classe B est conforme à la norme NMB003 du Canada.
Operation is subject to the following two conditions:
(1) this device may not cause interference, and
(2) this device must accept any interference, including interference
that may cause undesired operation of the device.
Page 43 of 44
Elatec GmbH
10. Trademarks
All referenced brands, product names, service names and trademarks mentioned in this document are
the property of their respective owners.
Page 44 of 44

Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.3
Linearized                      : No
Page Count                      : 44
Producer                        : AFPL Ghostscript 8.13
Create Date                     : 2008:11:04 10:50:34
Modify Date                     : 2008:11:04 10:50:34
Title                           : TH_TWN3_104.doc
Creator                         : PDF-WRITER 1.0.010 (c) by Dirk Paehl Freeware
Author                          : 
EXIF Metadata provided by EXIF.tools
FCC ID Filing: WP5TWN3M1

Navigation menu