CyPro User Manual v47
CyPro User Manual v47
version 47
applies to CyPro v3.2.0 and later
Index
Index ............................................................................................................................................ 3
Introduction .................................................................................................................................. 5
Installation ......................................................................................................................... 5
Communication ................................................................................................................. 6
User interface .................................................................................................................... 7
Main window ........................................................................................................... 7
Standard toolbar ..................................................................................................... 7
Program toolbar ...................................................................................................... 7
Communication toolbar ........................................................................................... 7
Project tree.............................................................................................................. 8
Status bar................................................................................................................ 8
Pull-down menu ...................................................................................................... 9
Edit window ........................................................................................................... 10
Online monitor ................................................................................................................. 11
Identify modules .............................................................................................................. 12
Multisend ......................................................................................................................... 13
Programming ............................................................................................................................. 14
Hardware ......................................................................................................................... 14
Expansion modules .............................................................................................. 14
Hardware setup..................................................................................................... 14
Device properties .................................................................................................. 15
Variables ......................................................................................................................... 16
Naming convention ............................................................................................... 16
Allocation .............................................................................................................. 16
Basic data types .................................................................................................... 16
Other data types ................................................................................................... 17
Retentive variables ............................................................................................... 17
EE variables .......................................................................................................... 18
I/O variables .......................................................................................................... 19
Timer ..................................................................................................................... 19
Pulse timer ............................................................................................................ 20
On-delay timer ...................................................................................................... 20
Counter ................................................................................................................. 21
Visibility ................................................................................................................. 21
Refresh processing ......................................................................................................... 21
Scan overrun......................................................................................................... 21
Structured text ................................................................................................................. 22
Assignment ........................................................................................................... 22
Expressions .......................................................................................................... 22
Operators .............................................................................................................. 22
Expression evaluation ........................................................................................... 22
Type conversion.................................................................................................... 23
Multiline expressions............................................................................................. 24
Flow control........................................................................................................... 24
Return value.......................................................................................................... 25
Operator panel........................................................................................................................... 26
General ........................................................................................................................... 26
Print functions ................................................................................................................. 26
OP keys ........................................................................................................................... 27
Mask ................................................................................................................................ 28
Program handling ............................................................................................................ 31
Serial interface........................................................................................................................... 33
Features .......................................................................................................................... 33
Free-programmable mode .............................................................................................. 34
Select port ............................................................................................................. 34
Create message ................................................................................................... 34
Send message ...................................................................................................... 35
Start receiver......................................................................................................... 36
3
Index Installation
4
Introduction Installation
Introduction
Installation
CyPro is integrated development environment for Cybro controllers, with text editor, compiler and
on-line monitor. It's running on Windows 7/8/10 or Linux/Wine.
Each controller has unique 5-digit serial number, also used as communication address (NAD).
Compiler implements structured text (ST) and instruction list (IL) from IEC 61131-3 standard for
programming logical controllers. Other languages are not supported.
Hardware requirements are low, any PC capable of running MS Windows should be sufficient.
Installation uses cca. 40Mb, default directory is C:\Program Files (x86)\Cybrotech\CyPro-3.
To upgrade CyPro, install a new release into the same directory. User settings will be preserved.
With new CyPro, it is required to also upgrade firmware (kernel). To do this, open Tools/Kernel
Maintenance and send new kernel.
5
Introduction Communication
Communication
To establish communication with controller in a local network, follow this steps:
File / New
Hardware / Autodetect
Internet connection
6
Introduction User interface
User interface
Main window
CyPro consists of editor, toolbars and status bar. Default screen is shown below:
Each component can be docked or floating. To undock, drag the component by the left vertical line
over the edit area. To dock it again, drag window to main window border.
Standard toolbar
Program toolbar
Communication toolbar
7
Introduction User interface
Project tree
Right clicking any component opens it's context sensitive pop-up menu. Depending on type, it is
possible to Add, Edit, Delete or change Properties of the selected component.
Status bar
Status bar shows various information about communication and connected Cybro.
Project status indicate that current project is not saved. It reflects changes in any part of the project,
such as source, allocation, mask, socket, data manager or monitor list.
A-bus address shows Cybro A-bus address (NAD). Right click to select another or enter a new one.
OK
cable not connected
communication port used by another application
Delay shows roundtrip time, from message sent to message received, in milliseconds.
Communication indicators show activity, green is transmit (Tx), red is receive (Rx).
8
Introduction User interface
Pull-down menu
File
Edit
View
Project
9
Introduction User interface
Program
Tools
Edit window
Edit window is used to type and edit PLC program. Each window is a single function.
Editor uses syntax highlight - variables, constants, functions and other language elements are
displayed in different colors. To customize colors, open Tools/Environment Options/Colors.
Insert identifier (Ctrl-Space) is used to display a list of allocated variables and available functions.
10
Introduction Online monitor
Online monitor
Online monitor is designed to display and change controller variables.
To insert new variables use Add button (Insert), select desired variables and press OK. To
rearrange variables, click Move Up / Move Down, or use Ctrl-Up / Ctrl-Down (arrow) keys.
Monitor update rate is 20ms (50 times per second). Scroll rate is 50ms, it can be changed with
Speed slider. First number is time to move a single pixel, second is total time from left to right.
To enter a new value, click Edit selected variables (Alt+Enter), right-click and select Properties, or
double-click the variable.
Enter value and press OK. Value is sent and immediately read back, monitor always display the
actual value. Multiple variables can be set at once.
Monitor supports multiple sets. To create a new set click Add new varset, then insert variables. For
a quick access press Alt-1 to Alt-5, or Ctrl-Left / Ctrl-Right (arrow) keys.
11
Introduction Identify modules
Identify modules
Identify modules is a tool used to identify individual inputs/outputs.
Each LED represents single digital input or output. When mouse is positioned over LED, signal
name is shown in the bottom left corner.
Input and output LEDs are defined according to the following table:
LED description
module is operating properly
error, module is not operative
1. Reset all
2. Press and hold unknown input for a second
3. Look for the yellow LED
12
Introduction Multisend
Multisend
Multisend is tool to update multiple controllers at once.
It is optional to send program either without initialization (only if allocation is not changed), with a
standard initialization (retentive variables are preserved), or with forced initialization (all variables
are initialized, including retentives).
Option Check all programs will verify all programs by reading back and comparing to original.
13
Programming Hardware
Programming
Hardware
Expansion modules
Cybro is expanded with IEX-2 modules. For the complete list, check hardware manual.
Each module occupies a single slot. Slot is logical entity, used to address the module.
Each IEX-2 module has unique address, equal to serial number. Autodetect will detect module type,
address, and assign slot number. Slot 0 is reserved for Cybro internal inputs and outputs.
Some modules implement autoaddress feature, used to fit devices into a predefined hardware list.
Hardware setup
Dialog shows slot number, module type, short description, communication address, variable prefix
and status.
14
Programming Hardware
Device properties
To open device properties, double click the module, or click right and select Properties.
Dialog shows automatically assigned i/o variables for the module. Everything device does is
accessable through this variables.
Everything is sorted in four columns. X are binary, W are analog (word) variables. I are inputs, Q
are outputs.
15
Programming Variables
Every module has four status variables (general_error, timeout_error, program_error, bus_error),
shaded gray. When general_error is zero, that means everything is ok, module is fully functional.
Yellow shaded variables are sent on change. When changed, it is sent automatically.
Red shaded variables are sent on request. Each group of four has it's own request. To send the
group, set request to 1.
To get description of each variable, hover mouse over. The description comes from the cym file.
Variables
Naming convention
Variable name may contain letters, digits and underline symbol. First character must not be a digit.
Maximum length is 32 characters. Name is not case sensitive. Special and national characters (ß,
ä, ü, ë, č, ć, š, ž...) should not be used.
i
caret_position
maximum_water_level
Allocation
Variables are allocated using Global Allocation Edit. To insert a new variable, choose group and
click New Variable.
Bit is a single boolean variable with only two possible states, zero or one. It is used for flags, logical
equations, logical states and other. The result of comparison instruction is also bit type.
Int is a 16-bit signed number. It is used for counting, encoding states, fixed point arithmetic and
similar.
16
Programming Variables
Long is a 32-bit signed value. It is used when numbers outside of 16-bit range may occur.
Processing speed is the same as for the 16-bit integers, but they use more memory.
Real is a floating point number. Float consist of 8-bit exponent and 24-bit mantissa, so the result
has 5 to 6 significant digits.
In bit, out bit, in word and out word variables represent physically connected binary (bit) and analog
(integer) signals. In bit and out bit are bit type. In word and out word are integer type.
Constant is used to represent a value that will never be changed. For example, Pi=3.141592 can be
defined for trigonometrical calculations. Constants are replaced in preprocessing, data type does
not apply.
Retentive variables
Retentive variables retain their value when power supply goes down, and also when PLC is
stopped. To make variable retentive, set the retentive flag in the global allocation dialog.
Both retentive and non-retentive variables reside in the same RAM, but retentives are automatically
copied to battery backup RAM.
RAM
PLC program
retentive
Number of retentive variables is not limited. If needed, the whole PLC memory can be retentive.
Data retention time is specified in Cybro hardware manual. When power is lost for a period longer
than specified, content of retentive memory may be lost.
System bit retentive_fail indicates that retentive memory is damaged or lost. It is set automatically
after power-on, and cleared next time PLC is started.
When allocation is changed, sending program to PLC will clear all variables. If allocation is not
changed, retentives are preserved. To send program without initialization, use Send Without Init.
17
Programming Variables
EE variables
Variables that must be preserved for a long period without electricity are stored in EEPROM. To
configure this, set "Copy to EE" checkbox.
EE variables resides in RAM memory as all other retentive and non-retentive variables, but they
also have a copy in EEPROM. Because of this, they are used by PLC program the same way as all
other variables, but in addition, reading and writing to EE is available.
EEPROM RAM
ee_read_req
To read all variables from EE to RAM, set bit ee_read_req. Bit will be automatically cleared when
copy is finished. Depending on number of EE variables, copy process may last a few seconds.
To write all variables from RAM to EE, set ee_write_magic to 31415 and set ee_write_req. When
copy is finished, both variables will be cleared. Depending on number of EE variables, write process
may last a few seconds. The purpose of magic is to protect from accidental writing.
Only the whole EE can be read or written, there is no method to read or write a single variable.
EE variables should not be accessed by program during read or write. The operation is finished
when command variables (ee_read_req and ee_write_req) are returned to zero.
18
Programming Variables
I/O variables
I/O variables are used to access physical inputs and outputs. Cybro uses four I/O address spaces,
two binary and two analog. Binary inputs and outputs are allocated respectively, starting from the
ix0 as the first input and qx0 as the first output.
... ...
IX63 QX63
slot 1 slot 1
IX32 QX32
IX31 QX31
IX0 on-board QX0 on-board
Analog i/o space has 32 analog inputs and 32 analog outputs for each slot. Slot 0 is reserved for
Cybro local inputs and outputs. In word and out word variables are both integer type (16 bit signed).
... ...
IW63 QW63
slot 1 slot 1
IW32 QW32
IW31 QW31
IW0 reserved QW0 reserved
Input and output variables are auto-allocated, their name is in the form:
nnnxx_varname
where nnn is prefix (e.g. bio for Bio-24), xx is card number (starting from zero) and varname is the
function it performs. For example, operator panel key F is allocated as op00_key_f.
Timer
Special structured type, used to determine time interval. To define a new timer variable, open Insert
New Variable dialog box, choose timer type, enter name, adjust preset, type and timer base, then
press OK.
Timer base is a period in which the timer is incremented, time resolution of the timer.
19
Programming Variables
Timer may be represented as the function block with two inputs and two outputs:
timer
in q
pt et
Correspondingly, the timer variable consists of four fields. Each field is an elementary data type.
<timer name>.<field>
For example, to set the preset of the wash_timer to 15 seconds (assuming the base is 100ms):
wash_timer.pt:=150;
Elapsed time of the wash_timer will start at 0 and increment every 100ms until it reaches 150.
Pulse timer
Timer output is activated immediately after the rising edge of input signal. After the specified time,
the output will go off. Changes of input signal during active pulse do not affect output.
IN
ET
T T T
On-delay timer
When input is activated, timer starts counting. After specified time output activates and stays high,
until input goes low. Available fields are the same as pulse timer.
IN
ET
T T
20
Programming Refresh processing
Counter
Visibility
Refresh processing
Cybro implements soft refresh processing. In a regular cycle, inputs are sampled immediately
before and outputs are refreshed immediately after the execution of PLC program.
When scan time is very short, inputs and outputs may not refresh in each scan.
When scan time is very long, inputs may update during the scan, to reduce lag.
IEX modules are updated strictly before and after the scan.
Scan overrun
Scan time is defined as a time needed to complete a full program cycle. It consists of system tasks
and PLC program.
When scan time exceeds 100ms, controller goes into scan overrun error and stops program
execution (current scan will be finished). Error code is displayed on the status bar. To disable this
feature, uncheck Scan overrun stops program in Configuration options dialog box.
When scan time exceeds 250ms, program will be interrupted by hardware watchdog, regardless of
overrun settings. When this happens 10 times in a row, program will be stopped with repetitive reset
error.
21
Programming Refresh processing
Structured text
Structured text is a high level language similar to Pascal, specifically developed for industrial
applications.
Assignment
Assignment is used to store value in a variable. An assignment statement has the following format:
variable := expression;
The assigned value should be lower or equal data type than the variable.
Expressions
Expressions are used to calculate a value, derived from other variables and constants. Expression
may use one or more constants, variables, operators or functions. Using expressions, Cybro can
perform complex arithmetic operations, including nested parentheses and mixed data types.
Examples:
y_position:=5;
down_timer.pt:=15000;
case_counter:=case_counter+1;
start:=(oil_press and steam and pump) and not emergency_stop;
valid_value:=(value = 0) or ((value > 10) and (value <= 60));
Operators
Cybro supports a number of arithmetic and logical operators, listed in the following table:
operator alias unary binary function bit int long real result
+ • • • • same
- • • • • • same
• • • • same
/ • • • • same
mod % • • • same
not ! • • • • • same
and & • • • • same
or | • • • • same
xor • • • • same
shl, shr • • • same
rol, ror • • • same
= == • • • • • bit
<> != • • • • • bit
<, <= • • • • bit
>, >= • • • • bit
:= • • • • • same
Expression evaluation
Expressions are evaluated in a particular order depending on precedence of the operators and
other sub-expressions. Parenthesized expressions have the highest precedence. Top precedence
operators are evaluated first, followed by lower precedence. Operators of the same precedence are
evaluated left to right.
22
Programming Refresh processing
Speed1 := 30.0;
Speed2 := 40.0;
Press := 50.0;
Rate := Speed1/10 + Speed2/10 - (Press+4)/9;
Speed1 := 30.0;
Speed2 := 40.0;
Press := 50.0;
Rate := Speed1/10 + Speed2/(10 - (Press+4)/9);
Type conversion
bit int
int long
real long
real
If both arguments are integer, result of operation is also integer, no matter where it is assigned.
i := 25;
r := i/10; // result is r=2
i := 25;
r := i/10.0; // result is r=2.5
i := 25;
r := real(i)/10; // result is r=2.5
23
Programming Refresh processing
Multiline expressions
Flow control
if..then..else
if <expression> then
<statements>;
elsif <expression> then
<statements>;
else
<statements>;
end_if;
Example:
if a>(2*b) then
d:=3;
elsif a>b then
d:=2;
elsif a=b then
d:=1;
else
d:=0;
end_if;
case..of
Conditionally execute one of multiple statements. It consists of an selector and a list of statements,
each preceded by a constant. Selector type must be ordinal (boolean, integer or long).
case <expression> of
<value>: <statements>;
<value>: <statements>;
<value>: <statements>;
else
<statements>;
end_case;
Example:
case material_type of
1: speed:=5;
2: speed:=20;
fan:=ON;
3: speed:=40;
fan:=ON;
cooling:=ON;
else
speed:=0;
end_case;
24
Programming Refresh processing
for..do
The for...do construction allows a set of statements to be repeated specified number of times.
Counting variable is incremented by 1 at the end of the loop.
Example:
for i:=0 to 19 do
channel[i]:=TRUE;
end_for;
while..do
The while...do construction allows one or more statements to be repeatedly executed while
particular boolean expression is true. The expression is tested prior to executing the statements.
When if becomes false, statements are skipped and the execution continues after the loop.
while <expression> do
<statements>;
end_while;
Example:
while value<(max_value-10) do
value:=value+position;
end_while;
Return value
Structured text function may return a single value of one of the basic types (bit, int, long, real).
Return value is defined by the following expression:
result := expression;
Variable result is automatically declared when function is configured to return a value (function
properties). Data type is the same as the type returned by function. Within a function, result may be
used more then once:
if a<=b then
result:=a;
else
result:=b;
end_if;
25
Operator panel General
Operator panel
General
Operator panel is the optional external device connected to the Cybro via the IEX-2 bus. OP
provides LCD display and a few keys readable from the PLC program.
OP has to be defined in the Hardware Setup dialog box. Configuration is saved within project.
Print functions Structured text functions typed in the PLC program. Used to display strings
and values.
OP keys Bit variables readable from PLC program, represent current key state.
Masks Visual tool for programming operator panel, used to enter parameters.
Capable of entering integer values, decimal values and values represented
by strings. Parameters may be hierarchically organized.
Print functions
Print functions are structured text functions used to display text messages and values.
First parameter is slot number where display appears in the hardware setup. Two following
parameters of all functions are x and y coordinates. They are used to set display position. Print
origin is in the upper left corner.
dclr(slot:int);
Print single ASCII character on specified coordinates. Character may be entered directly ('A'), as
ASCII constant (65), or as integer variable. Values from 0 to 255 are allowed.
Print first or second ASCII character, depending on bit value. If value is false, the first character is
printed, otherwise the second.
Print integer value to specified coordinates. Parameter w defines width. For example, if w is 4, print
range is -999 to 9999. Parameter zb is zero blanking. If zb is 1, leading zeroes are replaced with
spaces.
Print long value to specified coordinates. Parameter w defines width. For example, if w is 6, print
range is -99999 to 999999. Parameter zb is zero blanking. If zb is 1, leading zeroes are replaced
with spaces.
Print real value to specified coordinates. Parameter w defines width, parameter dec defines number
of decimals. For example, if w is 6 and dec is 2, print range is -99.99 to 999.99. Zero blanking is
always on.
OP keys
OP keys are accessible from PLC program as input variables:
Key P is usually used to invoke and exit mask, so it's not available for PLC program (reading is
zero). However, if no entry point is defined, it behaves the same as other keys. In such case, mask
may be invoked by writing mask number to op00_next_mask.
When mask is active, up, dn and e are not available (readout is zero). Key F is always available.
Key variable is true as long as the key is pressed. When key is released, it becomes false.
Any two (or more) keys may be pressed simultaneously. This may be used to initiate a special
function. In the following example, pressing up and down simultaneously resets product_count.
27
Operator panel Mask
Mask
Mask is visual tool for creating a query with operator terminal. More precisely, mask is a container
for a variable to be edited. Masks are transferred to the Cybro together with PLC code.
User creates a new mask or edits the existing one by using Mask Editor. Created masks are listed
in the Mask List. Masks are integral part of the PLC project, they are saved on the disc and
transferred to the Cybro.
PLC project
Mask Editor
Mask List
CyBro-2
When user presses P, Cybro sends first mask to the OP. Pressing E advances it to the next mask.
Entry point P
mask01
Next mask E
mask02
Next mask E
mask03
[exit] E
Entry point P
mask01
Branching E
E E E
28
Operator panel Mask
To start working with masks, press Masks button or F7. Mask List dialog box will appear.
To create a new mask click Add or press Insert key. Mask Editor dialog box will appear.
Next mask defines a mask that becomes active after E key is pressed.
Escape mask defines a mask that becomes active after P key is pressed. Usually, this key is used
to exit from mask.
Caption field is a short string that will appear on the display to identify the currently edited variable.
Caption position is represented by the yellow rectangle. To move the caption, drag the rectangle
into the desired position. To resize caption, drag the right edge of the rectangle.
Edit field is a display area in which the value of edited variable is displayed. It is represented by the
red rectangle. Edit field should have enough space for editing variable in the desired range. To
move and resize field, drag it like the caption.
Unit field is a short string, similar to caption. Unit field is represented with green rectangle, and it is
commonly used for displaying engineering units.
Bargraph is a semi-graphic horizontal progress bar. Few different styles are available. To use
bargraph, both low and high limits should be defined.
29
Operator panel Mask
Step defines a value for which the variable will be changed for a single key press.
Decimal places may be used for real as well as for integer and long variables. In the former case,
only the display is fractional (e.g. for decimal places=1, value 254 is shown as 25.4).
Enter required and Jump on first press define method to operate with navigation keys (P, E). Three
combinations are available:
Enter required: no
P E
escape mask current mask next mask
P E
escape mask current mask next mask
PE
value changed
(flashing)
P E
escape mask current mask next mask
P value changed E
(flashing)
If enter required is false, changed value will be sent to Cybro immediately after up or dn key is
pressed. If enter required is true, changed value will be sent to Cybro only when E key is pressed.
To indicate that change is not confirmed, changed value will flash.
30
Operator panel Program handling
Variable may be entered as menu rather than as numerical value. To define menu entries, run
Mask Editor, click Menu tab and Add as many items as needed.
When executing Cybro program, the display will show items by name, and variable product_type will
take value 0, 1 or 2.
Branching tab provides branching onto different masks according to the entered value. This can be
used to organize parameters into various parameter sets, but also for a password protected
parameters.
Active mask takes control of all panel keys except the F key, so it is not possible to use them from
Cybro program at the same time. Mask fields are displayed “over” the user display. After exiting
mask, display content is restored.
If mask is too large to fit into operator panel it will not be activated, and it will operate like an empty
mask. Mask size is displayed in Mask List dialog box. Available operator panel mask memory is
displayed in the Hardware Setup dialog box. To decrease mask size reduce number of menu
entries or reduce edit field width. Reducing caption and unit field width may also save few bytes.
Program handling
Cybro program can get currently active mask number by reading variable current_mask. When
current_mask is zero, no mask is active.
Program may force execution of a certain mask by writing to variable next_mask. After the mask is
sent, next_mask is set to -1, and current_mask changes accordingly.
31
Operator panel Program handling
mask03 mask04
1 2 3 4
mask03 variable 20 20 25 25 25
current_mask 3 3 3 0 4
next_mask -1 -1 -1 4 -1
1. Enter is pressed
2. Value is sent to Cybro
3. Request for new mask is sent to Cybro
4. New mask sent to operator panel and activated
The same transition may be initiated with the following plc program:
if <condition> then
op00_next_mask:=4;
end_if;
Short gap in current_mask value comes from the network response time. To check if there is an
active mask, program should also check the value of next_mask, like the following example:
Both mask control variables may also be accessed remotely, using the A-bus.
32
Serial interface Features
Serial interface
Features
Cybro controller features multiple communication ports which can all be used simultaneously.
A-bus is native protocol used to send program (A-bus slave), read/write variables (A-bus slave) and
exchange data between controllers (A-bus socket). For more details, check Networking section.
Modbus is data communications protocol developed for industrial applications. It is relatively easy to
deploy and maintain compared to other standards, and places few restrictions on the format of the
data to be transmitted. Modbus has become de facto standard and is now a commonly available
means of connecting electronic devices.
Free-programmable means that PLC program is responsible for sending and receiving messages,
which opens up controller for implementing any simple protocol.
COM3 port is serial port available on models Cybro-3H and Cybro-3W as RS485 interface. For
more details check hardware manual.
RFM wireless interface uses standard 868MHz ISM band (industrial, scientific and medical) to send
and receive messages. It is used to control WD-1 (DALI bridge), WM-1 (Modbus bridge) and WR-1
(Modbus relay). It can also be used for Cybro-to-Cybro communication. For more details, check
data sheet of each device.
Port parameters are set at compile time, it's not possible to change them within the program.
33
Serial interface Free-programmable mode
Free-programmable mode
With this feature, a wide range of devices can be controlled: various sensors, scales, printers, radio
modems, camera and other. Protocol is implemented using the PLC program.
COM1, COM2 and ETH communication ports are full duplex, COM3 and RFM are half duplex. Both
master and slave operation is possible.
Serial ports have separate transmit and receive buffer. Each buffer is 1042 bytes in size. That
allows for 1024 bytes payload and a few bytes for eventual descriptor and redundancy check.
Rx buffer
Tx buffer
Select port
com_select(port: int);
Select must be executed first, before other communication commands. Available ports are:
The best position for com_select() is at the beginning of code section which implements the
protocol. It may be executed in each scan, only pointers are changed, with no effect on current
receive and transmit operation.
Create message
Binary messages are created by writing byte by byte to the transmit buffer.
tx_bufwr(pos:int, data:int);
tx_bufrd(pos:int):int;
Read data byte from transmit buffer. Position is 0 to 1041, value is 0 to 255.
ASCII messages may be created with display print commands. Slot number is zero, x coordinate is
buffer position, y coordinate is ignored. Output goes to the selected transmit buffer.
34
Serial interface Free-programmable mode
dclr(0);
Write a string enclosed in single quotes ('abcd'). Special characters are entered as two or three-
character combinations:
The last option is used to enter any hexadecimal code 00 to FF, e.g. '\41' is the letter 'A'.
Write 16-bit signed integer as ASCII decimal number. Parameter w is width, zb is zero blanking.
Write 32-bit signed integer as ASCII decimal number. Parameter w is width, zb is zero blanking.
Write floating point value as ASCII number with decimals. Parameter w is total width, including
decimal point and decimals. Parameter dec is number of decimals. Zero blanking is always on.
Send message
tx_start(size:int);
Send the prepared message. Parameter size is the number of characters to transmit.
tx_active():bit;
tx_count():int;
Number of characters left to send. When tx_count() is zero and tx_active() is true, the last character
is transmitting.
tx_stop();
Stop transmitter. Current character will be finished, then tx_active() goes to zero.
35
Serial interface Free-programmable mode
Start receiver
beg_ch - first character of received message. When receiving is started, all characters are ignored,
until the specified character is received. The character is written in the zero position of the receive
buffer. To receive message with no specific start character, set to zero.
end_ch - last character of received message. When specified character is received, receiver is
stopped (status 2). Character is written as the last byte of the received message. To receive
message with no specific end character, set to zero.
len - expected length of received message. After the specified number of bytes is received, receiver
is stopped (status 3). To receive a message of variable size, set to zero.
beg_tout - maximum waiting time for the first character, in milliseconds. When timeout is reached,
receiver is stopped (status 4). To receive with no time limit, set to zero.
For example, with 1200 bps, 8 bits and no parity; transmission of a single character takes about
8ms (start bit + 8 data bits + stop bit = 10bits, 10bits/1200bps = 8.3ms). In such case, end time is
typically set to about 25ms.
Examples:
Maximum message length is 1042 bytes. When one character more is received, receiver is
restarted and the number of received characters starts from 1 again. The buffer is not cleared.
rx_stop();
rx_count():int;
Returns number of received characters. Function rx_start() reset number of characters to zero.
rx_active():bit;
rx_status():int;
0 - receiver active
1 - stopped by stop command
2 - end character detected
3 - requested size received
4 - timeout expired
36
Serial interface Free-programmable mode
rx_bufrd(pos:int):int;
Read data byte from receive buffer. Position is 0 to 1041, value is 0 to 255.
rx_bufwr(pos:int, data:int);
rx_strcmp(pos:int, str:string):bit;
Compare receive buffer with a specified string. True when string matches, false otherwise.
rx_strpos(pos:int, str:string):int;
Search for the specified string. Search starts from the given position. If string is found, function
returns position of the first matching character, otherwise it returns -1.
rx_strtoi(pos:int):int;
Read ASCII decimal number at the given position. If character at the specified position is space, it is
skipped until a digit is found. Conversion continues until the first non-digit character.
rx_strtol(pos:int):long;
Read ASCII decimal number at the given position. If character at the specified position is space, it is
skipped until a digit is found. Conversion continues until the first non-digit character.
rx_strtor(pos:int):real;
Read ASCII decimal number at the given position. If character at the specified position is space, it is
skipped until a digit is found. Conversion goes until the first non-numeric character.
Example:
Received message may contain keywords OPEN, CLOSE, AUTO and SET=<value>. Keywords are
sent in no particular order and separated by one or more spaces.
if rx_strpos(0,'OPEN')<>-1 then
main_valve=1;
end_if;
if rx_strpos(0,'CLOSE')<>-1 then
main_valve=0;
end_if;
if rx_strpos(0,'AUTO')<>-1 then
automatic_mode=1;
end_if;
position=rx_strpos(0,'SET=');
if position<>-1 then
setpoint=rx_strtoi(position+4);
end_if;
37
Serial interface Free-programmable radio
Free-programmable radio
Initialize socket
The first command must be com_select(4), it directs all consecutive commands to the radio driver.
Rx/Tx buffer
The folowing command is rx_start(), providing parameters to initialize the radio interface:
Wireless devices use factory default address 10 seconds from power on, then switch to configured
address, if one exists. That allows sending new group address to all devices at the same time.
When 10s period runs out, address is locked to protect device against intrusion. The process on
Cybro is under the control of PLC program, which allow receiving address without shutting off.
RFM radio behaves very much like any other serial port. When message is received, receiver is
stopped and need to be started again. To stop receiving at any time, use rx_stop(). Function
rx_active() returns receiver state (0-off, 1-on), function rx_status() returns more details:
0 - receiver active
1 - stopped by stop command
2 - message received
4 - timeout expired
Command tx_start() transmits prepared message, tx_active() returns transmitter state (0-off, 1-on).
It is active immediately after the start command is executed.
Message type
The type byte (position 64) specifies the content of the message:
0 - DALI (WD-1)
1 - group address (all devices)
2 - Modbus (WM-1 and WR-1)
Type must be set before the message is sent, and comes with the received message. Range 0..3 is
reserved, the rest is free to use. Type 2 can be used for any serial communication.
Group address
Devices that listen to each other's messages must share the same group address. The factory
default is the same for all devices. When privacy is not needed, this address may be used
permanently.
When data security and privacy is required, new group address must be assigned. One device
generate and send the new address to other devices. Address must be sent within 10 seconds from
power on, while the RF led is blinking. New address is randomly generated, with restriction that not
a single byte should be zero.
38
Serial interface Free-programmable TCP/IP
Free-programmable TCP/IP
Initialize socket
The first command must be com_select(5), it directs all consecutive commands to TCP/IP driver.
With ETH selected, first 10 bytes of buffer are reserved for IP header:
Tx buffer
Rx buffer
Receiver IP address and port must be written by plc program before the message is sent. Sender
IP address and port are written by system when message is received.
The following command is rx_start(), providing parameters to initialize the TCP/IP socket:
In UDP mode, the controller is ready to receive and transmit UDP messages right away.
In TCP mode, either master (client) or slave (server) operation is selected. When initialized as a
master, Cybro uses receiver address and port to open the connection and send the first message.
When initialized as a slave, Cybro enters listen mode, waiting for connection on the selected port.
To prepare the outgoing message, use tx_bufwr() or display print commands. To send the
message, use tx_start(). Parameter size is the length of the message, without the header. Other
transmit commands are not used.
To check if the message has been received, read the first byte of the buffer using rx_bufrd(). When
result is not zero, message has arrived. The rx_count() returns received size, without the header.
Parsing is the same as with the serial port. When finished, use rx_bufwr() to invalidate the message
and prepare for the next one.
0 - closed
1 - UDP open
2 - TCP initialised
3 - TCP listen
4 - TCP connected
When message is transmitted or received, timeout is reloaded and rx_active() is set. When timeout
expires, rx_active() goes to zero.
Command rx_active() returns 1 when connection is extablished (status 4). To close connection at
any time, use rx_stop() command. To close the socket, use rx_start() with protocol set to zero.
Reserved local ports are 53 (DNS), 68 (DHCP), 8442 (A-bus LAN), 20000..29999 (A-bus WAN) and
502 (Modbus slave). Other port numbers are free to use.
39
Serial interface Free-programmable TCP/IP
UDP mode
User Datagram Protocol (UDP) is a simple connectionless protocol that allow devices to send and
receive messages. Sender destination port must be the same as the receiver local port. Message
can be sent to multiple recipients using the subnet broadcast address.
Once socket is open, use tx_start() to send and rx_bufrd() to detect the received messages.
Although the state is not changed, autostop and timeout can be used by reading rx_active().
TCP master
If autostop is set, connection is closed when message is received. If timeout is set, connection
closes when time runs out. Timer is reloaded with each received and transmitted message. Only
one connection can be opened at a time.
TCP slave
The message can only be sent when the connection is established. When sending the message,
receiver ip address and port are not used, since connection is already established.
If autostop is set, connection is closed when message is transmitted. If timeout is set, connection
closes when time runs out. Slave timeout should be longer than or equal to the master timeout.
Timer is reloaded with each received and transmitted message. Only one connection can be
opened at a time.
40
Networking Ethernet connection
Networking
Ethernet connection
Cybro may have a dynamic IP address given by DHCP server, or static IP address set by Kernel
Maintenance. To configure static address, turn on checkbox Static IP address and fill-in the
subsequent fields. DNS server is needed only when push to domain name is used.
Cybro with static IP is accessable immediately after power-on. Dynamic address may need a few
seconds in the same, and up to a minute in a new network. If DHCP server is not available, Cybro
will have invalid IP address (0.0.0.0).
Checkbox 10M is used to disable baud autonegotiation and force 10Mbps speed. It may be used
when negotiation fails, for whatever reason.
Cybro has 6-byte MAC address in form 00-CB-00-xx-xx-xx, where last three bytes are serial
number (NAD). For example, Cybro 20000 (0x4E20) has MAC address 00:CB:00:00:4E:20.
41
Networking Connection options
Connection options
LAN, IP address is detected automatically
Direct connection using limited broadcast
Each controller has it's own static IP address, stored in project
All controllers share a single common IP address (proxy)
When computer has multiple network adapters, the proper one should be selected manually.
Extra timeout and Extra retries are used when communication is slow.
local network
0..5ms - - - -
connection
wired internet 10..100ms 200ms 2x 100ms 3x
3G/4G/5G
10..200ms 500ms 5x 200ms 5x
connection
2G connection 50..500ms 1000ms 5x 500ms 5x
42
Networking Connection options
This is the most common setup. All devices belong to the same subnet. IP address may be
dynamic (DHCP) or static. CyPro uses subnet broadcast (192.168.0.255) to detect IP address.
2. Direct connection
This connection is used only as emergency (no valid IP). Messages are transmitted as limited
broadcast (255.255.255.255:65535). Do not start CyPro before PC autoconfiguration address
(169.254.x.x) is established.
2. Router b Configure port forward UDP 8442 to Cybro (use static address).
If router b has no dynamic DNS support, update client may be installed on a local PC in network b.
43
Networking Connection options
Connection is established by sending push message from Cybro to CyBroRelay. Push is used to
open NAT (network addres translation) on router b, to enable traversing for messages that follows.
For more details, search for "UDP hole punching".
Thanks to CyBroRelay, CyPro sees Cybro as it is inside the local network. Other programs, like mini
scada, may also take advantage of the same connection.
This connection provides Internet connection using relay server as a mid point.
2. CyPro Set connection to common IP, enter server address, then click Copy session ID.
44
Networking Connection options
3. Server Enable relay, Set new session ID, and paste your id.
45
Networking Ethernet sockets
Ethernet sockets
Socket is used for Cybro-Cybro communication. User defines a matching pair of sockets, one for
each controller. Both sockets must have the same id. Also, both sockets must use the same list of
variables (order and type matters, name is ignored).
When multiple sockets are used, pairs are matched by socket id:
Sender does not know if the receiver actually received the socket. When the acknowledge is
needed, it can be sent back through a second pair of sockets.
Receiver does not know who sent the message. If needed, socket may include sender serial
number (or alias) as one field within the socket.
Socket size is limited only by maximum size of A-bus message. In most cases, it is 1024 bytes.
46
Networking Ethernet sockets
1. Periodic 1s
2. Periodic 10s
3. On-request
Transmission begins when request bit is set. Kernel responds by clearing the request and sending
the socket.
Request bit is the first bit variable in the socket. This bit is always transmitted as 1, so it can be
used by receiver to check if socket is received. Although the request is set, received socket is never
retransmitted.
Two pairs of on-request sockets can be used to implement request/reply communication between
controllers.
4. On-change
Socket transmitted each time socket variable is changed, when plc is running.
47
Networking Socket examples
Socket examples
Event-driven action
On-request socket may be used to send an event to multiple controllers. Each controller may trigger
the event, all others will receive it. Number of controllers is not limited.
Each controller has the same program, local i/o assignment may be different.
When receiver needs to know request source, 1 is local, 3 is remote (cast to bit when comparing).
Request will stay active for at least one scan, possibly longer if a large number sockets are defined.
Synchronized value
On-change socket may be used to synchronize a value between multiple controllers. Each
controller may modify the value, all others will receive the new value. Number of controllers is not
limited.
The example shows a light level setting (0-100%), shared among controllers.
Each controller has the same program, local i/o assignment may be different.
48
Networking Modbus slave
Modbus slave
Modbus communication protocol is published in 1979, for use with programmable logic controllers.
It has since become de facto standard for connecting various devices.
Cybro supports:
Modbus data model describes how modbus coils and registers are translated to Cybro memory.
Modbus model include coils and holding registers. Discrete inputs and input registers are not
supported.
When "Entire plc data memory" is selected, list of available coils/registers can be exported in csv
format. List may be imported by modbus master, refering variables by name instead of a number.
Function codes:
Data types:
49
Additional features Real-time clock
Additional features
Real-time clock
Real-time clock (RTC) consist of a hardware clock and calendar. When power is down, it runs from
internal battery. For accuracy and data retention time, check hardware manual.
RTC is synchronized to PC when program is sent to the PLC. To enable or disable synchronization,
use checkbox Environment/Communication/Synchronize RTC to PC Clock. RTC is also synced with
OPC server and HIQ Commander mobile application. It can be set also with PLC program.
rtc_hour:int;
rtc_min:int;
rtc_sec:int;
hour 0..23
min 0..59
sec 0..59
rtc_year:int;
rtc_month:int;
rtc_date:int;
year 2000..2099
month 1..12
date 1..31
rtc_weekday:int;
0 - Sunday
1 - Monday
2 - Tuesday
3 - Wednesday
4 - Thursday
5 - Friday
6 - Saturday
To set real-time clock, write new time/date to variables and set request flag:
rtc_write_req:=1;
50
Additional features NAD alias
NAD alias
Each controller has unique serial number, used as communication address (NAD). Serial number is
permanent and can not be changed.
NAD alias is a second, replacement address configurable by user. Alias functions same as the
original NAD, controller may be addressed both ways.
4001
4006
4002
4005
4003
4004
broken
4547
replacement
NAD alias = 4004
To set new NAD alias, open Kernel Maintenance dialog box, enter alias and send.
Because of security issues, alias is used in local communication only. When controller is connected
to the internet, the original serial number is used exclusively.
51
Additional features Password protection
Password protection
Cybro controller can restrict access to it's data with password. Depending on selected level,
protection may cover only program, program and variables, or everything. For example, when
protection level is Program protected, anybody can read and write variables, but needs a password
to send a new program.
Password protection affect only Ethernet interface. Serial ports are not restricted (including USB),
even when full protection is used.
Password may contain any combination of letters and numbers of a reasonable length. It is case
sensitive. Don't use spaces or national characters.
Password is common for all programs in project, it's not possible to define individual password for
each controller. Password stored in project file is not secure, so keep your project safe.
To send a new program to protected controller, use command Erase protected program.
If you forget the password, unlock controller using the USB port.
52
Additional features Command-line options
Command-line options
Command-line options are specified upon starting CyPro. They are used to automatically perform
some tasks, such as sending a program to a connected controller.
Using command-line options, CyPro may be used as external compiler for another application.
SCADA CyPro
CyBro
cypro /OPEN myfile.cyp /START
CyPro.log myfile.cyp
cypro.exe filename.cyp
cypro.exe /OPTION1 /OPTION2 /OPTION3…
First style is used by operating system, when user double-clicks a cyp file.
/NAD number Select program. If specified NAD exists, that program will be
selected, otherwise NAD is appended to current program.
Filename may be given as name or full path. When file name contain spaces, double-quote should
be used ("my file.cyp"). If an operation requires user input to continue execution, default option is
53
Additional features Command-line options
used automatically. For example, when autodetect asks for a network address, default address
(zero) will be used automatically.
When started with command-line options, CyPro creates log file with all commands and results. Log
file is saved in CyPro directory (c:\Program Files (x86)\Cybrotech\CyPro-3\CyPro.log).
When /HIDDEN mode is used, CyPro will automatically exit after last command is executed.
When using command-line options, it is advisable to turn on checkbox Allow multiple instances in
Environment Options. If only single instance is allowed and CyPro is already running, command-line
requests will be proceeded to the active copy.
Examples:
cypro.exe myfile.cyp
Start CyPro and open project myfile.cyp in specified directory. As path may contain spaces, quotas
are required.
Start CyPro, open an existing project (myfile.cyp), start PLC (compile, send & run) and exit.
Operation is hidden, no window or dialog box will appear. Possible errors are saved in CyPro.log.
Start CyPro, open a new project, start Autodetect, save as myfile.cyp and exit. Operation is hidden,
no window or dialog box will appear. Possible errors are saved in CyPro.log.
Start CyPro, open a new project, add new NAD, start Autodetect to detect connected IEX-2
modules, save as myfile.cyp and exit. Operation is invisible, no window or dialog box appears.
Possible errors are saved in CyPro.log.
Start CyPro, open an existing project (myfile.cyp), start Autodetect (assuming the project has no
defined hardware setup and network address), start PLC (compile, send & run) and exit. Original
file remain unchanged. Operation is invisible, no window or dialog box will appear. Errors are saved
in log file.
54
Getting started Command-line options
Getting started
This example, a simple timer activated with a key, will show all steps to get a program running.
Step 1: hardware
We need Cybro controller and OP-2 panel. Connect power supply, ethernet and panel according to
hardware manual.
Open CyPro and select File/New Project. Open Hardware Setup and run Autodetect.
Step 2: variables
Our project will need a variable of timer type. Start Allocation Editor, and press Insert:
PLC code connects the OP key to the timer input, and the timer output to the output relay:
tim0.in:=op00_key_f;
cybro_qx00:=tim.q;
55
Getting started Command-line options
Step 4: run
To compile and send program, just press Start button. Status line shows the program is running.
To check operation, open Variable Monitor, add variables, and press F key.
56
Appendix Data type summary
Appendix
Data type summary
Elementary
(*) Each bit variable is stored as a byte, casting int to bit extends range to 255.
Input/Output
Timer
Constants
decimal
address := 256;
hexadecimal
address := 16#100;
57
Appendix Structured text summary
operator alias unary binary function bit int long real result
+ • • • • same
- • • • • • same
• • • • same
/ • • • • same
mod % • • • same
not ! • • • • • same
and & • • • • same
or | • • • • same
xor ^ • • • • same
shl, shr << >> • • • same
rol, ror • • • same
= == • • • • • bit
<> != • • • • • bit
<, <= • • • • bit
>, >= • • • • bit
:= • • • • • same
Flow control
if...then...else
if <expression> then
<statements>;
elsif <expression> then
<statements>;
else
<statements>;
end_if;
case...of
case <expression> of
<value>: <statements>;
<value>: <statements>;
else
<statements>;
end_case;
for...do
while...do
while <expression> do
<statements>;
end_while;
58
Appendix Structured text summary
Edge detect
fp(b:bit):bit;
fn(b:bit):bit;
Type conversion
Serial ports
port select
transmit
receive
59
Appendix Structured text summary
Display functions
Legend:
Network functions
Return value
60
Appendix Function library
Function library
Function library is a collection of commonly used functions, written in structure text. It is a part of
CyPro package, located in \CyPro\Examples\FunctionLibrary.cyp. To use a function, copy and paste
from library (right click project tree) to your program. For more details, check function source.
bit manipulation
elementary functions
trigonometric functions
pseudo-random generator
other functions
61
Appendix Instruction list summary
Logic
Arithmetic
Compare
Branch
62
Appendix Instruction list summary
Type combinations
63
Appendix Operator panel characters
To enter character code, press Alt, type decimal character code preceded by 0, then release Alt.
Numeric keypad should be used, Num Lock should be on.
Example:
According to table, symbol ° (degrees centigrade) hexadecimal code is DF, which is 223 decimal.
Because of a character set, character "ß" will appear on screen, but LCD will display properly.
dprns(1,0,0,'T=xx.xßC');
dprnr(1,2,0,4,1,cybro_temperature*0.1);
64
Appendix Keyboard shortcuts
Keyboard shortcuts
General
F1 Help
F2 Syntax check
F4 Program settings
Shift-F4 Environment settings
F5 Hardware setup
F6 Allocation editor
F7 Mask editor
F8 Socket editor
Ctrl-Shift-S Save As
Ctrl-D Connect/disconnect communication
Ctrl-L Select NAD
Text editor
Ctrl-F Find
F3 Find next
Ctrl-R Replace
Ctrl-G Go to line
65