MNL 041 Q 100
MNL 041 Q 100
MNL 041 Q 100
Use of Remoter
Commands index
File management commands
Editing commands
View commands
Project management commands
Target management commands
Project compiling commands
Macro management commands
Tools configuration commands
Windows management commands
Help commands
Workspace
Creation of a new workspace
Project
Creation of a new project
How to compile the project
Project settings
Hardware target selection
Software target selection
Target system configuration
Project type selection
Library selection
Memory limits setting
PLC settings
Various settings
Programming communication
Debug communication
RLD File
How to add a file
How to build a branch
How to run the debug
RIL File
How to add a file
How to run the debug
RFB File
How to add a RFB file
FB MODBUS communication
FB terminal operator
Assembly File
How to add file
How to run the debug
C File
How to add a file
How to run the debug
Operations on target
System catch
Information request
Software version
Memory deletion
Program upload
Program download
Program running
Project information
Mass memory manager
Utilities
Terminal emulation
Function blocks
C Language
Macros
Data types
Variables
Functions
ANSI Functions
RIL Language
Operands
reserved operands
Instructions
Operand definition instructions
Logical instructions
Data management instructions
Math instructions(Fixed)
Math instructions(Float)
Serial instructions
Program management instructions
Utility instructions
How to
Appendix
How to migrate the program from 7.x versions
How to migrate the program from 8.0.x versions
Ascii code table
Error list
Libraries
Memory map
Loaders
Kernels
Netsyst line
Picosyst line
Worspaces list
Index
Remoter
Remoter is a set of development for every single product, easy and nice to use. it allows to generate "multi
file" projects, with the opportunity of integrating some code parts developed in the C language. The
powerful and versatile set allows the development of your own work, as well as to load it in the device and
to manage the debug. Proper dialog windows, that you can size and place as you like, let you monitor the
different conditions of the controller and its operands.
A set of commands for the file management, view, project management, editing, project compiling, target
management, macro management is directly accessible from toolbars, which can be personalized in order
to satisfy particular user's needs, and it gives a faster access to the most useful functions .
A powerful set of instructions, that contains operand definitions, logic, data management,program
management, fixed or float mathematical, serial, or utility, lets the user to realize programs that solve any
automation requirements.
The symbolical programming allows to use a proper name for every single operand making easier the
comprehension of the program by breaking the limits of the numerical programming, that imposes a defined
numerical range for every operand. Indeed the symbolical programming gives the opportunity of using the
whole memory area of the product by placing the operands according to your own needs. The interaction
between the RIL program and the functions carried out in other languages, such as assembler and C, see
the proper chapter.
Application development
The application development is very easy, here they are the steps to follow.
With Remoter are supplied some example programs that shows different programming techniques.
Index
These commands are accessible from the File menu. However, you can find some keys in the proper
toolbar to have the direct access to the different functions. Here it is the list of the available commands.
Index
Editing commands
These commands are accessible from the Edit menu. However, you can find some keys in the proper
toolbar to have the direct access to the different functions. Here it is the list of the available commands.
Index
View commands
These commands are accessible from the View menu. However, you can find some keys in the proper
toolbar to have the direct access to the different functions. Here it is the list of the available commands.
Index
These commands are accessible from the Project menu. However, you can find some keys in the proper
toolbar to have the direct access to the different functions. Here it is the list of the available commands.
Add to Project...
I comandi permettono di aggiungere al progetto nuovi oggetti. Di seguito riportiamo elenco dei comandi
disponibili.
Index
These commands are accessible from the Target menu. However, you can find some keys in the proper
toolbar to have the direct access to the different functions. Here it is the list of the available commands.
Debug...
I comandi permettono di eseguire il debug del programma sul sistema target. Di seguito riportiamo elenco
dei comandi disponibili.
Start... Actives the program debug, it allows to visualize and change the values of
Figure 2
the program variables, while it's in execution on the target system. Please
refer to the RIL o C debug chapters.
Index
These commands are accessible from the Build menu. However, you can find some keys in the proper
toolbar to have the direct access to the different functions. Here it is the list of the available commands.
Build It compiles all the project files changed after the previous
compilation. The control executed on the dates of the files
included in the project. If the include directive is used in a C
files, it's possible that some changed files are not compiled, so
we suggest to use the Rebuild All command.
Figure 1 Rebuild All It compiles all the project files.
Stop Building It stops the build procedure.
Index
These commands are accessible from the Macro menu. However, you can find some keys in the proper
toolbar to have the direct access to the different functions. Here it is the list of the available commands.
New It enables/disables the record of a macro. The record allows to store all the
operations executed with the keyboard. With the Play command the
operations stored are repeated in the same order in wich were memorized.
Play It executes the registered macro.
Stop It stops the playing of the macro.
Figure 1
Index
Tools commands
These commands are accessible from the Tools menu. However, you can find some keys in the proper
toolbar to have the direct access to the different functions. Here it is the list of the available commands.
Language
It allows to select the desired language. Here it is the list of the available commands.
Italian It select the italian language. All the menus, the file header, will be visualized
in italian language.
Figure 2
English It select the english language. All the menus, the file header, will be
visualized in english language.
Index
Window commands
These commands are accessible from the Window menu. However, you can find some keys in the proper
toolbar to have the direct access to the different functions. Here it is the list of the available commands.
Index
Help commands
These commands are accessible from the View menu. However, you can find some keys in the proper
toolbar to have the direct access to the different functions. Here it is the list of the available commands.
Help Topics... It opens the Remoter help visualizing the topics index.
Help Index... It opens the Remoter help visualizing the index.
Splash Screen... It displays the Remoter splash screen, it reports the
version.
Tip of the day... It displays the tip of the day window, to every
command a new tip is displayed.
About Remoter... It displays the window with the information about
Remoter. ATTENTION! From this window it's possible
Figure 1 to input the registration code, in order to register the
product.
Register... It displays the window with the register request form.
ATTENTION! If you already have the user name and
password to register the products, please use the
About Remoter... command.
Index
Workspace
Remoter allows to organize your own work easily and rationally. the element that contains the list of the
projects used by the developer is the workspace that appears as a file, under extension rws (remoter
workspace); follow the information at the chapter create a new Workspace. Every workspace can contain
different projects, different in characteristics and code type; the workspace are to be considered as global
containers that can be set up and separately visualized. The figure below shows an example of workspace
with 2 projects.
Figure 1
Every project contained in the workspace follows its own project settings, the project compiling will work
only on the active project (green project icon) ; therefore you have to set the project you want to operate
on, as active project. You can use the keys Ctrl+Tab, which move the selection among the different
projects of the workspace, to select the active project. Otherwise you can place the mouse on the icon of
the project you desire operate on and select the option Set as Active Project, with the right key of the
mouse.
Figure 2
Workspace
To create a new workspace, please choose New item of the File menu, press the Ctrl+N keys or press the
key. The command opens the new workspace window, which allows to to choose the type and the
destination folder of the workspace. After to defined the disk path in the Location box, it's necessary to
define in the name in the Workspace name box. Automatically inside the defined path will be created a
directory and inside of it a file with the with the name of the workspace and rws extension. It supposing to
want to create a project with name Mnl041 on the local disk C, we will have a like condition like that
reported in figure.
By clicking on the key located near the Position box a window appears allowing the disk browsing,
so it's possible to select the path instead of digit it.
Figure 1
Index
Project
A project represents a list of files written in different languages, all together generate a unique program to
be transferred to the target system, follow the instructions to create a new project. The program will be
generated according to the defined project settings, every file is represented with an icon indicating its type.
To add a new file in the project choose the item New from the File menu, use the key or push the key
sequence Ctrl+N. Will be displayed a window with allows to select the file type desired.
You can execute the project debug only if you insert a function block (FB) allowing the operation. So
yo have to insert the Modbus slave communication FB in the project.
By clicking on the key located near the Position box a window appears allowing the disk browsing,
so it's possible to select the path instead of digit it.
Figure 1
rld Program files in Ladder diagram language, by default they are automatically called.
ril Program files in Instruction list language, by default they are automatically called.
c Program files in C language, they are never automatically called, the functions are contained in
them, have to be called by the RIL file using the TASK instruction or by other Assembler or C files
using the function call.
h These files doesn't have a program, but only the definitions for the C program files.
a51 Program files in Assembler language, they are never automatically called, the functions are
contained in them, have to be called by the RIL file using the TASK instruction or by other
Assembler or C files using the function call.
txt Text file, they are not taken in consideration for the creation of the program. They can be included
to contain useful text notes for the description of the project.
rfb Graphic FB management files, by default they are automatically called. You can add a terminal
operator management FB or MODBUS communication management FB.
Inserted the new file, it will be visible in the project tree as in the figure.
Figure 2
Next to the file type icon could be a green ball and a blue arrow . The green ball indicates that the file is
inserted in the program, there are files that are present in the project tree but they don't are inserted in the
project (Example the text files txt). The blue arrow indicates that the file will be automatically executed
Autocalled File. The execution order of the files is that with which they are reported in the project tree
starting from the top to the low. Positioning the mouse on a file name and clicking on the right key it's
possible to choose the relate options:
Figure 3
Remove Item, allows to remove the file from the project. The removed files are moved to the Trash
directory created in the project path.
Rename Item, allows to rename the file, it will be renamed also on the disk. It isn't possible modify the file
extension, so the file still remain of the same type.
Duplicate Item, allows to duplicate the file, will be created a new file of the same type with the same
extension on the disk and inserted in the project tree. The new file will have the name of the original file
followed by Copy.
Excluded from Project, allows you to include or exclude the file from the project. The excluded files
(Displayed in gray) doesn't have any effects on the creation of the final program. This option allows you
to delete files from the project leaving them in the tree. An excluded file can be included in the project
afterwards. The exclusion of a Container automatically causes the exclusion of all the file contained in it.
Autocalled File, selects if the file has to be automatically executed or not. This option is available only for
the RLD, RIL, RFB files. If a file is not autocalled it must be called by other files with the CALF instruction to
be executed.
To add a Container to the project, place the mouse on the project name, use the right key and select the
item Add to project...->Container....
The container isn't a real directory on the disk, but it is only a virtual folder in which you can move the
project files to make it more readable. To move the file to the container you have to execute a drag
and drop operation on the files you need. We remind you that the file execution rules are maintaneid
also in the Container.
Figure 4
Project
To create a new project, please choose the New item of the File menu, press the sequence of keys Ctrl+N or to use the
icon. A window appear, from it it's possible to choose the type and the destination folder of the project. After to have defined the
Location it's necessary to define the Project name. Supposing to create a project with name English, we will have condition
like that reported in figure.
By clicking on the key located near the Position box a window appears allowing the disk browsing, so it's possible to
select the path instead of digit it.
Figure 1
Confirming the selection, the project settings windows with the request of the target hardware is displayed. Select the proper
target system.
Figure 2
It's important to correctly define the target system, so below the selection an image of the chosen device is displayed. However
to avoid mistakes we suggest to read the product code reported on the product identification label figure 3, the presence of
asterisks indicates that any number or letter in that position is however valid.
Figure 3
Press the Next key until to reach the end of the settings, to this point will be automatically created a project with some files
included in the project tree as reported in the figure.
Figure 4
Project
Finished to write all the program files, it's necessary to execute the compiling and link procedures. The icon
Build all allows to execute this procedure automatically on all the project files, generating only one file in
intel-hex format to be transfered to the target system. During the program changes you can use the icon Build
that compiles only the modified files, avoiding loss of time for the compilation of files not modified.
The Build procedure is a shortcut to save time, in some cases is possible that the result of the
procedure doesn't respects the modifies done, it is advised so to execute a Rebuild all.
Figure 1
The project files are subject to different operations according to their type and every operation executes on
them specific controls. Ended the compilation and the link procedures, a message reporting information about
how much memory the project used is displayed.
Possible errors cause the block of the procedure and in the Build window a message is displayed reporting
information about the number of error and a short message with information about it. If you place the mouse on
the error message and click twice on it, the file with the error will open automatically and the cursor will be
pointed to the line where the error is, as shown in figure. For a complete list of the errors please refer to the
proper chapter.
Figure 2
Index
Project settings
Every project has its own settings, choose the Settings item of Project menu, to visualize the settings of the active project.
The settings are visualized in sequence with specific windows for every type. To pass from one set to the next one, use the Next key
in the lower part of every window.
It is also possible to position with the mouse on the project icon and with the right key choose the Settings option.
Figure 1
A window will be opened with all the possible settings subdivided for the different categories.
Figure 2
Target Hardware Permette la definizione del target per il quale viene creato il programma.
Software Permette la definizione del software installato sul target per il quale viene creato il programma.
Configurazione Target Permette la definizione delle configurazioni del kernel
Progetto Tipo di Progetto Permette la definizione del tipo di progetto.
Librerie Permette la definizione delle librerie utilizzate per lo sviluppo del progetto.
Limiti di Memoria Permette la definizione dei limiti di memoria.
PLC Permette la definizione delle impostazioni variabili PLC.
Varie Permette la definizione di alcune impostazioni selezionabili dall'utente.
Computer
Comunicazioni
Programmazione Protocollo Permette la definizione del protocollo di comunicazione da utilizzarsi per la programmazione del
sistema target.
Mezzo di Permette la definizione del mezzo di comunicazione da utilizzarsi per la programmazione del
comunicazione sistema target.
Protocollo Analog Devices uC Loader Utilizza il protocollo di comunicazione proprietario Analog Devices presente nei chips ADuC845.
Atmel 89C51 Loader Utilizza il protocollo di comunicazione proprietario Atmel presente nei chips 89C51.
Modbus Utilizza il protocollo di comunicazione Modbus.
Philips 89C51 Loader Utilizza il protocollo di comunicazione proprietario Philips presente nei chips 89C51.
Media Porta Seriale Permette la definizione delle impostazioni della linea seriale per la programmazione del sistema target.
Driver Seriale Permette la definizione delle impostazioni del driver seriale per la programmazione del sistema target.
TCP/IP Permette la definizione delle impostazioni comunicazione TCP/IP per la programmazione del sistema target.
Debugging Protocollo Permette la definizione del protocollo di comunicazione da utilizzarsi per il debug del sistema
target.
Mezzo di Permette la definizione del mezzo di comunicazione da utilizzarsi per il debug del sistema target.
comunicazione
Protocollo Modbus Permette la definizione delle impostazioni del protocollo modbus per la comunicazione con il sistema target.
Media Porta Seriale Permette la definizione delle impostazioni della linea seriale per il debug del sistema target.
Driver Seriale Permette la definizione delle impostazioni del driver seriale per per il debug del sistema target.
TCP/IP Permette la definizione delle impostazioni comunicazione TCP/IP per per il debug del sistema target.
Project settings
Target hardware
It allows the definition of the target you create the program for. First you choose the products family NetSyst line and PicoSyst
line, then you can choose in the relate tree the target system you desire.
Figure 1
It's important to correctly define the target system, so below the selection an image of the chosen device is displayed. However
to avoid mistakes we suggest to read the product code reported on the product identification label figure 2, the presence of
asterisks indicates that any number or letter in that position is however valid.
Figure 2
Project settings
Target software
It allows to define the software installed on the target you create the program for. Remoter shows a default choice, that is valid for
the target hardware, previously selected.
Figure 1
Software
Allows to define the kind of software installed on the target system to which the application is referred.
Software version
Allows to define the software version installed on the target device. It's suggested to choose the last version available, Remoter
will automatically check the version really installed and will set up itself according to it.
Project settings
Target configuration
The target system can be configured according the user needs. The system configuration is stored into a non volatile memory
and remain memorized in the target system until a new configuration is been stored. The target configuration option opens a
window with the visualization of all possible settings divided into a several categories.
To modify the target configuration, a new configuration must be transferred into the target system.
Figure 1
Security
Users User ... Allows to define the access rights, the username and password for the users. Up to 4 users can be configured with
different settings.
Hardware resources
Serial ports
Serial Serial Port Allows to define the serial port settings.
Port ...
Serial Driver Allows to define the serial driver settings.
Drivers
Access Points Access point ... Allows to define the access point parameters.
Command Managers
Modbus Modbus ... Allows to define the modbus protocol parameters.
Devices
Modems Modem ... Allows to define the modem settings.
Project settings
Project type
It allows to define the project type. Now the only type you can select is the default shown.
Figure 1
Project settings
Libraries
It allows to define the libraries to use, they are divided into categories, as shown in figure.
After to have added a new library in Remoter, press the Save Current key to replace the previous versions presents in the project.
Figure 1
System library Defines the version of the system library. The system library contains the functions allowing the management of the target system,
every system needs its own library, the only available versions for the selected target are shown.
PLC library Defines the version of the library for the PLC instruction management. The library contains the functions allowing to execute the RIL
language instructions, the only available versions for the selected target are shown.
FB libraries Defines the list of the function blocks used in the project. If you execute a call to a FB in the project, you also need to insert it in the
list so that the linker can link its proper code. The FB are supplied in different versions, it's important to select the only the version
used in the project.
Project settings
Memories limits
The memory configuration window allows you to define the memory areas for the compilation of the program, as shown in figure.
The default configuration selects the best values for the type of target that is being used.
To avoid problems, we suggest to keep all the ranges set as shown in default.
Figure 1
Code Defines the allocation range of the Code memory for the user program, to see the target memory configuration please refer to the
memory map.
XData Range Defines the allocation range of the RAM memory for the user program, to see the target memory configuration please refer to the
memory map.
Data Range Defines the allocation range of the RAM memory /Inside of the uP) for the user program, to see the target memory configuration
please refer to the memory map.
Ranges definition
The ranges change according to the different targets and the type of program must be realized. In the gray box are reported
the settings that are automatically defined by Remoter.
Code Target system Program type Data Bit XData Code Page
MPS022**** Netlog User program (Loader) 0x00-0x7F 0x00-0x7F 0x8000-0xFFFF 0x0000-0xFFFF 0x0000
CPU016**** Picosyst Millenium CPU
MPS026**** Picolog Millenium
User program (Loader) 0x00-0x7F 0x00-0x7F 0x8000-0xFFFF 0x0000-0xFFFF 0x0000
MPS027**** Facelog Millenium
OIF018*0*0 Picoface Millenium
MPS029**** NetlogII Lite User program (On chip loader) 0x00-0x7F 0x00-0x7F 0x0000-0x07FF 0x0000-0xF7FF 0x0000
MPS030**** NetmasterII TINI
MPS031**** NetmasterII SNAP
MPS033**** NetmasterII TSTICK User program (Loader) 0x00-0x7F 0x00-0x7F 0x0000-0x07FF 0x0000-0xDFFF 0x0000
CPU017**** Picosyst MilleniumII CPU User program (Loader) 0x00-0x7F 0x00-0x7F 0x0000-0x5FFF 0x0000-0xFFFF 0x0800
MPS036**** Picolog MilleniumII
Kernel program (Loader) 0x00-0x5F 0x00-0x3F 0xE000-0xFFFF 0x0000-0xFFFF 0x0800
MPS037**** Facelog MilleniumII
OIF020*0*0 Picoface MilleniumII User program (Kernel) 0x60-0x7F 0x40-0x7F 0x0000-0x5FFF 0x0800-0xFFFF 0x0800
User program (Loader) 0x00-0x7F 0x00-0x7F 0x0000-0x5FFF 0x0000-0xFFFF 0x0800
Kernel program (Loader) 0x00-0x5F 0x00-0x3F 0xE000-0xFFFF 0x0000-0xFFFF 0x0800
MPS034**** NetlogII
User program (Kernel) 0x60-0x7F 0x40-0x7F 0x0000-0x5FFF 0x0800-0xFFFF 0x0800
User program paged (Kernel) 0x60-0x7F 0x40-0x7F 0x0000-0x5FFF 0x0800-0x7FFF 0x0800 0x8000-0xFFFF 5
Project settings
PLC settings
It allows the definition of the memory areas to place for the PLC variables, as shown in figure. The configuration of default sets up
the best values for the type of target you are using.
Figure 1
Call User Startup If selected, enables the call of a startup function defined by the user. This function is called once before to execute the user
program further information.
In the Real time clock section, it's possible to define the configuration for the real time clock management.
Manage Target Rtc If selected, enables the management of the real time clock on the target system providing the updating of the proper reserved
operands. If the user program doesn't need the use of the real time clock, can deselect it reducing the program loop time.
Rtc Data Start Add Defines the allocation address of the PLCRtcData variable for the management of the real time clock. If not defined the variable
will be allocated automatically.
In the Logic Input section, it's possible to define the configuration for the logic input (I) management.
Start Address Defines the start address of the allocation buffer in the RAM memory.
End Address Defines the end address of the allocation buffer in the RAM memory, it's automatically calculated using the defined Nr.of
bytes.
Nr.of bytes Defines the allocation buffer dimension expressed in bytes.
Disable management If selected, disables the logic input management.
Debouncing Time It defines the logic input debouncing time.
In the Logic Output section, it's possible to define the configuration for the logic input (O) management.
Start Address Defines the start address of the allocation buffer in the RAM memory.
End Address Defines the end address of the allocation buffer in the RAM memory, it's automatically calculated using the defined Nr.of
bytes.
Nr.of bytes Defines the allocation buffer dimension expressed in bytes.
Disable management If selected, disables the logic output management.
In the F, Y, W, DW, FL section, it's possible to define the configuration for the Flag (F), Byte (Y), Word (W), Double (DW), Float
(FL) operands.
Start Address Defines the start address of the allocation buffer in the RAM memory.
End Address Defines the end address of the allocation buffer in the RAM memory, it's automatically calculated using the defined Nr.of bytes.
Nr.of bytes Defines the allocation buffer dimension expressed in bytes.
In the Backup Area section, it's possible to define the configuration for backup memory.
Start Address Defines the start address of the allocation buffer in the RAM memory. All variables that start from this address for the Nr.of
bytes defined are automatically stored in the backup buffer.
End Address Defines the end address of the allocation buffer in the RAM memory, it's automatically calculated using the defined Nr.of
bytes. After this address will be allocated all the mnemonic backup variables defined in the RIL program by using the
DEFB instruction.
Nr.of bytes Defines the allocation buffer dimension expressed in bytes.
If it's not required to have numeric backup variables, this value must be set to 0. Anyway all the mnemonic backup
variables defined in the RIL program by using the DEFB instruction will be allocated.
Copy buffer mem. Type Defines the backup buffer memory type, see the memory map of target system.
Copy buffer start add. Defines the start address of the backup memory. Please note that the dimension of the total buffer required it's calculated
adding to the defined Nr.of bytes all the variables defined in the RIL program by using the DEFB instruction.
Project settings
Various settings
It allows the definition of some settings that the user can select, as shown in figure.
Figure 1
In the Project Info window you can insert a description of the project, the text that has been inserted will be saved in the project file.
Under the text box for the description insertion, some information about the build number, the date of the last compilation and
the version of Remoter you used, are reported. This information are managed automatically (every time you compile the build
number increases). This information are transferred to the PLCRemoterProjectInfo structure by carrying out the project uploading
the target, you can read it again from the target system by using the Loaded Project Info procedure.
The tick box Ask before Stop Target, if selected, forces to ask a confirmation before stopping the target system with the catch.control.
The tick box Allows code download, if selected, allows the download of the program from the target device.
Index
A graphic ladder file RLD is shown in a window as that reported below. The PgUp and PgDw keys allows
zoom in and zoom out the graphic sheet so you can have a better view of the project. The + and - keys of
the numerical keyboard allow to modify the size of the characters.
Figure 1
On the right hand of the drawing sheet it is visible the line numerator, clicking on the Show Grid icon it's
possible to show or hide the line numerator and the grid on the drawing sheet. To write the program it's
available a toolbar that contains all the graphic objects. The toolbar doesn't include specific components for
the program manipulation for the serial line management, so if required the as complement to the RLD files,
RIL and/or C language files must be used. For further information on the management of the RLD files
please refer to how to create a rung in RLD or to the debug chapters.
Figure 2
Open and close rung. A rung must init with symbol and end with the symbol.
Normally open contact, it can be used with the Counter (C), Flag (F), Input (I), Output (O), Timer
(T) operands.
One shot normally open contact, it can be used with Counter (C), Flag (F), Input (I), Output (O),
Timer (T) operands.
Normally close contact, it can be used with the Counter (C), Flag (F), Input (I), Output (O), Timer
(T) operands.
Output, it can be used with the Flag (F), Output (O) operands.
One shot output, it can be used with the Flag (F), Output (O) operands.
Inverted output, it can be used with the Flag (F), Output (O) operands.
Set output, the output condition still active until a rung with the symbol will becomes active. it can
be used with the Flag (F), Output (O) operands.
Reset output, the output condition still inactive until a rung with the symbol will becomes active. it
can be used with the Flag (F), Output (O) operands.
Timer output, it can be used with the Timer (T) operand.
Counter output, it can be used with the Counter (C) operand.
mAthematical operation, it can be used to define all mathematics operations.
Show/hide grid, allows to make visible or to hide the grid in the drawing sheet.
Comment box, allows to define a box where to insert comments.
Insert space up, insert space up the selected rung.
Insert space down, insert space down the selected rung.
With a double click of the mouse on the drawing sheet, it's possible to open a window that allows to define
the greatest number of lines present in the drawing. After to have defined the value press ok to confirm.The
grid can contain at maximum a matrix of max 600 lines for 14 columns. If the number pressed exceeds the
greatest or minimum value, will appear a window that will indicate the limits.
Figure 3
RLD file
To add a graphic ladder file RLD into the project, choose the New item from the menu File, use the
icon, or press the Ctrl+N key sequence. A window will be displayed allowing the possibility to choose the
desired file type. Select the Ladder Diagram Source File (*.rld) entry from the list and specify the name
you want to give the file in the text box signed by the File name label, for instance RldFile, it is not
necessary to specify the extension because it is assigned automatically. If you press the OK key, you
create the file in the directory selected in Location, add it into the project tree and open it in editing. Further
information about the RLD file programming techniques are reported in the proper chapter.
By clicking on the key located near the Position box a window appears allowing the disk browsing,
so it's possible to select the path instead of digit it.
Figure 1
RLD file
To insert in the shutter a component available in the toolbars, you just have to click on the component and
place it through a following Click, where you want it to be, the component will be placed inside the square
automatically, without any other actions. the following images show the above procedure.
Figure 1
By clicking over a symbol it will becames blue it means thai it is selected. It is possible to select whole rungs
and with copy and past operations double them.
Figure 2
If the symbol is visualized on red background indicates that in that position exist two or more symbols, it's
necessary to select the symbol (The color will become purple) and cancel the symbols with the Canc key.
Figure 3
Rung structure
All of the rungs always should begin with the Left power rail, the absence of such symbol causes
errors during the project compilation. Subsequently can be drawn the branch opening symbols: , , ,
that, connected between them by means of the components connection symbols , , , , , ,
, , , , , , allow to realize the rung wanted. The rungs should be drawn following all of the
defined rules, otherwise could verify errors during the project compilation. After to have drawn the whole
branch, it's possible draw the close symbols, , , , , , , , that always be followed by the
Right power rail, the absence of such symbol causes errors during the project compilation.
Operands
By double clicking on the operand will appear a component properties window, on it it will be possible to
define the component type and its address.
Figure 4
Comments
Inside of the drawing sheet can be introduced comment blocks by using the Add comment icon. To
change the text and the dimension of the comment box double click with the mouse on it. It will appear a
window that allows to define the new text and the dimension in number of grill column.
Figure 5
Grid
The graphic objects that are present in the program always are positioned inside of a reference grid, it's
possible to show or hide it hidden simply maintaining all the features of posizionamento of the same
components. Acting on the Show grid icon it's possible to display or hide the grid.
RLD file
After the upload running of the user program on the target system, you can carry out the debug. If the FB
communication MODBUS has been inserted in the project the debug will work, by using the key, when
the target system is connected to the PC through the selected communication media and when the user
program is running.
If you select the file RLD you want to debug, from the project tree, it will be displayed and at every
instruction will be reported the status of the logical branch. The instruction underlined by the green box
means that it is in a true logical status.
If you realize the example in figure linking the input I 0000 to the button that is normally open (RUN) and the
input I 0001 to the button that is normally closed (STOP), you can verify that the behavior of the output and
of its auxiliary contact through the simulation of the different logical status.
Figure 1
The RUN occurs through the pressing of the button START, while the stop occurs through the pressing of
the button STOP; you can notice that the pressing of START doesn't have effects if you keep pressing the
button STOP.
Index
A RIL file is shown as the window reported below, see figure. This is an editing window; you can write the program
on it, by using the typical facilities of an editor. See the proper chapter for a full list of the editing controls. You have
to refer to the instructions, operands and function blocks for the program writing. We remind that it is not important
to keep the alignment of the program, the use of capital or small letters for the instruction and operand writing too.
All the written text after ";" has no importance and it is considered as a comment. To add a file to the project, please
refer to the information reported in the proper chapter.
Figure 1
Syntax coloring
In order to have better reading of the file, an automatic coloring of the syntax is carried out. The instructions are
blue colored, the operands are pink colored, the mnemonics of the reserved operands are gray colored and the
comments are green colored.
Operand comment
In the RIL programming you can automatically match every operand with a comment string, all the text following the
instruction, after ";", are considered as the operand comment.
By acting on the Scan and Xreference icon, is executed a scansion of all the RIL and RLD files of the project
and to every operand is matched with its own comment, if exists. If the instruction has more than one operand, the
comment is matched only with the first operand.
By acting on the Update comments and format icon, the instructions and the operands automatically become
in capital letters and the written program will be aligned on the predefined tabulations. The proper comment is
automatically reported to any operand by overwriting the eventual edited comments.
File example
It 's reported an example of file written in RIL language, this example can be used as a track to write a file to add to
own Remoter project.
; ******************************************************************************
; Project :
; Programmer :
; Date :
; ******************************************************************************
; Description :
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Blinking Flag")
; ------------------------------------------------------------------------------
ORGR
LODT F PLCTimeBase800 ;Timebase 800 mSec
OUTT F 0000 ;Blinking Flag
; [End of file]
RIL file
To add a RIL file in the project, choose the New item from the menu File, use the icon, or press the Ctrl
+N key sequence. A window will be displayed allowing the possibility to choose the desired file type. Select
the Instruction List Source File (*.ril) entry from the list and specify the name you want to give the file in
the text box signed by the File name label, for instance RilFile, it is not necessary to specify the extension
because it is assigned automatically. If you press the OK key, you create the file in the directory selected in
Location, add it into the project tree and open it in editing. Further information about the RIL file
programming techniques are reported in the proper chapter.
By clicking on the key located near the Position box a window appears allowing the disk browsing,
so it's possible to select the path instead of digit it.
Figure 1
RIL file
After the upload running of the user program on the target system, you can carry out the debug. If the FB communication
MODBUS has been inserted in the project the debug will work, by using the key, when the target system is connected to
the PC through the selected communication media and when the user program is running.
You have to activate and configurable correctly the window Watch for the file debug in language C, by using the proper button
. The window Watch, that contains 8 index cards, will be activated by using the key and it will appear as shown in figure.
Figure 1
You can insert the operands in two different ways in it. The first one consists of placing the operands involved at the window
WorkSpace and dragging it with the mouse to the window Watch. This operation is simple and immediate, because it allows
you to compile all the fields you need, automatically and without mistakes. When you address an operand to the window
Watch, this one will be placed in the active folder.
Figure 2
The second one consists of "Clicking" twice on a box of the Watch window activating the window that allows you to define the
operand in debug.
Figure 3
Memory Defines the kind of memory where the variable is allocated. For all the RIL operands is Auto detected.
Type Defines the operand type as defined in the RIL program. The possible types are:
C [Counter] Counter (C) operand.
F [Flag] Flag (F) operand, refer to project settings for the range definition.
I [Input] Input (I) operand, refer to project settings for the range definition.
O [Output] Output (O) operand, refer to project settings for the range definition.
M [Memory] Memory (M) operand.
T [Timer] Timer (T) operand.
Y [Byte] Byte (Y) operand, refer to project settings for the range definition.
W [Word] Word (W) operand, refer to project settings for the range definition.
DW [Double Word] Double word (DW) operand, refer to project settings for the range definition.
FL [Float] Float (FL) operand, refer to project settings for the range definition.
Address Defines the memory address of the operand, the value is hexadecimal (ie: 0x123). For the mnemonic
operands the operand name must be defined.
Bit Number Allows to manage a single bit within the variable. ie: 0x02 manages the bit 2.
Local Filename Defines the file name in which the operand is defined, it's used only for local operands.
Comment Allows to define a comment.
After having correctly compiled all the fields involved, you can confirm with the OK key and the operand is transferred in the
Watch window to the proper box. If the debug works correctly, the Watch window appears as shown below. The green
background of the table shows that the link is active. Therefore you can monitor the state changes of the different operands.
You can change its properties any time, by clicking twice on the operand involved, or delete it from the window by selecting it
and then pushing the Canc button.
Figure 4
You can force a specific value by clicking on the operand with the right key of the mouse, as shown the window below. You
can force it differently according to the kind of operand and the display format you had chosen. A Byte (Y) operand will be
under different rules from a Flag (F) one or an Input (I) one.
Figure 5
Index
A RFB file is the graphic representation of a funtion block, some FB have its own graphic representation, it
provided only for those more complex. We remind that a FB can be included in a project by using the
proper graphic representation, executing the call with the TASK instruction from RIL files, or by executing
the call from Assembler and C files. To add a file to the project, please refer to the informations reported in
the proper chapter.
The insertion of a function block in a program requires also the selection of the function block
version in the project settings.
Figure 1
RFB file
To add a RFB file in the project, choose the New item from the menu File, use the icon, or press the Ctrl
+N key sequence. A window will be displayed allowing the possibility to choose the desired file type. Select
one of the function blocks FB from the list and specify the name you want to give it in the text box signed
File name, for instance DebugFile, it is not necessary to specify the extension because it is assigned
automatically. If you press the OK key, you create the file in the directory selected in Location, add it into
the project tree and open it in editing. Further information about the RFB file programming techniques are
reported in the proper chapter.
By clicking on the key located near the Position box a window appears allowing the disk browsing,
so it's possible to select the path instead of digit it.
Figure 1
RFB file
FB MODBUS communication
The FB of communication provides the management of the MODBUS protocol. The MODBUS protocol is used by Remoter to
execute the debug of the application. In the window all the needed parameters must be set, at the beginning we suggest a
minimum set.
Figure 1
Select the serial port on the target device to use, by choosing among the options given in the list (Instruction SETV). You can
automatically set the FB management controls for the communication with the RS232 line, by clicking with the mouse on the
RS232 Default key.
All the others definitions are used for a ModBus communication management, with different aims from that one for the
application debug, If you want a full list of the different fields, see the comment page for the Modbus Ascii or the Modbus Rtu.
RFB file
FB system terminal
The FB of terminal operator management is a function block providing the management of the Picoface terminal, and the
keyboards and display integrated in the Netsyst systems. Further information about the FB working are in the relate comment
page. In the window you have to set all the necessary parameters, at the first use we suggest a minimum set. Select the port
to use (Instruction SETV), the IOTerminal value has to be used for all the terminals connected directly to the system. Select
the type of the display Display Target to use according to the product. by clicking on the Set Default key all the parameters
for the Picoface terminal are set.
Figure 1
Executed all the necessary settings will be possible to proceed in the definition of the messages to visualize. Positioning the
mouse in the window Message list and pressing the right key, will be visualized a menu with all the possible type of
messages.
Figure 2
Add Message Allows you to add an ordinary message, it can be displayed by defining its number in the
MessageNr variable.
Add Page Message Allows you to add a page message, it can be displayed by defining its number in the
MessageNr variable or by using the page selection keys.
Add Alarm Page Message It allows you to add a page message for the alarms display, it can be displayed by defining its
number in the MessageNr variable or by using the page selection keys.
Add Warning Page Message It allows you to add a page message for the warnings display, it can be displayed by defining
its number in the MessageNr variable or by using the page selection keys.
Change ID Message It allows you to change the ID Message. We remind you that ID is the number that has to be
written in the MessageNr variable to have the message displayed.
ID Locked It allows you to lock the ID Message. So the message compression function doesn't have
effect on it. The messages are introduced with a progressive ID, the cancel or move
operations can modify the message ID.
For every message it is possible to define an operation that must be executed, on special events, following the table below:
The tick box Back on Timeout, if selected, after the time defined in KeyboardTimeOut, automatically display the previous
message. If the message is a page message it will be possible to define the following functions:
Page Nr It defines the page number of the message, the pages from 0 to 6 are directly selected by the relate
to keys, all the pages will be however selected with the , or , keys. If the
page number isn't defined will not be possible to reach the message with the keyboard, to visualize
the message its number must be written in the MessageNr variable.
Autoscroll time (mSec) It defines the automatic scroll time in msec of the submessages.
Not reachable If selected, avoid the message to be displayed by the using of the key buttons dedicated to the page.
Not scrollable If selected, it avoids the submessages to be scrolled by the using of the key function , or ,
.
Selecting a message, by placing the mouse on the Variables windows the right key allows to display the option for the
message variable insertion. A message can have an infinite number of variables, every time you insert a new variable, its ID is
automatically increased. You have to put the ID included between the <> signs, as shown in figure below, to have the variable
display and to be able to input the variable value. In the green part, representing the display, is displayed the message as will
be in the reality. To display in the message special characters it is necessary to reference to the characters set of the display
controller HT011.
Figure 3
Include File It defines the name and the path of the variable definition file.
Display format
Dec Decimal, the visualization will become as decimal format plus sign.
UDec Unsigned decimal, the visualization will become as decimal format without sign.
Hex Hexadecimal, the visualization will become as hexadecimal format.
Oct Octal, the visualization will become as octal format.
Bin Binary, the visualization will become as binary format.
BinEnh Binary enhanced, the visualization will become as binary advanced format.
String String, the visualization will become as string format.
Password Password,the visualization will become as UDec format, but the value will be shown as *.
This selection is possible only if a DW or unsigned long is selected as a Type.
For the floating point variables is possible to define also the number of decimal digit to be visualized.
Some ticks allow to define more selection on the variable format.
Fill with 0 It forces the value display with the zero blanked before the value..If a variable has a
value equal to 10 and it is displayed with 4 digits, without the option it will be shown as
10, with the option as 0010.
Left Align It forces the value display with left alignment, the default setting show the value aligned
to the right side.
Editable It forces the variable to be editable, in this way the variable value can be modified using
the keyboard keys.
Prefix with Sign It places the sign before the value display.
Pre view function It defines a function that will be automatically executed before the variable value visualization. In this
function, the user will be able to execute all the necessary calculations and an eventually recalculation of
the value that have to be visualized.
Post edit function It defines a function that will be automatically executed just after the editing of a new value of the variable.
In this function, the user will be able to execute the control of the edited value.
The page messages are a special type of messages, which submessages can be referred to by placing the mouse on the
page message and pressing the key on the right, the option will be displayed for the insertion of the submessages, figure 4.
To display them the ID number must be defined in the MessageNr variable or in case of Picoface terminals by using the
numerical key defined in the page number , , , , , , . By using the and keys of the Picoface
terminal or the and keys in the Netsyst systems you can scroll all the defined page messages.
Activated the page message display, it's possible by acting on the the and keys of the Picoface terminal or the
and keys in the Netsyst systems execute the scroll of all the defined page submessages. Defining a time in the variable
Autoscroll Time (mSec) variable, all the submessages are automatically scrolled with the defined time.
Figure 4
Warning messages
Alarm messages
The editable variables can be entered directly by using the terminal keys, when the editing is done, the input value will take
over the variable value, if it is in the defined range.
Picoface The value of the first editable variable of the message will flash, by using the key. If you keep pushing that key
without pushing others, the value of the second editable variable will flash, and the same for all the variables that
are declared to be editable in the message. You can edit a new value with a flashing variable, by using the numeric
key of the terminal, then use the key to accept the new value. During the editing, the key allows you to
correct the input value and the key allows you to abort the editing phase. If the variable is decimal type, the
key allows you to edit the sign first, and then the point for the decimal.
Hexadecimal variables
To edit hexadecimal variables it is necessary edit the digit from A to F, to do this the numerical keys from to
must be used. With a pressure in rapid sequence on the key, the input value changes between 0 to A, with
a pressure in rapid sequence on the key, the input value changes between 1 to B, and so on.
Index
An Assembly file is shown as windows like which reported in the figure below. This is an editing window; you can
write the program on it, by using the typical facilities of an editor. See the proper chapter for a full list of the editing
controls. To write a program you have to refer to the specifications of the Assembly language for the MCS51
microprocessor family. To add a file to the project, please refer to the information reported in the proper chapter.
Figure 1
Syntax coloring
In order to have better reading of the file, an automatic syntax coloring is provided. The reserved names are blue
colored, the mnemonics of the reserved operands are gray colored and the comments are green colored.
File example
It 's reported an example of file written in Assembly language, this example can be used as a track to write a file to
add to own Remoter project .
; ******************************************************************************
; Project :
; Programmer :
; Date :
; ******************************************************************************
; Description :
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; GLOBAL FUNCTIONS AND VARIABLES DECLARATION
; ------------------------------------------------------------------------------
; Global functions declaration.
PUBLIC AssemblyFct
PUBLIC BitValue
PUBLIC RandomNr
; ------------------------------------------------------------------------------
; EXTERN FUNCTIONS AND VARIABLES DECLARATION
; ------------------------------------------------------------------------------
; Extern functions declaration.
; ------------------------------------------------------------------------------
; FILE INCLUSION
; ------------------------------------------------------------------------------
include ElSystemLib.inc
; ------------------------------------------------------------------------------
; BIT VARIABLES DEFINITION
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; XDATA VARIABLES DEFINITION
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; CODE SEGMENT DEFINITION
; ------------------------------------------------------------------------------
; Code segment definition.
; ------------------------------------------------------------------------------
; @Section("void AssemblyFct(void)")
; ------------------------------------------------------------------------------
; This function must be called by the RIL language using the TASK instruction.
; Store a random number in the "RandomNr" variable.
cpl BitValue
mov dptr,#SystemConfig+3
movx a,@dptr
ret
END
; [End of file]
Assembly file
To add ac Assembly file in the project, choose the New item from the menu File, use the icon, or press
the Ctrl+N key sequence. A window will be displayed allowing the possibility to choose the desired file type.
Select the C Source File (*.c) entry from the list and specify the name you want to give the file in the text
box signed by the File name label, for instance CFile, it is not necessary to specify the extension because
it is assigned automatically. If you press the OK key, you create the file in the directory selected in
Location, add it into the project tree and open it in editing. Further information about the C file
programming techniques are reported in the proper chapter.
By clicking on the key located near the Position box a window appears allowing the disk browsing,
so it's possible to select the path instead of digit it.
Figure 1
Assembly file
Debug a C program
To debug an Assembly program please refer to the information reported in the debug a C program chapter.
Index
C file overview
A C file is shown as windows like which reported in the figure below. This is an editing window; you can write the
program on it, by using the typical facilities of an editor. See the proper chapter for a full list of the editing controls.
You have to refer to the ANSI specifications of the C language for the program writing. To add a file to the project,
please refer to the information reported in the proper chapter.
Figure 1
Syntax coloring
In order to have better reading of the file, an automatic syntax coloring is provided. The reserved names are blue
colored, the mnemonics of the reserved operands are gray colored and the comments are green colored.
File example
It 's reported an example of file written in C language, this example can be used as a track to write a file to add to
own Remoter project .
// *****************************************************************************
// Project :
// Programmer :
// Date :
// *****************************************************************************
// Description :
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// @Section("void CustomFunction(void)")
// -----------------------------------------------------------------------------
// This function must be called by the RIL language using the TASK instruction.
void CustomFunction(void)
{
// Local variables definition.
// -------------------------------------------------------------------------
// COUNTER MANAGEMENT
// -------------------------------------------------------------------------
// The "Counter" variable is incremented every 100 mSec.
if (PLCPulse100)
Counter++; //Counter
}
// [End of file]
"C" file
Add a C file
To add a C file in the project, choose the New item from the menu File, use the icon, or press the Ctrl
+N key sequence. A window will be displayed allowing the possibility to choose the desired file type. Select
the C Source File (*.c) entry from the list and specify the name you want to give the file in the text box
signed by the File name label, for instance CFile, it is not necessary to specify the extension because it is
assigned automatically. If you press the OK key, you create the file in the directory selected in Location,
add it into the project tree and open it in editing. Further information about the C file programming
techniques are reported in the proper chapter.
By clicking on the key located near the Position box a window appears allowing the disk browsing,
so it's possible to select the path instead of digit it.
Figure 1
"C" file
Debug a C program
After the upload running of the user program on the target system, you can carry out the debug. If the FB communication
MODBUS has been inserted in the project the debug will work, by using the key, when the target system is connected to
the PC through the selected communication media and when the user program is running.
You have to activate and configurable correctly the window Watch for the file debug in language C, by using the proper
button . The window Watch, that contains 8 index cards, will be activated by using the key and it will appear as shown in
figure.
Figure 1
You can insert the variables you want debug. You have to click twice on a box of the window Watch, activating the window
Watch that allows you to insert the variables.
Figure 2
Memory Defines the kind of memory where the variable is allocated. All the mnemonic variables are Auto detected.
Internal Ram Defines the microprocessor internal RAM (Range from 0x00 to 0xFF).
Defines the microprocessor external RAM. For the address range please refer to memory
Ram
map.
Flash Defines the FLASH memory. For the address range please refer to memory map.
EEProm Defines the EEPROM memory. For the address range please refer to memory map.
Defines the PCB088 mass memory module. For the address range please refer to memory
Pcb088
map.
Defines the PCB111 mass memory module. For the address range please refer to memory
Pcb111
map.
Type Defines the variable type as defined in the C program. The possible types are:
Char Signed 8 bit variable.
Unsigned char Unsigned 8 bit variable.
Int Signed 16 bit variable.
Unsigned int Unsigned 16 bit variable.
Long Signed 32 bit variable.
Unsigned long Unsigned 32 bit variable.
Float Floating point variable.
String String variable. The variable length (number of character) must be specified.
Address Defines the memory address where the variable is allocated, the value is hexadecimal (ie: 0x123). For the
mnemonic variables the variable name must be defined.
Bit Number Allows to manage a single bit within the variable. ie: 0x02 manages the bit 2.
Local Filename Defines the file name in which the variable is defined, it's used only for local variables.
Comment Allows to define a comment.
After having correctly compiled all the fields involved, you can confirm your work with the OK key and the variable is
ransferred to the Watch window to the proper box. If it works correctly, the window appears as shown below. The green
background of the table shows that the link is active. Therefore you can monitor the state changes of the different operands.
You can change its properties any time, by clicking twice on the operand involved, or delete it from the window by selecting it
and then pushing the Canc button.
Figure 3
You can force a specific value by clicking on the operand with the key at the right of the mouse, as shown the window below.
You can force it differently according to the kind of operand and the display format you chose.
Figure 4
Index
Catch procedure
The Catch icon allows to force a reset to the target system and connect it to Remoter. To execute the catch procedure it's
necessary to connect the target system to the PC by using the communication media set up in the project, usual is used the
serial line, but the connection is possible also through a TCP/IP. If in the project settings is select the tick of request before stop
the system, a window will appear with the request confirm. During the catch procedure in the Results window is visualized the
message Waiting please... as shown in the figure.
If the target device is running, the catch is possible only if the communication FB is working in the program. By using the
icon, a reset is sent to the device, which will be forced in stop condition, when it restarts it will be forced in stop
condition activating the connection with Remoter.
If the catch condition doesn't work automatically, you can manually turning off and turning on the target device.
Figure 1
If the catch procedure ends correctly in the Results window is visualized the message Device linked! followed by the
information about the version of the software that is on the target device as shown in the figure. The catch procedure can be
aborted at any time by acting on the icon, or pressing the Esc key.
Figure 2
Index
Information request
When the target system is connected and in catch condition, you can request the state, by using the Info icon. The request
string will be sent to the target system that will answer with a hexadecimal string displayed in the Results window, as shown
below.
Figure 1
Index
Software version
When the target system is connected and in catch condition, you can request the current software version, by using the Version
key. The request will be sent to the target system, it will answer with the version that will be seen at the Results window as
shown below.
Figure 1
Index
Clear memory
With the target system in catch condition by acting on the Clear Memory icon is possible to execute the deletion of the whole
RAM and FLASH memory of the system, this operation is useful to to be sure that all the data in memory are zeroed. Working on
the icon the clear memory order will be sent to the target system, the system will answers with a message that indicates the order
execution, the message is displayed in the Results window as shown in the figure.
The command causes the deletion of the RAM and FLASH memory and also the loss of the user program and the BIOS
configuration parameters.
Figure 1
This command is not supported by all the target systems. Here the table with the targets that support this command.
Code Target
CPU016**** CPU Picosyst Millennium, central processor unit used in all Picosyst ME products
MPS026*0*0 PICOLOG Millennium relè, small programmable controller.
MPS026*3*0 PICOLOG Millennium static, small programmable controller.
MPS027***0 FACELOG, hybrid operator terminal, it has also digital I/Os.
OIF018*0*0 PICOFACE, low cost operator terminal.
MPS022**** Netlog, programmable controller inserted in a DIN43880 box.
If the control is sent to a system that cannot support it, an error message will be displayed in the Results window, as shown
below.
Figure 2
Index
Upload procedure
This procedure allows you to transfer to the target only the files that are selected into the upload table. In order to
display the upload table, you have to place the mouse on the project and select the Set Upload Table , by the right
key of the mouse.
Figure 1
The upload table allows you the define the files that has to be transferred. The selection of Builded Program selects
the upload of the realized program, otherwise you can carry out the upload process of one of the last download
processes.
Figure 2
When you have the target system connected and when you are in catch condition, you can transfer the selected file to
the upload table on the target system by using the Upload key. During the procedure, a report of the last
Figure 3
The upload procedure allows the deletion of the memory sectors involved, on the target system based on FLASH
memory. If the tick box On erase execute an "All sectors" erase was selected in the project settings, the deletion will
be done on the whole FLASH memory area with a time saving compared to the single deletion of the sectors.
After the deletion, the program file transfer in the target device begins. During this phase, a flowing stroke displays the
progression condition in the lower part of the window. If the tick box Allows code download in the project settings
selected, you will be able to a future download process of the program that was previously transferred in the target
device. When the upload process successfully ends, a window with the operations request will be seen, as shown
below.
Figure 4
When the upload procedure ends, the program will keep being in the target system that will automatically carry
it out when the target is turned on.
Index
Download procedure
With the target system in catch condition by acting on the Download from Target icon, it's possible to transfer the entire
memory map of the target system to a file on the PC. During the procedure, a report of the operations will be seen at the
Results window as shown in the figure.
Figure 1
When the reading of the whole memory map of the system is finished will be displayed the request of the definition of the file
in which to save the download executed. For default it's proposed the DownloadFile1.rdn inside of the project directory. It's
possible to change the name and the location of the file. Defined the name it wil be added to the project tree and a window
with relate information will be displayed. The Title and Notes fields can be changed and the user can write the relate
information.
Figure 2
The download procedure is possible only if the project transferred to the target system has the download allowed in
the project settings. Otherwise the download process will not be possible and an error message will be displayed in the
Results window.
Figure 3
Index
Program running
The program running on the target system automatically occurs at the end of the upload process, however in some target
systems you can force the program running after a catch condition. The control of program running will be sent by using the Run
key, the target system will check that the program to carry out really exists and it will send it to running, giving back an answer
string at the Results window, as shown below.
Figure 1
Index
When the target system is connected and it is in run condition , you can request information about the current project, by using
the Loaded Project Info icon. An information request about the loaded project will be sent to the target system, and the
information will be seen at the Results window, as shown in the figure.
Figure 1
The returned information includes the name of the project, date and time of the latest bulid, and the version of Remoter, that has
been used for the building. We remind that all these information are automatically generated during every building and they are
transferred to the target system in the stucture PLCRemoterProjectInfo during the upload. If you want to compare the information
just read with that one of the project being used by Remoter, see the project settings.
Index
When the target system is connected and in catch condition, by pressing the Mass memory manager icon, you can activate
the mass memory module management window.
The Make backup procedure is possible only if the project transferred to the target system has the download allowed in
the project settings.
Figure 1
Format Mass Memory By pressing the OK key, the mass memory module will be format. The formatted module inserted in a
programmed system at it power on will provide to automatially transfer to the mass memory module
the data defined in Data to Manage.
Make Backup By pressing the OK key, the data defined in Data to Manage will be transferred to the mass memory
module.
Esegui da Mass Memory By pressing the OK key, the operation defined on the mass memory module will be executed.
In the Data to Manage field it's possible to select the memory on which the perations are executed:
In the Mass Memory Type is possibile to select the memory support on which to execute the operations:
The mass memory management order, it isn't supported from all of the target systems, following we report a table with the
indication of the targets and the BIOS version that support it.
CPU016**** SFW128F000 CPU Picosyst Millennium, central processor unit used in all Picosyst ME products
MPS026*0*0 SFW128F000 PICOLOG Millennium relè, small programmable controller.
If the command is executed on a target that doesn't support it, in the Results window an error message will be displayed.
Figure 2
Index
Terminal emulation
Clicking on the Show Terminal Bar icon, it visualizes a terminal emulation window inside of Remoter program. A
windows like below will be opened:
Figure 1
A drop down menu allows to select the communication media to be connected to the terminal:
Serial port direct Uses the serial COM, by acting to the Set key, it's possible to set the function parameters desired.
TCP/IP Uses the TCP/IP socket, It can be used in with a TCP/IP to serial converter. Working on the key it
Plans it is possible to plan the parameters of operation wanted. can be used può essere utilizzato
in unione ad un convertitore TCP/IP seriale. By acting to the Set key, it's possible to set the
function parameters desired.
Terminal settings
By acting to the Set key and choosing the Terminal Settings, it's possible to set the terminal working parameters.
Figure 2
Substitute Unprintable Chars Selected forces the display of the received unprintable characters from the
communication media. The unprintable characters are replaced with their exadecimal
code between square brackets, (Example: [0x33]).
Terminal in Hex Mode Selected forces the display in hexadecimal code of the received characters from the
communication media. The characters are replaced with their hexadecimal code
between square brackets, (Example: [0x33]).
Local Echo Selected forces the display in the terminal window of the characters pressed locally
on the keyboard.
Transmit LF After CR Selected forces the transmission of a line feed character after any carriage return.
With the Font Rx and Font Tx keys it's possible to set the font to be used to display in the terminal window, the
received and the transmitted characters (Only if Local Echo chosen). For default are displayed in red the transmitted
and in blue the received characters. If activated the management of the control characters on the serial line, it's
possible to set the DTR and RTS signals by set a tick in the relate box.
Figure 3
Index
Function blocks
The function blocks FB are functions that execute complex operations or are used as drivers for specific
hardware module. Here it is the index of the function blocks available. If in the user program a function block is
used, you have to insert it also in the libraries otherwise Remoter cannot include it in the program and a link
error will be created.
The function blocks can be used both by the RIL and by the C language. Every function block uses a data
structure in external memory for the interface with the user program, in the call instruction need to be defined the
allocation address of this structure. Here it is the example of data structure definition of a function block.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
...
...
...
}FB...DATA;
The members under the indication Members that can be managed by user program can be used by the user
program for the setting definition and for the return value reading.
The members under the indication Members automatically managed by Remoter, in case of using the
management graphic utility, are managed automatically by Remoter, in case of using it by the C program they
have to be managed by the user program.
The members under the indication Internal use only members are used inside the function block and they don't
have to be used by the user program.
For the activation of the FB, need to be defined their call by using the proper instruction TASK, also defining the
function and the allocation address od the data structure. Remoter will automatically provide for adding the
function code in the executable program.
In the programming in absolute mode, if you use the numerical addressing of the operands, you have to pay
attention to the size of the data structure of the function block in order to avoid to allocate other operands in the
same allocation address of the structure.
Here it is an example of program with the call to the function block FbEncoderOverIO, the data structure of the
FB uses 8 bytes, and it is allocated at the address Y 0100, so all the operands from Y 0100 to Y 0108 will be
used by the function block.
ORGR
SETR
MOVI Y 0100 K 0000 ; Logic inputs selection
TASK L FbEncoderOverIO Y 0100 ; Encoder acquisition
LODA W 0102 ; Encoder value
; [End of file]
Programming in mnemonic mode, the allocation of the data structure is carried out automatically by Remoter,
need to be defined the memory size by using the instructions DEFL or DEFG. Here it is an example of program
with the call to the function block FbEncoderOverIO.
DEFL Y EncAcq KD 8
DEFL Y Inputs Y EncAcq KH 0000 ; Logic inputs selection
DEFL Y Error Y EncAcq KH 0001 ; Acquisition error
DEFG W Value Y EncAcq KH 0002 ; Encoder value
ORGR
SETR
MOVI Y Inputs K 0000 ; Logic inputs selection
TASK L FbEncoderOverIO Y EncAcq ; Encoder acquisition
LODA W Value ; Encoder value
; [End of file]
To program in C language, a definition file h is given for every function block. In this file the data structure and
the prototype of the function block are defined. In the user program just need to be included the definition file,
and carry out a function, giving the allocation address of the data structure, Remoter will automatically provide
for adding the function code in the executable program.
void Example(void)
{
unsigned int EncoderQuote; //Encoder quote
static FBENCODEROVERIODATA EncoderStruct; //PFB018, data struct
// [End of file]
Index
"C" macros
The system libraries have some type of predefined macro functions, here follows the list.
DISABLEINT Alows to disable all the interrupt sources, it prevents the program - - - - - - A
execution interruption
ENABLEINT Alows to enable all the interrupt sources. It must be used after the - - - - - - A
DISABLEINT macro
HEXToASCII Convert an hexadecimal number to an ASCII character D E - C A B A
HICHAR It returns an unsigned char number that represents the high nibble of an - H - - E - A
unsigned int number
HIINT It returns an unsigned int number that represents the high nibble of an - H - - E - A
unsigned long number
LOCHAR It returns an unsigned char number that represents the low nibble of an - H - - E - A
unsigned int number
LOINT It returns an unsigned int number that represents the low nibble of an - H - - E - A
unsigned long number
MAKEINT It returns an unsigned int number by attaching two unsigned char - H - - E - A
numbers
MAKELONG It returns an unsigned long number by attaching two unsigned int - H - - E - A
numbers
PLCOp(x) Alows to read or write any numerical RIL language operand - - A - - - A
Index
The system libraries have some type of predefined data, here follows the list.
Type Description
Index
"C" variables
The system libraries have some predefined variables. In the programs development it's necessary to refer
to the used library version verifying in the following table if the variable is supported. In a migration of a
project from a target to another one it's possible that the library of the new target doesn't support one of the
used variables, in that case a linker error will be generated.
The data struct variables are recognized by the linker only with the name of data structure and not
with the names of the internal members. So it's possible that the use of a member not defined in the
library, even if doesn't generate a linker error, can create a mistakes in the program. Please refer to
the variable documentation to know the internal members supported for every variable.
Index
"C" functions
Remoter is provided with a libraries series for the different target systems supported, the libraries contain all
the functions needed for the system management.
Loader
Kernel
Utility
Hardware management
System management
GetRtc It returns the time structure from the real time clock B C - A A A A
Tick management
Timer management
GetWDogTime It returns the time value of the intervention watch dog circuit B C - A A A A
Terminal management
I/O terminal
SetTermIOData It sets the data structure allocation address of the defined I/O - - - - E - A
terminal
TermIORxClear It clears the reception buffer and resets errors to the defined I/ B C - A A A A
O terminal
TermIORxFlush It executes the flush of the reception buffer to the defined I/O B C - A A A A
terminal
TermIOTick It manages the tick of the defined I/O terminal B C - A A A A
CAN controller
PLC
The functions with are obsolete, they have been reported in order to guarantee the compatibility with the
previous versions, we advice to don't use them in the new projects. Please follow the indications reported in
the documentation of the function.
Index
The C compiler included in Remoter support a lot of the ANSI standard functions, a list of the functions supported.
modf Fractional and integer parts double modf(double value, double *iptr);
pow Raises to the power double pow(double arg1, double arg2);
sin Sine double sin(double arg);
sinh Hyperbolic sine double sinh(double arg);
sqrt Square root double sqrt(double arg);
tan Tangent double tan(double x);
tanh Hyperbolic tangent double tanh(double arg);
Non-local jumps <setjmp.h>
mempool_init Inits dinamic memory allocation void mempool_init (dynamic_allocator_struct allocmem *p, size_t size);
qsort Makes a generic sort of an array void qsort(const void *base, size_t nmemb, size_t size, int (*compare) (const void *_key, const void *_base));
rand Random number int rand(void);
realloc Reallocates memory void *realloc(void *ptr, size_t size);
srand Sets random number sequence void srand(unsigned int seed);
strtod Converts a string to double double strtod(const char *nptr, char **endptr);
strtol Converts a string to a long integer long int strtol(const char *nptr, char **endptr, int base);
strtoul Converts a string to an unsigned long unsigned long int strtoul (const char *nptr, char **endptr, base int);
String handling <string.h>
memchr Searches for a character in memory void *memchr(const void *s, int c, size_t n);
memcmp Compares memory int memcmp(const void *s1, const void *s2, size_t n);
memcpy Copies memory void *memcpy(void *s1, const void *s2, size_t n);
memmove Moves memory void *memmove(void *s1, const void *s2, size_t n);
memset Sets memory void *memset(void *s, int c, size_t n);
strcat Concatenates strings char *strcat(char *s1, const char *s2);
strchr Searches for a character in a string char *strchr(const char *s, int c);
strcmp Compares two strings int strcmp(const char *s1, const char *s2);
strcpy Copies string char *strcpy(char *s1, const char *s2);
strcspn Spans excluded characters in string size_t strcspn(const char *s1, const char *s2);
strerror Gives an error message string char *strerror(int errnum);
strlen String length size_t strlen(const char *s);
strncat Concatenates characters with a string char *strncat(char *s1, const char *s2, size_t n);
strncmp Compares characters with a string int strncmp(const char *s1, const char *s2, size_t n);
strncpy Copies characters from a string char *strncpy(char *s1, const char *s2, size_t n);
strpbrk Copies character in a string char *strpbrk(const char *s1, const char *s2);
strrchr Copies character from right in a string char *strrchr(const char *s, int c);
strspn Spans characters in a string size_t strspn(const char *s1, const char *s2);
strstr Searches for a substring char *strstr(const char *s1, const char *s2);
strtok Breaks a string into tokens char *strtok(char *s1, const char *s2);
Index
Operands list
An operand of an instruction is the variable treated by the instruction itself. An operand is usually made with
the type and the address. The operand address can change according to the target type you selected.
The operand range indicated with (*), represents the default value, the user can modify the range by
defining a new value on the window project settings.
Operands
Reserved operands
To give facilities to the user during the editing of the program, there are available some operands that have
predefined assignment, here follow the table of them. To give more facilities to import a project made with
an old version of Remoter, in the column V.7.X are reported the old value operands that must be
substituted. All the reserved operands can be used in a C program file, see proper chapter.
F PLCRxBufEmpty It becomes active if the serial reception buffer is empty (Managed F05C0 A
by SRXC instruction)
F PLCTxBufFull It becomes active if the serial transmission buffer is full (Managed F05C1 A
by STXC instruction)
F PLCTxBufEmpty It becomes active if the serial transmission buffer is empty F05C4 A
(Managed by STXC instruction)
F PLCChrReceived It becomes active if the SRXD instruction has transferred the F05C5 A
arrived character in AccA
F PLCClock100 Change its logic status (blinks) every 100 msec A
F PLCFirstLoop It stay true only in the first loop of the program F05D0 A
F PLCLoopToggle Change its logic status (blinks) every program execution loop F05D1 A
F PLCTimeBase100 Change its logic status (blinks) every 100 msec F05D2 A
F PLCTimeBase200 Change its logic status (blinks) every 200 msec F05D3 A
F PLCTimeBase400 Change its logic status (blinks) every 400 msec F05D4 A
F PLCTimeBase800 Change its logic status (blinks) every 800 msec F05D5 A
F PLCTimeBase1600 Change its logic status (blinks) every 1.6 Sec F05D6 A
F PLCTimeBase3200 Change its logic status (blinks) every 3.2 Sec F05D7 A
F PLCTimeBase6400 Change its logic status (blinks) every 6.4 Sec F05D8 A
F PLCTimeBase12800 Change its logic status (blinks) every 12.8 Sec F05D9 A
F PLCPulse100 It becomes active for a program execution loop every 100 mSec A
F PLCPulse500 It becomes active for a program execution loop every 500 mSec A
F PLCBackupOneShot Set by the user program, it forces a single backup cycle, it's D
automatically resets.
(Valid only if the PLCBackupDisable=TRUE)
F PLCBackupEnd It becomes active for a program execution loop every backup cycle C
The backup cycle requires a number of program loops equal to: (Nr
backup bytes /4)+Nr backup bytes
Y PLCRtcYear Real time clock year value (Range 0 - 99) A
W PLCSystemTime System time value, it's increased at every 1 mSec (Range 0 - FFFF) D
Index
The language used by Remoter for the programming is called RIL (Remoter Instruction Language), it's
based on a set of instructions divided in function groups.
Type Description
The instruction function is the operation that the function carries out in the rung. The instructions have 5
different functions we can identify the instructions of:
Function Description
It is necessary that every logical block begins with a Rung open instruction and ends with at least one
Rung close. If some more instructions Rung close are inserted, they will be considered in parallel.
An operand of an instruction is the variable treated by the instruction itself. An operand is usually made by a
type and an address. The instructions can have up to 3 operands, in some instructions the operands can be
optional.
There are some reserved operands, having a specific meaning in the program, see the summary page for a
full list.
Instructions
These instructions allow the definition of the mnemonic operands. Instead of the numerical operands can
be used without definition, the mnemonic operands have to be define their mnemonic name, type and if are
local, global, backup or external.
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
F, T, C, Y, W, DW, FL
DEFG DEFine Global operand None Y KD No A
Y Y KD
F, T, C, Y, W, DW, FL
DEFL DEFine Local operand None Y KD No A
Y Y KD
F, C, Y, W, DW, FL
DEFB DEFine Backup operand None No A
Y KD
Instructions
Logic instructions
These instructions allows you to realize the logical sequences, they can operate both on real inputs and
outputs and on internal variables as flags (F), timer (T), counter (C). Moreover you can use any bit of a
Byte (Y), Word (W) or Double (DW) operands as internal flag of program.
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
C, F, I, O, T
LODT LOaD True Open branch No A
Y, W, DW K, BD, BH
C, F, I, O, T
LODF LOaD False Open branch No A
Y, W, DW K, BD, BH
C, F, I, O, T
ANDT AND logic True Modify branch No A
Y, W, DW K, BD, BH
C, F, I, O, T
ANDF AND logic False Modify branch No A
Y, W, DW K, BD, BH
C, F, I, O, T
ORLT OR Logic True Modify branch No A
Y, W, DW K, BD, BH
C, F, I, O, T
ORLF OR Logic False Modify branch No A
Y, W, DW K, BD, BH
F, O
OUTT OUT True Close rung No A
Y, W, DW K, BD, BH
F, O
OUTF OUT False Close rung No A
Y, W, DW K, BD, BH
F, O
LTCH LaTCH Close rung No A
Y, W, DW K, BD, BH
F, O
UTCH UnlaTCH Close rung No A
Y, W, DW K, BD, BH
F, O
SBSR Step By Step Relay Close rung Yes A
Y, W, DW K, BD, BH
KD, KH, Y, W,
DW
OUTM OUt TiMer Close rung T No A
KD, KH, Y, W,
KE
DW
Y, W, DW
Y, W, DW KD, KH, KO, KB
INCO INCrement Operand Close rung No C
FL
FL KF
Y, W, DW
Y, W, DW KD, KH, KO, KB
DECO DECrement Operand Close rung No C
FL
FL KF
The instructions with the symbol are obsolete, they are reported only to maintain the compatibility with
the previous versions, we suggest to not use them in the new projects. Please follow the indications
reported in the instruction documentation.
Instructions
In the RIL programs the data management is based on the use of two 32 bits accumulators, called AccA e
AccB, the instructions below allow you to operate on the two accumulators. Use the LODA instruction to
transfer the value from the operands to the AccA accumulator and the STRA instruction to transfer the
value from the AccA accumulator to the operands.
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
Instructions
The math instructions operate on two accumulators AccA e AccB, the result is always transferred in AccA.
Use the LODA instruction to transfer the value from the operands to the AccA accumulator and the STRA
instruction to transfer the value from the AccA accumulator to the operands. Proper instructions of data
management allow you to operate on the data of the two accumulators.
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
Instructions
The math instructions operate on two accumulators AccA e AccB, the result is always transferred in AccA.
Use the LODA instruction to transfer the value from the operands to the AccA accumulator and the STRA
instruction to transfer the value from the AccA accumulator to the operands. Proper instructions of data
management allow you to operate on the data of the two accumulators.
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
Instructions
Serial instructions
These instructions allow to operate on the serial line directly from the RIL program. You can define the
communication parameters and manage the data reception and transmission. We remind that the serial line
is buffered by the operating system, so the serial instructions will operate on the reception and transmission
buffers.
On targets that have mode than one serial line you need to define the serial line, which you want to
operate on, using the SETV instruction, the selection will remain active till a different selection.
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
Instructions
These instructions allow to manage the program execution by changing the flow. You can jump some parts,
run routines, run parts of program written in RIL, assembler or C language.
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
L
L Y A
TASK TASK call Close rung B Y No
W
C
W Y
K, KH, KD
TINE Temporal INterrupt Enable Close rung No A
K, KH, KD KE
Instructions
Utility instructions
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
I, O, F, C I, O, F, C
Y I, O, F, C, Y
W I, O, F, C, Y, W
MOVM MOVe Memory Close rung No A
I, O, F, C, Y, W,
DW
DW
FL FL
I, O, F, Y, W,
MOVA MOVe Address Close rung W No A
DW, FL, L
Index
How to
In this chapter some information more detailed and some examples are provided to help the user in the
solution of difficult problems.
Description
Index
Remoter Version 8.x introduced a lot of new functions, like symbolic system programming and the "C"
language integration. All these new functions required a complete re - writing of the Remoter code and,
tough the efforts done in order to keep the compatibility with the programs written with the previous versions
7.x, the importing of projects written with the previous versions requires some small manual intervention.
Once imported in the new Remoter Version, the RLD and RIL files will have to be updated as follow:
For all the operands (F, Y, W) that have addresses included between 05C0 and 05FF, the numerical
address will have to be replaced with the correspondent symbolic indication, see the default operands
table. So for example the instruction LODT F 05D0, will become LODT F PLCFirstLoop, the
instruction LODT F 05D4 will become LODT F PLCTimeBase400 and so on
All the OUTM instructions will have to be updated replacing, in the time indication, the (K) constant
with the (KD) constant. So for example the instruction OUTM T OOOO K OO10 will become
OUTM T 0000 KD 0010.
If in the program was used backup counters (from C 0040 to C 007F) they must be changed with
mnemonic counters defined in the backup memory with the DEFB instruction.
If in the program the function blocks FB 0024 or FB 0032 were used for the conversion from
hexadecimal to BCD, it will be necessary to remove them and use the new instruction HBCD HBCD.
If in the program was used the function block FB 0025 for the conversion from BCD to hexadecimal, it
will be necessary to remove it and use the new instruction BCDH.
If in the program the function block FB 0028 of flag settings was used on index, it will be necessary to
remove it and use the new instruction EQUC to compare the byte value with a constant that
represents the desired value of the flag.
If in the program the function block FB 0036 of real time clock management was used , it will be
necessary to remove it and use the default operands of clock management.
If in the program the function block FB 0037 of multiplication between words was used, it will be
necessary to remove it and use the new MULA instruction.
If in the program the function block FB 0038 of division between words was used, it will be necessary
to remove it and use the new DIVA instruction.
The accumulator acts on 32 bits, in the 7.x versions acted on 16 bits, so ROLA instruction has a
different behaviour. Charging in accumulator the 0x8000 value and doing a ROLA K 0001, saving the
result in a (W), it will be obtained 0x0000, instead of 0x0001 with the previous versions.
The accumulator acts on 32 bits, in the 7.x versions acted on 16 bits, so RORA instruction has a
different behaviour. Charging in accumulator the 0x8000 value and doing a RORA K 0001, saving the
result in a (W), it will be obtained 0x0000, instead of 0x1000 with the previous versions.
Concerning the Picoface file messages, you don’t need any importing instrument, so the file messages will
have to be rewritten in the imported program using the specific FB graphic management.
Index
All the programs written with Remoter Version 8.0.x can be directly imported to the Version 8.1.x opening
the project workspace. However, there are some operations to be done manually on the project files, to
make them compatible with the new version. Once imported the files, is essential to compile all the files of
the project and then save both the project and the workspace.
Once imported in the new Remoter Version, the RLD and RIL files will have to be updated as follow:
The function blocks management by graphic utility for both MODBUS communication and terminal
management, in the previous versions needed the project library automatic definition. In the new
version it is necessary to define the use in the project settings
The function blocks are not identified anymore with a progressive number but with a function name,
therefore it is necessary to research all the call instructions and replace the function block number with
the correspondent name. For example, the instruction TASK B 0018 Y 0000 or the instruction
TASK L Pfb018 Y 0000 will have to become TASK L FbEncoderOverIO Y 0000. For a complete list
of the function blocks and their correspondent names make reference to the list page. Updating
suggested, not indispensable.
C Files
Once imported in the new Remoter Version, the C files will have to be updated as follow:
The function blocks are not identified anymore with a progressive number but with a function name,
therefore it is necessary to research all the call instructions and replace the function block number with
the correspondent name. For example, the inclusion #include <Pfb018b000.h> will have to
become#include <FbEncoderOverIO.h>.
The function blocks are not identified anymore with a progressive number but with a function name,
therefore it is necessary to research all the call instructions and replace the function block number with
the correspondent name. For example, the instruction Pfb018(&EncoderStruct); will have to become
FbEncoderOverIO(&EncoderStruct). Also the definition of the data structures type has been
modified in the same way, for example, the statement FB018_DATASTRUCT EncoderStruct will
have to become FBENCODEROVERIODATA EncoderStruct. Updating suggested, not
indispensable.
The libraries are not identified anymore with a number depending on the target system but with a
name that is the same for all the targets, this makes easier to turn a program from a target to another
one. Therefore it is necessary to research all the inclusions of definition files and replace the function
block number with the correspondent name. For example, the inclusion #include <Sfr026c000> will
have to become #include <ElSystemLib.h>.
Index
To send out to the serial line text strings by using the STXI e STXD instructions, the Ascii code must be
used it uses a 8 bits hexadecimal data to codify all the characters. In the table below the code used:
ASCII codes
Index
Error list
All the project compiling phases can produce errors that are reported with the indication of a number for an
easier identification. For the different phases we will have groups of numbers as indicated in the following
table:
Scanner RME100 RME199 The scanner considers all the project RIL files examining the
instructions and the operands contained.
Parser RME200 RME299 The parser considers all the project RIL files examining the instructions
and the operands contained.
RFB Converter RME300 RME349 The RFB converter converts all the project FB graphics files,
examining the instructions and the operands contained.
RLD Converter RME350 RME399 The RLD converter converts all the project files written in ladder
diagram, examining the instructions and the operands contained.
AOF Converter RME400 RME499 The AOF converter converts the file created by the linker in the Intel-
hex format to be transferred on the target system.
Linker RMW500 RMW549 The linker merges the different project files in one program file to be
RME500 RME549 passed to the AOF converter.
Assembler RMW550 RMW599 The assembler converts the files written in assembler language in the
RME550 RME599 format to be interpreted by the linker.
Compiler RMW600 RMW649 The compiler converts the files written in C language in the format to
RME600 RME649 be interpreted by the linker.
Project RMW650 RMW699 Before to execute all the project compiling phases all the project
RME650 RME699 settings are checked.
Index
For every target system the related library of system is supplied. Here follows the table with references
between the libraries and the different target systems.
Code Description
SFR037 Library for Netreader with Temic T89C51 microcontroller systems History report
SFR039 Library for Netreader with Philips P89C664 microcontroller systems History report
SFR043 Library for Picosyst special and NetlogII systems History report
For every target system the related library PLC is supplied. Here follows the table with references between
the libraries and the different target systems.
Code Description
Index
Memory map
Every target system is characterized by its own memory configuration, the access to the memory is
possible by using the SystemMemoryRead, SystemMemoryWrite functions. It's necessary to set the proper
memory configuration in the project settings according to the target system.
Backup memory
In some systems exists a retentive memory for the data backup, it can be battery backed up RAM or
EEPROM. The backup is executed by transferring the data memory area selected as back memory in the
retentive memory, for the definition of the backup area and the type and address of the retentive memory to
use, see project settings.
Index
Loaders
All the targets systems have a loader program, it allows the transfer of the application developed with
Remoter, in the target device by using the selected communication media. Usually it's used the serial line.
Some loaders are supplied from the manufacturer of the microcontroller and are residents in it, other were
specially developed for the purpose.
Any loader has a proper set of commands, the loaders supplied by the manufacturer of the microcontroller
usually use a different set of ascii commands for every type of microcontroller used. The loaders specially
developed for the purpose, uses the Modbus RTU protocol with some specially implemented commands.
Is important to set the correct loader for the target device using the project settings procedure,
otherwise will be not possible to upload the application on the target.
In the following table we report the loaders code referred to the proper target system.
Code Description
SFW154 Picosyst ME III systems loader (With PICOLOG1st series emulator package) History report
Index
Kernels
Some target systems have a kernel program that besides to allow the transfer of the application developed
with Remoter in the device, contains all the of interface functions between the user program and the target
device hardware. Using the kernel functions it's possible to maintain the compatibility of the user program
with the different versions of available hardware.
To allow the transfer of the application developed with Remoter in the device, the kernel uses the Modbus
RTU protocol with some specially implemented commands.
Is important to set the correct kernel for the target device using the project settings procedure,
otherwise the user program doesn't work properly.
In the following table we report the kernels code referred to the proper target system.
Code Description
Kernel variables
In the kernel exist variables allocated at absolute addresses it is possible to visualize their value with the
debug procedure from Remoter. The value of every variable allows a detailed information on the the kernel
status.
The allocation of these variables is reported only to allow to debug them. It is unadvised to reference
in the user program to the addresses reported, the allocation it's s not guaranteed.
BOOL 0xE000 UserModuleError User module error flag. It's activated by the
ExecutetKernelFct function, it allows to the user
program to force the run led to blink with error code.
BOOL 0xE001 SwitchToKernelCode Code memory access exchange flag. If set the
commands of modbus kernel, when access to the
code memory, are directed towards to the kernel code
memory allowing to perform the debug of the kernel
code.
unsigned int 0xE002 WrongFctsAdd Function call error address. If the user program calls a
kernel that does not exist, in the variable it's saved the
address of the function called.
TERMIOVECTORS* 0xE004 TermIOInError Terminal I/O error address. If the user program sets
an I/O terminal that does not exist SystemErrors.
IODeviceNotCorrect flag set, in the variable it's
saved transferred the address of the terminal set.
unsigned char 0xE008 NSystModError Nsyst module error address. If the user program
accesses on Nsyst bus to a module that does not
exist, besides the set of the SystemErrors.
NSYSTModAddress flag it's saved in this variable the
address of the module accessed.
unsigned char 0xE012 LoaderRunSts Kernel execution command from loader status report.
unsigned int 0xE010 KrnCfgWrCode Kernel configuration warning code. If a warning in
kernel configuration is detect, KernelErrors.
KrnCfgWarning bit set, in this variable the parameter
code in warning is returned.
unsigned int 0xE012 KrnCfgErCode Kernel configuration error code. If an error in kernel
configuration is detect, KernelErrors.KrnCfgError bit
set, in this variable the parameter code in error is
returned.
unsigned int 0xE014 PrjCfgWrCode Project configuration warning code. If a warning in
project configuration is detect, KernelErrors.
PrjCfgWarning bit set, in this variable the parameter
code in warning is returned.
unsigned int 0xE016 PrjCfgErCode Project configuration error code. If an error in project
configuration is detect, KernelErrors.PrjCfgError bit
set, in this variable the parameter code in error is
returned.
unsigned int 0xE018 KrnReadVarErID KernelReadVar function error code. If an error is
detect, KernelErrors.KrnReadVarErID bit set, in this
variable the variable ID in error is reported.
unsigned int 0xE01A KrnWriteVarErID KernelWriteVar function error code. If an error is
detect, KernelErrors.KrnWriteVarErID bit set, in this
variable the variable ID in error is reported.
Index
Netsyst line
MPS022**** Netlog
It's a programmable controller, engineered in standard container DIN43880,
which offers an economical solution of the automation problems. Based on
ADuC812 Analog devices (core MCS51 compatible) microcontroller, it has, as
base module, of 12 optoisolated logic inputs, 8 relays or static logic outputs, 4
analog inputs 0÷10Vdc 12bit, 2 analog outputs 0÷2,5Vdc 12bit and 2 serial port
RS232. Manual
MPS024**2* Netreader
It's a programmable controller equipped with smart card interface. This feature
makes it particularly interesting in the applications in which, at the classic
management of the logics typical of the PLC, it is necessary to have an
identification system. Based on T89C51 Temic (core MCS51 compatible)
microcontroller, it disposes, as base module of 6 optoisolated logic inputs, 4
relays or static logic outputs, a serial port RS232. Manual
MPS029****, NetlogII lite
It is a programmable controller, engineered in standard container DIN43880,
which offers an economical solution of the automation problems. Based on
ADuC845 Analog devices (core MCS51 compatible) microcontroller, it
disposes, as base module, of 12 optoisolated logic inputs, 8 relays or static
logic outputs, 4 analog inputs 0÷10Vdc 16bit, 2 analog outputs 0÷10Vdc 12bit
and 1 serial port RS232. Manual
MPS031****, Netmaster SNAP
MPS033****, Netmaster TSTICK
Is a network I/O interface, that offer a flexible and cheap solution to the remote
control problems and to data acquisition through internet/intranet networks.
The I/O section is based on ADuC845 Analog devices (core MCS51
compatible) microcontroller, it disposes, as base module, of 12 optoisolated
logic inputs, 8 relays or static logic outputs, 4 analog inputs 0÷10Vdc 16bit, 2
analog outputs 0÷10Vdc 12bit and 1 serial port RS232. RS485 version
manual CAN version manual
PCB099****, 20 I/O extension module
The module is engineered in a standard DIN43880 enclosure. Based on
ADuC845 Analog devices (core MCS51 compatible) microcontroller it provides
12 optoisolated digital input, 8 isolated digital output, 4 analog inputs 0-10V (or
RTD) 16bit resolution, 2 analog outputs 0-10V. Each digital input/output is
equipped with LED status indicator. Manual
Index
Picosyst line
MPS027***0, FACELOG
It is a hybrid operator terminal, equipped with optoisolated digital entries and exits, it
integrates, in just one product, the hardware e software features of a static PICOLOG
and of a PICOFACE. The shape and use flexibility is maintained and improved anyway,
with further containment of the costs. Manual
OIF018*0*0, PICOFACE
It is a low cost operator terminal, for panel assembly, specially designed to be combined
with the products of the Picosyst Millennium line. It permits an interactive dialog with the
operator through the showing of alphanumerical messages and numerical variables,
which can also be input. Manual
Index
Workspaces list
With Remoter are supplied some application and example programs, al the programs are supplied as
workspaces. To load this programs is necessary to choose the Open Workspace... item of the File menu,
it will be displayed a windows like this:
Figure 1
Existing It allows the directory browsing to search for a workspace. The search starts from the
directory definite in the Work directory options of Remoter. The open workspace will be
saved in the Recents.
Recents It contains list of the last opened workspaces.
Applications It contains list of the application programs.
Examples It contains list of example programs.
By selecting with the mouse the workspace name, in the window below a brief description of it will be
How to
Numerical operands
All the numerical operands are accessible from program C. Proper macrofunctions divided for type of operand
permit to entry in writing and in reading to all the operands addressable, you need to define the addresse of the
operand in esadecimal so as indicated in the program RIL.
In the following example, from program C some operands are acquired from language RIL.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES DEFINITION
// -----------------------------------------------------------------------------
BOOL InputValue;
BOOL OutputValue;
BOOL FlagValue;
unsigned char ByteValue;
unsigned int WordValue;
unsigned long DoubleValue;
float FloatValue;
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
InputValue=PLCOpI(0x0001); //To read the input 0001
PLCOpI(0x0001)=InputValue; //To write the input 0001
// [End of file]
Mnemonic operands
To entry a mnemonic operand, you need to define it as global operand (Instructions DEFG, DEFB). From C
program define an external variable of the same type of the operand putting before the mnemonic a
suffix that depends on the type so as in the following table. As already expressed previously the operands
(I) and (O) cannot be declared in mnemonic way.
In the following example, some global operands are declared by RIL language, by C program an external
variable is declared for every operand. As an example in the program loop the reading and the writing of the
flag operand is executed.
RIL C program
void Example(void)
{
// Local variable declarations.
BOOL FlagValue;
reserved operands
All the predefined operands are directly accessible by C program. In the following example some of them are
used.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM EXECUTION
// -------------------------------------------------------------------------
// Execute the variable init at first program execution loop.
if (PLCFirstLoop)
SecsCtr=0; //Seconds counter
if (PLCPulse1000)
SecsCtr++; //Seconds counter
}
// [End of file]
Worspaces list
Example programs
Normally the example programs are realized for a specific target system, but it's easy to change the
target system to adapt the program to the proper needs, please refer to the relate documentation.
PTP058E100:Alias "MotorSpeed"
It calculates the motor rotation speed using an encoder fixed on the shaft. To read the encoder is
used the FbEncoderOverIO executed in interrupt.
TASK
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
L A
L Y A
TASK TASK call Close rung B Y No A
W C
W Y C
The instruction TASK call allows the functions written in other languages to be executed directly from the
RIL program, allows the execution of standard function blocks (FB) supplied as libraries or developed by a
client. It also allows to execute functions loaded at relative address.
To execute a function blocks (FB), the function block type (B) must be used as 1st operand followed by the
function block to be executed. The second operand defines the memory Byte (Y) address allocation for the
function block.
To execute a function written in other languages, the label type (L) must be used as 1st operand followed
by the name of the function. The second operand (optional) defines the address Byte (Y) of memory
allocation for the function.
To execute a function loaded at relative address, it is necessary to memorize the address in a Word (W)
and use as it 1st operand. The second operand (optional) defines the address Byte (Y) of memory
allocation for the function.
Examples
In the following example, if the I 0000 is active the function block FbCounterOverIOis executed, defining
Y 0100 as the allocation address of the data structure. When the function block ends, the program
execution continues from the next branch.
CALF
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction CALl File should be used to call the RLD, RIL o RFB files in the project with the option
Autocalled file disabled (See project rules). The call depends on the status of the logical branch where the
instruction is and is executed only if it is active. When the instruction is active, the program in the called file
is executed. When the program ends, executions backs to the instruction that follows it. You can nesting
CALF instructions without any limit.
ATTENTION! The instruction execution doesn't change the status of logic stack.
Examples
A specific example of the use of this instruction is in the Ptp077, see the example programs
Project settings
Programming
This window allows to configure the communication settings with the target device for the programming operations.
Figure 1
In the Protocol section it's possible to define the type of protocol to be used to program the target system.
Analog Devices uC Loader Uses the proprietary Analog Devices protocol, it's present in the ADuC845 microcontrollers.
Atmel 89C51 Loader Uses the proprietary Atmel protocol, it's present in the 89C51 microcontrollers.
Modbus Uses the ModBus communication protocol.
Philips 89C51 Loader Uses the proprietary Philips protocol, it's present in the 89C51 microcontrollers.
In the Media, section it's possible to define the type of media to be used to program the target system.
Serial direct The PC serial port will be used, it's possible to select any PC COM port.
TCP/IP The TCP/IP protocol over ethernet, on PPP connection, over Internet will be used.
Project settings
Figure 1
Answer Timeout Define the time to wait the answer after a command.
Max Data Record Length Define the maximun length of data record.
Allows High Baud Rate Selected forces Remoter to increase the baud rate during the program upload, reducing the time needed.
Project settings
Figure 1
Answer Timeout Define the time to wait the answer after a command.
Max Data Record Length Define the maximun length of data record.
Project settings
Modbus protocol
Figure 1
Modbus Type Defines the type of modbus protocol to be used to program the target system.
Slave Node Number Defines the target Modbus node number.
Answer Timeout Defines the waiting time for the answer from the target system. After this time an error timeout is detect.
Command Wait Time Defines the waiting time after the reception of the command answer and the send of a new command.
Max Data Record Length Defines the maximum length of the record data to be used to dialogue with the target system.
Allows High Baud Rate Selected allows to automatically change the baud rate when upload program is started.
Project settings
Figure 1
Answer Timeout Define the time to wait the answer after a command.
Max Data Record Length Define the maximun length of data record.
Project settings
Serial set
Figure 1
Project settings
Serial driver
This window allows the setting of the serial driver parameter as reported in the figure below.
Figure 1
Enable Driver Capability Selected, enables the serial driver allowing the options set.
Wait Time Before Tx Indicates the wait time between the Tx signal activation and the and the real transmission of the characters
Wait Time After Tx Indicates the wait time between the transmission of the last character and the Tx signal deactivation.
Clear Tx Echo Selected forces the clear of the echo received string.
Tx Signal Complement Selected complement the status of the selected signal for Tx enable.
Tx Signal Management Defines the operation way of the selected signal for Tx enable.
Signal for Tx Enable Defines the signal must be used to enable the transmission.
Project settings
TCP/IP set
This window allows to set the TCP/IP communication settings for the programming communication.
Figure 1
IP Address Defines the IP address of the interface device connected with the target system.
Port Defines the port of the interface device connected with the target system.
Project settings
Modbus protocol
Figure 1
Modbus Type Defines the type of modbus protocol to be used to debug application on target system.
Slave Node Number Defines the target Modbus node number.
Answer Timeout Defines the waiting time for the answer from the target system. After this time an error timeout is detect.
Command Wait Time Defines the waiting time after the reception of the command answer and the send of a new command.
Max Data Record Length Defines the maximum length of the record data to be used to dialogue with the target system.
Allows High Baud Rate Selected allows to automatically change the baud rate when debug is started.
Project settings
Serial set
Figure 1
Project settings
Serial driver
This window allows the setting of the serial driver parameter as reported in the figure below.
Figure 1
Enable Driver Capability Selected, enables the serial driver allowing the options set.
Wait Time Before Tx Indicates the wait time between the Tx signal activation and the and the real transmission of the characters
Wait Time After Tx Indicates the wait time between the transmission of the last character and the Tx signal deactivation.
Clear Tx Echo Selected forces the clear of the echo received string.
Tx Signal Complement Selected complement the status of the selected signal for Tx enable.
Tx Signal Management Defines the operation way of the selected signal for Tx enable.
Signal for Tx Enable Defines the signal must be used to enable the transmission.
Project settings
TCP/IP set
This window allows to set the TCP/IP communication settings for the debug communication.
Figure 1
IP Address Defines the IP address of the interface device connected with the target system.
Port Defines the port of the interface device connected with the target system.
Target configuration
User configuration
The user configuration will be used only if an access point is used to access to the target system.
Figure 1
User Type Defines the access rights for the user. The possibles choices are.
Admin The user has the maximum rights on the system, he can debug the program, change the variable values, stop and run the
program and change the program.
Guest The user can debug the program and change the variable values but he cannot stop and change the program.
User The user can only debug the program but he cannot change the variable values.
Username Defines the username to be used to access. (Case sensitive)
Password Defines the password to be used to access. (Case sensitive)
Target configuration
Serial set
Figure 1
Target configuration
Serial driver
It allows to define the serial criver parameters as reported in the following figure.
Figure 1
Enable Driver Capability Selected, enables the serial driver allowing the options set.
Wait Time Before Tx Indicates the wait time between the Tx signal activation and the and the real transmission of the characters
Wait Time After Tx Indicates the wait time between the transmission of the last character and the Tx signal deactivation.
Clear Tx Echo Selected forces the clear of the echo received string.
Tx Signal Complement Selected complement the status of the selected signal for Tx enable.
Tx Signal Management Defines the operation way of the selected signal for Tx enable.
Signal for Tx Enable Defines the signal must be used to enable the transmission.
Target configuration
Access point
Allows to define the access point configuration. The access point authenticate the user to allow the acces to the defined terminal I/O.
A set of parametrs must be defined for any user.
Figure 1
TermIO Defines the I/O terminal where the access point is connected to.
The defined terminal I/O cannot be used by any other resource.
Timeout Defines the inactivity time on the access point after which the user will be disconnected.
No Login If selected allow to access without login.
User nr Associates one of the 4 users when the No Login is selected.
Target configuration
Modbus protocol
Figure 1
TermIO Defines the I/O terminal where the modbus manager is connected to.
The defined terminal I/O cannot be used by any other resource.
Modbus Type Defines the type of modbus protocol to be used to debug application on target system.
Node Number Defines the target Modbus node number.
Answer Timeout Defines the waiting time for the answer from the target system. After this time an error timeout is detect.
User prg debug enable If set it will be possible to execute the user program debug.
Target configuration
Modem settings
Figure 1
TermIO Defines the I/O terminal where the access point is connected to.
The defined terminal I/O cannot be used by any other resource.
Modem type Defines the type of modem is used.
Ring Nr Defines the number of ring waited before to answer a call.
Dial Tries Defines the unsuccessful number of attempts on telephone call. After the definite number the call is aborted.
Inter Dial Time Defines the wait time between the call attempts.
SMS Send Tries Defines the unsuccessful number of attempts on SMS send. After the definite number the SMS send is aborted.
Inter SMS Send Time Defines the wait time between the SMS send attempts.
Timeout Defines the inactivity check time. After the defined time with non modem acrtivity the line is disconnected.
How to
It is possible to force the execution of a startup function before passing to the execution of the user program. By
activating the related option in the project settings, and by defining in the program the function to be executed
written in RIL, C or assembler language and labelled with the name PLCUserStartUp, at the ignition of the
target system before passing to the execution of the user program, the function will be executed.
Example RIL
The example that follows does not have a real utility it is just an indication of how possible it is to define a startup
function by using the RIL language. The subroutine labelled with LABL L PLCUserStartUp will be executed just
once at the ignition of the target system before passing to the ciclic execution of the user program.
; ------------------------------------------------------------------------------
; @Section("User program")
; ------------------------------------------------------------------------------
ORGR
LODT F PLCTimeBase400
OUTT O 0001 ; Blinking Output
ORGR
SETR
RETN
; ------------------------------------------------------------------------------
; @Section("User startup routine")
; ------------------------------------------------------------------------------
; This function is automatically called once before to execute the user program.
ORGR
LABL L PLCUserStartUp
SETR
LTCH O 0000 ; Startup output
RETN
; [End of file]
"C" variables
This variable contains the real time clock data, the variable is automatically allocated by Remoter.
Writing from program or from MODBUS a new value in an any member of the variable, the real time
clock will be automatically updated with the new value.
By acting in the project settings it's possible to define the address of memory where this variable will
be allocated. This is useful in the case it should be reached from MODBUS.
typedef struct
{
unsigned char Year; //Year, range from 0 to 99
unsigned char Month; //Month, range from 1 to 12
unsigned char Day; //Day, range from 1 to 31
unsigned char WeekDay; //Week day, range from 0 to 6
unsigned char Hour; //Hour, range from 0 to 23
unsigned char Minute; //Minute, range from 0 to 59
unsigned char Second; //Second, range from 0 to 59
unsigned char Hundred; //Hundred, range from 0 to 99
}RTCDATA;
Some fields of the data structure are not managed in some libraries because the target system has not the
real time clock. In the following table the indication of the different field are reported with reference to the
supported libraries.
Operands
Input
The Input operand can be used in the logical instructions, it represents the status of a logic input. Its status
can have only 2 values, FALSE or TRUE.
All the logic inputs are acquired as process image at the beginning of the program loop and their status is
transferred to the memory. The Input operand tests the status as it was saved in the process image, so the
status of the operand doesn't change during the program loop even if the real input status changes. In case
you need to test the real status of a logic input you can use the IOAQ instruction it directly acquire the logic
inputs.
Numerical declarations
The Input operands can be defined in numerical mode according to the defined addressing range. Using
the numerical declaration it's possible to know their memory address referring to the allocation address
defined in the project settings window.
Numerical range
Type Description
PSYST NSYST Netreader
The numerical ranges with (*), indicates the default accepted values, user can change the defined range in
the project settings window. Naturally the total quantity of definable operands for every target depends on
the RAM memory available.
Mnemonic declarations
The Input operands cannot be defined mnemonically, so we suggest to copy their status to a Flag (F)
declared in mnemonic mode, as in the example.
Ladder RIL
DEFG F CmdPushButton ;Global flag
ORGR
LODT I 0000
OUTT F CmdPushButton
In order to use the Input operand from C language we suggest to define a global BOOL variable and from
RIL language define it as external Flag (F)and then copy the Input operand to the Flag. In the example the
status of the F Input is tested, in the RIL program the status of logic input I 0000 has been copied to it. For
more information about how to access from C language to the RIL operands see the proper chapter.
if (Input == FALSE)
IsFalse=TRUE;
else
IsTrue=TRUE;
}
Operands
Output
The Output operand can be used in the logical instructions, it represents the status of a logic outputs. Its
status can have only 2 values, FALSE or TRUE.
All the logic outputs are managed as process image, at the end of the program loop their status is
transferred to the physical outputs. So if during the program loop the status of the Output operand change
the real output will be updated only at the program loop end. In case you need to set the real output during
the program loop you can use theIOAQ instruction, it set the logic output directly.
Numerical declarations
The Output operands can be defined in numerical mode according to the defined addressing range. Using
the numerical declaration it's possible to know their memory address referring to the allocation address
defined in the project settings window.
Numerical range
Type Description
PSYST NSYST Netreader
The numerical ranges with (*), indicates the default accepted values, user can change the defined range in
the project settings window. Naturally the total quantity of definable operands for every target depends on
the RAM memory available.
Mnemonic declarations
The Output operands cannot be defined mnemonically, so we suggest to use Flag (F) declared in
mnemonic mode and copy their status to the operand, as in the example.
Ladder RIL
DEFG F MotorOn ;Global flag
ORGR
LODT F MotorOn
OUTT O 0000
In order to use the Output operand from C language we suggest to define a global BOOL variable and
from RIL language define its mnemonic as external Flag (F) and copy the Output operand status to it. In
the example the status of the F Output is managed, in the RIL program it's copied to the O 0000. For more
information about how to access from C language to the RIL operands see the proper chapter.
Operands
Flag
The Flag operand can be used in the logical instructions, it represents a boolean variable inside the
memory area. Its status can have only 2 values, FALSE or TRUE.
Numerical declarations
The Flag operands can be defined in numerical mode according to the defined addressing range. Using the
numerical declaration it's possible to know their memory address referring to the allocation address defined
in the project settings window.
Numerical range
Type Description
PSYST NSYST Netreader
The numerical ranges with (*), indicates the default accepted values, user can change the defined range in
the project settings window. Naturally the total quantity of definable operands for every target depends on
the RAM memory available.
ATTENTION ! The operand uses 1 memory byte, when allocated in numerical mode, it uses the same
allocation of the variable Byte (Y). So the operand F 0100 uses the same allocation of the operand Y 0100.
Please pay attention to not use the same memory area for different operands.
Mnemonic declarations
If you don't need to know the allocation address you can define the operand in mnemonic mode by using
the RIL instructions:
DEFG F Name To define a mnemonic operand called Name with global visibility, it can be used in all the
project files.
DEFB F Name To define a mnemonic operand called Name with global visibility it can be used in all the
project files. The operand value will be saved at the system power off and restored when
the system will be switched on again.
DEFL F Name To define a mnemonic operand called Name with local visibility, it can be used only in the
file where it is defined.
Example
If the F BackupFlag is in the logical status TRUE and if F CommandFlag is in the logical status TRUE,
and F EnableFlag is in the logical status TRUE, the F IsActive will be forced in the logical status TRUE.
The variable F BackupFlag is defined as backup, so it retains its status when the system turns off.
Ladder RIL
EXTR F IsActive ;Extern flag
DEFB F BackupFlag ;Backup flag
DEFG F CommandFlag ;Global flag
DEFL F EnableFlag ;Local flag
ORGR
LODT F CommandFlag
ANDT F BackupFlag
ANDT F EnableFlag
OUTT F IsActive
Are executed the he same operations of the RIL example, the F variables are defined as BOOL. It is not
possible to define backup variables, so the BackupFlag variable is declared as global variable. For more
information about how to access from C language to the RIL operands see the proper chapter.
"C" language
#extern BOOL IsActive; //Extern boolean
BOOL BackupFlag; //Global boolean
BOOL CommandFlag; //Global boolean
void Example(void)
{
BOOL EnableFlag; //Local boolean
IsActive=CommandFlag&BackupFlag&EnableFlag;
}
Operands
Byte
The Byte operand can be used in all the mathematical instructions, it represents a 8 bits variable in the
memory area. Its range is 0x00-0xFF in hexadecimal or 0-255 in decimal. The logical instructions can
operate on Byte operand by testing the status of every bit, so the LODT Y 0100 BD 0004 instruction will
returns a true logical condition if the bit 4 of Y 0100 is set.
Numerical declarations
The Word operands can be defined in numerical mode according to the defined addressing range. Using
the numerical declaration it's possible to know their memory address referring to the allocation address
defined in the project settings window.
Numerical range
Type Description
PSYST NSYST Netreader
The numerical ranges with (*), indicates the default accepted values, user can change the defined range in
the project settings window. Naturally the total quantity of definable operands for every target depends on
the RAM memory available.
ATTENTION ! The operand uses 1 memory byte, when allocated in numerical mode, it uses the same
allocation of the variable Flag (F). So the operand Y 0100 uses the same allocation of the operand F 0100.
Please pay attention to not use the same memory area for different operands.
Mnemonic declarations
If you don't need to know the allocation address you can define the operand in mnemonic mode by using
the RIL instructions:
DEFG Y Name To define a mnemonic operand called Name with global visibility, it can be used in all the
project files.
DEFB Y Name To define a mnemonic operand called Name with global visibility it can be used in all the
project files. The operand value will be saved at the system power off and restored when
the system will be switched on again.
DEFL Y Name To define a mnemonic operand called Name with local visibility, it can be used only in the
file where it is defined.
Example
At every second the value of the variable Y Counter increases, it is executed the operation
Y Result=Y Threshold-Y Counter, and when the value of the Y Counter is the same one of the value
Y Threshold, its value is taken to zero and Y Comparisons increases. The variable Y Threshold is
defined as backup, so it retains its value when the system turns off.
Ladder RIL
EXTR Y Counter ;Extern byte
DEFB Y Threshold ;Backup byte
DEFG Y Result ;Global byte
DEFL Y Comparisons ;Local byte
ORGR
LODT F PLCPulse1000
PULS
LODA Y Counter
INCA KD 1
STRA Y Counter
LODA Y Threshold
SUBA
STRA Y Result
ORGR
EQUC Y Counter Y Threshold
MOVI Y Counter KD 0
LODA Y Comparisons
INCA KD 1
STRA Y Comparisons
Are executed the same operations of the RIL example, the Y variables are defined as unsigned char. It is
not possible to define backup variables, so the Threshold variable is declared as global variable. For more
information about how to access from C language to the RIL operands see the proper chapter.
"C" language
#extern unsigned char Counter; //Extern char
unsigned char Threshold; //Global char
unsigned char Result; //Global char
void Example(void)
{
unsigned char Comparisons; //Local char
if (PLCPulse1000)
{
Counter++;
Result=Threshold-Counter;
}
Counter=0;
Comparisons++;
}
}
Operands
Word
The Word operand can be used in all the mathematical instructions, it represents a 16 bits variable in the
memory area. Its range is 0x0000-0xFFFF in hexadecimal or 0-65535 in decimal. The logical instructions
can operate on Word operand by testing the status of every bit, so the LODT W 0100 BD 0008 instruction
will returns a true logical condition if the bit 8 of W 0100 is set.
Numerical declarations
The Word operands can be defined in numerical mode according to the defined addressing range. Using
the numerical declaration it's possible to know their memory address referring to the allocation address
defined in the project settings window.
Numerical range
Type Description
PSYST NSYST Netreader
The numerical ranges with (*), indicates the default accepted values, user can change the defined range in
the project settings window. Naturally the total quantity of definable operands for every target depends on
the RAM memory available.
ATTENTION ! The operand uses 2 memory bytes, when allocated in numerical mode, it uses the same
allocation of 2 variables Flag (F) or Byte (Y). So the operand W 0100 uses the same allocation of the
operands F 0100, F 0101 or the operands Y 0100, Y 0101. Please pay attention to not use the same
memory area for different operands.
Mnemonic declarations
If you don't need to know the allocation address you can define the operand in mnemonic mode by using
the RIL instructions:
DEFG W Name To define a mnemonic operand called Name with global visibility, it can be used in all the
project files.
DEFB W Name To define a mnemonic operand called Name with global visibility it can be used in all the
project files. The operand value will be saved at the system power off and restored when
the system will be switched on again.
DEFL W Name To define a mnemonic operand called Name with local visibility, it can be used only in the
file where it is defined.
Example
At every second the value of the variable W Counter increases, it is executed the operation
W Result=W Threshold-W Counter, and when the value of the W Counter is the same one of the value
W Threshold, its value is taken to zero and W Comparisons increases. The variable W Threshold is
defined as backup, so it retains its value when the system turns off.
Ladder RIL
EXTR W Counter ;Extern word
DEFB W Threshold ;Backup word
DEFG W Result ;Global word
DEFL W Comparisons ;Local word
ORGR
LODT F PLCPulse1000
PULS
LODA W Counter
INCA KD 1
STRA W Counter
LODA W Threshold
SUBA
STRA W Result
ORGR
EQUC W Counter W Threshold
MOVI W Counter KD 0
LODA W Comparisons
INCA KD 1
STRA W Comparisons
Are executed the same operations of the RIL example, the W variables are defined as unsigned int. It is
not possible to define backup variables, so the Threshold variable is declared as global variable. For more
information about how to access from C language to the RIL operands see the proper chapter.
"C" language
#extern unsigned int Counter; //Extern int
unsigned int Threshold; //Global int
unsigned int Result; //Global int
void Example(void)
{
unsigned int Comparisons; //Local int
if (PLCPulse1000)
{
Counter++;
Result=Threshold-Counter;
}
{
Counter=0;
Comparisons++;
}
}
Operands
Double word
The Double Word operand called also Double, can be used in all the mathematical instructions, it
represents a 32 bits variable in the memory area. Its range is 0x00000000-0xFFFFFFFF in hexadecimal or
0-4294967295 in decimal. The logical instructions can operate on Double operand by testing the status of
every bit, so the LODT DW 0100 BH 0010 instruction will returns a true logical condition if the bit 0x10 of
DW 0100 is set.
Numerical declarations
The Double operands can be defined in numerical mode according to the defined addressing range. Using
the numerical declaration it's possible to know their memory address referring to the allocation address
defined in the project settings window.
Numerical range
Type Description
PSYST NSYST Netreader
The numerical ranges with (*), indicates the default accepted values, user can change the defined range in
the project settings window. Naturally the total quantity of definable operands for every target depends on
the RAM memory available.
ATTENTION ! the operand uses 4 memory bytes, when allocated in numerical mode, it uses the same
allocation of 4 variables Flag (F) or Byte (Y), of 2 variables Word (W) or of one variable Float (FL). So the
operand DW 0100 uses the same allocation of the operands F 0100, F 0101, F 0102, F 0103 or the
operands Y 0100, Y 0101, Y 0102, Y 0103 or the operands W 0100, W 0102, or the operand FL 0100.
Please pay attention to not use the same memory area for different operands.
Mnemonic declarations
If you don't need to know the allocation address you can define the operand in mnemonic mode by using
the RIL instructions:
DEFG DW Name To define a mnemonic operand called Name with global visibility, it can be used in all the
project files.
DEFB DW Name To define a mnemonic operand called Name with global visibility it can be used in all the
project files. The operand value will be saved at the system power off and restored when
the system will be switched on again.
DEFL DW Name To define a mnemonic operand called Name with local visibility, it can be used only in the
file where it is defined.
Example
At every second the value of the variable DW Counter increases, it is executed the operation
DW Result=DW Threshold-DW Counter, and when the value of the DW Counter is the same of the value
DW Threshold, its value is reset and DW Comparisons increased. The variable DW Threshold is
defined as backup, so it retains its value when the system turns off.
Ladder RIL
EXTR DW Counter ;Extern double
DEFB DW Threshold ;Backup double
DEFG DW Result ;Global double
DEFL DW Comparisons ;Local double
ORGR
LODT F PLCPulse1000
PULS
LODA DW Counter
INCA KD 1
STRA DW Counter
LODA DW Threshold
SUBA
STRA DW Result
ORGR
EQUC DW Counter DW Threshold
MOVI DW Counter KD 0
LODA DW Comparisons
INCA KD 1
STRA DW Comparisons
Are executed the same operations of the RIL example, the DW variables are defined as unsigned long. It
is not possible to define backup variables, so the Threshold variable is declared as global variable. For
more information about how to access from C language to the RIL operands see the proper chapter.
"C" language
#extern unsigned long Counter; //Extern long
unsigned long Threshold; //Global long
unsigned long Result; //Global long
void Example(void)
{
unsigned long Comparisons; //Local long
if (PLCPulse1000)
{
Counter++;
Result=Threshold-Counter;
}
Operands
Float
The Float operand can be used in all the mathematical instructions, it represents a 32 bits variable in the
memory area. Its range is from -3.4028233e+38 to +3.4028233e+38 in decimal.
Numerical declarations
The Float operands can be defined in numerical mode according to the defined addressing range. Using
the numerical declaration it's possible to know their memory address referring to the allocation address
defined in the project settings window.
Numerical range
Type Description
PSYST NSYST Netreader
The numerical ranges with (*), indicates the default accepted values, user can change the defined range in
the project settings window. Naturally the total quantity of definable operands for every target depends on
the RAM memory available.
ATTENTION ! The operand uses 4 memory bytes, when allocated in numerical mode, it uses the same
allocation of 4 variables Flag (F) or Byte (Y), of 2 variables Word (W) or of one variable Double (DW). So
the operand FL 0100 uses the same allocation of the operands F 0100, F 0101, F 0102, F 0103 or the
operands Y 0100, Y 0101, Y 0102, Y 0103 or the operands W 0100, W 0102, or the operand DW 0100.
Please pay attention to not use the same memory area for different operands.
Mnemonic declarations
If you don't need to know the allocation address you can define the operand in mnemonic mode by using
the RIL instructions:
DEFG FL Name To define a mnemonic operand called Name with global visibility, it can be used in all the
project files.
DEFB FL Name To define a mnemonic operand called Name with global visibility it can be used in all the
project files. The operand value will be saved at the system power off and restored when
the system will be switched on again.
DEFL FL Name To define a mnemonic operand called Name with local visibility, it can be used only in the
file where it is defined.
Example
At every second the value of the variable FL Counter increases, it is executed the operation
FL Result=FL Threshold-FL Counter, and when the value of the FL Counter is the same of the value
FL Threshold, its value is reset and FL Comparisons increased. The variable FL Threshold is defined as
backup, so it retains its value when the system turns off.
Ladder RIL
EXTR FL Counter ;Extern float
DEFB FL Threshold ;Backup float
DEFG FL Result ;Global float
DEFL FL Comparisons ;Local float
ORGR
LODT F PLCPulse1000
PULS
LODA FL Counter
FINC KF 1.000000
STRA FL Counter
LODA FL Threshold
FSUB
STRA FL Result
ORGR
EQUC FL Counter FL Threshold
MOVI FL Counter KF 0.000000
LODA FL Comparisons
FINC KF 1.000000
STRA FL Comparisons
Are executed the he same operations of the RIL example, the FL variables are defined as float. It is not
possible to define backup variables, so the Threshold variable is declared as global variable. For more
information about how to access from C language to the RIL operands see the proper chapter.
"C" language
#extern float Counter; //Extern float
float Threshold; //Global float
float Result; //Global float
void Example(void)
{
float Comparisons; //Local float
if (PLCPulse1000)
{
Counter++;
Result=Threshold-Counter;
}
Counter=0;
Comparisons++;
}
}
DEFB
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
F, C, Y, W, DW, FL
DEFB DEFine Backup operand None No A
Y KD
The instruction DEFine Backup operand has to be used to define a new mnemonic operand, having a
global visibility inside the project. The value of the defined operand will be memorized when the system is
turned off and reloaded at the next turning on. The instruction doesn't have any logical function in the
program so it has to be inserted without any definition of the logical branch, we suggest of inserting the
instruction at the beginning of the RIL file. Instructions can access to the defined operand from any RIL file
of the project by only indicating its type and name.
ATTENTION! You cannot define two operands with the same name in the same project (even they are in
different files) even they have different type. So you cannot define local operands DEFL, or global operands
DEFG using names defined as backup operands.
Examples
In the following example, when I 0000 is activated, the value of the W Counter is increased. In case of
turning off of the system the value of the W Counter gets memorized and at the next system on it will have
the value it had when the system was turned off. You cannot define an operand with the name Counter in
any other file.
ORGR
LODT I 0000
PULS
INCO W Counter
"C" variables
This variable is automatically allocated by Remoter in area code and it is set with the project information so
as reported in the project settings. The information contained can be read with the proper command of
project information request.
typedef struct
{
// --------------------------------------[Members returned as project info]--
Operands
Counter
The Counter operand allows to define a counter, the counters are expressed as variables with 8 bits in the
memory area. Its range is 0x00-0xFF in hexadecimal or 0-255 in decimal. The allocation of the Counter
operand is made automatically it is assigned a memory space of 8 bytes to every operand, one for the
status, and the others for the management.
The Counter operand as how implemented in the version 7.x of Remoter had some limits, it was not
possible to perform its decrement, to know its value, to preset it to a desired value. Besides its range was
expressed only by using a 8 bits variable. With the version 8.0 of Remoter were implemented new logic
instructions, they make obsolete the Counter operand. By using the INCO and DECO instructions it is
possible to increase and decrease any operand value, while with the GRTC, EQUC, LESC instructions it is
possible to compare the value with a constant (K) or with another operand.
We suggest to not use in the future this operand and to use in alternative the INCO, DECO, GRTC, EQUC,
LESC instructions.
Numerical declarations
The operand can be defined in numerical mode according to the defined addressing range. Anyway it's not
possible to know its memory allocation address, because also using the numerical declaration it will be
allocated automatically.
Numerical range
Type Description
PSYST NSYST Netreader
The numerical ranges with (*), indicates the accepted numerical values, naturally the total quantity of
operands definable for every target depends on the quantity of RAM memory available. The sequentially of
the numbering it doesn't matter for the memory use optimization.
Mnemonic declarations
if you don't need to know the allocation address you can define the operand in mnemonic mode by using
the RIL instructions:
DEFG C Name To define a mnemonic operand called Name with global visibility, it can be used in all the
project files.
DEFB C Name To define a mnemonic operand called Name with global visibility it can be used in all the
project files. The operand value will be saved at the system power off and restored when
the system will be switched on again.
DEFL C Name To define a mnemonic operand called Name with local visibility, it can be used only in the
file where it is defined.
Example
At every second the value of Y Counter variable it's increased, when the value is equal to 4 the operand
F 0000 it's activated.
ORGR
LODT F PLCPulse1000
INCO Y Counter
ORGR
EQUC Y Counter KD 4
OUTT F 0000
Operands
Timer
The Timer operand can be used in the logical instructions, it represents a boolean variable inside the
memory area. Its status can have only 2 values, FALSE or TRUE. In the OUTM instruction, even if it
represents a boolean variable it needs the activation delay time definition. The allocation of the Timer
operand is made automatically, it is assigned a memory space of 16 bytes to every operand, one for the
status, and the others for the management.
Numerical declarations
The operand can be defined in numerical mode according to the defined addressing range. Anyway it's not
possible to know its memory allocation address, because also using the numerical declaration it will be
allocated automatically.
Numerical range
Type Description
PSYST NSYST Netreader
The numerical ranges with (*), indicates the accepted numerical values, naturally the total quantity of
operands definable for every target depends on the quantity of RAM memory available. The sequentially of
the numbering it doesn't matter for the memory use optimization.
Mnemonic declarations
if you don't need to know the allocation address you can define the operand in mnemonic mode by using
the RIL instructions:
DEFG T Name To define a mnemonic operand called Name with global visibility, it can be used in all the
project files.
DEFL T Name To define a mnemonic operand called Name with local visibility, it can be used only in the
file where it is defined.
Example
If F CommandFlag is in the logical status TRUE and if T StartDelay is in the logical status TRUE, after 10
mSec T WorkDelay will be in status TRUE and after 60 Sec T OffDelay will be in status TRUE. When
F CommandFlag or T StartDelay are in status FALSE, immediately T WorkDelay and T OffDelay will be
in status FALSE.
ORGR
LODT F CommandFlag
ANDT T StartDelay
OUTM T WorkDelay KD 10 KE Base1mS
OUTM T OffDelay KD 1 KE Base60S
The operand Timer can be tested by C language but it cannot be managed. In the example the status T
WorkDelay defined as a global variable in the RIL program is tested.
"C" language
#extern BOOL WorkDelay; //Extern boolean
void Example(void)
{
BOOL IsFalse=FALSE; //Local boolean
BOOL IsTrue=FALSE; //Local boolean
if (WorkDelay == FALSE)
IsFalse=TRUE;
else
IsTrue=TRUE;
}
Utility instructions
SETV
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction SEt Terminal I/O device Vectors allows the definition of the vectors for the management of
the standard I/O devices. All the standard I/O management instructions will operate with the device set with
this instruction.
The operand Word (W) allows to set the vector, whom address is defined in a memory word.
Examples
In the following example, when I 0000 gets activated, the string Hello! will be sent to the serial line A.
Function blocks
FbModbusAsciiSl
This function block allows the management of the MODBUS ASCII protocol as slave. The function block can be
called also by using the proper graphic utility this simplify the use. In case of mistake in the user defined
parameters, the StatusBit.ParamErrs and the FBParameters bit in the PLCErrors data structure are set.
Declaration
void FbModbusAsciiSl(FBMODBUSASCIISLDATA* S);
Parameters
FBMODBUSASCIISLDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 64 bytes data structure, we report a prototype. The members, reported under the
Members automatically managed by Remoter label are managed automatically by Remoter in case of use the
graphic utility, on the contrary they have to be managed by the user program. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //Enable
BOOL ResetCtrs:1; //Resets all the counters
BOOL b2:1;
BOOL b3:1;
BOOL b4:1;
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}CmdBit; //Command
struct
{
BOOL Enabled:1; //Enabled
BOOL ReceiveOk:1; //Receive ok
BOOL CmActive:1; //Communication active
BOOL ParamErrs:1; //Parameters error
00 CmdBit
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: It disables the FB and the communication is hang up. By disabling the FB all the error
bits in StatusBit are reset and all the other command bits are not active.
TRUE: It enables the FB.
1 ResetCtrs TRUE: It resets all the counters, the bit is automatically reset.
01 StatusBit
Status bits of the function block, the user program can test these bits. The value can be acquired by
MODBUS with the diagnostic command 0002: Return diagnostic register.
0 Enabled TRUE: The FB is enabled.
1 ReceiveOk It's activated for a program loop at the reception of every MODBUS command.
2 CmActive It's activated at FB enable or when a MODBUS command is received. It's reset if MODBUS
commands are not received for a time longer than the time defined in CmActiveDelay or by
resetting the CmdBit.Enable.
3 ParamErrs TRUE: Indicates an error on user defined parameters. It can be reset by resetting the CmdBit.
Enable.
4 Timeouts TRUE: Indicates a command execution timeout error. It can be reset by resetting the CmdBit.
Enable or at the reception of the 000A: Clear counters and diagnostic registers diagnostic
command.
5 Overruns TRUE: Indicates an overruns error in reception from serial line, more characters than the
reception buffer length has been received. It can be reset by resetting the CmdBit.Enable or
at the reception of the 000A: Clear counters and diagnostic registers diagnostic command.
6 CommErrs TRUE: Indicates an error command reception from serial line, a wrong character or a number
of characters different from the requested has been received. It can be reset by resetting the
CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers
diagnostic command.
7 Excepts TRUE: Indicates a reception of a MODBUS function that is not supported. It can be reset by
resetting the CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic
registers diagnostic command.
02 NodeAdd
Loaded by user program it defines the address of slave node (From 0x00 to 0xFF).
04 AnswerWt
Loaded by user program it defines the waiting time expressed in mSec between the reception of a MODBUS
command and the transmission of the proper answer (From 0x0000 to 0xFFFF).
06 TimeOutCk
Loaded by user program it defines the available time expressed in mSec to receive an entire command
frame. Time is considered from the reception of the start frame ":" character. (From 0x0000 to 0xFFFF).
08 Timeouts
It returns the occurred timeouts errors counting (From 0x0000 to 0xFFFF). It can be reset by resetting the
CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers diagnostic command.
0A Overruns
It returns the occurred overrun errors counting (From 0x0000 to 0xFFFF). The value can be acquired by
MODBUS with the 0012: Return bus character overrun count diagnostic command. It can be reset by
resetting the CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers
diagnostic command.
0C CommErrs
It returns the occurred communication errors counting (From 0x0000 to 0xFFFF). The value con be acquired
by MODBUS with the 000C: Return bus error count diagnostic command. It can be reset by resetting the
CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers diagnostic command.
0E ExceptsErr
It returns the occurred except errors counting (From 0x0000 to 0xFFFF). The value con be acquired by
MODBUS with the 000D: Return bus exception error count diagnostic command. It can be reset by resetting
the CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers diagnostic
command.
10 Communs
It returns the received MODBUS commands counting (From 0x0000 to 0xFFFF). The value con be acquired
by MODBUS with the 000B: Return bus message count diagnostic command. It can be reset by resetting the
CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers diagnostic command.
12 Answers
It returns the sent MODBUS answers counting (From 0x0000 to 0xFFFF). The value con be acquired by
MODBUS with the 000E: Return slave message count diagnostic command. It can be reset by resetting the
CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers diagnostic command.
16 CmActiveDelay
Loaded by user program it defines the time in mSec, after that if no MODBUS command are received the
active communication bit StatusBit.CmActive is reset (From 0x0000 to 0xFFFF).
18 FrameLength
Loaded by user program it defines the dimension of the frame reception/transmission buffer (From 12 to
255). To maintain compatibility with the previous versions a buffer of at least 40 bytes must be defined.
1C FrameBuf
Automatically loaded by Remoter if the graphic utility is used, otherwise it must by loaded by user program, if
defines the allocation address of the frame reception/transmission buffer (From 0x0000 to 0xFFFF).
1E Compatibility
Automatically loaded by Remoter if the graphic utility is used, otherwise it must by loaded by user program, if
defines the working of the Read holding register, Read input registers, Preset single register e Preset
multiple registers MODBUS command:
FALSE: The commands are managed with byte addressing as used in Remoter.
TRUE: The commands are managed with word addressing as defined in MODICON specifications. The
memory word address it's calculated by multiplying for 2 the address specified in the command frame. So to
reach the W 0100 it will be necessary to define in the command frame the starting address 0080.
RIL example
In the following example the MODBUS slave communication management is executed, when the MODBUS
ASCII command strings are received, the system will answer by sending the answer strings.
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; MODBUS slave communication, data structure.
DEFL Y Mdb KD 64
DEFL Y MdbCmdBit Y Mdb KH 0000 ; Mdb.CmdBit
DEFL Y MdbStatusBit Y Mdb KH 0001 ; Mdb.StatusBit
DEFL Y MdbNodeAdd Y Mdb KH 0002 ; Mdb.NodeAdd
DEFL W MdbAnswerWt Y Mdb KH 0004 ; Mdb.AnswerWt
DEFL W MdbTimeOutCk Y Mdb KH 0006 ; Mdb.TimeOutCk
DEFL W MdbTimeouts Y Mdb KH 0008 ; Mdb.Timeouts
DEFL W MdbOverruns Y Mdb KH 000A ; Mdb.Overruns
DEFL W MdbCommErrs Y Mdb KH 000C ; Mdb.CommErrs
DEFL W MdbExceptsErr Y Mdb KH 000E ; Mdb.ExceptsErr
DEFL W MdbCommuns Y Mdb KH 0010 ; Mdb.Communs
DEFL W MdbAnswers Y Mdb KH 0012 ; Mdb.Answers
DEFL W MdbCmActiveDelay Y Mdb KH 0016 ; Mdb.CmActiveDelay
DEFL Y MdbFrameLength Y Mdb KH 0018 ; Mdb.FrameLength
DEFL W MdbFrameBuf Y Mdb KH 001C ; Mdb.FrameBuf
DEFL F MdbCompatibility Y Mdb KH 001E ;Mdb.Compatibility
DEFL Y FrameBuf KD 45
; ------------------------------------------------------------------------------
; @Section("Program init")
; ------------------------------------------------------------------------------
ORGR
LODT F PLCFirstLoop
MOVI Y MdbNodeAdd KD 0 ; Mdb.NodeAdd
MOVI W MdbAnswerWt KD 0 ; Mdb.AnswerWt
MOVI W MdbTimeOutCk KD 2000 ; Mdb.TimeOutCk
MOVI W MdbCmActiveDelay KD 2000 ; Mdb.CmActiveDelay
MOVI Y MdbFrameLength KD 40 ; Mdb.FrameLength
MOVA W MdbFrameBuf Y FrameBuf ; Mdb.FrameBuf
UTCH F MdbCompatibility ; Mdb.Compatibility
LTCH Y MdbCmdBit K 0001 ; Mdb.CmdBit.ResetCtrs
; ------------------------------------------------------------------------------
; @Section("MODBUS communication, slave management")
; ------------------------------------------------------------------------------
; MODBUS slave communication management on port "A".
ORGR
SETR
SETV KE IOSerialPortA
TASK L FbModbusAsciiSl Y Mdb ; MODBUS slave management
LTCH Y MdbCmdBit K 0000 ; Mdb.CmdBit.Enable
; [End of file]
"C" example
In the following example the MODBUS slave communication management is executed, when the MODBUS
ASCII command strings are received, the system will answer by sending the answer strings.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbModbusAsciiSl.h>
// -----------------------------------------------------------------------------
// GENERAL DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute the system init at first program execution loop.
if (PLCFirstLoop)
{
// Set variables to manage the MODBUS slave communication.
// -------------------------------------------------------------------------
// MODBUS SLAVE COMMUNICATION
// -------------------------------------------------------------------------
// Here define the serial line that must be used.
// [End of file]
To reduce the code the FB doesn't implement all the functions previewed in the MODBUS protocol, following are
described those implemented.
ATTENTION! The hexadecimal codes are made by 2 characters, as the example Function code 03 corresponds
to the reception of the ascii codes 0x30 and 0x33. The characters Begin frame, Carriage return and Line feed
correspond to the ascii codes 0x3A, 0x0D, 0x0A.
answer frame is returned the value of the MODBUS answers sent counter Answers (From 0x0000 to 0xFFFF).
7 6 5 4 3 2 1 0
The Access mode byte is divided a bits as reported in the following table:
00: Byte
7, 6 Type 01: Word
02: Double o Float
Code 47: Flat read memory variables (User function) Command frame Answer frame
It returns the content of variables located sequentially in Begin frame character : Begin frame character :
memory, by using the memory type specification and an Node address FF Node address FF
addressing with 4 bytes, it can manage all the types of Function code 47 Function code 47
memory as defined in the SystemMemoryRead function. The Security code 00 Security code FF
maximum number of consecutive bytes that can be read, can Flat access mode 40 No of bytes 02
be calculated with the formula FrameLength-5. Memory type 00 0x0000E300 data 12
Starting address (Hi) 00 0x0000E301 data 34
Starting address 00 Error check (LRC) 73
The example frame :FF470040000000E3000196^M^J
Starting address E3 Carriage return CR
returns the value of 2 consecutive bytes from RAM memory
Starting address (Lo) 00 Line feed LF
(Type: 00) at the address 0x0000E300, in the answer frame
No of variables 01
are returned the values of the bytes 0x0000E300=0x12,
Error check (LRC) 96
0x0000E301=0x34.
Carriage return CR
Line feed LF
Code 48: Flat write memory variables (User function) Command frame Answer frame
It allows to write variables located sequentially in memory, by Begin frame character : Begin frame character :
using the memory type specification and an addressing with 4 Node address FF Node address FF
bytes, it can manage all the types of memory as defined in the Function code 48 Function code 48
SystemMemoryWrite function. The maximum number of the Security code 00 Security code FF
consecutive bytes that can be written, can be calculated with Flat access mode 40 Error check (LRC) BA
the formula FrameLength-11. Memory type 00 Carriage return CR
Starting address (Hi) 00 Line feed LF
Starting address 00
The example frame :FF480040000000E3000112344F^M^J
Starting address E3
writes 2 consecutive bytes from the address 0x0000E300. In
Starting address (Lo) 00
the byte 0x0000E300 is written the data 0x12 and in the byte
No of variables 01
0x0000E301 is written the data 0x34. In the answer frame the
0x0000E300 data 12
Security code is returned. 0x0000E301 data 34
Error check (LRC) 4F
Carriage return CR
Line feed LF
length is wrong.
LRC (Longitudinal redundancy check)calculation
As described before, every data frame has a control data called LRC, the frames are considered correct only if
the control by LRC is correct. In order to calculate the LRC you have to add all the frame fields using a 8 bits
sum without carry, the result has to be complemented to 2.
Here an example for the command frame "10: Preset multiple registers".
: FF 10 01 84 00 02 12 34 EB 0D Lrc CR LF
To control the frame received LRC you have to add all the frame fields including the LRC with a 8 bits sum
without carry, if the frame is correct, the result will be 0.
Function blocks
FbModbusRtuSl
This function block allows the management of the MODBUS RTU protocol as slave. The function block can be
called also by using the proper graphic utility this simplify the use. In case of mistake in the user defined
parameters, the StatusBit.ParamErrs and the FBParameters bit in the PLCErrors data structure are set.
Declaration
void FbModbusRtuSl(FBMODBUSRTUSLDATA* S);
Parameters
FBMODBUSRTUSLDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 64 bytes data structure, we report a prototype. The members, reported under the
Members automatically managed by Remoter label are managed automatically by Remoter in case of use the
graphic utility, on the contrary they have to be managed by the user program. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //Enable
BOOL ResetCtrs:1; //Resets all the counters
BOOL b2:1;
BOOL b3:1;
BOOL b4:1;
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}CmdBit; //Command
struct
{
BOOL Enabled:1; //Enabled
BOOL ReceiveOk:1; //Receive ok
BOOL CmActive:1; //Communication active
BOOL ParamErrs:1; //Parameters error
...
}FBMODBUSRTUSLDATA;
00 CmdBit
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: It disables the FB and the communication is hang up. By disabling the FB all the error
bits in StatusBit are reset and all the other command bits are not active.
TRUE: It enables the FB.
1 ResetCtrs TRUE: It resets all the counters, the bit is automatically reset.
01 StatusBit
Status bits of the function block, the user program can test these bits. The value can be acquired by
MODBUS with the diagnostic command 0002: Return diagnostic register.
02 NodeAdd
Loaded by user program it defines the address of slave node (From 0x00 to 0xFF).
04 AnswerWt
Loaded by user program it defines the waiting time expressed in mSec between the reception of a MODBUS
command and the transmission of the proper answer (From 0x0000 to 0xFFFF).
06 TimeOutCk
Loaded by user program it defines the available time expressed in mSec to receive an entire command
frame. Time is considered from the reception of the start frame ":" character. (From 0x0000 to 0xFFFF).
08 Timeouts
It returns the occurred timeouts errors counting (From 0x0000 to 0xFFFF). It can be reset by resetting the
CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers diagnostic command.
0A Overruns
It returns the occurred overrun errors counting (From 0x0000 to 0xFFFF). The value can be acquired by
MODBUS with the 0012: Return bus character overrun count diagnostic command. It can be reset by
resetting the CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers
diagnostic command.
0C CommErrs
It returns the occurred communication errors counting (From 0x0000 to 0xFFFF). The value con be acquired
by MODBUS with the 000C: Return bus error count diagnostic command. It can be reset by resetting the
CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers diagnostic command.
0E ExceptsErr
It returns the occurred except errors counting (From 0x0000 to 0xFFFF). The value con be acquired by
MODBUS with the 000D: Return bus exception error count diagnostic command. It can be reset by resetting
the CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers diagnostic
command.
10 Communs
It returns the received MODBUS commands counting (From 0x0000 to 0xFFFF). The value con be acquired
by MODBUS with the 000B: Return bus message count diagnostic command. It can be reset by resetting the
CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers diagnostic command.
12 Answers
It returns the sent MODBUS answers counting (From 0x0000 to 0xFFFF). The value con be acquired by
MODBUS with the 000E: Return slave message count diagnostic command. It can be reset by resetting the
CmdBit.Enable or at the reception of the 000A: Clear counters and diagnostic registers diagnostic command.
16 CmActiveDelay
Loaded by user program it defines the time in mSec, after that if no MODBUS command are received the
active communication bit StatusBit.CmActive is reset (From 0x0000 to 0xFFFF).
18 FrameLength
Loaded by user program it defines the dimension of the frame reception/transmission buffer (From 12 to
255). To maintain compatibility with the previous versions a buffer of at least 40 bytes must be defined.
1C FrameBuf
Automatically loaded by Remoter if the graphic utility is used, otherwise it must by loaded by user program, if
defines the allocation address of the frame reception/transmission buffer (From 0x0000 to 0xFFFF).
1E Compatibility
Automatically loaded by Remoter if the graphic utility is used, otherwise it must by loaded by user program, if
defines the working of the Read holding register, Read input registers, Preset single register e Preset
multiple registers MODBUS command:
FALSE: The commands are managed with byte addressing as used in Remoter.
TRUE: The commands are managed with word addressing as defined in MODICON specifications. The
memory word address it's calculated by multiplying for 2 the address specified in the command frame. So to
reach the W 0100 it will be necessary to define in the command frame the starting address 0080.
RIL example
In the following example the MODBUS slave communication management is executed, when the MODBUS RTU
command strings are received, the system will answer by sending the answer strings.
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; MODBUS slave communication, data structure.
DEFL Y Mdb KD 64
DEFL Y MdbCmdBit Y Mdb KH 0000 ; Mdb.CmdBit
DEFL Y MdbStatusBit Y Mdb KH 0001 ; Mdb.StatusBit
DEFL Y MdbNodeAdd Y Mdb KH 0002 ; Mdb.NodeAdd
DEFL W MdbAnswerWt Y Mdb KH 0004 ; Mdb.AnswerWt
DEFL W MdbTimeOutCk Y Mdb KH 0006 ; Mdb.TimeOutCk
DEFL W MdbTimeouts Y Mdb KH 0008 ; Mdb.Timeouts
DEFL W MdbOverruns Y Mdb KH 000A ; Mdb.Overruns
DEFL W MdbCommErrs Y Mdb KH 000C ; Mdb.CommErrs
DEFL W MdbExceptsErr Y Mdb KH 000E ; Mdb.ExceptsErr
DEFL W MdbCommuns Y Mdb KH 0010 ; Mdb.Communs
DEFL W MdbAnswers Y Mdb KH 0012 ; Mdb.Answers
DEFL W MdbCmActiveDelay Y Mdb KH 0016 ; Mdb.CmActiveDelay
DEFL Y MdbFrameLength Y Mdb KH 0018 ; Mdb.FrameLength
DEFL Y FrameBuf KD 45
; ------------------------------------------------------------------------------
; @Section("Program init")
; ------------------------------------------------------------------------------
; MODBUS slave communication, variables settings.
ORGR
LODT F PLCFirstLoop
MOVI Y MdbNodeAdd KD 0 ; Mdb.NodeAdd
MOVI W MdbAnswerWt KD 0 ; Mdb.AnswerWt
MOVI W MdbTimeOutCk KD 2000 ; Mdb.TimeOutCk
MOVI W MdbCmActiveDelay KD 2000 ; Mdb.CmActiveDelay
MOVI Y MdbFrameLength KD 40 ; Mdb.FrameLength
MOVA W MdbFrameBuf Y FrameBuf ; Mdb.FrameBuf
UTCH F MdbCompatibility ; Mdb.Compatibility
LTCH Y MdbCmdBit K 0001 ; Mdb.CmdBit.ResetCtrs
; ------------------------------------------------------------------------------
; @Section("MODBUS communication, slave management")
; ------------------------------------------------------------------------------
; MODBUS slave communication management on port "A".
ORGR
SETR
SETV KE IOSerialPortA
TASK L FbModbusRtuSl Y Mdb ; MODBUS slave management
LTCH Y MdbCmdBit K 0000 ; Mdb.CmdBit.Enable
; [End of file]
"C" example
In the following example the MODBUS slave communication management is executed, when the MODBUS RTU
command strings are received, the system will answer by sending the answer strings.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbModbusAsciiSl.h>
// -----------------------------------------------------------------------------
// GENERAL DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute the system init at first program execution loop.
if (PLCFirstLoop)
{
// Set variables to manage the MODBUS slave communication.
// -------------------------------------------------------------------------
// MODBUS SLAVE COMMUNICATION
// -------------------------------------------------------------------------
// Here define the serial line that must be used.
// [End of file]
To reduce the code the FB doesn't implement all the functions previewed in the MODBUS protocol, following are
described those implemented.
7 6 5 4 3 2 1 0
The Access mode byte is divided a bits as reported in the following table:
00: Byte
7, 6 Type 01: Word
02: Double o Float
FALSE: Access to variables
5 Selection
TRUE: Access to bit
4, 3, 2, 1, 0 Bit number It defines the bit number to access to if Selection=TRUE
Code 47: Flat read memory variables (User function) Command frame Answer frame
It returns the content of variables located sequentially in Node address FF Node address FF
memory, by using the memory type specification and an Function code 47 Function code 47
addressing with 4 bytes, it can manage all the types of memory Security code 00 Security code FF
as defined in the SystemMemoryRead function. The maximum Flat access mode 40 No of bytes 02
number of consecutive bytes that can be read, can be calculated Memory type 00 0x0000E300 data 12
with the formula FrameLength-6. 00
Starting address (Hi) 0x0000E301 data 34
Starting address 00 3C
Error check (CRC)
Starting address E3 B8
The example frame FF 47 00 40 00 00 00 E3 00 01 23 F5
00
Starting address (Lo)
returns the value of 2 consecutive bytes from RAM memory
No of variables 01
(Type: 00) at the address 0x0000E300, in the answer frame are
23
returned the values of the bytes 0x0000E300=0x12, Error check (CRC)
F5
0x0000E301=0x34.
Code 48: Flat write memory variables (User function) Command frame Answer frame
It allows to write variables located sequentially in memory, by Node address FF Node address FF
using the memory type specification and an addressing with 4 Function code 48 Function code 48
bytes, it can manage all the types of memory as defined in the Security code 00 Security code FF
SystemMemoryWrite function. The maximum number of the Flat access mode 40 37
Error check (CRC)
consecutive bytes that can be written, can be calculated with the Memory type 00 B0
formula FrameLength-11. 00
Starting address (Hi)
Starting address 00
Starting address E3
The example frame FF 48 00 40 00 00 00 E3 00 01 12 34 E4 14
00
Starting address (Lo)
writes 2 consecutive bytes from the address 0x0000E300. In the
No of variables 01
byte 0x0000E300 is written the data 0x12 and in the byte
0x0000E300 data 12
0x0000E301 is written the data 0x34. In the answer frame the
0x0000E301 data 34
Security code is returned.
E4
Error check (CRC)
14
Function blocks
FbSysTerminal
This function block allows the management of the operator terminal, it can be executed only by using the proper
graphic utility.
Declaration
void FbSysTerminal(FBSYSTERMINALDATA* S);
Parameters
FBSYSTERMINALDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 96 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// ----------------------[Members that can be managed by the user program]--
struct
{
BOOL Enable:1; //Active enables the function block
BOOL DisablePageSel:1; //Active disables the page selection
BOOL DisableMsgScroll:1; //Active disables the message scroll
BOOL DisableEdit:1; //Active disables the variables edit
BOOL DisablePageScroll:1; //Active disables the page scroll
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Command;
struct
{
BOOL Enabled:1; //Active if the function block is enabled
BOOL Warnings:1; //Active if warnings present
BOOL Alarms:1; //Active if alarms present
BOOL b3:1;
BOOL KeyPressed:1; //Active if any key is pressed
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Status;
struct
{
BOOL LED0:1; //Key [0] led command
BOOL LED1:1; //Key [1] led command
BOOL LED2:1; //Key [2] led command
BOOL LED3:1; //Key [3] led command
BOOL LED4:1; //Key [4] led command
BOOL LED5:1; //Key [5] led command
BOOL LED6:1; //Key [6] led command
BOOL LCDBacklight:1; //LCD backlight command
}LEDCommand;
struct
{
BOOL K0:1; //Key [0] status
BOOL K1:1; //Key [1] status
BOOL K2:1; //Key [2] status
BOOL K3:1; //Key [3] status
BOOL K4:1; //Key [4] status
BOOL K5:1; //Key [5] status
BOOL K6:1; //Key [6] status
BOOL K7:1; //Key [7] status
struct
{
unsigned long High; //Warnings from 0x20 to 0x3F
unsigned long Low; //Warnings from 0x00 to 0x1F
}Warnings;
struct
{
unsigned long High; //Warnings from 0x20 to 0x3F
unsigned long Low; //Warnings from 0x00 to 0x1F
}Alarms;
struct
{
BOOL EnableWarnings:1; //Active enables the warnings management
BOOL EnableAlarms:1; //Active enables the alarms management
BOOL AutoAckWarnings:1; //Active enables the warnings auto ack
BOOL AutoAckAlarms:1; //Active enables the alarms auto ack
BOOL DisablePageLED:1; //Active disables the page LED management
}ICommand;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB and resets Status.
TRUE: Enables the FB.
1 DisablePageSel TRUE: Disables the page selection from terminal keyboard. The page messages
cannot be automatically displayed, by using the page selection keys but they can be
displayed only by defining their number in MessageNr.
2 DisableMsgScroll TRUE: Disables the page submessages selection from the scroll message keys ,
o , . The page submessages can be displayed only by defining their number
in MessageNr.
3 DisableEdit TRUE: Disables the message variables editing from terminal keyboard.
4 DisablePageScroll TRUE: Disables the page messages selection from the scroll page keys , o ,
. The page messages can be displayed only by defining their number in
MessageNr.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: The FB is enabled.
1 Warnings TRUE: There are warnings, at least one bit of the Warnings structure is set.
2 Alarms TRUE: There are alarms, at least one bit of the Alarms structure is set.
4 KeyPressed Set for a program loop when a key on the terminal is pressed.
02 LEDCommand
Terminal LED management bits (For Picoface terminals only). The user program can manage these bits
according to its own needs.
0 LED0 It commands the LED on the key of the Picoface terminal.
1 LED1 It commands the LED on the key of the Picoface terminal.
2 LED2 It commands the LED on the key of the Picoface terminal.
3 LED3 It commands the LED on the key of the Picoface terminal.
4 LED4 It commands the LED on the key of the Picoface terminal.
5 LED5 It commands the LED on the key of the Picoface terminal.
6 LED6 It commands the LED on the key of the Picoface terminal.
7 LCDBacklight It commands the display backlight of the Picoface terminal.
03 MessageNr
Loaded by user program it defines the message to display on the terminal. Refer to the Msg# reported near
the message in the graphic utility. In case the user program loads the number of an undefined message, the
Message:nnnnn is not been found message will be displayed (Range from 0 to 65535).
05 KeyStatus
Terminal key status, the user program can test these bits.
00 K0 Returns the Picoface terminal key status.
01 K1 Returns the Picoface terminal key status.
02 K2 Returns the Picoface terminal key status.
03 K3 Returns the Picoface terminal key status.
04 K4 Returns the Picoface terminal key status.
05 K5 Returns the Picoface terminal key status.
06 K6 Returns the Picoface terminal key status.
07 K7 Returns the Picoface terminal key status.
08 K8 Returns the Picoface terminal key status.
09 K9 Returns the Picoface terminal key status.
0A KUP Returns the Picoface terminal key or the Netsyst systems key status.
0B KDW Returns the Picoface terminal key or the Netsyst systems key status.
0C KFUN Returns the Picoface terminal key or the Netsyst systems key status.
0D KESC Returns the Picoface terminal key status.
0E KCLR Returns the Picoface terminal key status.
0F KENT Returns the Picoface terminal key or the Netsyst systems key status.
10 KLEFT Returns the Netsyst system key status.
11 KRIGHT Returns the Netsyst system key status.
08 PageNr
Returns the page number of displayed message. Refer to the Page# reported near the message in the
graphic utility. If the message is not a page message or submessage 0xFF will be returned. (Range from
0x00 to 0xFF).
09 Warnings
Loaded by user program, every bit is a warning. If the warning page message is displayed, by executing the
page submessages scroll, will be displayed only those, whose proper bit is set. Refer to the <WarningBitx>
reported near the message in the graphic utility.
11 Alarms
Loaded by user program, every bit is an alarm. If the alarm page message is displayed, by executing the
page submessages scroll, will be displayed only those, whose proper bit is set. Refer to the <AlarmBitx>
reported near the message in the graphic utility.
19 NrOfWarnings
Returns the number of bits set in the Warnings structure.
1A NrOfAlarms
Returns the number of bits set in the Alarmsstructure.
RIL example
No examples reported because the FB use is possible only using the graphic utility.
"C" example
No examples reported because the FB use is possible only using the graphic utility.
How to
The LCD terminal supplied with ours systems are realized by using an alphanumeric display of 2 lines for 16
characters. The display is based on the Hitachi HD44780 controller, it's provided of an internal characters
generator. The correspondence of every character with the relate hexadecimal code is reported in the following
table.
As visible in the table for the ASCII characters whose code is greater than 0x80, the relate symbol in the
characters generator is different from the ASCII symbol reported in the standard table. To display it, it's necessary
to insert the hexadecimal value of it, in the message edited in the operator terminal FB.
Special characters
If it's request to display in the terminal messages special characters, it's necessary to define in the text of the
message a sequence of symbols, please refer to the following table.
\x Hexadecimal constant t allows to display the character relate to the hexadecimal defined code. Example, the
constant "\x041" will display ASCII character "A". The hexadecimal number must be
always defined with 3 digits, the "\x000" cannot be used.
\" Quotation marks It allows to display the quotation marks symbol.
\' Apex It allows to display the apex symbol.
\\ Backslash It allows to display the backslash symbol.
How to
The operator terminal management FB, allows the display of warnings and alarms easily, avoiding the user
to realize specific programs for their management. Two data structures are defined one for the warnings
and one for the alarms, every structure is composed from two Double (DW) variables, to every Bit (B) of
the variable a warning or alarm is associated, therefore in total up to 64 warnings and 64 alarms can be
managed.
By activating the page of the warnings or alarms display, by acting on the and keys of the Picoface
terminal or on the e keys of the Netsyt systems it's possible to scroll along the visualization of all of
the submessages that have the relative bit in the data structure active. At the exit from the page of the
warnings or alarms display, all the bits in the data structure whose message was visualized, will be reset.
RIL program
To manage the warnings and the alarms from RIL program, it's necessary to define some global variables
of Double type, that variables must be copied in the warnings and alarms data structure of the of the
operator terminal FB. To every Bit of the defined variables, will be possible to copy the warning or alarm
condition. In the following example 4 warnings and 4 alarms are managed joining them to the state of logic
inputs. Please note the use of LTCH, OUTT and OUTF instructions that allow to have different result of
warning or alarm.
LTCH The condition remains memorized also when the event that has forced it disappears. It will remain
memorized until the display screen is reached, the relative message is displayed and the display
screen is exited.
OUTT The condition follows the state of the event that force it. In this case an impulsive event will set the
OUTF condition only for the time in which the event is true.
We suggest to privilege the use of LTCH instruction instead of the OUTT or OUTF. It guarantees the
memorization of the condition until the relate message is displayed.
; ----------------------------------------------------
; @Section("Global definitions")
; ----------------------------------------------------
; ----------------------------------------------------
; @Section("Warnings management")
; ----------------------------------------------------
ORGR
LODT I 0000
LTCH DW WarningsLow BD 0 ;Warning bit 0
ORGR
LODT I 0001
OUTT DW WarningsLow BD 31 ;Warning bit 31
ORGR
LODT I 0002
LTCH DW WarningsHigh BD 0 ;Warning bit 32
ORGR
LODF I 0003
OUTF DW WarningsHigh BD 31 ;Warning bit 63
; ----------------------------------------------------
; @Section("Alarms management")
; ----------------------------------------------------
ORGR
LODT I 0004
OUTT DW AlarmsLow BD 0 ;Alarm bit 0
ORGR
LODT I 0005
LTCH DW AlarmsLow BD 31 ;Alarm bit 31
ORGR
LODF I 0006
OUTF DW AlarmsHigh BD 0 ;Alarm bit 32
ORGR
LODT I 0007
LTCH DW AlarmsHigh BD 31 ;Alarm bit 63
"C" variables
typedef struct
{
// ------------------------------------------------[Bit from 0x18 to 0x1F]--
// ----------------------------------------------------[Device definition]--
// --------------------------------------------[Microprocessor definition]--
In the following table the indication of the different field are reported with reference to the supported libraries.
14 GetCharEchoEnable TRUE: On data input from standard terminal I/O a character echo is - - - - - - C
executed.
15
16
17
18 MemoryAccessWait It configures how the SystemMemoryRead and E D - C B B A
SystemMemoryWrite functions manage the condition of memory not
ready when they access to EEPROM and FLASH memories.
FALSE: The functions immediately exit with error. TRUE: The
functions wait for a timeout and then exit with error.
19
1A CfgAccessEnable Enables the function SystemMemoryWrite to write on the - - - - C - A
configuration memory.
1B MemoryAccessErrors Set disable the SystemErrors.MemoryType management in the - - - - C - A
SystemMemoryRead and SystemMemoryWrite functions.
1C UserGoProgram TRUE: The user program is started by a serial command. - - - - - - C
1D
1E
1F
This bit must be set by the user program before call the memory access function. ATTENTION! The debug
procedure returns the state of the bit always TRUE independently from its real state in the program.
TargetDevice
Value Description
Microprocessor
It contains indication of the type of microprocessor available on the target system as in the table:
Value Description
How to
The upload operations of the application from Remoter to the target system are executed by a proper BIOS
software that is preloaded in the system. In some target systems the BIOS can be personalized. In the
following table we report the target systems that support the BIOS configuration.
Code Target
With the target system connected and in catch condition it is possible to use the utility terminal emulation
send a BIOS configuration setting command by using the MODBUS RTU protocol.
The BIOS configuration parameters are stored in the FLASH memory, so the setting command
completely deletes the RAM and the FLASH memory of the target system the loosing the user
program.
The execution of the clear memory command loosing also the BIOS configuration parameters.
Code FF, Subfunction 0A: BIOS configuration Command frame Answer frame
It allows to set the serial communication parameters on port B Node address FF Node address FF
and the number of MODBUS node for both the communication Function code FF Function code FF
ports. The set values are memorized in the FLASH memory of Byte number 07 Byte number 06
the system and become permanent. It is not possible to change Security byte 00 Security byte FF
the serial communication mode on port A. SubFunction 0A SubFunction 0A
Node to set 01 Result 01
The example frame FF FF 07 00 0A 01 75 B1 D9 sets the Serial mode 75 F7
Error check (CRC)
MODBUS node 01 and sets the communication parameters on B1 D8
Error check (CRC)
port B to 9600, e, 8. For the value to be set in Serial mode refer D9
to the table reported in the SMOD instruction. The value returned
in Result if 01, indicates the correct execution of the command.
On the Netlog systems starting from the BIOS version SFW116F000, a FLASH writing unlock command
was added. With writing locked from user program will not be possible to write on it.
Code FF, Subfunction 0A: Configurazione BIOS Command frame Answer frame
It allows to set the serial communication parameters on port B, Node address FF Node address FF
the number of MODBUS node for both the communication ports Function code FF Function code FF
and the FLASH unlock. The set values are memorized in the Byte number 08 Byte number 06
FLASH memory of the system and become permanent. It is not Security byte 00 Security byte FF
possible to change the serial communication mode on port A. SubFunction 0A SubFunction 0A
Node to set 01 Result 01
The example frame FF FF 08 00 0A 01 75 01 B4 00 sets the Serial mode 75 F7
Error check (CRC)
MODBUS node 01, sets the communication parameters on port
FLASH unlock 01 D8
B to 9600, e, 8 and unlocks the FLASH. For the value to be set in Error check (CRC)B4
00
Serial mode refer to the table reported in the SMOD instruction.
The value returned in Result if 01, indicates the correct
execution of the command.
Terminal emulation
Serial settings
The window of serial communication settings divided in tabs, reporting the various definitions.
Figure 1
Figure 2
Enable driver capability Selected, forces the use of the options of the communication driver.
Wait time before Tx Defines the wait time between the activation of the transmission enable signal
and the transmission of the first character.
Wait time after Tx Defines the wait time between the transmission of the last character and the
deactivation of the transmission enable signal.
Signal for Tx enable Selects the signal to be used to enable the data transmission.
Clear Tx echo Forces the automatic deletion of the received echo string.
Terminal emulation
TCP/IP settings
Figure 1
IP Address Defines the IP address of the interface device used to communicate with the target system.
Port Defines the output port must be used.
Function blocks
FbCounterOverIO
This function block manages a 16 bits counter, using a digital input of the base module as a clock signal. You
can choose the counting only on the raising edge or on raising and falling edges.
For the use in interrupt it is reported the execution time, at 11 Mhz is about 200 uSec.
Declaration
void FbCounterOverIO(FBCOUNTEROVERIODATA* S);
Parameters
FBCOUNTEROVERIODATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 8 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// ----------------------[Members that can be managed by the user program]--
struct
{
unsigned char Inputs:4; //Logic inputs selection
unsigned char Mode:4; //Counter mode selection
}Command;
00 Command
0 Inputs It defines on which input of the base module is connected the clock signal, according to the table
1 below.
2
3
Value Description Value Description
0 Input 0 8 Input 8
1 Input 1 9 Input 9
2 Input 2 A Input A
3 Input 3 B Input B
4 Input 4 C Input C
5 Input 5 D Input D
6 Input 6 E Input E
7 Input 7 F Input F
4 Mode It defines the type of acquisition of the clock, according to the table below.
5
6
7 Value Description
02 Value
It returns the value of the counted impulses. The value is in hexadecimal and it has a range from 0x0000 to
0xFFFF. When the values reaches the maximum value 0xFFFF, it restarts from the value 0x0000.
RIL example
In the example below, it's executed the counting on both raising and falling edges of the clock connected to the
digital input INP 00. Debugging the operand W CounterValue it's possible to see the counting value.
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; Counter management function block data structure.
DEFL Y Ctr KD 8
DEFL Y CtrCommand Y Ctr KH 0000 ; Ctr.Comand
DEFL W CtrValue Y Ctr KH 0002 ; Ctr.Value
; ------------------------------------------------------------------------------
; @Section("Init")
; ------------------------------------------------------------------------------
; Counter management function block parameters set.
; Input 0 is used to read input pulses, rising and falling edges are count.
ORGR
LODT F PLCFirstLoop
; ------------------------------------------------------------------------------
; @Section("Counter management")
; ------------------------------------------------------------------------------
; Counter management function block call.
ORGR
SETR
TASK L FbCounterOverIO Y Ctr ; Counter management
LODA W CtrValue ; Ctr.Value
STRA W CounterValue ; Counter value
; [End of file]
"C" example
In the example below, it's executed the counting on both raising and falling edges of the clock connected to the
digital input INP 00. Debugging the operand unsigned int CounterValue it's possible to see the counting value.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbCounterOverIO.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLE DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute variables init at first program execution loop.
if (PLCFirstLoop)
{
Ctr.Command.Inputs=0; //Logic inputs selection
Ctr.Command.Mode=1; //Counter mode selection
}
// -------------------------------------------------------------------------
// COUNTER MANAGEMENT
// -------------------------------------------------------------------------
// Counter management and value store.
// [End of file]
Function blocks
FbDMXProtocol
This function block manages the DMX protocol, it's possible to manage on RS845 line up to 512 dimmers. The FB will
provide to send to everyone the defined value of brightness.
Declaration
void FbDMXProtocol(FBDMXPROTOCOLDATA* S);
Parameters
FBDMXPROTOCOLDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 32 bytes data structure, we report a prototype. The members reported under the Internal
use only members label, are members used inside by the function block and they don't have to be changed by the
user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //FB enable
BOOL TxStart:1; //Tx frame command
BOOL b2:1;
BOOL b3:1;
BOOL b4:1;
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Command;
struct
{
BOOL Enabled:1; //FB enabled
BOOL TxEnd:1; //Tx frame end
BOOL b2:1;
BOOL b3:1;
BOOL WrongTermIO:1; //Wrong I/O terminal
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Status;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB and resets Status.
TRUE: Enables the FB allowing the DMX protocol.
1 TxStart TRUE: Commands a DMX frame send. It's automatically reset by the FB, if a continuous stream of
frames it's required this bit must be set to TRUE permanently.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: The FB is enabled.
1 TxEnd Is set for a program loop at every DMX frame sent.
4 WrongTermIO TRUE: Indicates that the defined I/O terminal cannot be used by the FB. No DMX frames will be
sent.
04 CmdArray
Loaded by user program it defines the address of the DMX command array, (Range from 0x0000 to 0xFFFF).
06 Devices
Loaded by user program it defines the number of DMX devices to be managed, it must be equal or less than the
command array length, (Range from 0 to 512).
08 Delay
Loaded by user program it defines the delay time between the DMX frame transmission when the TxStart is
always set. The value is in mSec (Range da 0 a 60000).
RIL example
In the following example a DMX communication is managed, the example manages 4 dimmers.
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; FbDMXProtocol function block data structure.
DEFL Y Dmx KD 32
DEFL Y DmxCommand Y Dmx KH 0000 ;Dmx.Command
DEFL Y DmxStatus Y Dmx KH 0001 ;Dmx.Status
DEFL W DmxCmdArray Y Dmx KH 0004 ;Dmx.CmdArray
DEFL W DmxDevices Y Dmx KH 0006 ;Dmx.Devices
DEFL W DmxDelay Y Dmx KH 0008 ;Dmx.Delay
DEFL Y Dim KD 4
DEFL Y DimNr0 Y Dim KH 0000 ;Dimmer [0]
DEFL Y DimNr1 Y Dim KH 0001 ;Dimmer [1]
; ------------------------------------------------------------------------------
; @Section("DMX protocol management")
; ------------------------------------------------------------------------------
; Setup parameters for the DMX protocol management.
ORGR
SETR
SETV KE IOSerialPortA
ORGR
LODT F PLCFirstLoop
MOVA W DmxCmdArray Y Dim ;Dmx.CmdArray
MOVI W DmxDevices KD 4 ;Dmx.Devices
MOVI W DmxDelay KD 100 ;Dmx.Delay
TASK L TermIOOpen
ORGR
SETR
OUTT Y DmxCommand BD 0 ;Dmx.Command.Enable
OUTT Y DmxCommand BD 1 ;Dmx.Command.TxStart
TASK L FbDMXProtocol Y Dmx ;FbDMXProtocol management
; [End of file]
"C" example
In the following example a DMX communication up to 512 dimmers is managed. The logic input I 0000 enables the FB
and the logic input I 0001 enables the frame transmission.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbDMXProtocol.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
// -------------------------------------------------------------------------
// MANAGE THE DMX PROTOCOL
// -------------------------------------------------------------------------
// Set the serial port to be used by the DMX protocol.
if (PLCFirstLoop)
{
Dmx.CmdArray=&Dimmers; //Command array
Dmx.Devices=sizeof(Dimmers); //Number of devices
Dmx.Delay=100; //Interframe delay time (mSec)
TermIOOpen(); //Open the terminal I/O
}
// [End of file]
Function blocks
FbElevatorCall
This function block manages the up and down multiply reservation call for an elevator. The calls from the cabin,
are sequentially managed according to the direction of the cabin. The calls from the floor are managed according
to the type of reservation (up direction or down direction) through two push buttons. The function block can
manage elevators till 32 floors, the most important characteristics are:
Management up to 32 push buttons with proper lamp for call from cabin
Management up to 32 push buttons with proper lamp for call in up direction from floor
Management up to 32 push buttons with proper lamp for call in down direction from floor
Reservation reset (Clears all the active reservations)
Cabin overload sensor management, it locks the reservations
Elevator direction indication
Flashing of the cabin lamp which indicates the floor to be reach
For example: The cabin is going up from the floor 0 to the 5th floor, while the cabin hasn't reached the 3rd floor
yet, an user makes a up direction call from 3rd floor, another user makes a down direction call from 3rd floor. The
cabin stops to the 3rd floor and clear the reservation in up direction, maintaining the reservation in down
direction. When all the stops in up direction are ended, the cabin will starts in down direction stopping at the 3rd
floor to satisfy the reservation.
Declaration
void FbElevatorCall(FBELEVATORCALLDATA* S);
Parameters
FBELEVATORCALLDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Floor definition
The function block manages up to 32 floors, to manage the call buttons and the lamps a Double (DW) is used.
From the RIL program it's necessary to refer to the proper bit to address the different floor. From the C program
it's necessary to define a typedef to assign the value of the floor to any variable bit, here it's the prototype.
typedef struct
{
BOOL Floor24:1; //Floor 24
BOOL Floor25:1; //Floor 25
BOOL Floor26:1; //Floor 26
BOOL Floor27:1; //Floor 27
BOOL Floor28:1; //Floor 28
BOOL Floor29:1; //Floor 29
BOOL Floor30:1; //Floor 30
BOOL Floor31:1; //Floor 31
Data structure
The function block uses a 64 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //Enable
BOOL CallLock:1; //Call lock
BOOL CallReset:1; //Call reset
BOOL b3:1;
BOOL CabinReady:1; //Cabin ready
BOOL CabinIsStop:1; //Cabin is stop
BOOL b6:1;
BOOL b7:1;
}Command; //Command
struct
{
BOOL Enabled:1; //Enabled
BOOL NewCall:1; //New call
BOOL ActiveCalls:1; //Active calls
BOOL b3:1;
BOOL OpenDoors:1; //Open doors command
BOOL CabinStart:1; //Cabin start command
BOOL CabinUp:1; //Cabin in up direction
BOOL CabinDw:1; //Cabin in down direction
}Status; //Status
00 Command
Comand bits, the user program can manage these bits according to its own needs.
0 Enable FALSE: Disables the FB.
TRUE: Enables the FB.
1 CallLock TRUE: Locks the call management. It can be used to avoid new calls if the cabin is full.
2 CallReset TRUE: Resets all the reservations.
4 CabinReady TRUE: Enables the OpenDoors, CabinStart, CabinUp, CabinDw status bit.
5 CabinIsStop TRUE: Indicates that the cabin is stopped.
01 Status
Status bits, the user program can test these bits
0 Enabled TRUE: The FB is enabled.
1 NewCall It's set for a program loop at every new call.
2 ActiveCalls TRUE: It shows the presence of at least an active call.
4 OpenDoors If Command.CabinReady=TRUE and Status.CabinStart=FALSE, this bit will remains active
until a call from the current floor from any button is active.
5 CabinStart TRUE: The cabin has to move to reach the floor indicated in FloorRequested.
6 CabinUp TRUE: The cabin has to move in up direction.
7 CabinDw TRUE: The cabin has to move in down direction.
02 NumberOfFloors
Loaded by the user program, it defines the number of floors to manage. It is necessary to set the number of
the highest floor to be reach. For example in a palace of 8 floors the value will be set to 8 (Range from 1 to
31).
04 CabinPosition
Loaded by the user program, it defines the current position of the cabin (Range from 0 to 31).
05 FloorRequested
Returns the floor to reach when the Status.CabinStart bit is active (Range from 0 to 31). Its value is reset
by clearing the Command.Enable bit.
08 CabinCall
Loaded by the user program, with the status of every button call from cabin, every button is copied on the
proper bit.
00 Floor00 Call on floor 00.
.. ... Call on floor
1F Floor31 Call on floor 31.
08 FloorUpCall
Loaded by the user program, with the status of every button call from floor in up direction, every button is
copied on the proper bit.
00 Floor00 Call on floor 00.
.. ... Call on floor
1F Floor31 Call on floor 31.
0C FloorDwCall
Loaded by the user program, with the status of every button call from floor in down direction, every button is
copied on the proper bit.
00 Floor00 Call on floor 00.
.. ... Call on floor
1F Floor31 Call on floor 31.
10 CabinLamp
Returns the cabin floor lamp status, the user program has to copy the status of every bit to the proper lamp.
Its value is reset by clearing the Command.Enable bit.
00 Floor00 Call on floor 00.
.. ... Call on floor
1F Floor31 Call on floor 31.
14 FloorUpLamp
Returns the floor up call lamp status, the user program has to copy the status of every bit to the proper lamp.
Its value is reset by clearing the Command.Enable bit.
00 Floor00 Call on floor 00.
.. ... Call on floor
1F Floor31 Call on floor 31.
18 FloorDwLamp
Returns the floor down call lamp status, the user program has to copy the status of every bit to the proper
lamp. Its value is reset by clearing the Command.Enable bit.
00 Floor00 Call on floor 00.
.. ... Call on floor
1F Floor31 Call on floor 31.
Examples
It's reported an example program realized in either RIL language and C, it manages an elevator up to 3 floors.
Using a static PICOLOG Millennium system with 16 inputs and 16 outputs it's possible to test it by connecting the
inputs and the outputs according to the following table:
RIL example
The current position of the cabin has to be set manually by debugging the Y RealCabinPosition operand, the
current position of the cabin to reach can be read by debugging the Y SetCabinPosition operand.
; ------------------------------------------------------------------------------
; @Section("Global definitions")
; ------------------------------------------------------------------------------
; Elevator call, data structure.
DEFG Y ElC KD 64
DEFG Y ElCCommand Y ElC KH 0000 ;ElC.Command
DEFG Y ElCStatus Y ElC KH 0001 ;ElC.Status
DEFG Y ElCNumberOfFloors Y ElC KH 0002 ;ElC.NumberOfFloors
DEFG Y ElCCabinPosition Y ElC KH 0004 ;ElC.CabinPosition
DEFG Y ElCFloorRequest Y ElC KH 0005 ;ElC.FloorRequest
DEFG DW ElCCabinCall Y ElC KH 0008 ;ElC.CabinCall
DEFG DW ElCFloorUpCall Y ElC KH 000C ;ElC.FloorUpCall
DEFG DW ElCFloorDwCall Y ElC KH 0010 ;ElC.FloorDwCall
DEFG DW ElCCabinLamp Y ElC KH 0014 ;ElC.CabinLamp
DEFG DW ElCFloorUpLamp Y ElC KH 0018 ;ElC.FloorUpLamp
DEFG DW ElCFloorDwLamp Y ElC KH 001C ;ElC.FloorDwLamp
; ------------------------------------------------------------------------------
; @Section("Elevator call management")
; ------------------------------------------------------------------------------
; Function block init.
ORGR
LODT F PLCFirstLoop
MOVI Y ElCNumberOfFloors K 0003 ;ElC.NumberOfFloors
ORGR
SETR
TASK L FbElevatorCall Y ElC ; Elevator call management
; ------------------------------------------------------------------------------
; @Section("General commands")
; ------------------------------------------------------------------------------
; FB enable command.
ORGR
LODT I 0000 ;FB enable command
OUTT Y ElCCommand BD 0 ;ElC.Command.Enable
ORGR
LODT I 0001 ;Call lock command
OUTT Y ElCCommand BD 1 ;ElC.Command.CallLock
ORGR
LODT I 0002 ;Cabin ready command
OUTT Y ElCCommand BD 4 ;ElC.Command.CabinReady
ORGR
LODT I 0003 ;Cabin is stop command
OUTT Y ElCCommand BD 5 ;ElC.Command.CabinIsStop
; ------------------------------------------------------------------------------
; @Section("Status output")
; ------------------------------------------------------------------------------
; Open doors status.
ORGR
LODT Y ElCStatus BD 4 ;ElC.Status.OpenDoors
OUTT O 0000 ;Open doors status
ORGR
LODT Y ElCStatus BD 5 ;ElC.Status.CabinStart
OUTT O 0001 ;Cabin start status
ORGR
LODT Y ElCStatus BD 6 ;ElC.Status.CabinUp
OUTT O 0002 ;Cabin up direction status
ORGR
LODT Y ElCStatus BD 7 ;ElC.Status.CabinDw
OUTT O 0003 ;Cabin down direction status
; ------------------------------------------------------------------------------
; @Section("Cabin commands and lamps")
; ------------------------------------------------------------------------------
; Cabin call commands management.
ORGR
LODT I 0004 ;Cabin call command (Floor 00)
OUTT DW ElCCabinCall BD 0
ORGR
LODT I 0005 ;Cabin call command (Floor 01)
OUTT DW ElCCabinCall BD 1
ORGR
LODT I 0006 ;Cabin call command (Floor 02)
OUTT DW ElCCabinCall BD 2
ORGR
LODT I 0007 ;Cabin call command (Floor 03)
OUTT DW ElCCabinCall BD 3
ORGR
LODT DW ElCCabinLamp BD 0
OUTT O 0004 ;Cabin call lamp (Floor 00)
ORGR
LODT DW ElCCabinLamp BD 1
OUTT O 0005 ;Cabin call lamp (Floor 01)
ORGR
LODT DW ElCCabinLamp BD 2
OUTT O 0006 ;Cabin call lamp (Floor 02)
ORGR
LODT DW ElCCabinLamp BD 3
OUTT O 0007 ;Cabin call lamp (Floor 03)
; ------------------------------------------------------------------------------
; @Section("Floor up call commands and lamps")
; ------------------------------------------------------------------------------
; Floor up call commands management.
ORGR
LODT I 0008 ;Floor up call command (Floor 00)
OUTT DW ElCFloorUpCall BD 0
ORGR
LODT I 0009 ;Floor up call command (Floor 01)
OUTT DW ElCFloorUpCall BD 1
ORGR
LODT I 000A ;Floor up call command (Floor 02)
OUTT DW ElCFloorUpCall BD 2
ORGR
LODT I 000B ;Floor up call command (Floor 03)
OUTT DW ElCFloorUpCall BD 3
ORGR
LODT DW ElCFloorUpLamp BD 0
OUTT O 0008 ;Floor up call lamp (Floor 00)
ORGR
LODT DW ElCFloorUpLamp BD 1
OUTT O 0009 ;Floor up call lamp (Floor 01)
ORGR
LODT DW ElCFloorUpLamp BD 2
OUTT O 000A ;Floor up call lamp (Floor 02)
ORGR
LODT DW ElCFloorUpLamp BD 3
OUTT O 000B ;Floor up call lamp (Floor 03)
; ------------------------------------------------------------------------------
; @Section("Floor down call commands and lamps")
; ------------------------------------------------------------------------------
; Floor dw call commands management.
ORGR
LODT I 000C ;Floor dw call command (Floor 00)
OUTT DW ElCFloorDwCall BD 0
ORGR
LODT I 000D ;Floor dw call command (Floor 01)
OUTT DW ElCFloorDwCall BD 1
ORGR
LODT I 000E ;Floor dw call command (Floor 02)
OUTT DW ElCFloorDwCall BD 2
ORGR
LODT I 000F ;Floor dw call command (Floor 03)
OUTT DW ElCFloorDwCall BD 3
ORGR
LODT DW ElCFloorDwLamp BD 0
OUTT O 000C ;Floor dw call lamp (Floor 00)
ORGR
LODT DW ElCFloorDwLamp BD 1
OUTT O 000D ;Floor dw call lamp (Floor 01)
ORGR
LODT DW ElCFloorDwLamp BD 2
OUTT O 000E ;Floor dw call lamp (Floor 02)
ORGR
LODT DW ElCFloorDwLamp BD 3
OUTT O 000F ;Floor dw call lamp (Floor 03)
; [End of file]
"C" example
The current position of the cabin has to be set manually by debugging the unsigned char CabinPosition
variable, the current position of the cabin to reach can be read by debugging the unsigned char FloorRequest
variable.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbElevatorCall.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLE DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
struct
{
BOOL Inp08:1; //Inp 08 bit
BOOL Inp09:1; //Inp 09 bit
BOOL Inp0A:1; //Inp 0A bit
BOOL Inp0B:1; //Inp 0B bit
BOOL Inp0C:1; //Inp 0C bit
BOOL Inp0D:1; //Inp 0D bit
BOOL Inp0E:1; //Inp 0E bit
BOOL Inp0F:1; //Inp 0F bit
BOOL Inp00:1; //Inp 00 bit
BOOL Inp01:1; //Inp 01 bit
BOOL Inp02:1; //Inp 02 bit
BOOL Inp03:1; //Inp 03 bit
BOOL Inp04:1; //Inp 04 bit
BOOL Inp05:1; //Inp 05 bit
BOOL Inp06:1; //Inp 06 bit
BOOL Inp07:1; //Inp 07 bit
}LogInp;
struct
{
BOOL Out08:1; //Out 08 bit
BOOL Out09:1; //Out 09 bit
BOOL Out0A:1; //Out 0A bit
BOOL Out0B:1; //Out 0B bit
BOOL Out0C:1; //Out 0C bit
BOOL Out0D:1; //Out 0D bit
BOOL Out0E:1; //Out 0E bit
BOOL Out0F:1; //Out 0F bit
BOOL Out00:1; //Out 00 bit
BOOL Out01:1; //Out 01 bit
}LogOut;
// -------------------------------------------------------------------------
// LOGIC I/O MANAGEMENT
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// COMMANDS AND STATUS
// -------------------------------------------------------------------------
// General commands.
ElC.Command.Enable=LogInp.Inp00; //Enable
ElC.Command.CallLock=LogInp.Inp01; //Call lock
ElC.Command.CabinReady=LogInp.Inp02; //Cabin ready
ElC.Command.CabinIsStop=LogInp.Inp03; //Cabin is stop
// Status output.
// -------------------------------------------------------------------------
// ELEVATOR CALL MANAGEMENT
// -------------------------------------------------------------------------
// Elevator call init.
if (PLCFirstLoop)
ElC.NumberOfFloors=3; //Number of floors
// [End of file]
Function blocks
FbEncoderOverIO
This function block allows the acquisition of an encoder with quadrature directly connected to the digital inputs.
The quote value expressed in encoder pulses is returned into a 16 bits Word (W) operand, the function block
executes the multiplication for 4 of encoder pulses. For example an encoder of 1024 pulses/turn will returns a
value of 4096 pulses/turn. To manages quote on 32 bits Double (DW) operand the FbQuoteMng FB can be used.
For the use in interrupt it is reported the execution time, at 11 Mhz is about 200 uSec.
Declaration
void FbEncoderOverIO(FBENCODEROVERIODATA* S);
Parameters
FBENCODEROVERIODATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
To avoid errors in encoder acquisition it's important to be sure that the encoder frequency does not exceed the
maximum value that can be read by the FB. For the calculation of the greatest encoder frequency accepted by
the FB it's necessary to know the FB scansion time. It's defined scansion time the time that exists between two
executions. If the FB it's executed on user program, the scansion time is equal to program loop time, to decrease
scansion time it's possible to execute the FB many times in the user program, or to execute it on temporal
interrupt.
Following we report the formula for the calculation of the greatest encoder frequency that can be acquired by the
FB in function of its scansion time.
Ef=1/(St*5)
Ef: Encoder frequency (Hz)
St: Scansion time (Sec)
Data structure
The function block uses a 8 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
00 Inputs
It specifies to which inputs of the base modules, the encoder signals are connect, according to the table
below
Value Clock A Clock B
0 INP 00 INP 01
1 INP 02 INP 03
2 INP 04 INP 05
3 INP 06 INP 07
4 INP 08 INP 09
5 INP 0A INP 0B
6 INP 0C INP 0D
7 INP 0E INP 0F
01 Error
It returns the encoder acquisition error, the error flag has to be reset by the user program. The condition of
error is when the function block detects the contemporary change of both the clock signals. This eventuality
can occur if the frequency of the clock signals is higher than the maximum acceptable by the FB.
FALSE:No error.
TRUE:Acquisition error.
02 Value
It returns the encoder value expressed in pulses, the value is in hexadecimal and it has a range from 0x0000
to 0xFFFF. A clockwise rotation of the encoder increases the count value, when it reaches its higher limit of
0xFFFF, the count restarts from the value 0x0000. A anti-clockwise rotation decreases the count value,
when it reaches its minimum limit of 0x0000, the count restarts from the value 0xFFFF.
RIL example
In the example below, it's managed an encoder connected to the digital inputs INP 00 and INP 01. The quote
value expressed in pulses can be read by debugging the operand W EncoderQuote.
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; Encoder acquisition function block data structure.
DEFL Y Eacq KD 8
DEFL Y EacqInputs Y Eacq KH 0000 ; Eacq.Inputs
DEFL Y EacqError Y Eacq KH 0001 ; Eacq.Error
DEFL W EacqValue Y Eacq KH 0002 ; Eacq.Value
; ------------------------------------------------------------------------------
; @Section("Init")
; ------------------------------------------------------------------------------
; Encoder acquisition function block parameters set.
ORGR
LODT F PLCFirstLoop
MOVI Y EacqInputs K 0000 ; Eacq.Inputs
; ------------------------------------------------------------------------------
; @Section("Encoder acquisition")
; ------------------------------------------------------------------------------
; Encoder acquisition function block call.
ORGR
SETR
TASK L FbEncoderOverIO Y Eacq ; Encoder acquisition
LODA W EacqValue ; Eacq.Value
STRA W EncoderQuote ; Encoder quote
; [End of file]
"C" example
In the example below, it's managed an encoder connected to the digital inputs INP 00 and INP 01. The quote
value expressed in pulses can be read by debugging the variable unsigned int EncoderQuote.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbEncoderOverIO.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLE DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute variables init at first program execution loop.
if (PLCFirstLoop)
Eacq.Inputs=0x00; //Logic inputs selection
// -------------------------------------------------------------------------
// ENCODER ACQUISITION
// -------------------------------------------------------------------------
// Encoder acquisition and value store.
// [End of file]
Function blocks
FbI2CSerial
This function block, add to the system a serial line, using a Netsyst line extension module connected thru the I2C
BUS, see FbI2CSlaveManager. In case of errors in the parameters the bit FBParameters in the PLCErrors data
structure is set.
Declaration
void FbI2CSerial(FBI2CSERIALDATA *S);
Parameters
FBI2CSERIALDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 224 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //FB enable
BOOL UserOpen:1; //User open enable
BOOL b2:1;
BOOL b3:1;
BOOL b4:1;
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Command;
struct
{
BOOL Enabled:1; //FB enabled
BOOL b1:1;
BOOL b2:1;
BOOL b3:1;
BOOL WrongModule:1; //Wrong module address
BOOL RxBufferEmpty:1; //Received character with Rx buffer empty
BOOL TxBufferFull:1; //Sent character with Tx buffer full
BOOL b7:1;
}Status;
}FBI2CSERIALDATA;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: It disables the function block. The Status, I2CError and the I2CErrorCtr are reset.
TRUE: It enables the function block.
1 UserOpen FALSE: The device it's not automatically opened, it must be opened by the user program with
the TermIOOpen function.
TRUE: The device it's automatically opened.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: The function block is enabled
4 WrongModule TRUE: The extension module address is wrong.
5 RxBufferEmpty TRUE: The user program has read the data, GetCh or scanf, with the WaitLoop bit of the
SERIALSTRUCT in condition FALSE, when the reception buffer was empty.
6 TxBufferFull TRUE: The user program has written the data PutCh or printf, with the WaitLoop bit of the
SERIALSTRUCT in condition FALSE, when the transmission buffer was full.
03 ModuleAdd
Loaded by user program it defines the address of the extension module that is used for the serial line
management. The setting of a module address that is not present causes the abort of the management and
the setting of the proper error bit in Status.
04 I2CFrameCh
Loaded by user program it defines the maximum number of characters that can be received or transmitted for
every I2C frame. Higher numbers increases the communication speed but increases the of program execution
loop time. (Range from 1 to 32).
06 IOVector
It returns the address of the TERMIOVECTORS data structure to be used to define the driver as standard I/O
device.
RIL example
In the example below, it is managed the communication on a serial port of the extension module with address 1,
connected to I2C bus. The communication mode 9600, n, 8 will be set by activating the input I 0000, while
deactivating it the communication mode 19200, n, 8 will be set. If the input I 0001 is activated, the string "Hello!"
will be sent to the serial line of the extension module. If the input I 0002 is activated, the string "Hello!" will be sent
to the port A serial line.
; ------------------------------------------------------------------------------
; @Section("Global definitions")
; ------------------------------------------------------------------------------
; Serial driver function block data structure.
; ------------------------------------------------------------------------------
; @Section("Init")
; ------------------------------------------------------------------------------
; Here the serial driver function block parameters are set.
ORGR
LODT F PLCFirstLoop
LTCH Y SerCommand BD 0 ; Ser.Command.Enable
UTCH Y SerCommand BD 1 ; Ser.Command.UserOpen
MOVI Y SerModuleAdd KD 1 ; Ser.ModuleAdd
MOVI Y SerI2CFrameCh KD 4 ; Ser.I2CFrameCh
; ------------------------------------------------------------------------------
; @Section("Serial driver management")
; ------------------------------------------------------------------------------
; Here the serial driver function block is called. After this call the FB is
; defined as standard I/O console.
ORGR
SETR
TASK L FbI2CSerial Y Ser ; I2C serial driver
; By deactivating the "I 0000", the serial line of the addressed extension module
; is set at "19200, e, 8".
ORGR
LODF I 0000
SMOD K 0076 ; "19200, e, 8"
; By activating the "I 0000", the serial line of the addressed extension module
; is set at "9600, n, 8".
ORGR
LODT I 0000
SMOD K 0045 ; "9600, n, 8"
; By activating the "I 0001", "Hello!" string is out on the serial line of the
; addressed extension module.
ORGR
LODT I 0001
PULS
SETV W SerIOVector
STXI KH 0048
STXI KH 0065
STXI KH 006C
STXI KH 006C
STXI KH 006F
STXI KH 0021
STXI KH 000D
STXI KH 000A
; By activating the "I 0002", "Hello!" string is sent on the serial port "A".
ORGR
LODT I 0002
PULS
SETV KE IOSerialPortA
STXI KH 0048
STXI KH 0065
STXI KH 006C
STXI KH 006C
STXI KH 006F
STXI KH 0021
STXI KH 000D
STXI KH 000A
; [End of file]
e input I 0002 is activated, the string "Hello!" will be sent to the serial port A of the system.
"C" example
In the example below, it is managed the communication on a serial port of the extension module with address 1,
connected to I2C bus. Every second the string "Hello World!" will be sent to the serial line of the extention module
and on the port A of the system, the communication is set at its default of 19200, e, 8.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbI2CSerial.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
if (PLCFirstLoop)
{
Ser.Command.Enable=TRUE; //FB enable
Ser.ModuleAdd=1; //Peripheral module address
Ser.I2CFrameCh=4; //Characters in the I2C frame
}
if (PLCPulse1000)
{
// The string is sent on the serial port "A".
SetTermIOVectors(IOSerialPortA);
printf("Hello World! (Port A)\r\n");
SetTermIOVectors(Ser.IOVector);
printf("Hello World! (Extension module)\r\n");
}
}
// [End of file]
Function blocks
FbI2CSlaveManager
This function block manages the I2C bus communication on a slave system it can be used on the NETSYST 10 and 20
extension I/O modules. The FB manages also two communication channels on I2C bus with the master system, one is
used to allow the master system to manage the serial line of the slave system, this allows to add serial lines to the
master system, see FbI2CSerial. The second communication channel makes available a virtual standard I/O to the
slave system, thru this virtual Std I/O it's possible to load and debug programs on the slave system from the master
system. In case of errors in the I2C communication the FBManagement bit in PLCErrors data structure is set.
The function block uses static memory, so it's possible to define only one call to the FB in the program.
Declaration
void FbI2CSlaveManager(FBI2CSLAVEMANAGER* S);
Parameters
FBI2CSLAVEMANAGER* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Module addressing
The FB assigns to module the I2C address, all the extension modules have at the switching on 0x7F as default
address , the master system will provide automatically to assign to every module an address in the range from 0x21 to
0x27 in function of the position of the extension module respect to the master system. The first module connected will
take address 0x21, the second 0x22 and so on. The FB checks the state of the ReadyInAtPwOn bit of SystemConfig
to recognize if it's a base module of Netlog II or Netmaster system, in that case the address 0x20 is assigned to the
module. Further information about the module addressing can be reached at the proper chapter.
Using the startup function, see project settings, it's possible to set the TargetDevice in the SystemConfig to configure
the extension module that can operate in two different manners
Slave They give available all their resources as the I/Os, the display, the keyboard, the serial line, to the master
system.
Master They execute an own program that manages all or part of their resources, as the I/Os, the display, the
keyboard, the serial line. The master system can dialogue with them simply managing the reading or writing of
variables directly in the memory or managing the data in the communication structure. The Netlog II Lite
targets configured as master extensions are able to manage other extensions connected to their I2C
extension bus.
Data structure
The function block uses a 128 bytes data structure, we report a prototype. The members reported under the Internal
use only members label, are members used inside by the function block and they don't have to be changed by the
user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //Enable
BOOL AddressForce:1; //Address force
BOOL b2:1;
BOOL b3:1;
BOOL b4:1;
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Command;
struct
{
BOOL Enabled:1; //Enabled
BOOL I2CSReady:1; //I2C module ready
BOOL RdyInSignal:1; //Ready in signal status
BOOL b3:1;
BOOL RxBufferEmpty:1; //Received character with Rx buffer empty
BOOL TxBufferFull:1; //Sent character with Tx buffer full
BOOL b6:1;
BOOL b7:1;
}Status;
// -----------------------------------------------------[Terminal buffers]--
{
BOOL K0:1; //Key [0] status
BOOL K1:1; //Key [1] status
BOOL K2:1; //Key [2] status
BOOL K3:1; //Key [3] status
BOOL K4:1; //Key [4] status
BOOL K5:1; //Key [5] status
BOOL K6:1; //Key [6] status
BOOL K7:1; //Key [7] status
}Low;
struct
{
BOOL K8:1; //Key [8] status
BOOL K9:1; //Key [9] status
BOOL KUP:1; //Key [UP] status
BOOL KDW:1; //Key [DW] status
BOOL KFUN:1; //Key [FUN] status
BOOL KESC:1; //Key [ESC] status
BOOL KCLR:1; //Key [CLR] status
BOOL KENT:1; //Key [ENT] status
}High;
struct
{
BOOL KLEFT:1; //Key [KLEFT] status
BOOL KRIGHT:1; //Key [KRIGHT] status
}Fun;
}Key;
struct
{
char Up[16]; //Display Up data buffer
char Dw[16]; //Display Dw data buffer
}Display;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: It disables the function block. The Status is reset.
TRUE: It enable the function block.
1 AddressForce TRUE: Allows to define the module from the user program, the module assumes the address
defined in I2CSAddress. However the module address can be changed from the master system
using the I2C command Module address setting.
01 Status
Status bits, the user program can test these bits.
02 I2CSAddress
It returns the value of the address that the system master has assigned to the module (Range from 0x21 to 0x27).
Before the assignment the address value is 0x7F.
03 I2CSRxFrames
It returns the number of received I2C frames, reached its maximum the value starts from 0 (Range from 0x00 to
0xFF).
04 I2CSRxError
It returns the I2C bus communication error, reached its maximum the value starts from 0 (Range from 0x00 to
0xFF).
06 Serial
Loaded by user program it defines the TERMIOVECTORS data structure address of the serial line that must be
managed from the master system thru I2C communication. If not defined will be not used any serial line and the
relate I2C commands (codes from 0x10 to 0x16) will be not managed. (Range from 0x0000 to 0xFFFF).
08 I2CStdIO
It returns the the TERMIOVECTORS data structure address to be used to communicate with master system thru
the virtual standard I/O (Range from 0x0000 to 0xFFFF).
10 I2CSHLogInp
Loaded by user program with the state of the logic inputs high (From INP08 a INP0F), the value can be acquired
from the master system with the I2C commands, Logic I/O management and Logic input acquisition (Range from
0x00 to 0xFF).
11 I2CSLLogInp
Loaded by user program with the state of the logic inputs low (From INP00 a INP07), the value can be acquired
from the master system with the I2C commands, Logic I/O management and Logic input acquisition (Range from
0x00 to 0xFF).
13 I2CSLLogOut
It returns the status of the logic outputs (From OUT00 a OUT07), set by the master system with the I2C
commands, Logic I/O management e Logic output management (Range from 0x00 to0xFF).
14 I2CSADMode (Channel 0)
15 I2CSADMode (Channel 1)
16 I2CSADMode (Channel 2)
17 I2CSADMode (Channel 3)
It returns the acquisition mode set by the master system with the I2C command Analog input acquisition, it must
be transferred to the FbNetlogIIAD (Range from 0x00 to0xFF).
18 I2CSADFilter (Channel 0)
19 I2CSADFilter (Channel 1)
1A I2CSADFilter (Channel 2)
1B I2CSADFilter (Channel 3)
It returns the filter value for the analog acquisition set by the master system with the I2C command Analog input
acquisition, it must be transferred to the FbNetlogIIAD (Range from 0x00 to0xFF).
1C I2CSADValue (Channel 0)
20 I2CSADValue (Channel 1)
24 I2CSADValue (Channel 2)
28 I2CSADValue (Channel 3)
Loaded by user program with the value of the analog inputs as returned by the FbNetlogIIAD, the value can be
acquired from the master system with the I2C command Analog input acquisition.
2E I2CSDAMode (Channel 0)
2F I2CSDAMode (Channel 1)
It returns the analog output mode set by the master system with the I2C command Analog output management, it
must be transferred to the FbNetlogIIDA (Range from 0x00 to0xFF).
30 I2CSDAValue (Channel 0)
34 I2CSDAValue (Channel 1)
It returns the value of the analog output value set by the master system with the I2C command, Analog output
management, it must be transferred to the FbNetlogIIDA.
3C Key.Low
Loaded by user program with the value of the terminal keyboard. The value can be acquired from the master
system with the I2C command Keyboard read.
0 K0 Key status
1 K1 Key status
2 K2 Key status
3 K3 Key status
4 K4 Key status
5 K5 Key status
6 K6 Key status
7 K7 Key status
3D Key.High
Loaded by user program with the value of the terminal keyboard. The value can be acquired from the master
system with the I2C command Keyboard read.
0 K8 Key status
1 K9 Key status
2 KUP Key , status
3 KDW Key , status
4 KFUN Key , status
5 KESC Key status
6 KCLR Key status
7 KENT Key , status
3E Key.Fun
Loaded by user program with the value of the terminal keyboard. The value can be acquired from the master
system with the I2C command Keyboard read.
40 Display.Up
It returns the string to be displayed on the upper line of the display, set by the master system with the I2C
command Display write.
50 Display.Dw
It returns the string to be displayed on the lower line of the display, set by the master system with the I2C
command Display write.
RIL example
In the following example it's managed a I2C slave module based on a Netlog II target. To manage the terminal the
proper terminal management FB must be included in the project. Please note the startup function that sets the system
as a slave system, to execute the function the Call User Startup in the PLCSettings must be checked. An example of
use of this FB, can be found in the program loaded on the Netsyst family extension modules, SFW125 for the Netlog
based modules and SFW135 for the Netreader modules based on P89C664 processor.
; ------------------------------------------------------------------------------
; @Section("External variable definitions")
; ------------------------------------------------------------------------------
EXTR Y SystemConfig
EXTR W IOSerialPortB
DEFG Y SCTargetDevice Y SystemConfig KH 0002 ;SystemConfig.TargetDevice
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; "FbI2CSlaveManager" data structure definition.
DEFL Y ADs KD 80
DEFL Y ADsCommand Y ADs KH 0000 ;ADs.Command
DEFL Y ADsStatus Y ADs KH 0001 ;ADs.Status
DEFL Y ADsModule Y ADs KH 0002 ;ADs.Module
DEFL Y ADsMode0 Y ADs KH 0004 ;ADs.Mode[0]
DEFL Y ADsMode1 Y ADs KH 0005 ;ADs.Mode[1]
DEFL Y ADsMode2 Y ADs KH 0006 ;ADs.Mode[2]
DEFL Y ADsMode3 Y ADs KH 0007 ;ADs.Mode[3]
DEFL Y ADsFilter0 Y ADs KH 0008 ;ADs.Filter[0]
DEFL Y ADsFilter1 Y ADs KH 0009 ;ADs.Filter[1]
DEFL Y ADsFilter2 Y ADs KH 000A ;ADs.Filter[2]
DEFL Y ADsFilter3 Y ADs KH 000B ;ADs.Filter[3]
DEFL FL ADsValue0 Y ADs KH 0010 ;ADs.Value[0]
DEFL FL ADsValue1 Y ADs KH 0014 ;ADs.Value[1]
DEFL FL ADsValue2 Y ADs KH 0018 ;ADs.Value[2]
DEFL FL ADsValue3 Y ADs KH 001C ;ADs.Value[3]
DEFL Y DAs KD 32
DEFL Y DAsCommand Y DAs KH 0000 ;DAs.Command
DEFL Y DAsStatus Y DAs KH 0001 ;DAs.Status
DEFL Y DAsModule Y DAs KH 0002 ;DAs.Module
DEFL Y DAsMode0 Y DAs KH 0004 ;DAs.Mode[0]
DEFL Y DAsMode1 Y DAs KH 0005 ;DAs.Mode[1]
DEFL FL DAsValue0 Y DAs KH 0008 ;DAs.Value[0]
DEFL FL DAsValue1 Y DAs KH 000C ;DAs.Value[1]
; ------------------------------------------------------------------------------
; @Section("FbI2CSlaveManager function block management")
; ------------------------------------------------------------------------------
; Here the function block parameters are set.
ORGR
LODT F PLCFirstLoop
LTCH Y SlmCommand BD 0 ;Slm.Command.Enable
MOVM W SlmSerial W IOSerialPortB ;Slm.Serial
ORGR
SETR
TASK L FbI2CSlaveManager Y Slm
IOAQ K 0001
IOAQ K 0000
STRA Y SlmI2CSLLogInp ;Slm.I2CSLLogInp
; ------------------------------------------------------------------------------
; @Section("FbNetlogIIAD function block management")
; ------------------------------------------------------------------------------
; Here the function block parameters are set.
ORGR
LODT F PLCFirstLoop
LTCH Y ADsCommand BD 0 ;ADs.Command.Enable
MOVI Y ADsModule KH 0000 ;ADs.Module
; Here the I2C buffers are copied to the FbNetlogIIAD data structure.
ORGR
LODT Y ADsStatus BD 1 ;ADs.Status.DataReady
MOVM Y ADsMode0 Y SlmI2CSADMode0 ;ADs.Mode[0]
MOVM Y ADsMode1 Y SlmI2CSADMode1 ;ADs.Mode[1]
MOVM Y ADsMode2 Y SlmI2CSADMode2 ;ADs.Mode[2]
MOVM Y ADsMode3 Y SlmI2CSADMode3 ;ADs.Mode[3]
MOVM Y ADsFilter0 Y SlmI2CSADFilter0 ;ADs.Filter[0]
MOVM Y ADsFilter1 Y SlmI2CSADFilter1 ;ADs.Filter[1]
MOVM Y ADsFilter2 Y SlmI2CSADFilter2 ;ADs.Filter[2]
MOVM Y ADsFilter3 Y SlmI2CSADFilter3 ;ADs.Filter[3]
ORGR
SETR
TASK L FbNetlogIIAD Y ADs
ORGR
LODT Y ADsStatus BD 1 ;ADs.Status.DataReady
MOVM FL SlmI2CSADValue0 FL ADsValue0 ;Slm.I2CSADValue[0]
MOVM FL SlmI2CSADValue1 FL ADsValue1 ;Slm.I2CSADValue[1]
MOVM FL SlmI2CSADValue2 FL ADsValue2 ;Slm.I2CSADValue[2]
MOVM FL SlmI2CSADValue3 FL ADsValue3 ;Slm.I2CSADValue[3]
; ------------------------------------------------------------------------------
; @Section("FbNetlogIIDA function block management")
; ------------------------------------------------------------------------------
; Here the function block parameters are set.
ORGR
LODT F PLCFirstLoop
LTCH Y DAsCommand BD 0 ;ADs.Command.Enable
MOVI Y DAsModule KH 0000 ;DAs.Module
; Here the I2C buffers are copied to the FbNetlogIIDA data structure.
ORGR
LODT Y DAsStatus BD 1 ;ADs.Status.DataSet
MOVM Y DAsMode0 Y SlmI2CSDAMode0 ;DAs.Mode[0]
MOVM Y DAsMode1 Y SlmI2CSDAMode1 ;DAs.Mode[1]
MOVM FL DAsValue0 FL SlmI2CSDAValue0 ;DAs.Value[0]
MOVM FL DAsValue1 FL SlmI2CSDAValue1 ;DAs.Value[1]
ORGR
SETR
TASK L FbNetlogIIDA Y DAs
ORGR
SETR
RETN
; ------------------------------------------------------------------------------
; @Section("User startup function")
; ------------------------------------------------------------------------------
; This function is automatically called once before to execute the user program.
; Configure the system as "NETLOG_ADUC84X_LITE_SLAVE_EXT".
ORGR
LABL L PLCUserStartUp
SETR
MOVI Y SCTargetDevice KH 0042 ;SystemConfig.TargetDevice
RETN
; [End of file]
"C" example
In the following example it's managed a I2C slave module based on a Netlog II target. Please note the startup function
that sets the system as a slave system, to execute the function the Call User Startup in the PLCSettings must be
checked.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbNetlogIIAD.h>
#include <FbNetlogIIDA.h>
#include "FbI2CSlaveManager.h"
// -----------------------------------------------------------------------------
// FUNCTION "void PLC_L_PLCUserStartUp_Lbl(void)"
// -----------------------------------------------------------------------------
// This function is automatically called once before to execute the user program.
void PLC_L_PLCUserStartUp_Lbl(void)
{
// -----------------------------------------------------------------------------
// EXTENSION MANAGEMENT
// -----------------------------------------------------------------------------
// Extension management program.
void ExtensionMng(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute the function init at first program execution loop.
if (PLCFirstLoop)
{
// I2C slave manager function block parameters setting.
Slm.Command.Enable=TRUE; //Enable
Slm.Serial=IOSerialPortB; //Serial vector address
// -------------------------------------------------------------------------
// I2C SLAVE MANAGER
// -------------------------------------------------------------------------
// Execute the I2C slave manager function block.
// ---------------------------------------------------------[Logic inputs]--
// ---------------------------------------------------------[Logic outputs]--
// --------------------------------------------------------[Analog inputs]--
// Set the parameters.
FbNetlogIIAD(&ADs);
if (ADs.Status.DataReady)
for (i=0; i<4; i++)
Slm.I2CSADValue[i]=ADs.Value[i]; //I2C A/D value
// -------------------------------------------------------[Analog outputs]--
// Set the parameters.
FbNetlogIIDA(&DAs);
// -------------------------------------------------------------[Terminal]--
// Set the terminal as standard I/O console and call the terminal
// management function it must be called after the variables init.
if (Ts.Status.RefreshEnd)
OutputStream((char*)&Slm.Display, 32);
}
// [End of file]
Every I2C command begins with the writing by the master system of the comand frame and the successive reading of
the reply answer frame. Every frame has like terminator a checksum byte that represents the sum in 2' complement of
the whole frame included the I2C address.
0 Ready signal
1 Master watch dog enable
Code 04: Memory read Command frame Answer frame
This command allows the reading of numerical variables from the 21
Module address Module address21
extension module. For the variable address range please refer to the Command 04 Command 04
project settings, the number of bytes is included between 1 and 32. Address (Hi)07 Value (Hi) 12
Address (Lo)00 Value (Lo) 34
Nr of bytes 02 Frame checksum95
D2
Frame checksum
Code 05: Memory write Command frame Answer frame
This command allows the writing of numerical variables to the extension 21
Module address Module address 21
module. For the variable address range please refer to the project settings, Command 05 Command 05
the number of bytes is included between 1 and 32. Address (Hi)07 Frame checksum DA
Address (Lo)00
Nr of bytes 02
Value (Hi) 12
Value (Lo) 34
8B
Frame checksum
Code 06: Logic input acquisition Command frame Answer frame
This command allows the reading of 16 logic inputs from the extension Module address 21 Module address 21
module. Command 06 Command 06
Frame checksum D9 Input value (Hi) 10
Input value (Lo) 01
Frame checksum C8
Code 09: Logic output management Command frame Answer frame
This command allows the writing of 8 logic outputs to the extension 21
Module address Module address 21
module. Command 09 Command 09
Output value55 Frame checksum D6
81
Frame checksum
Code 0A: Display write Command frame Answer frame
This command allows the writing of data to the display of the extension 21
Module address Module address 21
module. Up to 32 bytes can be write. Command 0A Command 0A
Display address: Buffer display address (Range da 0 a 31) 00
Display address Frame checksum D5
Nr of characters: Number of bytes to be written (Range da 1 a 32) 03
Nr of characters
Char (00) 41
Char (01) 42
Char (02) 43
0C
Frame checksum
Function blocks
FbIOComm
This function block allows the data exchange between two systems, one master and one slave, using a
connection between logic I/Os. Two digital inputs and two digital outputs for every system are used, you can
define the number of data bytes to exchange to optimize the data exchange time.
Declaration
void FbIOComm(FBIOCOMMDATA *S);
Parameters
FBIOCOMMDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 32 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //Enable
BOOL b1:1;
BOOL b2:1;
BOOL Reset:1; //Errors reset
BOOL b4:1;
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Command;
struct
{
BOOL Enabled:1; //Enabled
BOOL TransferEnd:1; //Data transfer end
BOOL TransmitEnd:1; //Data transmit end
BOOL ReceiveEnd:1; //Data reception end
BOOL ILowError:1; //Logic inputs low error
BOOL IHighError:1; //Logic inputs high error
struct
{
BOOL IStrobe:1; //Strobe input signal
BOOL IData:1; //Data input signal
BOOL b2:1;
BOOL b3:1;
BOOL OStrobe:1; //Strobe output signal
BOOL OData:1; //Data output signal
BOOL b6:1;
BOOL b7:1;
}IOSignals;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: It disables the FB. The communication stops and the output signals go to zero.
TRUE: It enables the FB and the communication starts.
4 Reset TRUE: Resets the error bits.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: It shows that the FB is enabled.
1 TransferEnd It's activated for a program loop at the end of the data exchange.
2 TransmitEnd It's activated for a program loop at the end of the data transmission.
3 ReceiveEnd It's activated for a program loop at the end of the data reception.
4 ILowError TRUE: It shows an error on the communication signals, they were checked as reset when
they had to be set. It can be reset by activating the Command.Reset bit.
5 IHighError TRUE: It shows an error on the communication signals, they were checked as set when they
had to be reset. It can be reset by activating the Command.Reset bit.
6 CksError TRUE: It shows an error of data reception, the received packet has an check sum error. It
can be reset by activating the Command.Reset bit.
7 SincError TRUE: It shows a synchronization error with the other system. It can be reset by activating
the Command.Reset bit.
02 IOSignals
IO signal bytes, the user program can manage these bits according to its needs.
0 IStrobe The hardware signal (Logic input) used as strobe input, has to be copied to this bit.
1 IData The hardware signal (Logic input) used as data input, has to be copied to this bit.
4 OStrobe This bit has to be copied to the hardware signal Logic output) used as strobe output.
5 OData This bit has to be copied to the hardware signal (Logic output) used as data output.
04 ModeVector
Loaded by user program it defines the mode management vector, the two possible values are:
Pfb043_Master: It defines the master mode.
Pfb043_Slave: It defines the slave mode.
06 TxAddress
Loaded by user program it defines the begin address of the data buffer to be transmit to the other system,
the range is from 0x0000 to 0xFFFF.
08 TxBytes
Loaded by user program it defines the number of bytes to transmit to the other system, the range is from
0x00 to 0xFF.
0A RxAddress
Loaded by user program it defines the begin address of the data buffer to receive from the other system, the
range is from 0x0000 to 0xFFFF.
0C RxBytes
Loaded by user program it defines the number of bytes to receive from the other system, the range is from
0x00 to 0xFF.
RIL example
In the example below, the FB is parametrized as master and is executed. By executing the same program on
another system and parametrizing it as slave it's possible to test the data exchange between the two systems
using the logic I/Os.
; ------------------------------------------------------------------------------
; @Section("Extern variables definition")
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Local variables definition")
; ------------------------------------------------------------------------------
; Here define the data buffer to send to the other system.
DEFL Y TxD KD 4
DEFL Y TxDByte0 Y TxD KD 0 ; Tx data, Byte 0
DEFL Y TxDByte1 Y TxD KD 1 ; Tx data, Byte 1
DEFL W TxDWord0 Y TxD KD 2 ; Tx data, Word 0
; Here define the data buffer to receive from the other system.
DEFL Y RxD KD 4
DEFL Y RxDByte0 Y RxD KD 0 ; Rx data, Byte 0
DEFL Y RxDByte1 Y RxD KD 1 ; Rx data, Byte 1
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; Logic I/O communication function block data structure.
DEFL Y IOC KD 32
DEFL Y IOCCommand Y IOC KH 0000 ; IOC.Command
DEFL Y IOCStatus Y IOC KH 0001 ; IOC.Status
DEFL Y IOCIOSignals Y IOC KH 0002 ; IOC.IOSignals
DEFL W IOCModeVector Y IOC KH 0004 ; IOC.ModeVector
DEFL W IOCTxAddress Y IOC KH 0006 ; IOC.TxAddress
DEFL Y IOCTxBytes Y IOC KH 0008 ; IOC.TxBytes
DEFL W IOCRxAddress Y IOC KH 000A ; IOC.RxAddress
DEFL Y IOCRxBytes Y IOC KH 000C ; IOC.RxBytes
; ------------------------------------------------------------------------------
; @Section("Init")
; ------------------------------------------------------------------------------
; Here the logic I/O communication function block parameters are set.
ORGR
LODT F PLCFirstLoop
LTCH Y IOCCommand K 0000 ; I/O Comm, Command.Enable
MOVA W IOCTxAddress Y TxD ; IOC.TxAddress
MOVI Y IOCTxBytes KD 4 ; IOC.TxBytes
MOVA W IOCRxAddress Y RxD ; IOC.RxAddress
MOVI Y IOCRxBytes KD 4 ; IOC.RxBytes
; Uncomment the statement that define the mode you want to use.
; ------------------------------------------------------------------------------
; @Section("I/O communication")
; ------------------------------------------------------------------------------
; Copy the logical inputs to function blocks input bits.
ORGR
LODT I 0000 ; Strobe input
OUTT Y IOCIOSignals K 0000 ; IOC.IOSignals.IStrobe
ORGR
LODT I 0001 ; Data input
OUTT Y IOCIOSignals K 0001 ; IOC.IOSignals.IData
ORGR
SETR
TASK L FbIOComm Y IOC ; I/O communication management
ORGR
LODT Y IOCIOSignals K 0004 ; IOC.IOSignals.OStrobe
OUTT O 0000 ; Strobe output
ORGR
LODT Y IOCIOSignals K 0005 ; IOC.IOSignals.OData
OUTT O 0001 ; Data output
; [End of file]
"C" example
In the example below, the FB is parametrized as master and is executed. By executing the same program on
another system and parametrizing it as slave it's possible to test the data exchange between the two systems
using the logic I/Os.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbIOComm.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLE DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Logic inputs definition.
struct
{
BOOL Strobe:1; //Strobe input
BOOL Data:1; //Data input
BOOL Inp02:1; //Inp 02 bit
BOOL Inp03:1; //Inp 03 bit
BOOL Inp04:1; //Inp 04 bit
BOOL Inp05:1; //Inp 05 bit
BOOL Inp06:1; //Inp 06 bit
BOOL Inp07:1; //Inp 07 bit
}LogInp;
struct
{
static struct
{
unsigned char TxDByte0; //Tx data, Byte 0
unsigned char TxDByte1; //Tx data, Byte 1
unsigned int TxDWord0; //Tx data, Word 0
}TxD;
//; Here define the data buffer to receive from the other system.
static struct
{
unsigned char RxDByte0; //Rx data, Byte 0
unsigned char RxDByte1; //Rx data, Byte 1
unsigned int RxDWord0; //Rx data, Word 0
}RxD;
// Here the logic I/O communication function block parameters are set.
if (PLCFirstLoop)
{
IOC.Command.Enable=TRUE; //Enable
IOC.TxAddress=(unsigned int)&TxD; //Transmit data address
IOC.TxBytes=sizeof(TxD); //Number of transmit bytes
IOC.RxAddress=(unsigned int)&RxD; //Reception data address
IOC.RxBytes=sizeof(RxD); //Number of Reception bytes
// Uncomment the statement that define the mode you want to use.
// Here copy the logic input signals to the IOC data structure.
// Here copy the the IOC data structure to the logic output signals.
// [End of file]
Function blocks
FbModbusAsciiMs
This function block allows the data exchange between two systems, one master and one slave, using a
MODBUS ASCII connection in serial line. For the communication with the slave system the function block uses the
MODBUS functions 41: Read memory bytes (User function) e 42: Write memory bytes (User function), see the
FbModbusAsciiSl block function information to have the full information of the used functions. For an example of
communication between a master system and two or more Slave systems, please refer to HT001.
Declaration
void FbModbusAsciiMs(FBMODBUSASCIIMSDATA* S);
Parameters
FBMODBUSASCIIMSDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 64 bytes data structure, we report a prototype. The members reported under the Internal
use only members label, are members used inside by the function block and they don't have to be changed by the
user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //Enable
BOOL ResetCtrs:1; //Resets all the counters
BOOL b2:1;
BOOL b3:1;
BOOL DoWrite:1; //Write memory bytes
BOOL DoRead:1; //Read memory bytes
BOOL DoWrRd:1; //Write/read memory bytes
BOOL b7:1;
}Command; //Command
struct
{
BOOL Enabled:1; //Enabled
BOOL JobDone:1; //Command executed
BOOL b2:1;
BOOL b3:1;
BOOL Timeouts:1; //Timeout error
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: It disables the FB. The error bits in Status are reset and the communication is hung up.
TRUE: It enables the FB and the communication starts.
1 ResetCtrs TRUE: Resets all the counters, the bit is automatically reset.
4 DoWrite TRUE: It starts the data transfer to the slave system job. When the job starts the bit is
automatically reset.
5 DoRead TRUE: It orders the data read from the slave system job. When the job starts the bit is
automatically reset.
6 DoWrRd TRUE: It orders the data transfer to the slave system and the next reading job. When the job starts
the bit is automatically reset.
01 Status
Status bits, the user program can test these bits.
02 NodeAdd
Loaded by user program it defines the address of the slave node, that you need to communicate to (From 0x00
to 0xFF).
04 WrLcStAd
Loaded by user program it defines the begin address of the data area on master system to be transferred to the
slave system(From 0x0000 to 0xFFFF).
06 WrRmStAd
Loaded by user program it defines the begin address of the data area on slave system, where the data read
from the master system are written (From 0x0000 to 0xFFFF). The address used in the MODBUS command to
write the data to the Slave system will be the sum between this value and the value of PLCMemStart.
08 WrBytes
Loaded by user program it defines the number of bytes to transfer to the slave system (From 1 to 32).
0A RdLcStAd
Loaded by user program it defines the begin address of the area on master system where the data readed from
the slave system are stored (From 0x0000 to 0xFFFF).
0C RdRmStAd
Loaded by user program it defines the begin address of the area on slave system, from where the data to be
transferred to the master system are read (From 0x0000 to 0xFFFF). The address used in the MODBUS
command to read the data from the Slave system will be the sum between this value and the value of
PLCMemStart.
0E RdBytes
Loaded by user program it defines the number of bytes to read from the slave system (From 1 to 32).
10 CommndWt
Loaded by user program it defines the waiting time expressed in mSec between the end of the job (we remind
that every job, ends after the command frame transmission and the proper answer frame reception) and the
start of the next job. In case of DoWrRd job, it represents the time between the end of the write control and the
execution of the next read control. (From 0x0000 to 0xFFFF).
12 TimeOutCk
Loaded by user program it defines the available time to execute the job, expressed in mSec (From 0x0000 to
0xFFFF).
16 Timeouts
It returns the count of the timeouts errors occurred both in reception and transmission. It can be preset to 0 by
the user program or reset by activating the Command.ResetCtrs bit.
18 Overruns
It returns the count of the overrun errors occurred in reception (From 0x0000 to 0xFFFF). It can be preset to 0
by the user program or reset by activating the Command.ResetCtrs bit.
1A CommErrs
It returns the count of the communication errors occurred both in reception and transmission (From 0x0000 to
0xFFFF). It can be preset to 0 by the user program or reset by activating the Command.ResetCtrs bit.
1C TxFrames
It returns the count of the command strings transmitted (From 0x0000 to 0xFFFF). It can be preset to 0 by the
user program or reset by activating the Command.ResetCtrs bit.
1E RxFrames
It returns the count of the number of answer strings received (From 0x0000 to 0xFFFF). It can be preset to 0 by
the user program or reset by activating the Command.ResetCtrs bit.
20 PLCMemStart
Loaded by user program it defines the allocation address of the PLC variables in the slave systemmemory
(From 0x0000 to 0xFFFF).The address used in the MODBUS command to write the data to the Slave system
will be the sum between this value and the value of WrRmStAd. The address used in the MODBUS command
to read the data from the Slave system will be the sum between this value and the value of WrRmStAd.
23 FrameLength
Loaded by user program it defines the dimension of the frame reception/transmission buffer (From 12 to 255).
To maintain compatibility with the previous versions a buffer of at least 40 bytes must be defined.
24 FrameBuf
Loaded by user program it defines the allocation address of the frame reception/transmission buffer (From
0x0000 to 0xFFFF).
RIL example
In the following example the Modbus communication with a slave system is executed, the master system and the
slave system automatically exchange banks of data. To test the working, you just need to connect the master
system to a slave, on which run a program that manages the FbModbusAsciiSl function block.
; ------------------------------------------------------------------------------
; @Section("Communication buffer")
; ------------------------------------------------------------------------------
; Here define the data buffer to communicate with the slave system.
DEFG Y ToSlave KD 4
DEFG Y ToY0000 Y ToSlave KH 0000 ; ToSlave, Y 0000
DEFG Y ToY0001 Y ToSlave KH 0001 ; ToSlave, Y 0001
DEFG W ToW0002 Y ToSlave KH 0002 ; ToSlave, W 0002
DEFG Y FromSlave KD 2
DEFG Y FromY0020 Y FromSlave KH 0000 ; FromSlave, Y 0020
DEFG Y FromY0021 Y FromSlave KH 0001 ; FromSlave, Y 0021
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; MODBUS master communication, data structure.
DEFL Y Mdb KD 64
DEFL Y MdbCommand Y Mdb KH 0000 ; Mdb.Command
DEFL Y MdbStatus Y Mdb KH 0001 ; Mdb.Status
DEFL Y FrameBuf KD 40
; ------------------------------------------------------------------------------
; @Section("Program init")
; ------------------------------------------------------------------------------
; MODBUS master communication, variables settings.
ORGR
LODT F PLCFirstLoop
MOVI Y MdbNodeAdd KD 0 ; Mdb.NodeAdd
MOVA W MdbWrLcStAd Y ToSlave ; Mdb.WrLcStAd
MOVI W MdbWrRmStAd KH 0000 ; Mdb.WrRmStAd
MOVI Y MdbWrBytes KD 4 ; Mdb.WrBytes
MOVA W MdbRdLcStAd Y FromSlave ; Mdb.RdLcStAd
MOVI W MdbRdRmStAd KH 0020 ; Mdb.RdRmStAd
MOVI Y MdbRdBytes KD 2 ; Mdb.RdBytes
MOVI W MdbCommndWt KD 40 ; Mdb.CommndWt
MOVI W MdbTimeOutCk KD 500 ; Mdb.TimeOutCk
MOVI W MdbPLCMemStart KH 0000 ; Mdb.PLCMemStart
MOVI Y MdbFrameLength KD 40 ;Mdb.FrameLength
MOVA W MdbFrameBuf Y FrameBuf ;Mdb.FrameBuf
LTCH Y MdbCommand BD 1 ;Mdb.Command.ResetCtrs
; ------------------------------------------------------------------------------
; @Section("MODBUS communication, master management")
; ------------------------------------------------------------------------------
; MODBUS master communication management.
ORGR
SETR
SETV KE IOSerialPortA
TASK L FbModbusAsciiMs Y Mdb ; MODBUS master management
LTCH Y MdbCommand BD 0 ;Mdb.Command.Enable
LTCH Y MdbCommand BD 6 ;Mdb.Command.DoWrRd+
; [End of file]
"C" example
In the following example the Modbus communication with a slave system is executed, the master system and the
slave system automatically exchange banks of data. To test the working, you just need to connect the master
system to a slave, on which run a program that manages the FbModbusAsciiSl function block.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbModbusAsciiMs.h>
// -----------------------------------------------------------------------------
// GENERAL DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// DATA BUFFER DEFINITIONS
// -----------------------------------------------------------------------------
// Here define the data buffer to communicate with the slave system.
struct
{
unsigned char Byte0; //To slave system, byte 0
unsigned char Byte1; //To slave system, byte 1
unsigned int Word2; //To slave system, word 2
}ToSlave; //Data buffer to slave
struct
{
unsigned char Byte0; //From slave system, byte 0
unsigned char Byte1; //From slave system, byte 1
}FromSlave; //Data buffer from slave
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute the system init at first program execution loop.
if (PLCFirstLoop)
{
// -------------------------------------------------------------------------
// MODBUS MASTER COMMUNICATION
// -------------------------------------------------------------------------
// MODBUS master communication call.
SetTermIOVectors(IOSerialPortA);
FbModbusAsciiMs(&Mdb); //MODBUS master management
Mdb.Command.Enable=TRUE; //Enable
Mdb.Command.DoWrite=TRUE; //Write memory bytes
}
// [End of file]
Function blocks
FbModbusRtuMs
This function block allows the data exchange between two systems, one master and one slave, using a
MODBUS ASCII connection in serial line. For the communication with the slave system the function block uses the
MODBUS functions Code 03: Read holding registers, Code 04: Read input registers and Code 10: Preset
multiple registers, see the FbModbusRtuSl block function information to have the full information of the used
functions. For an example of communication between a master system and two or more Slave systems, please refer to
HT001.
Declaration
void FbModbusRtuMs(FBMODBUSRTUMSDATA* S);
Parameters
FBMODBUSRTUMSDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 64 bytes data structure, we report a prototype. The members reported under the Internal
use only members label, are members used inside by the function block and they don't have to be changed by the
user program.
typedef struct
{
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //Enable
BOOL ResetCtrs:1; //Resets all the counters
BOOL FctSelect:1; //Function select
BOOL b3:1;
BOOL DoWrite:1; //Write memory bytes
BOOL DoRead:1; //Read memory bytes
BOOL DoWrRd:1; //Write/read memory bytes
BOOL b7:1;
}Command; //Command
struct
{
BOOL Enabled:1; //Enabled
BOOL JobDone:1; //Command executed
BOOL b2:1;
BOOL b3:1;
BOOL Timeouts:1; //Timeout error
BOOL b5:1;
BOOL CommErrs:1; //Communication error
BOOL Parameters:1; //Parameter error
}Status; //Status
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: It disables the FB. The error bits in Status are reset and the communication is hung up.
TRUE: It enables the FB and the communication starts.
1 ResetCtrs TRUE: Resets all the counters, the bit is automatically reset.
2 FctSelect FALSE: To read the registers from the slave device the MODBUS function Code 03: Read holding
registers is used.
TRUE: To read the registers from the slave device the MODBUS function Code 04: Read input
registers is used.
4 DoWrite TRUE: It starts the data transfer to the slave system job. When the job starts the bit is automatically
reset.
5 DoRead TRUE: It orders the data read from the slave system job. When the job starts the bit is automatically
reset.
6 DoWrRd TRUE: It orders the data transfer to the slave system and the next reading job. When the job starts
the bit is automatically reset.
01 Status
Status bits, the user program can test these bits.
02 Node
Loaded by user program it defines the address of the slave node, that you need to communicate to (From 0x00 to
0xFF).
04 WrBuffer
Loaded by user program it defines the begin address of the write data buffer to be transferred to the slave system
(From 0x0000 to 0xFFFF).
06 WrAddress
Loaded by user program it defines the begin address of the data area on slave system, where the data read from
the master system are written (From 0x0000 to 0xFFFF).
08 WrRegisters
Loaded by user program it defines the number of registers to be preset on the slave system. The maximum
number of registers to be preset can be calculated with the formula: (FrameLength-9)/2.
0A RdBuffer
Loaded by user program it defines the begin address of the read data buffer where the data readed from the slave
system are stored (From 0x0000 to 0xFFFF).
0C RdAddress
Loaded by user program it defines the begin address of the area on slave system, from where the data to be
transferred to the master system are read (From 0x0000 to 0xFFFF).
0E RdRegisters
Loaded by user program it defines the number of registers to read from the slave system. The maximum number
of registers that can be read can be calculated with the formula: (FrameLength-5)/2.
10 CommndWt
Loaded by user program it defines the waiting time expressed in mSec between the end of the job (we remind that
every job, ends after the command frame transmission and the proper answer frame reception) and the start of the
next job. In case of DoWrRd job, it represents the time between the end of the write control and the execution of
the next read control. (From 0x0000 to 0xFFFF).
12 TimeOutCk
Loaded by user program it defines the available time to execute the job, expressed in mSec (From 0x0000 to
0xFFFF).
16 Timeouts
It returns the count of the timeouts errors occurred both in reception and transmission. It can be preset to 0 by the
user program or reset by activating the Command.ResetCtrs bit.
1A CommErrs
It returns the count of the communication errors occurred both in reception and transmission (From 0x0000 to
0xFFFF). It can be preset to 0 by the user program or reset by activating the Command.ResetCtrs bit.
1C TxFrames
It returns the count of the command strings transmitted (From 0x0000 to 0xFFFF). It can be preset to 0 by the user
program or reset by activating the Command.ResetCtrs bit.
1E RxFrames
It returns the count of the number of answer strings received (From 0x0000 to 0xFFFF). It can be preset to 0 by
the user program or reset by activating the Command.ResetCtrs bit.
20 PLCMemStart
Loaded by user program it defines the allocation address of the PLC variables in the slave systemmemory (From
0x0000 to 0xFFFF).The address used in the MODBUS command to write the data to the Slave system will be the
sum between this value and the value of WrRmStAd. The address used in the MODBUS command to read the
data from the Slave system will be the sum between this value and the value of WrRmStAd.
23 FrameLength
Loaded by user program it defines the dimension of the frame reception/transmission buffer (From 12 to 255). To
maintain compatibility with the previous versions a buffer of at least 40 bytes must be defined.
24 FrameBuf
Loaded by user program it defines the allocation address of the frame reception/transmission buffer (From 0x0000
to 0xFFFF).
RIL example
In the following example the Modbus communication with a slave system is executed, the master system executes the
read of two registers and preset two registers on the slave system. To test the working, you just need to connect the
master system to a slave, on which run a program that manages the FbModbusRtuSl function block.
; ------------------------------------------------------------------------------
; @Section("Communication buffer")
; ------------------------------------------------------------------------------
; Here define the data buffer to communicate with the slave system.
DEFL Y WriteBuffer KD 4
DEFL W Reg0000 Y WriteBuffer KH 0000 ;Register 0000
DEFL W Reg0002 Y WriteBuffer KH 0002 ;Register 0002
DEFL Y ReadBuffer KD 4
DEFL W Reg0010 Y ReadBuffer KH 0000 ;Register 0010
DEFL W Reg0012 Y ReadBuffer KH 0002 ;Register 0012
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; MODBUS master communication, data structure.
DEFL Y Mdb KD 64
DEFL Y MdbCommand Y Mdb KH 0000 ;Mdb.Command
DEFL Y MdbStatus Y Mdb KH 0001 ;Mdb.Status
DEFL Y MdbNode Y Mdb KH 0002 ;Mdb.Node
DEFL W MdbWrBuffer Y Mdb KH 0004 ;Mdb.WrBuffer
DEFL W MdbWrAddress Y Mdb KH 0006 ;Mdb.WrAddress
DEFL Y MdbWrRegisters Y Mdb KH 0008 ;Mdb.WrRegisters
DEFL W MdbRdBuffer Y Mdb KH 000A ;Mdb.RdBuffer
DEFL W MdbRdAddress Y Mdb KH 000C ;Mdb.RdAddress
DEFL Y MdbRdRegisters Y Mdb KH 000E ;Mdb.RdRegisters
DEFL W MdbCommndWt Y Mdb KH 0010 ;Mdb.CommndWt
DEFL W MdbTimeOutCk Y Mdb KH 0012 ;Mdb.TimeOutCk
DEFL W MdbTimeouts Y Mdb KH 0016 ;Mdb.Timeouts
DEFL W MdbCommErrs Y Mdb KH 001A ;Mdb.CommErrs
DEFL W MdbTxFrames Y Mdb KH 001C ;Mdb.TxFrames
; ------------------------------------------------------------------------------
; @Section("Program init")
; ------------------------------------------------------------------------------
; MODBUS master communication, variables settings.
ORGR
LODT F PLCFirstLoop
MOVI Y MdbNode KD 0 ;Mdb.Node
MOVA W MdbWrBuffer Y WriteBuffer ;Mdb.WrBuffer
MOVI W MdbWrAddress KH 0000 ;Mdb.WrAddress
MOVI Y MdbWrRegisters KD 2 ;Mdb.WrRegisters
MOVA W MdbRdBuffer Y ReadBuffer ;Mdb.RdBuffer
MOVI W MdbRdAddress KH 0010 ;Mdb.RdAddress
MOVI Y MdbRdRegisters KD 2 ;Mdb.RdRegisters
MOVI W MdbCommndWt KD 100 ;Mdb.CommndWt
MOVI W MdbTimeOutCk KD 500 ;Mdb.TimeOutCk
MOVI Y MdbFrameLength KD 40 ;Mdb.FrameLength
MOVA W MdbFrameBuf Y FrameBuffer ;Mdb.FrameBuf
LTCH Y MdbCommand BD 1 ;Mdb.Command.ResetCtrs
UTCH Y MdbCommand BD 2 ;Mdb.Command.FctSelect
; ------------------------------------------------------------------------------
; @Section("MODBUS communication, master management")
; ------------------------------------------------------------------------------
; MODBUS master communication management.
ORGR
SETR
SETV KE IOSerialPortB
TASK L FbModbusRtuMs Y Mdb ;MODBUS master management
LTCH Y MdbCommand BD 0 ;Mdb.Command.Enable
LTCH Y MdbCommand BD 6 ;Mdb.Command.DoWrRd
; [End of file]
"C" example
In the following example the Modbus communication with a slave system is executed, the master system executes the
read of two registers and preset two registers on the slave system. To test the working, you just need to connect the
master system to a slave, on which run a program that manages the FbModbusRtuSl function block.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbModbusRtuMs.h>
// -----------------------------------------------------------------------------
// GENERAL DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// DATA BUFFER DEFINITIONS
// -----------------------------------------------------------------------------
// Here define the data buffer to communicate with the slave system.
struct
{
unsigned int Reg0000; //Register 0000
unsigned int Reg0002; //Register 0002
}WriteBuffer; //Write buffer
struct
{
unsigned int Reg0010; //Register 0010
unsigned int Reg0012; //Register 0012
}ReadBuffer; //Read buffer
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute the system init at first program execution loop.
if (PLCFirstLoop)
{
// Set variables to manage the MODBUS master communication.
// -------------------------------------------------------------------------
// MODBUS MASTER COMMUNICATION
// -------------------------------------------------------------------------
// MODBUS master communication call.
SetTermIOVectors(IOSerialPortB);
FbModbusRtuMs(&Mdb); //MODBUS master management
Mdb.Command.Enable=TRUE; //Enable
Mdb.Command.DoWrRd=TRUE; //Write/read memory bytes
}
// [End of file]
Function blocks
FbModemMng
This function block allows the management of a MODEM for switched telephone network or GSM. The FB manages all the
MODEM set operations, executes calls, sends SMS messages, answers to the incoming calls, receives SMS messages. To
check if the MODEM works correctly, we suggest to execute the tests regarding the PSTN or GSM MODEMs. A complete
demo which use this FB is available in the demo programs.
Declaration
void FbModemMng(FBMODEMMNGDATA* S);
Parameters
FBMODEMMNGDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 64 bytes data structure, we report a prototype. The members reported under the Internal use
only members label, are members used inside by the function block and they don't have to be changed by the user
program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //Active enables the function block
BOOL Dial:1; //Active force the number dial
BOOL SMSSend:1; //Active force the SMS send
BOOL HangUp:1; //Active force the hang up
BOOL b04:1;
BOOL b05:1;
BOOL AnswerDisable:1; //Active disable the call answer
BOOL ResetError:1; //Active force error field reset
}Command;
struct
{
BOOL ModemOk:1; //Active if the MODEM is working
BOOL CLIPRxd:1; //Pulse active at every CLIP received
BOOL b0A:1;
BOOL Connect:1; //Active if the MODEM is connect
BOOL b0C:1;
BOOL b0D:1;
BOOL PowerOn:1; //Active if is powering on the MODEM
BOOL SwitchModemOn:1; //Used to switch MODEM On/Off
struct
{
BOOL CLIPReceive:1; //Active if error in CLIP receive
BOOL b09:1;
BOOL b0A:1;
BOOL b0B:1;
BOOL b0C:1;
BOOL b0D:1;
BOOL b0E:1;
BOOL b0F:1;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: It disables the FB, resets the Command, Status and Error and the MODEM is switched off.
TRUE: It enables the FB.
1 Dial TRUE: It commands the dialing of the number pointed by DialNumber.
When the command is activated the Status.Dial is set, and it remain active for the time required to
dial the number, to wait remote system answers and synchronization. When the connection is done,
both Command.Dial and Status.Dial are automatically reset.
If the command doesn't end within the time defined in ModemCfg->DialCommandTimeout, after the
delay time defined in ModemCfg->InterDialTime multiplied for a number from 1 to 4, another try is
made, and so on, until you reach the number of tries defined in ModemCfg->DialRetries. If the
operation cannot end positevely, both Command.Dial and Status.Dial are automatically reset and
Error.Dial is activated.
2 SMSSend TRUE: It commands sending of the message in the buffer pointed by SMSSend to the number in the
buffer pointed by DialNumber.
When the command is activated the Status.SMSSend is set, and it remain active for the time required
to send the message. When the message is send, both Command.SMSSend and Status.SMSSend
are automatically reset.
If the command doesn't end within the time defined in ModemCfg->SMSSendTimeout, after the
delay time defined in ModemCfg->InterSMSSendTime multiplied for a number from 1 to 4, another
try is made, and so on, until you reach the number of tries defined in ModemCfg->SMSSendRetries.
If the operation cannot end positively, both Command.SMSSend and Status.SMSSend are
automatically reset and Error.SMSSend is activated.
3 HangUp TRUE: It commands the MODEM hung-up and the Status.Connect is reset.
When the command is activated, the MODEM hangs-up, when the commands finishes the Command.
HangUp is automatically reset .
If the command doesn't end within the time defined in ModemCfg->HangUpTimeout, the Command.
HangUp are automatically reset and Error.HangUp is activated.
6 AnswerDisable TRUE: Disables and reset the count of the received ring. However the Status.Ring and Status.
RingFlag bits are managed and is returned the CLIP of the caller. Disabling the bit, after the number
of defined ring, the call its answered.
7 ResetError TRUE: It reset all the Error.
The command is automatically reset.
02 Status
Status bits, the user program can test these bits. they are reset, to forcing Command.Enable to FALSE.
0 Enabled TRUE: It shows that the FB is enabled.
1 Init TRUE: It shows that the initialization sequence is running. It's automatically set enabling the FB or if
an error occurs during the command management. It's reset at the end of the sequence.
2 Check TRUE: It shows that the MODEM cheek sequence is running. The sequence is automatically
activated during the execution of some commands or after the time defined in ModemCfg-
>CheckTime, it's reset at the end of the sequence.
3 Dial TRUE: It shows that the number dial sequence is running. It's activates on the Command.Dial
command, it's reset at the end of the sequence.
4 SMSSend TRUE: It shows that the SMS message send sequence is running. It's activates on the Command.
SMSSend command, it's reset at the end of the sequence.
5 SMSReceived It is activated for a program loop at the reception of a SMS message, The text of the received
message is in the buffer pointed by SMSRxBuf.
6 Ring It is activated for a program loop at every ring of an incoming call.
7 RingFlag It is activated for 1 second at every ring of an incoming call.
8 ModemOk TRUE: It shows that the MODEM has been correctly initialized and it's operative.
9 CLIPRxd It is activated for a program loop at the reception of a CLIP number. The received number is in the
buffer pointed by CLIPRxNumber.
B Connect TRUE: It shows that the MODEM is connected to a remote system.
It is activated after the execution of a Command.Dial or at the reception of a call after the number
of rings defined in ModemCfg->RingNr, only if the synchronization sequence between the two
MODEMs is correctly terminated.
When this bit is active, the FB doesn't use the serial line, that will be available for a dialog with the
remote system. No commands will be accepted except the Command.HangUp.
E PowerOn TRUE: It shows that the MODEM power on sequence is running. It's automatically set enabling the
FB or if an error occurs during the command management. It's reset at the end of the sequence.
F SwitchModemOn TRUE: It commands the MODEM switch on.
It must be copied by the user program to a logic output, it allows to manage the MODEM switch on
and off guaranteeing the possibility to completely reset the MODEM in case of errors.
04 Error
Error bits, the user program can test these bits. they are reset, to setting Command.ResetError or to forcing Command.
Enable to FALSE.
06 RingCtr
It returns the number of rings, the MODEM has received (Range from 0 to 255).
08 ModemCfg
Loaded by the user program, it defines the address on CODE memory, where the of MODEM configuration data
structure is defined.
For the MODEM configuration parameters a data structure is reported. The user program has to load in the data structure all
the initialization strings and the times needed by the MODEM used. We suggest to refer to the MODEM manual. The
initialization strings can contain many commands, commands are subdivided with the '\r' code, to every command the reply
string is waited. All the ' ' characters before the command are ignored.
typedef struct
{
// --------------------------------------------------------------[General]--
// --------------------------------------------------------[Init sequence]--
// -------------------------------------------------------[Check sequence]--
// --------------------------------------------------------------[Hang up]--
// ---------------------------------------------------------[Dial command]--
// -------------------------------------------------------[CLIP reception]--
00 OffTime
It defines the time in which the MODEM remains switched off after an error, Status.SwitchModemOn=FALSE. The
value is expressed in mSec (Range from 0 to 65535). Typically this value is set to 5000 mSec.
02 PowerOnTime
It defines the pause time between the MODEM switching on, Status.SwitchModemOn=TRUE and the send of the
initialization string InitCommand. The value is expressed in mSec (Range from 0 to 65535). At the the MODEM
switching on, it's necessary a relatively long time for the SIM card reading, so we suggest to set this value to 60000
mSec.
04 CmdWaitTime
It defines the pause time between the reception of an answer from the MODEM and the sending of a new command.
The value is expressed in mSec (Range from 0 to 65535). Typically this value is set to 500 mSec.
06 InitCommand
It defines the string to send to the MODEM to init it, it is sent after the MODEM is switched on Status.
SwitchModemOn=TRUE and the time defined in PowerOnTime.
Typically for the PSTN MODEM the initialization string is "ATV1\r AT&B1\r AT&K0\r ATH0X4E1L1\r".
Typically for the GSM MODEM the initialization string is "AT&F\r ATV1H0X3E1L1\r ATS0=0\r AT&D0\r AT+CLIP=1\r
AT+CMGF=1\r AT+CSMS=1\r AT+CNMI=3,3,0,0,1\r AT+CMGD=1\r".
ATTENTION! The MODEM must be always set in verbal answer mode, we suggest to insert in the initialization string the
command "ATV1" to set it.
09 InitAnswer
It defines the string the MODEM sends at the reception of the initialization string InitCommand. Typically this string is
"OK".
0C InitTimeout
It defines the initialization MODEM timeout time, when the time ends, the Error.Init is set and the initialization sequence
restarts. The value is expressed in mSec (Range from 0 to 65535). Typically this value is set to 2000 mSec.
0E CheckCommand
It defines the string to send to the MODEM to check it, it is sent cyclically according to the defined delay time
CheckTime. Typically this string is "AT\r".
11 CheckAnswer
It defines the string the MODEM sends at the reception of the control string CheckCommand. Typically this string is
"OK".
14 CheckTime
It defines the pause time between the sending of the check strings to the MODEM CheckCommand. The check
assures that the MODEM is always active, if an error in check is detect, the MODEM is initialized again. The value is
expressed in Sec (Range from 0 to 65535). Typically this value is set to 120 Sec.
16 CheckTimeout
It defines the check MODEM timeout time, when the time ends, the Error.Check is set and the MODEM is initialized
again. The value is expressed in mSec (Range from 0 to 65535). Typically this value is set to 2000 mSec.
18 SwitchToCommandModeCommand
It defines the string to send to the MODEM to switch it from data mode to control mode. Typically this string is "+++".
1B SwitchToCommandModeAnswer
It defines the string the MODEM sends at the reception of the switch to command mode command
SwitchToCommandModeCommand. Typically this string is "OK".
1E SwitchToCommandModePause
It defines the waiting time before sending the switch to command mode string to the MODEM. The value is expressed in
mSec (Range from 0 to 65535). Typically this value is set to 2000 mSec.
20 SwitchToCommandModeTimeout
It defines the switch to command mode timeout time, when the time ends, the Error.SwitchToCommand is set and the
MODEM is initialized again. The value is expressed in mSec (Range from 0 to 65535). Typically this value is set to 5000
mSec.
22 HangUpCommand
It defines the string to send to the MODEM to hang-up the line. Typically this string is "ATH0\r".
25 HangUpAnswer
It defines the string the MODEM answers at the reception of the hang-up command HangUpCommand. Typically this
string is "OK".
28 HangUpTimeout
It defines the hang-up command timeout time, when the time ends, the Error.HangUp is set and the MODEM is
initialized again. The value is expressed in mSec (Range from 0 to 65535). Typically this value is set to 2000 mSec.
2A IncomingCallHeader
It defines the string the MODEM sends when a phone call is received. Typically this string is "RING".
2D IncomingCallAccept
It defines the string to send to the MODEM to accept the incoming call. Typically this string is "ATA\r".
30 IncomingCallConnect
It defines the string the MODEM sends when the connection with the remote MODEM is established after an incoming
call. Typically this string is "CONNECT".
33 RingNr
it defines the number of expected rings before answering to an incoming call (Range from 0 to 255). If the value is set to
0, no answer to the incoming calls is executed.
34 IncomingCallTimeout
It defines the answer to an incoming call command timeout time, when the time ends, the Error.CallAnswer is set and
the MODEM is initialized again. The value is expressed in mSec (Range from 0 to 65535). Typically this value is set to
30000 mSec.
36 DialCommand
It defines the string to send to the MODEM to make a call. Typically this string is "ATDT".
39 DialAnswer
It defines the string the MODEM sends when the connection with the remote MODEM is established after a dial.
Typically this string is "CONNECT".
3C DialNumber
It defines the phone number string to call, on the Command.Dial command.
3F DialTries
It defines the number of tries if the connection with a remote system is not established before abort the call. (Range from
0 to 255). If the value is set to 0, the dial is repeated forever.
40 DialCommandTimeout
It defines the dial command timeout time, when the time ends, the time defined in InterDialTime is waited and then a
new call is made. After the defined number of tries defined in DialRetries, the Error.Dial is set and the MODEM is
initialized again. The value is expressed in mSec (Range from 0 to 65535). Typically this value is set to 60000 mSec.
42 InterDialTime
It defines the waiting time between a call in error and another try. The waiting time is from 1 to 4 times the value set. The
value is expressed in Sec (Range from 0 to 65535). Typically this value is set to 120 Sec.
44 SMSHeader
It defines the string the MODEM sends when a SMS message is received. Typically this string is "+CMTI: ".
47 SMSReadCommand
It defines the string to send to the MODEM to read the received SMS message. Typically this string is "AT+CMGR=1\r".
4A SMSReadAnswer
It defines the string the MODEM sends at the reception of the message read command SMSReadCommand. If the time
between the read string SMSReadCommand send and the reception of the read end string SMSReadEnd is more than
2 sec, the message reception sequence is aborted, the Error.SMSReceive is is set and the MODEM is initialized again.
Typically this string is "+CMGR:".
4D SMSReadEnd
It defines the string the MODEM sends at the end of the SMS read command. Typically this string is "OK".
50 SMSRxBuf
It defines the memory buffer address where the received SMS has to be transferred (Range from 0x0000 to 0xFFFF).
It's necessary to define a buffer of length suitable to contain the whole message (maximum 160 bytes). If not defined the
SMS reception isn't executed.
53 SMSRxLgt
It defines the memory buffer dimension where the received SMS has to be transferred (From 0 to 255). If the received
SMS message has length greather than the buffer dimension, the mesage is cropped and the bit Error.SMSReceive is
activated.
54 SMSSendCommand
It defines the string to send to the MODEM to send a SMS message. Typically this string is "AT+CMGS=".
57 SMSSendTerminator
It defines the string to send to the MODEM to end a SMS message. Typically this string is"\r\x1A".
5A SMSPrompt
It defines the string the MODEM sends to request the SMS text. Typically this string is ">".
5D SMSSendAnswer
It defines the string the MODEM sends at the end of the SMS sending. Typically this string is "+CMGS:".
60 SMSTxBuf
It defines the memory buffer address where the SMS to be transmit has to be transferred (Range from 0x0000 to
0xFFFF).
63 SMSNumber
It defines the phone number string to send the SMS, on the Command.SMSSend command.
66 SMSSendTries
It defines the number of tries if the SMS is non sent before abort the send. (Range from 0 to 255). If the value is set to 0,
the send is repeated forever.
67 SMSPromptWaitTime
It defines the prompt string SMSPrompt waiting timeout timet. Some models of MODEM don't send any prompt, so after
the defined time the message text is sent anyway. The value is expressed in mSec (Range from 0 to 65535). Typically
this value is set to 1000 mSec.
69 SMSSendTimeout
It defines the SMS send command timeout time, when the time ends, the time defined in InterSMSSendTime is waited
and then a new SMS send command is made. After the defined number of tries defined in SMSSendRetries, the Error.
SMSSend is set and the MODEM is initialized again. The value is expressed in mSec (Range from 0 to 65535).
Typically this value is set to 30000 mSec.
6B InterSMSSendTime
It defines the waiting time between a SMS send in error and another try. The waiting time is from 1 to 4 times the value
set. The value is expressed in Sec (Range from 0 to 65535). Typically this value is set to 120 Sec.
6D CLIPHeader
It defines the string the MODEM sends as a CLIP identifier. Typically this string is "+CLIP:".
70 CLIPNumber
It defines the memory buffer address where the received CLIP or the SMS sender numbr has to be transferred (Range
from 0x0000 to 0xFFFF). If not defined the CLIP management and the SMS reception aren't executed.
73 CLIPRxLgt
It defines the memory buffer dimension where the received CLIP has to be transferred (From 0 to 255). If the received
number has length greather than the buffer dimension, the number is cropped and the bit Error.CLIPReceive is
activated.
Examples
It's reported an example realized both in RIL and C language, it manages a TC35I Siemens GSM MODEM, the example
works on a PICOLOG Millennium system static version, with 16 inputs and 16 outputs. Connect the MODEM to the serial
port A with a Modem cable (Our code CBL055*000), to test the MODEM connect the logic I/O according the following table:
RIL example
The FB can be used in a RIL program however it's necessary a C file with the MODEM configuration parameters, following
we report the TC35I Siemens configuation parameters.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbModemMng.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// MODEM CONFIGURATION STRUCTURE
// -----------------------------------------------------------------------------
// In this structure are reported all the commands and answer strings used to
// set up the MODEM. In order to correctly configure your MODEM please refer to
// the MODEM manual.
// -----------------------------------------------------------------------------
5000, //OffTime
60000, //PowerOnTime
500, //CmdWaitTime
// --------------------------------------------------------[Init sequence]--
// -------------------------------------------------------[Check sequence]--
"AT\r", //CheckCommand
"OK", //CheckAnswer
120, //CheckTime
2000, //CheckTimeout
"+++", //SwitchToCommandModeCommand
"OK", //SwitchToCommandModeAnswer
2000, //SwitchToCommandModePause
5000, //SwitchToCommandModeTimeout
// --------------------------------------------------------------[Hang up]--
"ATH0\r", //HangUpCommand
"OK", //HangUpAnswer
2000, //HangUpTimeout
"RING", //IncomingCallHeader
"ATA\r", //IncomingCallAccept
"CONNECT", //IncomingCallConnect
3, //RingNr
30000, //IncomingCallTimeout
// ---------------------------------------------------------[Dial command]--
"ATDT", //DialCommand
"CONNECT", //DialAnswer
"+390142451987", //DialNumber
3, //DialTries
60000, //DialCommandTimeout
120, //InterDialTime
"+CMTI:", //SMSHeader
"AT+CMGR=1\r", //SMSReadCommand
"+CMGR:", //SMSReadAnswer
"OK", //SMSReadEnd
&SMSRxBuf, //SMSRxBuf
sizeof(SMSRxBuf), //SMSRxLgt
"AT+CMGS=", //SMSSendCommand
"\r\x1A", //SMSSendTerminator
">", //SMSPrompt
"+CMGS:", //SMSSendAnswer
"This is a message", //SMSTxBuf
"+390142451987", //SMSNumber
3, //SMSSendTries
1000, //SMSPromptWaitTime
30000, //SMSSendTimeout
120, //InterSMSSendTime
// -------------------------------------------------------[CLIP reception]--
// [End of file]
; ------------------------------------------------------------------------------
; @Section("External definitions")
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; Set serial parameters function block data structure.
DEFL Y SetS KD 16
DEFL Y SetSMode Y SetS KH 0000 ;SetS.Mode
DEFL Y SetSBaud Y SetS KH 0001 ;SetS.Baud
DEFL Y SetSDTRMng Y SetS KH 0002 ;SetS.DTRMng
DEFL W SetSDTROnTime Y SetS KH 0004 ;SetS.DTROnTime
DEFL W SetSDTROffTime Y SetS KH 0006 ;SetS.DTROffTime
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; Modem management function block data structure.
DEFG Y Mdm KD 64
DEFG Y MdmCommand Y Mdm KH 0000 ;Mdm.Command
DEFG W MdmStatus Y Mdm KH 0002 ;Mdm.Status
DEFG W MdmError Y Mdm KH 0004 ;Mdm.Error
DEFG Y MdmRingCtr Y Mdm KH 0006 ;Mdm.RingCtr
DEFG W MdmModemCfg Y Mdm KH 0008 ;Mdm.ModemCfg
; ------------------------------------------------------------------------------
; @Section("Serial port definition")
; ------------------------------------------------------------------------------
; Here the serial port is set.
ORGR
SETR
SETV KE IOSerialPortA
; ------------------------------------------------------------------------------
; @Section("Set the serial parameters")
; ------------------------------------------------------------------------------
; Here the serial parameters "9600, n, 8" are set on the serial port "A".
ORGR
LODT F PLCFirstLoop
UTCH Y SetSMode BH 0000 ;SetS.Mode.DTRComplement
UTCH Y SetSMode BH 0001 ;SetS.Mode.EchoFlush
LTCH Y SetSMode BH 0002 ;SetS.Mode.RxCtrlDisable
UTCH Y SetSMode BH 0003 ;SetS.Mode.ParityEnabled
UTCH Y SetSMode BH 0004 ;SetS.Mode.ParityType
LTCH Y SetSMode BH 0005 ;SetS.Mode.BitNumber
UTCH Y SetSMode BH 0006 ;SetS.Mode.WaitLoop
MOVI Y SetSBaud KD 5 ;SetS.Baud
MOVI Y SetSDTRMng KD 0 ;SetS.DTRMng
MOVI W SetSDTROnTime KD 0 ;SetS.DTROnTime
; ------------------------------------------------------------------------------
; @Section("Modem management")
; ------------------------------------------------------------------------------
; The logic inputs are copied to the modem management function block commands.
ORGR
SETR
IOAQ K 0000
STRA Y MdmCommand ;Mdm.Command
ORGR
SETR
TASK L FbModemMng Y Mdm ;Modem managent function block
; The modem management function block status is copied to the logic outputs.
ORGR
SETR
LODA W MdmStatus ;Mdm.Status
IOAQ K 0100
LODA W MdmStatus ;Mdm.Status
RORA K 0008
IOAQ K 0101
; [End of file]
"C" example
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <string.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbModemMng.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
"+390142451988",
"+390142451987",
};
// -----------------------------------------------------------------------------
// MODEM CONFIGURATION STRUCTURE
// -----------------------------------------------------------------------------
// In this structure are reported all the commands and answer strings used to
// set up the MODEM. In order to correctly configure your MODEM please refer to
// the MODEM manual.
// -----------------------------------------------------------------------------
5000, //OffTime
60000, //PowerOnTime
500, //CmdWaitTime
// --------------------------------------------------------[Init sequence]--
// -------------------------------------------------------[Check sequence]--
"AT\r", //CheckCommand
"OK", //CheckAnswer
120, //CheckTime
2000, //CheckTimeout
"+++", //SwitchToCommandModeCommand
"OK", //SwitchToCommandModeAnswer
2000, //SwitchToCommandModePause
5000, //SwitchToCommandModeTimeout
// --------------------------------------------------------------[Hang up]--
"ATH0\r", //HangUpCommand
"OK", //HangUpAnswer
2000, //HangUpTimeout
"RING", //IncomingCallHeader
"ATA\r", //IncomingCallAccept
"CONNECT", //IncomingCallConnect
3, //RingNr
30000, //IncomingCallTimeout
// ---------------------------------------------------------[Dial command]--
"ATDT", //DialCommand
"CONNECT", //DialAnswer
"+390142451987", //DialNumber
3, //DialTries
60000, //DialCommandTimeout
120, //InterDialTime
"+CMTI:", //SMSHeader
"AT+CMGR=1\r", //SMSReadCommand
"+CMGR:", //SMSReadAnswer
"OK", //SMSReadEnd
&SMSRxBuf, //SMSRxBuf
sizeof(SMSRxBuf), //SMSRxLgt
"AT+CMGS=", //SMSSendCommand
"\r\x1A", //SMSSendTerminator
">", //SMSPrompt
"+CMGS:", //SMSSendAnswer
"This is a message", //SMSTxBuf
"+390142451987", //SMSNumber
3, //SMSSendTries
1000, //SMSPromptWaitTime
30000, //SMSSendTimeout
120, //InterSMSSendTime
// -------------------------------------------------------[CLIP reception]--
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// SERIAL LINE DEFINITION
// -------------------------------------------------------------------------
// Here define the serial line used to manage the MODEM.
SetTermIOVectors(IOSerialPortB);
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute the system init.
if (PLCFirstLoop)
{
// Set the serial communication parameters: "9600, n, 8".
// -------------------------------------------------------------------------
// LOGIC I/O MANAGEMENT
// -------------------------------------------------------------------------
// Here acquire the 8 logic input from I 0000 to I 0007.
// Here copy the Mdm.Status to the 16 logic output from O 0000 to O 000F.
// -------------------------------------------------------------------------
// MODEM MANAGEMENT
// -------------------------------------------------------------------------
// Execute the modem management function block.
// -------------------------------------------------------------------------
// RESULTS MANAGEMENT
// -------------------------------------------------------------------------
// Compare the CLIP with the defined numbers and if it matches a bit is set.
if (Mdm.Status.CLIPRxd)
{
NumberFound=FALSE; //The Clip number matches one of the phone numbers defined
// Check the received message, if the message is "On" a bit is set, if the
// message is "Off" the bit is reset.
if (Mdm.Status.SMSReceived)
{
if (!strcmp(&SMSRxBuf, "On"))
CommandBit=TRUE; //SMS received command
if (!strcmp(&SMSRxBuf, "Off"))
// [End of file]
Function blocks
FbNetlogAD
This function block allows the analog input acquisition on Netlog systems, there are 4 analog inputs with range
from 0 to 10 volts, the resolution of the converter is 12 bits.
ATTENTION! Because of the input divider, the full scale of 10 volts in input corresponds to an acquired value of
3810.
Declaration
void FbNetlogAD(FBNETLOGADDATA* S);
Parameters
FBNETLOGADDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 12 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// ----------------------[Members that can be managed by the user program]--
struct
{
BOOL Enable:1; //FB enable
}Command;
struct
{
BOOL Enabled:1; //FB enabled
BOOL DataReady:1; //Data ready
BOOL b2:1;
BOOL b3:1;
BOOL Timeout:1; //Conversion timeout error
BOOL ModuleAddress:1; //Module address error
BOOL BusRetry:1; //Bus access retry
BOOL BusFault:1; //Extension bus error
}Status;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB and resets Status.
TRUE: Enables the FB to acquire the analog input.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: The FB is enabled.
1 DataReady TRUE: The analog value has been acquired and it is available.
4 Timeout TRUE: Conversion timeout error
5 ModuleAddress TRUE: Module address error, the specified Module is not available.
6 BusRetry TRUE: Repeated the access to the peripheral bus.
7 BusFault TRUE: Access to the peripheral bus error.
02 Module
Loaded by user program it defines the module address from which execute the analog acquisition (Range
from 0x00 to 0x07). The value 0x00 is the base module, 0x01 is the first extension module and so on. The
setting of a module address that is not present, aborts the acquisition and sets the proper error bit in Status.
03 ADChannel
Loaded by user program it defines the channel on the module from which execute the analog acquisition,
(Range from 0x00 to 0x03).
04 ADValue
Returns the acquired value expressed in bits. Netlog modules acquire only positive values of tension with
range between 0 to 10 volt. To calculate the voltage value it is necessary to consider the reading error
introduced by the input divider, to calculate the voltage value the formula Voltage=
(10*Value acquired )/3810 must be used (Range from 0x0000 to 0x0FFF).
RIL example
In the following example is acquired the analog input channel 0 of the base module. Debugging the operand
FL VoltageIn it's possible to display the analog value acquired, expressed in volt.
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Local variables definition")
; ------------------------------------------------------------------------------
; Netlog A/D data structure.
DEFL Y ADs KD 12
DEFL Y ADsCommand Y ADs KH 0000 ; ADs.Command
DEFL Y ADsStatus Y ADs KH 0001 ; ADs.Status
DEFL Y ADsModule Y ADs KH 0002 ; ADs.Module
DEFL Y ADsADChannel Y ADs KH 0003 ; ADs.ADChannel
DEFL W ADsADValue Y ADs KH 0004 ; ADs.ADValue
; ------------------------------------------------------------------------------
; @Section("A/D acquisition")
; ------------------------------------------------------------------------------
; Function block setup parameters.
ORGR
LODT F PLCFirstLoop
MOVI Y ADsModule K 0000 ; ADs.Module
MOVI Y ADsADChannel K 0000 ; ADs.ADChannel
ORGR
SETR
OUTT Y ADsCommand K 0000 ; ADs.Command.Enable
TASK L FbNetlogAD Y ADs ; Netlog A/D function block
ORGR
LODT Y ADsStatus K 0001 ; ADs.Status.DataReady
LODA KF 381.000000
LODA W ADsADValue ; ADs.ADValue
FLTC
FDIV
STRA FL VoltageIn ; Input voltage
; [End of file]
"C" example
In the following example is acquired the analog input channel 0 of the base module. Debugging the variable
VoltageIn it's possible to display the analog value acquired, expressed in volt.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbNetlogAD.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLE DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
if (PLCFirstLoop)
{
ADs.Command.Enable=TRUE; //FB enable
ADs.Module=0; //Module address
ADs.ADChannel=0; //A/D channel
}
if (ADs.Status.DataReady)
VoltageIn=(10.0*ADs.ADValue)/3810.0; //Voltage value (V)
}
// [End of file]
Function blocks
FbNetlogDA
This function block allows the analog output management on Netlog systems, there are 2 analog outputs with
range from 0 to 2.5 volts, the resolution of the converter is 12 bits.
Declaration
void FbNetlogDA(FBNETLOGDADATA *S);
Parameters
FBNETLOGDADATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 12 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// ----------------------[Members that can be managed by the user program]--
struct
{
BOOL Enable:1; //FB enable
}Command;
struct
{
BOOL Enabled:1; //FB enabled
BOOL b1:1;
BOOL b2:1;
BOOL b3:1;
BOOL b4:1;
BOOL ModuleAddress:1; //Module address error
BOOL BusRetry:1; //Bus access retry
BOOL BusFault:1; //Extension bus error
}Status;
...
}FBNETLOGDADATA;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB and resets Status.
TRUE: Enables the FB to manage the analog output.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: The FB is enabled.
5 ModuleAddress TRUE: Module address error, the specified Module is not available.
6 BusRetry TRUE: Repeated the access to the peripheral bus.
7 BusFault TRUE: Access to the peripheral bus error.
02 Module
Loaded by user program it defines the module address to which manage the analog output (Range from
0x00 to 0x07). The value 0x00 is the base module, 0x01 is the first extension module and so on. The setting
of a module address that is not present, aborts the acquisition and sets the proper error bit in Status.
03 DAChannel
Loaded by user program it defines the channel on the module to which manage the analog output, (Range
from 0x00 to 0x01).
04 DAValue
Loaded by user program it defines the output value expressed in bits. The Netlog modules manage only
positive values of tension with range between 0 to 2,5 volt. To calculate the value to be set, the formula
Value to be set=(Voltage*4095)/2.5 must be used (Range from 0x0000 to 0x0FFF).
RIL example
In the following example is managed the analog output channel 0 of the base module. Debugging the operand
FL VoltageOut it's possible to set the analog value expressed in volt.
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Local variables definition")
; ------------------------------------------------------------------------------
; Function block data structure.
DEFL Y DAs KD 12
DEFL Y DAsCommand Y DAs KH 0000 ; DAs.Command
DEFL Y DAsStatus Y DAs KH 0001 ; DAs.Status
DEFL Y DAsModule Y DAs KH 0002 ; DAs.Module
DEFL Y DAsDAChannel Y DAs KH 0003 ; DAs.DAChannel
DEFL W DAsDAValue Y DAs KH 0004 ; DAs.DAValue
; ------------------------------------------------------------------------------
; @Section("D/A management")
; ------------------------------------------------------------------------------
; Function block setup parameters.
ORGR
LODT F PLCFirstLoop
MOVI Y DAsModule K 0000 ; DAs.Module
MOVI Y DAsDAChannel K 0000 ; DAs.DAChannel
ORGR
SETR
LODA FL VoltageOut ; Output voltage
LODA KF 4095.000000
FMUL
LODA KF 2.500000
XCHA
FDIV
FIXC
STRA W DAsDAValue ; DAs.DAValue
ORGR
SETR
OUTT Y DAsCommand K 0000 ; DAs.Command.Enable
TASK L FbNetlogDA Y DAs ; D/A channel management
; [End of file]
"C" example
In the following example is managed the analog output channel 0 of the base module. Debugging the variable
VoltageOut it's possible to set the analog value expressed in volt.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbNetlogDA.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLE DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
if (PLCFirstLoop)
{
DAs.Command.Enable=TRUE; //FB enable
DAs.Module=0; //Module address
DAs.DAChannel=0; //D/A channel
}
// [End of file]
Function blocks
FbNetlogIIAD
This function block allows the analog input acquisition on NetlogII systems, are present 4 analog inputs with different
possibility of acquisition, voltage, current and temperature. If the configuration data area has an error SystemErrors.
SystemCfg=TRUE, the acquisition is disabled and it returns the value 0. If the module address is not set properly the
acquisition is disabled, the value 0 is returned and the SystemErrors.FBParameters bit is set.
Declaration
void FbNetlogIIAD(FBNETLOGIIADDATA* S);
Parameters
FBNETLOGIIADDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 80 bytes data structure, we report a prototype. The members reported under the Internal use
only members label, are members used inside by the function block and they don't have to be changed by the user
program.
typedef struct
{
// ----------------------[Members that can be managed by the user program]--
struct
{
BOOL Enable:1; //Enable
BOOL Calibration:1; //Calibration command
BOOL UnipolarAcq:1; //Unipolar acquisition
BOOL b3:1;
BOOL Adjustment:1; //Adjustment command
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Command;
struct
{
BOOL Enabled:1; //Enabled
BOOL DataReady:1; //Data ready
BOOL b2:1;
BOOL b3:1;
BOOL Timeout:1; //Conversion timeout error
BOOL ModuleAddress:1; //Module address error
BOOL b6:1;
BOOL BusFault:1; //Extension bus error
}Status;
}FBNETLOGADDATA;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB and resets Status.
TRUE: Enables the FB to acquire the analog inputs. When enabled it's automatically executed a
calibration cycle.
1 Calibration Activated it forces the execution of the calibration sequence, it's automatically reset. When it's
activated the Status.DataReady will not be activated until the calibration sequence is end.
2 UnipolarAcq Activated it dforces the unipolar acquisition. All negatives values acquired will be zeroed.
4 Adjustment TRUE: Force the FB to be used in adjustment mode. It should not be used by the user program.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: The FB is enabled.
1 DataReady TRUE: The analog value has been acquired and it's available. It's active only for a program loop at
every acquisition end.
4 Timeout TRUE: Conversion timeout error
5 ModuleAddress TRUE: Module address error, the specified Module is not available.
6 BusRetry TRUE: Repeated the access to the peripheral bus.
7 BusFault TRUE: Access to the peripheral bus error.
02 Module
Loaded by user program it defines the module address from which execute the analog acquisition (Range from 0x00
to 0x07). The value 0x00 is the base module, 0x01 is the first extension module and so on. The setting of a module
address that is not present, aborts the acquisition and sets the proper error bit in Status.
04 Mode (Channel 0)
05 Mode (Channel 1)
06 Mode (Channel 2)
07 Mode (Channel 3)
It's necessary to specify the analog acquisition mode, according to the following table. If the acquisition mode is
changed during the acquisition, it's executed a new calibration with the new acquisition mode. In differential mode
only two channels are used Channel 0 e Channel 1.
08 Filter (Channel 0)
09 Filter (Channel 1)
0A Filter (Channel 2)
0B Filter (Channel 3)
It's necessary to specify the value of the filter to be applied on the acquired value. Values less than 2 exclude the
filter (Range from 0x00 to 0xFF).
10 Value (Channel 0)
14 Value (Channel 1)
18 Value (Channel 2)
1C Value (Channel 3)
Returns the acquisition value expressed in the measure unit defined by the acqisition mode.
Calibration
The analog acquisition is made by a 24 bits converter, so to avoid offset and gain errors, it's necessary to execute a
calibration cycle before to acquire the analog value. Calibration it's automatically executed when the FB is enableb, when
the Command.Calibration bit is set and when the acquisition mode is changed on a channel.
RIL example
In the following example it's executed the acquisition of all the 4 channels of the base module. The acquisition is executed
on mode 1 from 0 to 10 volts. The analog value acquired from every channel is visible by executing the debug of the
operands FL ADsValue0, FL ADsValue1, FL ADsValue2, FL ADsValue3.
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Local variables definition")
; ------------------------------------------------------------------------------
; NetlogII A/D data structure.
DEFL Y ADs KD 80
DEFL Y ADsCommand Y ADs KH 0000 ;ADs.Command
DEFL Y ADsStatus Y ADs KH 0001 ;ADs.Status
DEFL Y ADsModule Y ADs KH 0002 ;ADs.Module
DEFL Y ADsMode0 Y ADs KH 0004 ;ADs.Mode[0]
DEFL Y ADsMode1 Y ADs KH 0005 ;ADs.Mode[1]
; ------------------------------------------------------------------------------
; @Section("A/D acquisition")
; ------------------------------------------------------------------------------
; Here the function block parameters are set.
; All channels are set in acquisition mode "2".
ORGR
LODT F PLCFirstLoop
LTCH Y ADsCommand BD 0 ;ADs.Command.Enable
MOVI Y ADsModule KH 0000 ;ADs.Module
MOVI Y ADsMode0 KH 0002 ;ADs.Mode[0]
MOVI Y ADsMode1 KH 0002 ;ADs.Mode[1]
MOVI Y ADsMode2 KH 0002 ;ADs.Mode[2]
MOVI Y ADsMode3 KH 0002 ;ADs.Mode[3]
ORGR
SETR
TASK L FbNetlogIIAD Y ADs ;Netlog A/D functional block
ORGR
LODT Y ADsStatus K 0001 ;ADs.Status.DataReady
MOVM FL VoltageIn0 FL ADsValue0 ;Input voltage Ch 0
MOVM FL VoltageIn1 FL ADsValue1 ;Input voltage Ch 1
MOVM FL VoltageIn2 FL ADsValue2 ;Input voltage Ch 2
MOVM FL VoltageIn3 FL ADsValue3 ;Input voltage Ch 3
; [End of file]
"C" example
In the following example it's executed the acquisition of all the 4 channels of the base module. The acquisition is executed
on mode 1 from 0 to 10 volts.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbNetlogIIAD.h>
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
if (PLCFirstLoop)
{
ADs.Command.Enable=TRUE; //FB enable
ADs.Module=0; //Module address
ADs.Mode[0]=0x02; //Mode
ADs.Mode[1]=0x02; //Mode
ADs.Mode[2]=0x02; //Mode
ADs.Mode[3]=0x02; //Mode
}
if (ADs.Status.DataReady)
for (i=0; i<4; i++)
VoltageIn[i]=ADs.Value[i]; //Voltage value (V)
}
// [End of file]
Function blocks
FbNetlogIIDA
This function block allows the analog output management on NetlogII systems, there are 2 analog outputs with
range from 0 to 10 volts, the resolution of the converter is 12 bits. If the configuration data area has an error
SystemErrors.HardwareCfg=TRUE, the management is disabled and the output value is set to 0. If the module
address is not set properly the management is disabled, the output value is set to 0 and the SystemErrors.
FBParameters is set.
Declaration
void FbNetlogIIDA(FBNETLOGIIDADATA *S);
Parameters
FBNETLOGIIDADATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 32 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// ----------------------[Members that can be managed by the user program]--
struct
{
BOOL Enable:1; //Enable
BOOL b1:1;
BOOL b2:1;
BOOL b3:1;
BOOL Adjustment:1; //Adjustment command
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Command;
struct
{
BOOL Enabled:1; //FB enabled
BOOL DataSet:1; //Data set
BOOL b2:1;
BOOL b3:1;
BOOL b4:1;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB and resets Status.
TRUE: Enables the FB to manage the analog output.
4 Adjustment TRUE: Force the FB to be used in adjustment mode. It should not be used by the user program.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: The FB is enabled.
1 DataSet TRUE: The analog value was transferred to the output (one shot, it remains active for a
program loop to every transfer on all the channels).
5 ModuleAddress TRUE: Module address error, the specified Module is not available.
6 BusRetry TRUE: Repeated the access to the peripheral bus.
7 BusFault TRUE: Access to the peripheral bus error.
02 Module
Loaded by user program it defines the module address to which manage the analog output (Range from 0x00
to 0x07). The value 0x00 is the base module, 0x01 is the first extension module and so on. The setting of a
module address that is not present, aborts the acquisition and sets the proper error bit in Status.
The module address 0x00 can be set only on target systems based on ADuC845 microcontroller.
04 Mode (Channel 0)
05 Mode (Channel 1)
It's necessary to specify the analog output mode, according to the following table.
Mode Function Channels Output value
08 Value (Channel 0)
0C Value (Channel 1)
Loaded by user program it defines the output value expressed in measure unit defined by the selected mode.
RIL example
In the following example is managed the analog output channels of the base module. By debugging the operands
FL Ch0Voltage and FL Ch1Voltage it's possible to set the analog value expressed in volt.
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Local variables definition")
; ------------------------------------------------------------------------------
; Function block data structure.
DEFL Y DAs KD 32
DEFL Y DAsCommand Y DAs KH 0000 ;DAs.Command
DEFL Y DAsStatus Y DAs KH 0001 ;DAs.Status
DEFL Y DAsModule Y DAs KH 0002 ;DAs.Module
DEFL Y DAsMode0 Y DAs KH 0004 ;DAs.Mode[0]
DEFL Y DAsMode1 Y DAs KH 0005 ;DAs.Mode[1]
DEFL FL DAsValue0 Y DAs KH 0008 ;DAs.Value[0]
DEFL FL DAsValue1 Y DAs KH 000C ;DAs.Value[1]
; ------------------------------------------------------------------------------
; @Section("D/A management")
; ------------------------------------------------------------------------------
; Function block setup parameters.
ORGR
LODT F PLCFirstLoop
LTCH Y DAsCommand BD 0 ;DAs.Command.Enable
MOVI Y DAsModule KH 0000 ;DAs.Module
MOVI Y DAsMode0 KH 0001 ;DAs.Mode[0]
MOVI Y DAsMode1 KH 0001 ;DAs.Mode[1]
ORGR
LODT Y DAsStatus BD 1 ;DAs.Status.DataSet
MOVM FL DAsValue0 FL Ch0Voltage ;DAs.Value[0]
MOVM FL DAsValue1 FL Ch1Voltage ;DAs.Value[1]
ORGR
SETR
TASK L FbNetlogIIDA Y DAs ;D/A channel management
; [End of file]
"C" example
In the following example are managed the analog output channels of the base module. By debugging the variables
Ch0Voltage and Ch1Voltage it's possible to set the analog value expressed in volt.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbNetlogIIDA.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLE DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
if (PLCFirstLoop)
{
DAs.Command.Enable=TRUE; //FB enable
DAs.Module=0; //Module address
DAs.Mode[0]=1; //Mode
DAs.Mode[1]=1; //Mode
}
// [End of file]
Function blocks
FbPicofaceSerial
This function block allows the management of a Picoface terminal connected thru the serial line on any target system. The
Picoface terminal must be the serial type and the proper serial driver Sfw106 must run on it. The terminal is managed as it
is directly connected to the system and it's possible to use also the FbSysTerminal FB to manage it.
Declaration
void FbPicofaceSerial(FBPICOFACESERIALDATA* S);
Parameters
FBPICOFACESERIALDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 128 bytes data structure, we report a prototype. The members reported under the Internal use
only members label, are members used inside by the function block and they don't have to be changed by the user
program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //FB enable
BOOL b1:1;
BOOL b2:1;
BOOL b3:1;
BOOL b4:1;
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Command;
struct
{
BOOL Enabled:1; //FB enabled
BOOL b1:1;
BOOL b2:1;
BOOL b3:1;
BOOL CommOk:1; //Communication ok
BOOL TimeoutError:1; //Terminal timeout error
BOOL b6:1;
BOOL b7:1;
}Status;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB and resets Status.
TRUE: Enables the FB.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: The FB is enabled.
4 CommOk TRUE: The communication with the Picoface terminal is ok.
5 TimeoutError TRUE: Timeout error on Picoface terminal serial communication.
02 TrmCommand
Loaded by user program, the loaded value is sent to the Picoface terminal as command byte (Range from 0x00 to
0xFF).
03 TrmStatus
Returns the status byte read from the Picoface terminal (Range from 0x00 to 0xFF).
04 IOVector
Returns the TERMIOVECTORS vector address.
RIL example
The following example inserted in a Remoter project, by using the terminal management graphic utility with the vector set
as W PcSIOVector, the display target Picoface and terminal address 0, allows to manage a Picoface terminal connected
to the serial port A.
Figure 1
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; FbPicofaceSerial driver, function block data structure.
; ------------------------------------------------------------------------------
; @Section("PICOFACE serial management")
; ------------------------------------------------------------------------------
; Set the port where the serial Picoface is connected and open it.
ORGR
SETR
SETV KE IOSerialPortA
ORGR
LODT F PLCFirstLoop
TASK L TermIOOpen ;Open the I/O console
ORGR
SETR
OUTT Y PcSCommand BD 0 ;PcS.Command.Enable
TASK L FbPicofaceSerial Y PcS ;FbPicofaceSerial management
ORGR
LODT F PLCFirstLoop
SETV W PcSIOVector ;PcS.IOVector
TASK L TermIOOpen ;Open the I/O console
; [End of file]
"C" example
In the following example a Picoface terminal connected to the serial port A is managed. Two variables are displayed and
data entry can be made on them.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbPicofaceSerial.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
// -------------------------------------------------------------------------
// MANAGE THE SERIAL PICOFACE TERMINAL
// -------------------------------------------------------------------------
// Set the serial port used to manage the Picoface terminal.
if (PLCFirstLoop)
{
TermIOOpen(); //Open the I/O console
PcS.Command.Enable=TRUE; //FB enable
Ts.TerminalAddress=0x00; //Terminal address
Ts.KeyboardTimeOut=5000; //Keyboard timeout definition
Ts.LEDCommand.LCDBacklight=TRUE; //LCD backlight command
}
// Set the terminal as standard I/O console and call the terminal
// management function, it must be called after the variables init.
// Copy the Keyboard status to the LED for keys [0] and [1].
if (Ts.Status.RefreshEnd)
printf("\nVarInt : %05d VarFloat: %05.1f ", VarInt, VarFloat);
// By pressing the [CLR] key, it's possible to select the parameter must be
// set. Please note that the parameter is select only if the [CLR] key is
// pressed as a first key.
if (Ts.Status.InputDataSkipped)
ParameterPtr^=TRUE; //Input parameter pointer
// If no keys are pressed, after the set timeout time the data input is
if (Ts.Status.KeyboardTimeOut)
ParameterPtr=FALSE; //Input parameter pointer
// When the data input is finished the value is stored into the variable.
if (Ts.Status.InputDataEnd)
if (!ParameterPtr)
scanf("%d", &VarInt);
else
scanf("%f", &VarFloat);
}
// [End of file]
Function blocks
FbPIDMng
Declaration
void FbPIDMng(FBPIDMNGDATA *S);
Parameters
FBPIDMNGDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 64 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //Regulation enable
BOOL b1:1;
BOOL IRegEnable:1; //I regulation enable
BOOL DRegEnable:1; //D regulation enable
BOOL b4:1;
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Command;
struct
{
BOOL Enabled:1; //Regulation enabled
BOOL b1:1;
BOOL b2:1;
BOOL OutLimit:1; //Output limit reached
BOOL IRegWorks:1; //I correction works
BOOL DRegWorks:1; //D correction works
BOOL b6:1;
BOOL b7:1;
}Status;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB and resets Status.
TRUE: Enables the FB.
2 IRegEnable TRUE: Enables the integrative regulation.
3 DRegEnable TRUE: Enables the derivative regulation.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: The FB is enabled.
3 OutLimit TRUE: The output value OutValue as reached the OutLimit value.
4 IRegWorks TRUE: The integrative regulation is enabled.
5 DRegWorks TRUE: The derivative regulation is enabled.
04 St
Loaded by user program it defines the FB scansion time. If executed on the main program have the program
scansion time must be copied. If executed on temporal interrupt interrupt time must be copied. The value is
expressed in mSec.
08 Pe
Loaded by user program it defines the process error. Process error is obtained by the subtraction of the
feedback value from the set point value of the process to control Pe=SetPoint-Feedback. The value is
expressed in the process to control measure unit.
0C Kp
Loaded by user program it defines the proportional coefficient. We remind that bigger is the value faster is
the regulation with an increasing of the overshot effect. The value is expressed as a number.
10 It
Loaded by user program it defines the integrative time. We remind that bigger is the value slower is the
integrative regulation to minimize the error. The value is expressed in second.
14 Dt
Loaded by user program it defines the derivative time. We remind that the bigger is the value faster is the
derivative regulation to minimize the error. The value is expressed in second.
18 Nb
Loaded by user program it defines the near band value. This value defines the error value more than the
regulation is disabled and the output value is set to its limit OutLimit. The value is expressed in the measure
unit of the process to control.
1C OutLimit
Loaded by user program it defines the output value limit. When the PID loop has an outputs value bigger
than the limit, the output value is limited to the limit value. The value is expressed in the measure unit of the
process to control.
20 OutValue
Returns the PID loop correction value. This value has to be used to command the process. The value is
expressed in the measure unit of the process to control.
RIL example
; ------------------------------------------------------------------------------
; @Section("Global definitions")
; ------------------------------------------------------------------------------
; Process variables.
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; PIDs management data structure.
DEFL Y PIDs KD 64
DEFL Y PIDsCommand Y PIDs KH 0000 ;PIDs.Command
DEFL Y PIDsStatus Y PIDs KH 0001 ;PIDs.Status
DEFL FL PIDsSt Y PIDs KH 0004 ;PIDs.St
DEFL FL PIDsPe Y PIDs KH 0008 ;PIDs.Pe
DEFL FL PIDsKp Y PIDs KH 000C ;PIDs.Kp
DEFL FL PIDsIt Y PIDs KH 0010 ;PIDs.It
DEFL FL PIDsDt Y PIDs KH 0014 ;PIDs.Dt
DEFL FL PIDsNb Y PIDs KH 0018 ;PIDs.Nb
DEFL FL PIDsOutLimit Y PIDs KH 001C ;PIDs.OutLimit
DEFL FL PIDsOutValue Y PIDs KH 0020 ;PIDs.OutValue
; ------------------------------------------------------------------------------
; @Section("Init")
; ------------------------------------------------------------------------------
; Function block setup parameters.
ORGR
LODT F PLCFirstLoop
LTCH Y PIDsCommand K 0000 ;PIDs.Command.Enable
LTCH Y PIDsCommand K 0002 ;PIDs.Command.IRegEnable
LTCH Y PIDsCommand K 0003 ;PIDs.Command.DRegEnable
MOVI FL PIDsKp KF 10.000000 ;PIDs.Kp
MOVI FL PIDsIt KF 2.000000 ;PIDs.It
; ------------------------------------------------------------------------------
; @Section("PIDs management")
; ------------------------------------------------------------------------------
; Here the scansion time is passed to the FB.
ORGR
SETR
LODA W PLCLoopTime
FLTC
STRA FL PIDsSt ;PIDs.St
; [End of file]
"C" example
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbPIDMng.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLE DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
static FBPIDMNGDATA PIDs; //PID management data structure
if (PLCFirstLoop)
{
PIDs.Command.Enable=TRUE; //Regulation enable
PIDs.Command.IRegEnable=TRUE; //I regulation enable
PIDs.Command.DRegEnable=TRUE; //D regulation enable
PIDs.Kp=10.0; //Proportional coefficent (Nr)
PIDs.It=2.0; //Integrative time (Sec)
PIDs.Dt=1.0; //Derivative time (Sec)
PIDs.Nb=50.0; //Near band
PIDs.OutLimit=1000.0; //Output limit
}
// [End of file]
Function blocks
FbPsystADSubm
This function block allows to manage the A/D submodule for the Picosyst family coprocessor module.
Declaration
void FbPsystADSubm(FBPSYSTADSUBMDATA* S);
Parameters
FBPSYSTADSUBMDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 24 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// ----------------------[Members that can be managed by the user program]--
struct
{
BOOL Enable:1; //Channel enable
BOOL Reset:1; //Channel reset
BOOL EnableReadPulse:1; //Enable read pulse
BOOL ReadPulse:1; //Read pulse
BOOL Utility:2; //Channel utility
BOOL PostFiltering:1; //Channel post filtering
BOOL b7:1;
}Command; //Command
struct
{
BOOL Enabled:1; //Channel enabled
BOOL DataReady:1; //Readed data is valid
BOOL EndCycle:1; //End of read cycle
BOOL b3:1;
BOOL b4:1;
BOOL TimeoutError:1; //Channel timeout error
BOOL ConversionError:1; //Channel conversion error
BOOL b7:1;
}Status; //Status
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB and stops the dialogue with the coprocessor module.
TRUE: Enables the FB and starts the dialogue with the coprocessor module.
1 Reset FALSE: Normal working.
TRUE: Commands a channel reset. This should be used to set new values for
OutMode, ScaleFactor, Calibration.The first time the FB is enabled, these settings
occur automatically.
2 EnableReadPulse FALSE: Allows the continuous acquisition of the analog value.
TRUE: Allows the acquisition of the analog value only on ReadPulse bit command.
3 ReadPulse Valid only if EnableReadPulse is set. It commands a pulse analog value acquisition,
the bit is automatically reset. The returned value AnalogValue valid when the Status.
EndCycle is set, is the analog value acquired when the bit has been set. With the pulse
reading, the PostFiltering bit has no action; so the filter is always disabled.
4 Utility Bit 5 Bit 4 Description
5
0 0 Normal acquisition
0 1 Self calibration
1 0 Zero system calibration
1 1 Full system calibration
Self calibration: Activates the A/D converter internal calibration procedure. This
command could be used if a very precise acquisitions are desired, for which A/D
converter relative factors, could influence subsequent reading. At the FB enable the self
calibration automatically starts. The self calibration can be activated with every kind of
acquisition (voltage, Pt100, etc.). The calibration value is lost when the system is turned
off.
Zero system calibration: Is used to calibrate the offset (offset setting) when
acquisition from strain-gage is used (see value in Function). The calibration value is
lost when the system is turned off.
Full system calibration: Is used to calibrate the gain setting when acquisition from
strain-gage is used (see value in Function and in Calibration). The calibration value is
lost when the system is turned off.
6 PostFiltering TRUE: Enables the acquired analog value filtering, so the acquired value is less
affected by the noises. When the impulsive reading is used (with the ReadPulse), this
bit doesn't act.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: The FB is enabled.
1 DataReady TRUE: Indicates that in AnalogValue a new value read by the A/D converter, is
available. This bit is one shot, it remains set only for a program loop.
2 EndCycle TRUE: Indicates that the acquisition cycle has been completed. To know if in
AnalogValue a valid data is available, it's necessary to verify the DataReady bit. For
impulsive readings, by calculating the time that goes from the ReadPulse bit setting and
the setting of this bit, you can obtain the analog value acquisition time. This bit is one
shot, it's set only for a program loop.
5 TimeoutError TRUE: Indicates a timeout error on the command given to the coprocessor module, it
could be verified if the coprocessor module is in STAND-BY.
6 ConversionError TRUE: Indicates a conversion error on the acquisition channel, it could be verified if the A/
D submodule is not present.
02 ModuleAddress
Loaded by user program it defines the coprocessor module address on witch the A/D submodule is mounted.
It must be set at the first program loop and cannot be changed (Range from 0x00 to 0x07).
03 DMACh
Loaded by user program it defines the DMA channel number, used to acquire the desired channel. It must be
set at the first program loop and cannot be changed. ATTENTION! Use different values of DMACh for every
channel managed from A/D or D/A submodule inserted in the same coprocessor module (Range from 0x00
to 0x0F).
04 Function
Loaded by user program it defines the function code to execute. The FB can be parameterized to read
different analog sources. It must be set at the first program loop and cannot be changed, the possible values
are reported in the table.
Value Description
06 SlotChannel
Loaded by user program it defines the coprocessor module slot where the A/D submodule is inserted, and
the software channel of the A/D submodule. It must be set at the first program loop and cannot be changed.
For example to acquire the channel 0 connected to terminal blocks 1-2 (IN1COM-IN1) of the submodule
inserted in the slot 1 of the coprocessor module, the value 0x10 must be set.
Slot It's the number of the coprocessor module slot where the A/D submodule is inserted (Range from 1
to 3).
Channel It defines the number of the A/D software channel to be acquired. This number can be obtained
from the submodule documentation, it's related to the analog SourceCode to be acquired and to
the connection pins (Range from 0 to 6).
07 OutMode
Loaded by user program it defines the representation of the acquired value. After having modified this
parameter, it's necessary to set the Command.Reset, to let it recognized by the board.
Acquisition type Bit 5 Bit 4 Bit 3 OutMode value Acquired value representation
08 ScaleFactor
Loaded by user program it has a real meaning only for voltage, current 4-20mA and strain-gage acquisitions.
After having modified this parameter, it's necessary to set the Command.Reset, to let it recognized by the
board.
For the voltage acquisition, the value in AnalogValue is given by the formula:
AnalogValue=Voltage value*ScaleFactor
For the 4-20mA current acquisitions, the value to insert is given by the formula:
ScaleFactor=Desired value/(Input current-4mA)+(Calibration/1000)
For the strain-gage acquisitions, the value to insert is given by the formula:
ScaleFactor=Maximum capacity of the strain-gage/ratio between outlet mV and strain-gage inlet Volt.
0A Calibration
Loaded by user program it has a real meaning only for strain-gage and 4-20mA acquisitions. After having
modified this parameter, it's necessary to set the Command.Reset, to let it recognized by the board.
0C AnalogValue
It returns the digital value acquired from the chosen channel. The value depends by the OutMode settings.
0E TimeOut
Loaded by user program it defines the number of milliseconds after that, if there is no answer from the
coprocessor module, the Status.TimeoutError bit is set. The value 0 is replaced with the value 5000. In the
timeout time it is necessary to consider the user program loop time.
Example RIL
The example uses a PCB085*000 A/D submodule mounted in the first slot of a PCB072*000 coprocessor
module set with address 1. To test the example it's necessary also the part of program that manages the
FbPsystAnaCp coprocessor module management FB.
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; Picosyst analog coprocessor module data structure.
DEFL Y Cpr KD 8
DEFL Y CprCommand Y Cpr KH 0000 ; Cpr.Command
DEFL Y CprModuleAddress Y Cpr KH 0002 ; Cpr.ModuleAddress
; ------------------------------------------------------------------------------
; @Section("Init")
; ------------------------------------------------------------------------------
; Here the Picosyst analog coprocessor function block parameters are set.
ORGR
LODT F PLCFirstLoop
MOVI Y CprCommand KD 1 ; Cpr.Command
MOVI Y CprModuleAddress KD 1 ; Cpr.ModuleAddress
; ------------------------------------------------------------------------------
; @Section("Coprocessor management")
; ------------------------------------------------------------------------------
; Here the Picosyst analog coprocessor function block is called.
ORGR
SETR
TASK L FbPsystAnaCp Y Cpr ; Coprocessor management
; [End of file]
In the example is executed a 0-10 Volt analog acquisition, of the voltage connected to the terminal blocks 1-2
(IN1COM-IN1). Debugging the operand W AnalogValue it's possible to read the analog value expressed in
millivolts from 0 to 10000. In case of conversion error the F ErrorFlag will be set.
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; Picosyst A/D submodule data structure.
DEFL Y ADs KD 24
DEFL Y ADsCommand Y ADs KH 0000 ; ADs.Command
DEFL Y ADsStatus Y ADs KH 0001 ; ADs.Status
DEFL Y ADsModuleAddress Y ADs KH 0002 ; ADs.ModuleAddress
DEFL Y ADsDMACh Y ADs KH 0003 ; ADs.DMACh
DEFL Y ADsFunction Y ADs KH 0004 ; ADs.Function
DEFL Y ADsSlotChannel Y ADs KH 0006 ; ADs.SlotChannel
DEFL Y ADsOutMode Y ADs KH 0007 ; ADs.OutMode
DEFL W ADsScaleFactor Y ADs KH 0008 ; ADs.ScaleFactor
DEFL W ADsCalibration Y ADs KH 000A ; ADs.Calibration
DEFL W ADsAnalogValue Y ADs KH 000C ; ADs.AnalogValue
DEFL W ADsTimeOut Y ADs KH 000E ; ADs.TimeOut
; ------------------------------------------------------------------------------
; @Section("Init")
; ------------------------------------------------------------------------------
; Here the Picosyst A/D submodule function block parameters are set.
ORGR
LODT F PLCFirstLoop
LTCH Y ADsCommand K 0000 ; ADs.Command.Enable
LTCH Y ADsCommand K 0006 ; ADs.Command.PostFiltering
MOVI Y ADsModuleAddress KD 1 ; ADs.ModuleAddress
MOVI Y ADsDMACh KH 0000 ; ADs.DMACh
MOVI Y ADsFunction KH 0009 ; ADs.Function
MOVI Y ADsSlotChannel KH 0010 ; ADs.SlotChannel
MOVI Y ADsOutMode KH 0000 ; ADs.OutMode
MOVI W ADsScaleFactor KH 0000 ; ADs.ScaleFactor
MOVI W ADsTimeOut KD 5000 ; ADs.TimeOut
; ------------------------------------------------------------------------------
; @Section("A/D acquisition")
; ------------------------------------------------------------------------------
; Here the Picosyst A/D submodule function block is called.
ORGR
SETR
TASK L FbPsystADSubm Y ADs ; A/D submodule management
ORGR
LODT Y ADsStatus K 0002 ; ADs.Status.EndCycle
ANDT Y ADsStatus K 0001 ; ADs.Status.DataReady
ORGR
LODT Y ADsStatus K 0002 ; ADs.Status.EndCycle
ANDF Y ADsStatus K 0001 ; ADs.Status.DataReady
LTCH F ErrorFlag ; A/D acquisition error
; [End of file]
"C" example
The example uses a PCB085*000 A/D submodule mounted in the first slot of a coprocessor module
PCB072*000 set as address 1. In the example is executed an analog acquisition 0-10 Volt, of the voltage
connected to the clamps 1-2 (IN1COM-IN1). Debugging the operand unsigned int AnalogValue it's possible to
read the analog value expressed in millivolts from 0 to 10000. In case of conversion error the BOOL ErrorFlag
will be set. In the example also the FbPsystAnaCp coprocessor module management FB is reported.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbPsystAnaCp.h>
#include <FbPsystADSubm.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLE DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute variables init at first at first program execution loop.
if (PLCFirstLoop)
{
// Set the Cpr variables.
// -------------------------------------------------------------------------
// A/D ACQUISITION
// -------------------------------------------------------------------------
// Manage the Coprocessor module and the A/D submodule.
if (ADs.Status.EndCycle&ADs.Status.DataReady)
AnalogValue=ADs.AnalogValue; //A/D analog value
if (ADs.Status.EndCycle&!ADs.Status.DataReady)
ErrorFlag=TRUE; //A/D acquisition error
}
// [End of file]
Function blocks
FbPsystAnaCp
This function block allows to manage the Picosyst family coprocessor module.
Declaration
void FbPsystAnaCp(FBPSYSTANACPDATA* S);
Parameters
FBPSYSTANACPDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 8 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// ----------------------[Members that can be managed by the user program]--
00 Command
Loaded by user program it defines the command that the module has to execute according to the table below.
Value Description
02 ModuleAddress
Loaded by user program it defines the module address (Range from 0x00 to 0x07).
RIL example
In the following example, the coprocessor module is parameterized and enabled. We remind that any
coprocessor module supports up to 3 A/D acquisition and/or D/A management submodules. For any A/D
acquisition channel the proper FbPsystADSubm FB must be used, for any D/A management channel the proper
FbPsystDASubm FB must be used.
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; Picosyst analog coprocessor module data structure.
DEFL Y Cpr KD 8
DEFL Y CprCommand Y Cpr KH 0000 ; Cpr.Command
DEFL Y CprModuleAddress Y Cpr KH 0002 ; Cpr.ModuleAddress
; ------------------------------------------------------------------------------
; @Section("Init")
; ------------------------------------------------------------------------------
; Here the Picosyst analog coprocessor function block parameters are set.
ORGR
LODT F PLCFirstLoop
MOVI Y CprCommand KD 1 ; Cpr.Command
MOVI Y CprModuleAddress KD 1 ; Cpr.ModuleAddress
; ------------------------------------------------------------------------------
; @Section("Coprocessor management")
; ------------------------------------------------------------------------------
; Here the Picosyst analog coprocessor function block is called.
ORGR
SETR
TASK L FbPsystAnaCp Y Cpr ; Coprocessor management
; [End of file]
"C" example
In the following example, the coprocessor module is parameterized and enabled. We remind that any
coprocessor module supports up to 3 A/D acquisition and/or D/A management submodules. For any A/D
acquisition channel the proper FbPsystADSubm FB must be used, for any D/A management channel the proper
FbPsystDASubm FB must be used.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbPsystAnaCp.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
if (PLCFirstLoop)
{
Cpr.Command=1; //Command
Cpr.ModuleAddress=0x01; //Module address
}
// [End of file]
Function blocks
FbPsystDASubm
This function block allows to manage the D/A submodule for the Picosyst family coprocessor module.
Declaration
void FbPsystDASubm(FBPSYSTDASUBMDATA* S);
Parameters
FBPSYSTDASUBMDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 20 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// ----------------------[Members that can be managed by the user program]--
struct
{
BOOL Enable:1; //Channel enable
BOOL b1:1;
BOOL EnableWritePulse:1; //Enable write pulse
BOOL WritePulse:1; //Write pulse
BOOL b4:1;
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Command; //Command
struct
{
BOOL Enabled:1; //Channel enabled
BOOL DataWritten:1; //Data was written
BOOL EndCycle:1; //End of write cycle
BOOL b3:1;
BOOL b4:1;
BOOL TimeoutError:1; //Channel timeout error
BOOL ConversionError:1; //Channel conversion error
BOOL b7:1;
}Status; //Status
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB no D/A conversions are executed.
TRUE: Enables the FB, it provides the management of the D/A channel.
2 EnableWritePulse FALSE: Commands the constant management of the analog value.
TRUE: Commands the management of the analog value only if the WritePulse bit is
set.
3 WritePulse Valid only if EnableWritePulse is set. It commands a pulse analog value management,
the bit is automatically reset. The Status.EndCycle bit set and the TimeoutError and
ConversionError bits not set indicates that the analog value is in output.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: The FB is enabled.
1 DataWritten TRUE: The data in AnalogValue has been transferred to the D/A converter.
2 EndCycle TRUE: Indicates that the writing cycle has been completed. If the TimeoutError and
ConversionError bits not set with this bit set indicates that the analog value is in output.
For impulsive writings, by calculating the time that goes from the WritePulse bit setting
and the setting of this bit, you can obtain the analog value management time. This bit is
one shot, it's set only for a program loop.
5 TimeoutError TRUE: Indicates a timeout error on the command given to the coprocessor module, it
could be verified if the coprocessor module is in STAND-BY.
6 ConversionError TRUE: Indicates a conversion error on the acquisition channel, it could be verified if the
D/A submodule is not present.
02 ModuleAddress
Loaded by user program it defines the coprocessor module address on witch the D/A submodule is mounted.
It must be set at the first program loop and cannot be changed (Range from 0x00 to 0x07).
03 DMACh
Loaded by user program it defines the DMA channel number, used to acquire the desired channel. It must be
set at the first program loop and cannot be changed. ATTENTION! Use different values of DMACh for every
channel managed from A/D or D/A submodule inserted in the same coprocessor module (Range from 0x00
to 0x0F).
04 Function
Loaded by user program it defines the function code to execute. The FB can be parameterized to manage
the output in voltage or in current. It must be set at the first program loop and cannot be changed, the
possible values are reported in the table.
Value Description
06 SlotChannel
Loaded by user program it defines the coprocessor module slot where the D/A submodule is inserted, and
the software channel of the D/A submodule to which the analog value exits. It must be set at the first
program loop and cannot be changed.
Slot It's the number of the coprocessor module slot where the D/A submodule is inserted (Range from 1
to 3).
Channel It defines the number of the D/A software channel to be acquired. This number can be obtained
from the submodule documentation, it's related to the analog SourceCode to be acquired and to
the connection pins (Range from 0 to 3).
08 AnalogValue
Loaded by user program it defines the digital value to be converted to analogical value on the chosen
channel. For voltage conversion, this value is in millivolt (Range from -10000 to +10000 mV). For current
conversion, this value is in microampere (Range from 0 to 20000 uA).
0A TimeOut
Loaded by user program it defines the number of milliseconds after that, if there is no answer from the
coprocessor module, the Status.TimeoutError bit is set. The value 0 is replaced with the value 5000. In the
timeout time it is necessary to consider the user program loop time.
Example RIL
The example uses a PCB086*000 D/A submodule mounted in the first slot of a PCB072*000 coprocessor
module set with address 1. To test the example it's necessary also the part of program that manages the
FbPsystAnaCp coprocessor module management FB.
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; Picosyst analog coprocessor module data structure.
DEFL Y Cpr KD 8
DEFL Y CprCommand Y Cpr KH 0000 ; Cpr.Command
DEFL Y CprModuleAddress Y Cpr KH 0002 ; Cpr.ModuleAddress
; ------------------------------------------------------------------------------
; @Section("Init")
; ------------------------------------------------------------------------------
; Here the Picosyst analog coprocessor function block parameters are set.
ORGR
LODT F PLCFirstLoop
MOVI Y CprCommand KD 1 ; Cpr.Command
MOVI Y CprModuleAddress KD 1 ; Cpr.ModuleAddress
; ------------------------------------------------------------------------------
; @Section("Coprocessor management")
; ------------------------------------------------------------------------------
; Here the Picosyst analog coprocessor function block is called.
ORGR
SETR
TASK L FbPsystAnaCp Y Cpr ; Coprocessor management
In the example is executed an analog output 0-10 Volt, the output value will be available on the clamps 1-3
(EGND-V1). Debugging the operand W AnalogValue it's possible to set the analog value expressed in millivolts
from -10000 to +10000. In case of conversion error the F ErrorFlag will be set.
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; Picosyst D/A submodule data structure.
DEFL Y DAs KD 20
DEFL Y DAsCommand Y DAs KH 0000 ; DAs.Command
DEFL Y DAsStatus Y DAs KH 0001 ; DAs.Status
DEFL Y DAsModuleAddress Y DAs KH 0002 ; DAs.ModuleAddress
DEFL Y DAsDMACh Y DAs KH 0003 ; DAs.DMACh
DEFL Y DAsFunction Y DAs KH 0004 ; DAs.Function
DEFL Y DAsSlotChannel Y DAs KH 0006 ; DAs.SlotChannel
DEFL W DAsAnalogValue Y DAs KH 0008 ; DAs.AnalogValue
DEFL W DAsTimeOut Y DAs KH 000A ; DAs.TimeOut
; ------------------------------------------------------------------------------
; @Section("Init")
; ------------------------------------------------------------------------------
; Here the Picosyst D/A submodule function block is called.
ORGR
LODT F PLCFirstLoop
LTCH Y DAsCommand K 0000 ; DAs.Command.Enable
MOVI Y DAsModuleAddress KD 1 ; DAs.ModuleAddress
MOVI Y DAsDMACh KH 0005 ; DAs.DMACh
MOVI Y DAsFunction KH 0030 ; DAs.Function
MOVI Y DAsSlotChannel KH 0020 ; DAs.SlotChannel
MOVI W DAsTimeOut KD 5000 ; DAs.TimeOut
; ------------------------------------------------------------------------------
; @Section("D/A management")
; ------------------------------------------------------------------------------
; The "DataWritten" is tested and the output value is stored.
ORGR
ORGR
SETR
TASK L FbPsystDASubm Y DAs ; D/A submodule management
ORGR
LODT Y DAsStatus K 0002 ; DAs.Status.EndCycle
ANDF Y DAsStatus K 0001 ; DAs.Status.DataWritten
LTCH F ErrorFlag ; D/A acquisition error
; [End of file]
"C" example
The example uses a PCB086*000 A/D submodule mounted in the first slot of a coprocessor module
PCB072*000 set as address 1. In the example is executed an analog output 0-10 Volt, the output value will be
available on the clamps 1-3 (EGND-V1). Debugging the operand unsigned int AnalogValue it's possible to set
the analog value expressed in millivolts from -10000 to +10000. In case of conversion error the BOOL ErrorFlag
will be set. In the example also the FbPsystAnaCp coprocessor module management FB is reported.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbPsystAnaCp.h>
#include <FbPsystDASubm.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLE DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute variables init at first at first program execution loop.
if (PLCFirstLoop)
{
// Set the Cpr variables.
// -------------------------------------------------------------------------
// D/A MANAGEMENT
// -------------------------------------------------------------------------
// Set the output value.
if (DAs.Status.DataWritten)
DAs.AnalogValue=AnalogValue; //D/A analog value
if (DAs.Status.EndCycle&!DAs.Status.DataWritten)
ErrorFlag=TRUE; //D/A management error
}
// [End of file]
Function blocks
FbPWMRegulation
This function block executes the PID regulation of a process using as output two PWM commands, up and dw.
Declaration
FbPWMRegulation(FBPWMREGULATIONDATA* S);
Parameters
FBPWMREGULATIONDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Struttura dati
The function block uses a 96 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //FB enable
BOOL b1:1;
BOOL IRegEnable:1; //I regulation enable
BOOL DRegEnable:1; //D regulation enable
BOOL UpLimit:1; //Up limit
BOOL DwLimit:1; //Dw limit
BOOL b6:1;
BOOL b7:1;
}Command;
struct
{
BOOL Enabled:1; //FB enabled
BOOL b1:1;
BOOL b2:1;
BOOL b3:1;
BOOL UpCmd:1; //Up command
BOOL DwCmd:1; //Dw command
BOOL b6:1;
BOOL b7:1;
}Status;
}FBPWMREGULATIONDATA;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB and resets Status.
TRUE: Enables the FB.
2 IRegEnable TRUE:Enables the integrative regulation.
3 DRegEnable TRUE:Enables the derivative regulation.
4 UpLimit TRUE: Indicates that the actuator has reached its up limit.
5 DwLimit TRUE: Indicates that the actuator has reached its dw limit.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE:The FB is enabled.
4 UpCmd TRUE: Actuator up command.
5 DwCmd TRUE:Actuator dw command.
04 SetPoint
Loaded by user program it defines the process set point.
08 Feedback
Loaded by user program it defines the process feedback.
10 PWMTime
Loaded by user program it defines the PWM pulse duration on Up and Dw commands.The value is
expressed in mSec.
12 UpMaxWidth
Loaded by user program it defines the maximum duration of the Up command as percentage value of the
defined PWMTime. If the Up command is greather than the defined value it's limited to it. The value is
expressed in %.
13 UpMinWidth
Loaded by user program it defines the minimum duration of the Up command as percentage value of the
defined PWMTime. If the Up command is less than the defined value the command is reset. The value is
expressed in %.
14 DwMaxWidth
Loaded by user program it defines the maximum duration of the Dw command as percentage value of the
defined PWMTime. If the Dw command is greather than the defined value it's limited to it. The value is
expressed in %.
15 DwMinWidth
Loaded by user program it defines the minimum duration of the Dw command as percentage value of the
defined PWMTime. If the Dw command is less than the defined value the command is reset. The value is
expressed in %.
20 NearBand
Loaded by user program it defines the near band value. When the process error given from the difference
between the SetPoint and the Feedback is less than the defined value the integrative and derivative
regulation are enabled.
24 DeadBand
Loaded by user program it defines the dead band value. When the process error given from the difference
between the SetPoint and the Feedback is less than the defined value the regulation are disabled.
28 Kp
Loaded by user program it defines the proportional coefficient. We remind that bigger is the value faster is
the regulation with an increasing of the overshot effect. The value is expressed as a number.
2C It
Loaded by user program it defines the integrative time. We remind that bigger is the value slower is the
integrative regulation to minimize the error. The value is expressed in Sec.
30 Dt
Loaded by user program it defines the derivative time. We remind that the bigger is the value faster is the
derivative regulation to minimize the error. The value is expressed in Sec.
Esempio RIL
In the following example it's managed a PWM regulation. In the example it's not reported the program part that
allow to define the set point and to read the feedback value.
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; "FbPWMRegulation" data structure definition.
DEFG Y PWMr KD 96
DEFG Y PWMrCommand Y PWMr KH 0000 ;PWMr.Command
DEFG Y PWMrStatus Y PWMr KH 0001 ;PWMr.Status
DEFG FL PWMrSetPoint Y PWMr KH 0004 ;PWMr.SetPoint
DEFG FL PWMrFeedback Y PWMr KH 0008 ;PWMr.Feedback
; ------------------------------------------------------------------------------
; @Section("FbPWMRegulation function block management")
; ------------------------------------------------------------------------------
; Here the function block parameters are set.
ORGR
LODT F PLCFirstLoop
LTCH Y PWMrCommand BD 0 ;PWMr.Command.Enable
LTCH Y PWMrCommand BD 2 ;PWMr.Command.IRegEnable
LTCH Y PWMrCommand BD 3 ;PWMr.Command.DRegEnable
ORGR
SETR
TASK L FbPWMRegulation Y PWMr
ORGR
LODT Y PWMrStatus BD 4 ;PWMr.Status.UpCmd
OUTT O 0000 ;Up command
ORGR
LODT Y PWMrStatus BD 5 ;PWMr.Status.DwCmd
OUTT O 0001 ;Dw command
; [End of file]
Esempio "C"
In the following example it's managed a PWM regulation. In the example it's not reported the program part that
allow to define the set point and to read the feedback value.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbPWMRegulation.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void ExampleC(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute variables init at first program execution loop.
if (PLCFirstLoop)
{
PWMr.Command.Enable=TRUE; //FB enable
PWMr.Command.IRegEnable=TRUE; //I regulation enable
PWMr.Command.DRegEnable=TRUE; //D regulation enable
// -------------------------------------------------------------------------
// PWM MANAGEMENT
// -------------------------------------------------------------------------
// Function block execution.
// [End of file]
Function blocks
FbQuoteMng
This function block manages the quote value expressed on 32 bits. The FB is a useful complement in the
encoder acquisition operation, allowing to manage the revolution counter on the encoder value overflow.
Declaration
void FbQuoteMng(FBQUOTEMNGDATA* S);
Parameters
FBQUOTEMNGDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 20 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// ----------------------[Members that can be managed by the user program]--
struct
{
BOOL Enable:1; //Enable quote management
BOOL Reverse:1; //Reverse quote counting
BOOL QuotePreset:1; //Quote preset
}Command;
struct
{
BOOL QuoteSign:1; //Quote sign
}Status;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB, the quote is not managed even if the value of the transducer
changes.
TRUE: Enables the FB to manage the quote.
1 Reverse TRUE: Commands the reverse quote counting.
2 QuotePreset TRUE: Copies the value of PresetValue on the quote value. The bit is automatically reset.
01 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: Indicates that the FB is enabled.
02 Transducer
Loaded by user program it is the value read by the quote transducer (Range da 0x0000 a 0xFFFF).
04 PresetValue
Loaded by user program it defines the value to which the quote is preset on Command.QuotePreset
command (Range from 0x00000000 to 0xFFFFFFFF).
08 Quote
Returns the quote value managed by the FB (Range from 0x00000000 to 0xFFFFFFFF).
0C Displacement
Returns the transducer displacement (Range from 0x0000 to 0xFFFF).
RIL example
In the following example it is acquired an encoder connected to the inputs INP 00 and INP 01 using the
FbEncoderOverIO FB, debugging the operand W EncoderQuote it's possible to display the encoder quote
expressed in pulses, it has range 0x0000-0xFFFF. The encoder quote value is passed to the FB that provide to
manage the revolution counter returning a quote value on Double (DW) operand, debugging the operand
DW AxleQuote it's possible to display the quote expressed in pulses.
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; Encoder acquisition data structure.
DEFL Y Eacq KD 8
DEFL Y EacqInputs Y Eacq KH 0000 ; Eacq.Inputs
DEFL Y EacqError Y Eacq KH 0001 ; Eacq.Error
DEFL W EacqValue Y Eacq KH 0002 ; Eacq.Value
DEFL Y Qte KD 20
DEFL Y QteCommand Y Qte KH 0000 ; Qte.Command
DEFL Y QteStatus Y Qte KH 0001 ; Qte.Status
; ------------------------------------------------------------------------------
; @Section("Init")
; ------------------------------------------------------------------------------
; Here the function block parameters are set.
ORGR
LODT F PLCFirstLoop
MOVI Y EacqInputs KH 0000 ; Eacq.Inputs
LTCH Y QteCommand K 0000 ; Qte.Command.Enable
UTCH Y QteCommand K 0001 ; Qte.Command.Reverse
; ------------------------------------------------------------------------------
; @Section("Quote management")
; ------------------------------------------------------------------------------
; Here the encoder and the quote management function blocks are called.
ORGR
SETR
TASK L FbEncoderOverIO Y Eacq ; Encoder acquisition
MOVM W EncoderQuote W EacqValue ; Encoder quote
MOVM W QteTransducer W EncoderQuote ; Qte.Transducer
TASK L FbQuoteMng Y Qte ; Quote management
MOVM DW AxleQuote DW QteQuote ; Axle quote
; [End of file]
"C" example
In the following example it is acquired an encoder connected to the inputs INP 00 and INP 01 using the
FbEncoderOverIO FB, debugging the variable unsigned int EncoderQuote it's possible to display the encoder
quote expressed in pulses, it has range 0x0000-0xFFFF. The encoder quote value is passed to the FB that
provide to manage the revolution counter returning a quote value on unsigned long variable, debugging the
variable unsigned long AxleQuote it's possible to display the quote expressed in pulses. It's managed also an
auxiliary long variable AuxQuote it returns the quote with sign.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbEncoderOverIO.h>
#include <FbQuoteMng.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLE DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute variables init at first program execution loop.
if (PLCFirstLoop)
{
Eacq.Inputs=0x00; //Logic inputs selection
Qte.Command.Enable=TRUE; //Enable quote management
Qte.Command.Reverse=FALSE; //Reverse quote counting
}
// -------------------------------------------------------------------------
// QUOTE MANAGEMENT
// -------------------------------------------------------------------------
// When the quote sign is negative the quote is preset to 0.
if (Qte.Status.QuoteSign)
{
Qte.PresetValue=0; //Preset quote value
Qte.Command.QuotePreset=TRUE; //Quote preset
}
// Here the encoder and the quote management function blocks are called.
// The following statements are written only to enable the debug of the
// encoder and axle quotes.
// Here an example how it's possible to manage a proper quote by using the
// displacement value.
// [End of file]
Function blocks
FbRtuManager
This function block executes the full management of a RTU (Remote Terminal Unit) telecontrol station. The main characteristics are:
Using this FB with the MODEM management FB and with the RTU and Ascii Modbus communication FB you can realize a
full telecontrol system on PSTN or GSM telephone.
Declaration
void FbRtuManager(FBRTUMANAGERDATA* S);
Parameters
FBRTUMANAGERDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Variables input
For the variables input the user program has to define three unsigned int data arrays. One is for the boolean variables, it must
have the same dimension as the number of variables defined FBRTUPROGRAMRPT.BooleanCh. One is for the analog variables,
it must have the same dimension as the number of variables defined FBRTUPROGRAMRPT.AnalogCh. One is for the counters,
it must have the same dimension as the number of variables defined FBRTUPROGRAMRPT.CounterCh.
.. BoolIdt
Boolean variables copy array, an unsigned int is used for every variable. The user program has to copy the status of every variable
in the proper buffer.
.. AnaIdt
Analog variables copy array, an unsigned int is used for every variable. The user program has to copy the status of every variable
in the proper buffer.
.. CntrIdt
Counters copy array, an unsigned int is used for every counter. The user program has to copy the status of every counter in
the proper buffer.
Program configuration
For the program configuration the user program has to allocate in the backup memory a 32 bytes data structure
of FBRTUPROGRAMRPT type, here the prototype.
typedef struct
{
// ------------------------------[Members that can be managed from remote]--
struct
{
BOOL b8:1;
BOOL b9:1;
BOOL bA:1;
BOOL bB:1;
BOOL bC:1;
BOOL bD:1;
BOOL bE:1;
BOOL bF:1;
BOOL b0:1;
BOOL b1:1;
BOOL b2:1;
BOOL b3:1;
BOOL b4:1;
http://192.168.0.61/Destination/Html/FctBlocks/FbRtuManager.htm (2 of 29) [06/10/2008 17.43.35]
Function blocks: FbRtuManager
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Command;
struct
{
BOOL b8:1;
BOOL b9:1;
BOOL bA:1;
BOOL bB:1;
BOOL bC:1;
BOOL bD:1;
BOOL bE:1;
BOOL bF:1;
BOOL b0:1;
BOOL b1:1;
BOOL b2:1;
BOOL b3:1;
BOOL b4:1;
BOOL b5:1;
BOOL b6:1;
BOOL b7:1;
}Status;
00 Command
RTU command bits.
02 Status
RTU status bits.
http://192.168.0.61/Destination/Html/FctBlocks/FbRtuManager.htm (3 of 29) [06/10/2008 17.43.35]
Function blocks: FbRtuManager
04 UnitNumber
Defines the number of the system, it can be read by the supervisor to identify the system in case of call from the remote
system (Range from 0x0000 to 0xFFFF).
06 TrendTiming
Defines the interval time between the execution of the temporal trend. The value is expressed in minutes (Range from 0 to 1080).
08 MinAcq
Defines the minimum number of acquisition to considered a variable value valid for the trend. The value is expressed in
percentage (Range from 0 to 100).
10 NextTrendAddr
Returns the next trend record memo address (Range from 0x00000000 to 0xFFFFFFFF).
14 NextEventAddr
Returns the next event record memo address (Range from 0x00000000 to 0xFFFFFFFF).
For the configuration of every boolean variable the user program has to allocate in the backup memory a 8 bytes data structure
of FBRTUBOOLCFG type, here the prototype. It's necessary to define a structure array equal to the number of variables to manage.
typedef struct
{
// ------------------------------[Members that can be managed from remote]--
struct
{
BOOL TrendOnTime:1; //Request trend on timing
BOOL EventOnMax:1; //Event on max value
BOOL EventOnMin:1; //Event on min value
BOOL bB:1;
BOOL CallOnMax:1; //Request call on max value
BOOL CallOnMin:1; //Request call on min value
BOOL bE:1;
BOOL bF:1;
00 Command
Logic variable command bits.
0 Enable TRUE: Enables the variable management.
8 TrendOnTime TRUE: Enables the variable trend on temporal time defined on TrendTiming.
9 EventOnMax TRUE: Enables the report of the event in case the variable reaches the maximum value. For the boolean variables the maximum
value is the condition TRUE.
A EventOnMin TRUE: Enables the report of the event in case the variable reaches the minimum value. For the boolean variables the minimum
value is the condition FALSE.
C CallOnMax TRUE: Enables the phone call in case the variable reaches the maximum value. For the boolean variables the maximum value is
the condition TRUE.
D CallOnMin TRUE: Enables the phone call in case the variable reaches the minimum value. For the boolean variables the minimum value is
the condition FALSE.
02 CallDelay
It defines the value of time during which the call should be enabled before to be executed. If the call condition doesn't last for
the definite time the call is not executed (Range from 0 to 65535 Sec).
04 Filter
Defines the time value, that the variable status has to be maintained to be considered valid. If the value is 0 the variable status
is immediately considered valid. The value is expressed in mSec (Range from 0 to 65535).
For the configuration of every analog variable the user program has to allocate in the backup memory a FBRTUANALOGCFG type
16 bytes data structure, here the prototype. It's necessary to define a structure array equal to the number of variables to manage.
typedef struct
{
// ------------------------------[Members that can be managed from remote]--
struct
{
BOOL TrendOnTime:1; //Request trend on timing
BOOL EventOnMax:1; //Event on max value
BOOL EventOnMin:1; //Event on min value
BOOL bB:1;
BOOL CallOnMax:1; //Request call on max value
BOOL CallOnMin:1; //Request call on min value
BOOL bE:1;
BOOL bF:1;
00 Command
Analog variable command bits
02 CallDelay
Defines the value of time during which the call should be enabled before to be executed. If the call condition doesn't last for the
definite time the call is not executed (Range from 0 to 65535 Sec).
04 Filter
Defines the filter value to apply to the variable value. If the value is 0, no filter is applied (Range from 0 to 65535).
06 MaxValue
Defines the maximum value the variable can reach, over than an event and/or a phone call will be made (Range from 0 to 65535).
08 MaxValueReturn
Defines the value under which a return from MaxValue value it's considered (Range from 0 to 65535).
0A MinValueReturn
Defines the value over which a return from MinValue value it's considered (Range from 0 to 65535).
0C MinValue
Defines the minimum value the variable can reach, under than an event and/or a phone call will be made (Range from 0 to 65535).
Counter configuration
For the configuration of every counter the user program has to allocate in the backup memory a FBRTUCOUNTERCFG type 16
bytes data structure, here the prototype. It's necessary to define a structure array equal to the number of variables to manage.
typedef struct
{
// ------------------------------[Members that can be managed from remote]--
struct
{
BOOL TrendOnTime:1; //Request trend on timing
BOOL EventOnMax:1; //Event on max value
BOOL EventOnMin:1; //Event on min value
BOOL bB:1;
BOOL CallOnMax:1; //Request call on max value
BOOL CallOnMin:1; //Request call on min value
BOOL bE:1;
BOOL bF:1;
00 Command
Counter command bits
02 CallDelay
Defines the value of time during which the call should be enabled before to be executed. If the call condition doesn't last for the
definite time the call is not executed (Range from 0 to 65535 Sec).
04 MaxValue
Defines the maximum value the counter can reach, over than an event and/or a phone call will be made (Range from 0 to 65535).
06 MaxValueReturn
Defines the value under which a return from MaxValue value it's considered (Range from 0 to 65535).
08 MinValueReturn
Defines the value over which a return from MinValue value it's considered (Range from 0 to 65535).
0A MinValue
Defines the minimum value the counter can reach, under than an event and/or a phone call will be made (Range from 0 to 65535).
For the status of every boolean variable the user program has to allocate a FBRTUBOOLSTS type 4 bytes data structure, here
the prototype. It's necessary to define a structure array equal to the number of variables to manage.
typedef struct
{
// ---------------------------------[Members that can be read from remote]--
struct
{
BOOL MaxValue:1; //Max value
BOOL b9:1;
BOOL bA:1;
BOOL bB:1;
BOOL MinValue:1; //Min value
BOOL bD:1;
BOOL bE:1;
BOOL bF:1;
00 Status
Returns the boolean variable status bits.
0 Enabled TRUE: The variable management is enabled. It is the answer to the FBRTUBOOLCFG.Command.Enable bit.
8 MaxValue TRUE: The variable is at high level. For the boolean variable is considered as high level the the condition TRUE.
C MinVaule TRUE: The variable is at low level. For the boolean variable is considered as low level the the condition FALSE.
02 OutputValue
Returns the boolean variable value (Range from 0 to 1).
For the status of every analog variable the user program has to allocate a FBRTUANALOGSTS type 4 bytes data structure, here
the prototype. It's necessary to define a structure array equal to the number of variables to manage.
typedef struct
{
// ---------------------------------[Members that can be read from remote]--
struct
{
BOOL MaxValue:1; //Max value
BOOL b9:1;
BOOL bA:1;
BOOL bB:1;
BOOL MinValue:1; //Min value
BOOL bD:1;
BOOL bE:1;
BOOL bF:1;
00 Status
Returns the analog variable status bits.
0 Enabled TRUE: The variable management is enabled. It is the answer to the FBRTUANALOGCFG.Command.Enable bit.
8 MaxValue TRUE: The variable value is equal or bigger than the value set in FBRTUANALOGCFG.MaxValue.
C MinValue TRUE: The variable value is equal orslower than the value set in FBRTUANALOGCFG.MinValue.
02 OutputValue
Returns the analog variable value (Range from 0 to 65535).
Counter status
http://192.168.0.61/Destination/Html/FctBlocks/FbRtuManager.htm (11 of 29) [06/10/2008 17.43.35]
Function blocks: FbRtuManager
For the status of every counter the user program has to allocate a FBRTUCOUNTERSTS type 4 bytes data structure, here
the prototype. It's necessary to define a structure array equal to the number of variables to manage.
typedef struct
{
// ---------------------------------[Members that can be read from remote]--
struct
{
BOOL MaxValue:1; //Max value
BOOL b9:1;
BOOL bA:1;
BOOL bB:1;
BOOL MinValue:1; //Min value
BOOL bD:1;
BOOL bE:1;
BOOL bF:1;
00 Status
Returns the counter variable status bits.
0 Enabled TRUE: The counter management is enabled. It is the answer to the FBRTUCOUNTERCFG.Command.Enable bit.
8 MaxValue TRUE: The counter value is equal or bigger than the value set in FBRTUCOUNTERCFG.MaxValue.
C MinValue TRUE: The counter value is equal or lower than the value set in FBRTUCOUNTERCFG.MinValue.
02 OutputValue
Returns the counter value (Range from 0 to 65535).
For the management of every boolean variable the user program has to allocate a FBRTUBOOLMNG type data structure, here
the prototype. It's necessary to define a structure array equal to the number of variables to manage.
typedef struct
{
// --------------------------------------------[Internal use only members]--
...
}FBRTUBOOLMNG;
For the management of every analog variable the user program has to allocate a FBRTUANALOGMNG type data structure, here
the prototype. It's necessary to define a structure array equal to the number of variables to manage.
typedef struct
{
// --------------------------------------------[Internal use only members]--
...
}FBRTUANALOGMNG;
Counter management
For the management of every counter the user program has to allocate a FBRTUCOUNTERMNG type data structure, here
the prototype. It's necessary to define a structure array equal to the number of counters to manage.
typedef struct
{
// --------------------------------------------[Internal use only members]--
...
}FBRTUCOUNTERMNG;
Data structure
The function block uses a 192 bytes data structure, we report a prototype. The members reported under the Internal use
http://192.168.0.61/Destination/Html/FctBlocks/FbRtuManager.htm (13 of 29) [06/10/2008 17.43.35]
Function blocks: FbRtuManager
only members label, are members used inside by the function block and they don't have to be changed by the user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL UserTrend:1; //Start trend by user
BOOL b9:1;
BOOL bA:1;
BOOL bB:1;
BOOL bC:1;
BOOL bD:1;
BOOL bE:1;
BOOL bF:1;
struct
{
BOOL TrendAddressError:1; //Trend address error
BOOL TrendWriteError:1; //Trend write error
BOOL TrendTimeError:1; //Trend time error
BOOL bB:1;
BOOL EventAddressError:1; //Event address error
BOOL EventWriteError:1; //Event write error
BOOL bE:1;
BOOL bF:1;
}FBRTUMANAGERDATA;
00 Command
Command bits, the user program can manage these bits according to its needs.
02 Status
Status bits, the user program can test these bits.
0 Enabled TRUE: The FB is enabled.
3 TrendEnabled TRUE: The trend management is enabled.
7 Call TRUE: MODEM call in progress. It remains active until the Command.Acknowledge bit is set.
8 TrendAddressError TRUE: At system power up the value of FBRTUPROGRAMRPT.NextTrendAddr is outside the defined trend memory address
range, the value is set to the begin address. It remains active until the Command.Acknowledge bit is set.
9 TrendWriteError TRUE: Trend write error. It remains active until the Command.Acknowledge bit is set.
A TrendTimeError TRUE: It's not possible of to save the trend because the definite time value of in TrendTiming is greater of 18 hours.
C EventAddressError TRUE: At system power up the value of FBRTUPROGRAMRPT.NextEventAddr is outside the defined event memory address
range, the value is set to the begin address. It remains active until the Command.Acknowledge bit is set.
D EventWriteError TRUE: Event write error. It remains active until the Command.Acknowledge bit is set.
04 BooleanCh
Loaded by user program it defines the number of boolean variables to manage (Range from 1 to 255).
05 AnalogCh
Loaded by user program it defines the number of analog variables to manage (Range from 1 to 255).
06 CounterCh
Loaded by user program it defines the number of counters to manage (Range from 1 to 255).
08 BoolIdt
Loaded by user program it defines the allocation address of the boolean variable in input (Range from 0x0000 to 0xFFFF).
0A AnaIdt
Loaded by user program it defines the allocation address of the analog variable in input (Range from 0x0000 to 0xFFFF).
0C CntrIdt
Loaded by user program it defines the allocation address of the counters in input (Range from 0x0000 to 0xFFFF).
10 TrendAreaType
Loaded by user program it defines the memory type used as trend memory. Please refer to SystemMemoryRead
e SystemMemoryWrite functions. ATTENTION! The user code memory cannot be useed.
14 TrendAreaBegin
Loaded by user program it defines the trend memory start address (Range from 0x00000000 to0xFFFFFFFF).
18 TrendAreaEnd
Loaded by user program it defines the trend memory end address (Range from 0x00000000 to0xFFFFFFFF).
1C EventAreaType
Loaded by user program it defines the memory type used as event memory. Please refer to SystemMemoryRead
e SystemMemoryWrite functions. ATTENTION! The user code memory cannot be useed.
20 EventAreaBegin
Loaded by user program it defines the event memory start address (Range from 0x00000000 to 0xFFFFFFFF).
24 EventAreaEnd
Loaded by user program it defines the event memory end address (Range from 0x00000000 to 0xFFFFFFFF).
2C ChAtLoop
Loaded by user program it defines the number of channels for every variable type (boolean, analog, counter) that should be
managed at every program loop. If the value is "0" it will be automatically set to "1" (Range from 0x00 to 0xFF).
30 Pr
Loaded by user program it defines the FBRTUPROGRAMRPT program report data structure allocation address (Range from
0x0000 to 0xFFFF).
32 Bc
Loaded by user program it defines the FBRTUBOOLCFG boolean variables configuration data structure (Range from 0x0000
to 0xFFFF).
34 Ac
Loaded by user program it defines the FBRTUANALOGCFG analog variables configuration data structure allocation address
(Range from 0x0000 to 0xFFFF).
36 Cc
Loaded by user program it defines the FBRTUCOUNTERCFG counters configuration data structure allocation address (Range
from 0x0000 to 0xFFFF).
38 Bs
Loaded by user program it defines the FBRTUBOOLSTS boolean variables status data structure allocation address (Range
from 0x0000 to 0xFFFF).
3A As
http://192.168.0.61/Destination/Html/FctBlocks/FbRtuManager.htm (18 of 29) [06/10/2008 17.43.35]
Function blocks: FbRtuManager
Loaded by user program it defines the FBRTUANALOGSTS analog variables status data structure allocation address (Range
from 0x0000 to 0xFFFF).
3C Cs
Loaded by user program it defines the FBRTUCOUNTERSTS counters status data structure allocation address (Range from
0x0000 to 0xFFFF).
3E Bm
Loaded by user program it defines the FBRTUBOOLMNG boolean variables management data structure allocation address
(Range from 0x0000 to 0xFFFF).
40 Am
Loaded by user program it defines the FBRTUANALOGMNG analog variables management data structure allocation address
(Range from 0x0000 to 0xFFFF).
42 Cm
Loaded by user program it defines the FBRTUCOUNTERMNG counters management data structure allocation address (Range
from 0x0000 to 0xFFFF).
44 Rtc
Loaded by user program it defines the real time clock data structure allocation address (Range from 0x0000 to 0xFFFF).
48 TrendRecordSize
Returns the trend record length in bytes (Range from 0 to 65535).
4A TrendRecords
Returns the number of trend records that can be contained in the defined trend memory area (Range from 0 to 65535).
4C EventRecordSize
Returns the event record length in bytes (Range from 0 to 65535).
4E EventRecords
Returns the number of event records that can be contained in the defined event memory area (Range from 0 to 65535).
50 FbCode[11]
String that contains the FB version, i.e.: "PFB061D000".
5B FbDataSize
Returns the FBRTUMANAGERDATA FB data structure size, in bytes (Range from 0 to 255).
5C PrSize
Returns the FBRTUPROGRAMRPT program report data structure size in bytes (Range from 0 to 255).
5D BcSize
Returns the FBRTUBOOLCFG boolean configurations data structure size in bytes (Range from 0 to 255).
5E AcSize
Returns the FBRTUANALOGCFG analog configurations data structure size in bytes (Range from 0 to 255).
5F CcSize
Returns the FBRTUCOUNTERCFG counter configurations data structure size in bytes (Range from 0 to 255).
60 BsSize
Returns the FBRTUBOOLSTS boolean status data structure size in bytes (Range from 0 to 255).
61 AsSize
Returns the FBRTUANALOGSTS analog status data structure size in bytes (Range from 0 to 255).
62 CsSize
Returns the FBRTUCOUNTERSTS counter status data structure size in bytes (Range from 0 to 255).
63 BmSize
Returns the FBRTUBOOLMNG boolean management data structure size in bytes (Range from 0 to 255).
64 AmSize
Returns the FBRTUANALOGMNG analog management data structure size in bytes (Range from 0 to 255).
65 CmSize
Returns the FBRTUCOUNTERMNG counter management data structure size in bytes (Range from 0 to 255).
Trend record
As seen before, the FB can save any defined time FBRTUPROGRAMRPT.TrendTiming the trend data for every variable. Must
be defined the memory type FBRTUMANAGERDATA.TrendAreaType, the start address FBRTUMANAGERDATA.
TrendAreaBegin and the end address FBRTUMANAGERDATA.TrendAreaEnd of the system memory area where the trends
are saved. The defined area is divided in a number of records FBRTUMANAGERDATA.TrendRecords everyone of the dimension
to contain all the variables in trend FBRTUMANAGERDATA.TrendRecordSize. At every trend execution it will be write a
record, starting from the trend memory begin address till the trend memory end address. Reached the memory end address the
next trend will be write to starting from the trend memory begin again.
The trend record starts with a FBRTUSYSTEMTIME data structure, it contains informations about date and time.
typedef struct
{
unsigned char Year; //Year, range from 0 to 99
unsigned char Month; //Month, range from 1 to 12
unsigned char Day; //Day, range from 1 to 31
unsigned char Hour; //Hour, range from 0 to 23
unsigned char Minute; //Minute, range from 0 to 59
unsigned char Second; //Second, range from 0 to 59
}FBRTUSYSTEMTIME;
00 Year
Year (Range from 0 to 99).
01 Month
Month (Range from 1 to 12).
02 Day
Day (Range from 1 to 31).
03 Hour
Hour (Range from 0 to 23).
04 Minute
Minutes (Range from 0 to 59).
05 Second
Seconds (Range from 0 to 59).
typedef struct
{
unsigned char Value; //Entry value
unsigned char EdgeCntr; //EdgeCntr
unsigned int HighLevelTime; //High level Time [sec]
}FBRTUTRENDBOOL;
00 Value
Entry value of the variable (Range from 0 to 1).
01 EdgeCntr
http://192.168.0.61/Destination/Html/FctBlocks/FbRtuManager.htm (21 of 29) [06/10/2008 17.43.35]
Function blocks: FbRtuManager
Number of changes of the variable during the trend interval (Range from 0 to 255).
02 HighLevelTime
Time on wich the variable was in the level TRUE during the trend interval, expressed in Sec (Range from 0 to 65535).
typedef struct
{
unsigned int Value; //Entry value
unsigned int MinValue; //Min value
unsigned int MaxValue; //High level
unsigned int AverageValue; //Average value
unsigned int OfsTimeMinVal; //Offset time for min value
unsigned int OfsTimeMaxVal; //Offset time for max value
}FBRTUTRENDANALOG;
00 Value
Entry value of the variable (Range from 0 to 65535).
02 MinValue
Minimum value reached during the trend interval (Range from 0 to 65535).
04 MaxValue
Maximum value reached during the trend interval (Range from 0 to 65535).
06 AverageValue
Average value during the trend interval (Range from 0 to 65535).
08 OfsTimeMinVal
Offset time to which the variable has reached its minimum value starting at the trend interval, expressed in second (Range from 0
to 65535).
0A OfsTimeMaxVal
Offset time to which the variable has reached its maximum value starting at the trend interval, expressed in second (Range from 0
to 65535).
typedef struct
{
unsigned int Value; //Entry value
signed int CntrIncr; //Partial increment
}FBRTUTRENDCOUNTER;
00 Value
Entry value of the counter (Range from 0 to 65535).
02 CntrIncr
Variation value from the entry value during the trend interval (Range from -32768 to +32767).
The trend record terminates with the whole record CRC value. It's calculated by using the MemCRC function defining as init CRC
the 0xFFFF value (Range from 0 to 65535).
Event record
As seen before, the FB can save events. Must be defined the memory type FBRTUMANAGERDATA.EventAreaType, the
start address FBRTUMANAGERDATA.EventAreaBegin and the end address FBRTUMANAGERDATA.EventAreaEnd of
the system memory area where the events are saved. The defined area is divided in a number of records
FBRTUMANAGERDATA.EventRecords everyone of the dimension to contain the event FBRTUMANAGERDATA.
EventRecordSize. At every event it will be write a record, starting from the event memory begin address till the event memory
end address. Reached the memory end address the next event will be write to starting from the event memory begin again. Any
event is stored in the FBRTUEVENT event data structure.
typedef struct
{
FBRTUSYSTEMTIME Date; //Event record time
unsigned char Type; //Variable type
unsigned char Nr; //Variable number
unsigned int Value; //Variable value
unsigned int CRC; //Event record CRC
}FBRTUEVENT;
00 Date
Contains informations about day, month, year and hour, minute, second when the event is happened, refer to
FBRTUSYSTEMTIME data structure.
06 Type
RIL example
No examples available.
"C" example
In the following example are managed 4 bolean variables, 4 analog variables and 4 counters. The program transferred on a
NetlogII system allows to verify the operation of the function block.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbNetlogAD.h>
#include <FbModbusAsciiSl.h>
#include "Source\FbRtuManager.h"
// -----------------------------------------------------------------------------
// GENERAL DEFINITIONS
// -----------------------------------------------------------------------------
typedef struct
{
BOOL b00:1; //Bit 00
BOOL b01:1; //Bit 01
BOOL b02:1; //Bit 02
BOOL b03:1; //Bit 03
BOOL b04:1; //Bit 04
BOOL b05:1; //Bit 05
BOOL b06:1; //Bit 06
BOOL b07:1; //Bit 07
}BYTEBIT;
// -----------------------------------------------------------------------------
// VARIABLES DECLARATION
// -----------------------------------------------------------------------------
// ------------------------------------------------------------[Backup memory]--
// The memory area from 0x0500 to 0x05FF it's sets as backup memory. Please
// refer to project PLC settings.
// ----------------------------------------------------------[Assigned memory]--
// The following variables are located in assigned memory. This enables the
// access by the MODBUS communication.
// -------------------------------------------------------------[Event memory]--
// The following memory area it's used as a trend and events buffer, so it
// must be declared as "noinit". This means that it isn't initialized at system
// startup. So data stored in it will remain even the system is switched off.
#pragma noinitstaticvar
at (0x3000) unsigned char TrendBuff[TRENDBUFFSIZE]; //Trend buffer
at (0x4000) unsigned char EventBuff[EVENTBUFFSIZE]; //Event buffer
#pragma initstaticvar
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Execute the function init at first program execution loop.
if (PLCFirstLoop)
{
// ---------------------------------------------------------------------
// Set the A/D channels variables.
// ---------------------------------------------------------------------
// Set variables to manage the "FbRtuManager" function block.
// -------------------------------------------------------------------------
// BOOLEAN ACQUISITION
// -------------------------------------------------------------------------
// Acquire the boolean signals.
// -------------------------------------------------------------------------
// A/D ACQUISITION
// -------------------------------------------------------------------------
// Acquire the analog signal.
if (++ADCh >= 4)
ADCh=0; //A/D channel acquisition sequencer
if (ADs[ADCh].Status.DataReady)
Analog[ADCh]=ADs[ADCh].ADValue; //Input value
// -------------------------------------------------------------------------
// COUNTER ACQUISITION
// -------------------------------------------------------------------------
http://192.168.0.61/Destination/Html/FctBlocks/FbRtuManager.htm (28 of 29) [06/10/2008 17.43.35]
Function blocks: FbRtuManager
// Acquire the counter signal.
if (LogInp.b04 != InpOneShot.b04)
Counter[0]++; //Counter channel 0
if (LogInp.b05 != InpOneShot.b05)
Counter[1]++; //Counter channel 1
if (LogInp.b06 != InpOneShot.b06)
Counter[2]++; //Counter channel 2
if (LogInp.b07 != InpOneShot.b07)
Counter[3]++; //Counter channel 3
// -------------------------------------------------------------------------
// RTU MANAGER
// -------------------------------------------------------------------------
// Execute the "FbRtuManager" function block.
FbRtuManager(&Rtu);
Rtu.Command.Enable=TRUE; //Enable
// -------------------------------------------------------------------------
// MODBUS SLAVE COMMUNICATION
// -------------------------------------------------------------------------
// Here define the serial line must be used.
SetTermIOVectors(IOSerialPortA);
TermIOTick(); //Execute the tick
// [End of file]
Function blocks
FbSetSerialPar
This function block allows to set the communication parameters of the serial line. The FB allows to set the
communication mode as to the SMOD instruction and the DTR signal management as the DTRE instruction.
Declaration
void FbSetSerialPar(FBSETSERIALPARDATA *S);
Parameters
FBSETSERIALPARDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 16 bytes data structure, we report a prototype. The members reported under the
Internal use only members label, are members used inside by the function block and they don't have to be
changed by the user program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL DTRComplement:1; //Complement the DTR signal
BOOL EchoFlush:1; //Flush the echo
BOOL RxCtrlDisable:1; //Disable Rx control characters
BOOL ParityEnabled:1; //Enables the parity management
BOOL ParityType:1; //FALSE:Odd parity, TRUE:Even parity
BOOL BitNumber:1; //FALSE:7 bit, TRUE:8 bit
BOOL WaitLoop:1; //FALSE:No wait, TRUE:Wait
BOOL b7:1;
}Mode;
00 Mode
Communication mode selection bits, the user program can manage these bits according to its needs.
0 DTRComplement TRUE: Complements the status of the DTR signal.
1 EchoFlush TRUE: Enables the automatic deletion of the received characters as echo during the
transmission on RS485 line.
2 RxCtrlDisable TRUE: Disables the control character management during the reception. The XON and
XOFF characters are not automatically managed by the communication drivers but the
are returned as received characters. It must be set in case of binary communications, for
example MODBUS Rtu.
3 ParityEnabled TRUE: Enables the parity control management in reception and the transmission of the
parity bit.
4 ParityType This bit is managed only if the ParityEnabled bit is set, it defines the parity type:
FALSE: Odd parity.
TRUE: Even parity.
5 BitNumber FALSE: It is managed the 7 bits communication.
TRUE: It is managed the 8 bits communication.
6 WaitLoop FALSE: Is not waited the character in reception and is not waited the space in the
transmission buffer.
TRUE: Is waited the character in reception and the space in transmision buffer.
01 Baud
Loaded by user program it defines the desired baud rate, please refer to the table.
Hex Baud Hex Baud Hex Baud Hex Baud
02 DTRMng
Loaded by user program it defines the DTR signal management. The DTR signal on the serial port is used to
command the devices connected to it. In the targets that has the RS485 line in multidrop, the signal is used
to connect the transmission driver to the serial line. To set it please refer to to table.
0 Set the DTR signal to the FALSE logic level.
1 Set the DTR signal to the TRUE logic level.
2 Set the DTR signal in automatic working without any time. The signal is set to the TRUE logic level just
before the data transmission, and it is set to the FALSE logic level after the transmission of the last data.
3 Set the DTR signal in automatic working with time delay. Before start the data transmission the signal is
set to the TRUE logic level, the time defined in DTROnTime is waited, and then the data transmission is
started. When the last data is sent, the time defined in DTROffTime is waited and the signal is set to the
FALSE logic level.
04 DTROnTime
Loaded by user program it defines the waiting time between the activation of the DTR signal and the
transmission of data, the value is expressed mSec. It works only if the DTRMng is set to 3 (Range from 0 to
65535).
06 DTROffTime
Loaded by user program it defines the waiting time between the transmission of the last data and the
deactivation of the DTR signal, the value is expressed mSec. It works only if the DTRMng is set to 3 (Range
from 0 to 65535).
RIL example
In the following example the communication parameters on the A and B ports are set, by activating the input
I 0000 the string "Hello!" will be sent to the serial port A . By activating the input I 0001 the string "Hello!" will be
sent to the serial port B.
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; Set serial parameters function block data structure.
DEFL Y SetS KD 16
DEFL Y SetSMode Y SetS KH 0000 ; SetS.Mode
DEFL Y SetSBaud Y SetS KH 0001 ; SetS.Baud
DEFL Y SetSDTRMng Y SetS KH 0002 ; SetS.DTRMng
DEFL W SetSDTROnTime Y SetS KH 0004 ; SetS.DTROnTime
DEFL W SetSDTROffTime Y SetS KH 0006 ; SetS.DTROffTime
; ------------------------------------------------------------------------------
; @Section("Serial port tick call")
; ------------------------------------------------------------------------------
; To manage the DTR times it's necessary to call the device tick function. Here
; both functions for port "A" and "B" are called.
ORGR
SETR
SETV KE IOSerialPortA
TASK L TermIOTick
SETV KE IOSerialPortB
TASK L TermIOTick
; ------------------------------------------------------------------------------
; @Section("Set the serial parameters")
; ------------------------------------------------------------------------------
; Here the serial parameters "19200, e, 8" are set on the serial port "A".
ORGR
LODT F PLCFirstLoop
UTCH Y SetSMode BH 0000 ; SetS.Mode.DTRComplement
UTCH Y SetSMode BH 0001 ; SetS.Mode.EchoFlush
LTCH Y SetSMode BH 0002 ; SetS.Mode.RxCtrlDisable
LTCH Y SetSMode BH 0003 ; SetS.Mode.ParityEnabled
LTCH Y SetSMode BH 0004 ; SetS.Mode.ParityType
LTCH Y SetSMode BH 0005 ; SetS.Mode.BitNumber
UTCH Y SetSMode BH 0006 ; SetS.Mode.WaitLoop
MOVI Y SetSBaud KD 6 ; SetS.Baud
MOVI Y SetSDTRMng KD 3 ; SetS.DTRMng
MOVI W SetSDTROnTime KD 500 ; SetS.DTROnTime
MOVI W SetSDTROffTime KD 500 ; SetS.DTROffTime
SETV KE IOSerialPortA
TASK L FbSetSerialPar Y SetS ; Set serial parameters
; Here the serial parameters "9600, n, 7" are set on the serial port "B".
ORGR
LODT F PLCFirstLoop
UTCH Y SetSMode BH 0000 ; SetS.Mode.DTRComplement
UTCH Y SetSMode BH 0001 ; SetS.Mode.EchoFlush
LTCH Y SetSMode BH 0002 ; SetS.Mode.RxCtrlDisable
UTCH Y SetSMode BH 0003 ; SetS.Mode.ParityEnabled
UTCH Y SetSMode BH 0004 ; SetS.Mode.ParityType
UTCH Y SetSMode BH 0005 ; SetS.Mode.BitNumber
UTCH Y SetSMode BH 0006 ; SetS.Mode.WaitLoop
MOVI Y SetSBaud KD 5 ; SetS.Baud
MOVI Y SetSDTRMng KD 0 ; SetS.DTRMng
MOVI W SetSDTROnTime KD 0 ; SetS.DTROnTime
MOVI W SetSDTROffTime KD 0 ; SetS.DTROffTime
SETV KE IOSerialPortB
TASK L FbSetSerialPar Y SetS ; Set serial parameters
; ------------------------------------------------------------------------------
; @Section("Send strings")
; ------------------------------------------------------------------------------
; By activating the "I 0000", "Hello!" string is sent on the serial port "A".
ORGR
LODT I 0000
PULS
SETV KE IOSerialPortA
STXI KH 0048
STXI KH 0065
STXI KH 006C
STXI KH 006C
STXI KH 006F
STXI KH 0021
STXI KH 000D
STXI KH 000A
; By activating the "I 0001", "Hello!" string is sent on the serial port "B".
ORGR
LODT I 0001
PULS
SETV KE IOSerialPortB
STXI KH 0048
STXI KH 0065
STXI KH 006C
STXI KH 006C
STXI KH 006F
STXI KH 0021
STXI KH 000D
STXI KH 000A
; [End of file]
"C" example
In the following example the communication parameters on the A and B ports are set. Every second the string
"Hello World! (Port A)" will be sent to the serial port A and the string "Hello World! (Port B)" will be sent to the
serial port B.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbSetSerialPar.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// To manage the DTR times it's necessary to call the device tick function.
// Here both functions for port "A" and "B" are called.
SetTermIOVectors(IOSerialPortA);
TermIOTick();
SetTermIOVectors(IOSerialPortB);
TermIOTick();
if (PLCFirstLoop)
{
// The parameters "19200, e, 8" are set on the serial port "A".
SetTermIOVectors(IOSerialPortA);
SetS.Mode.DTRComplement=FALSE; //Complement the DTR signal
SetS.Mode.EchoFlush=FALSE; //Flush the echo
SetS.Mode.RxCtrlDisable=FALSE; //Disable Rx control characters
SetS.Mode.ParityEnabled=TRUE; //Enables the parity management
SetS.Mode.ParityType=TRUE; //FALSE:Odd parity, TRUE:Even parity
SetS.Mode.BitNumber=TRUE; //FALSE:7 bit, TRUE:8 bit
SetS.Mode.WaitLoop=FALSE; //FALSE:No wait, TRUE:Wait
SetS.Baud=6; //Baud rate
SetS.DTRMng=3; //Define the DTR management
SetS.DTROnTime=100; //DTR On wait time
SetS.DTROffTime=100; //DTR Off delay time
FbSetSerialPar(&SetS); //Set serial parameters
// The parameters "9600, n, 7" are set on the serial port "B".
SetTermIOVectors(IOSerialPortB);
SetS.Mode.DTRComplement=FALSE; //Complement the DTR signal
SetS.Mode.EchoFlush=FALSE; //Flush the echo
SetS.Mode.RxCtrlDisable=FALSE; //Disable Rx control characters
SetS.Mode.ParityEnabled=FALSE; //Enables the parity management
if (PLCPulse1000)
{
// The string is sent on the serial port "A".
SetTermIOVectors(IOSerialPortA);
printf("Hello World! (Port A)\r\n");
SetTermIOVectors(IOSerialPortB);
printf("Hello World! (Port B)\r\n");
}
}
// [End of file]
Function blocks
FbSle44x2Card
This function block manages the reading and writing up to 256 data bytes on Sle4432 and Sle4442 chip cards on the
Netreader systems, based on both the processor P89C664 and P89C664. The FB manages the chip card data access in
two modes, normal and advanced.
In normal mode the chip card is read and written without any control on the data. The available area of memory for the
data is up to 256 bytes.
In advanced mode is used a double structure data with a CRC of control on every structure, in this way the chip card
can be extracted from the reader/writer at any time even during the writing and reading operations, without damaging
the data memorized in it. The available area of memory for the data is up to 110 bytes.
The FB automatically manages the LED on the reader, at the insertion of the card if it's read correctly the LED is switched
on, during the writing the LED is switched off. In case of anomaly the number of LED flashes indicates the anomaly.
By using the FB in C program, a series of functions for a low level access to the chip card are available, you can manage
the whole memory area of 256 bytes, protect in writing some areas and change the PSC access code (only Sle4442). We
provide a demo program Sfw111 for an example of FB use in C language. This program accepts a series of commands
by the serial line, it's possible to unlock the card (through the PSC code), to read and write the protection memory and the
main memory, to duplicate the card.
Declaration
void FbSle44x2Card(FBSLE44X2CARDDATA* S);
Parameters
FBSLE44X2CARDDATA* S Data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Data structure
The function block uses a 40 bytes data structure, we report a prototype. The members reported under the Internal use
only members label, are members used inside by the function block and they don't have to be changed by the user
program.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
struct
{
BOOL Enable:1; //Enable chip card management
BOOL WriteData:1; //Write data to chip card
BOOL DisableLEDMng:1; //Disable LED management
BOOL ChipCardLED:1; //LED on chip card reader
BOOL AdvancedMode:1; //Advanced mode selection
BOOL DisablePSC:1; //Disable PSC management
}Command;
struct
{
BOOL ReadDataOk:1; //Chip card read data ok
BOOL ReadDataError:1; //Chip card read data error
BOOL WriteDataOk:1; //Chip card write data ok
BOOL WriteDataError:1; //Chip card write data error
BOOL bC:1;
BOOL bD:1;
BOOL bE:1;
BOOL bF:1;
void (*CardReset)(void);
unsigned char (*PSCVerification)(void);
unsigned char (*UpdateSecurityMemory)(void);
unsigned char (*MainMemoryRead)(unsigned char Address, unsigned char* Data);
unsigned char (*MainMemoryWrite)(unsigned char Address, unsigned char Data);
void (*ProtectionMemoryRead)(void);
unsigned char (*ProtectionMemoryWrite)(unsigned char Address, unsigned char Data);
}FBSLE44X2CARDDATA;
00 Command
Command bits, the user program can manage these bits according to its needs.
0 Enable FALSE: Disables the FB, all the Status bits are reset.
TRUE: Enables the FB.
1 WriteData TRUE: Forces the chip card writing with the data of the memory buffer pointed by CardData. It
will be automatically reset at the end of writing, if a writing error occurs or if the chip card is
extracted from the reader.
2 DisableLEDMng TRUE: Disables the automatic management of the LED on the chip card reader.
3 ChipCardLED Commands the LED on the chip card reader. The command is valid only if the automatic
management of the LED is disabled Command.DisableLEDMng=TRUE. Otherwise the LED is
managed automatically from the FB.
4 AdvancedMode FALSE: Normal mode, no controls on the data. Can be managed up to 256 bytes.
TRUE: Advanced mode, double writing of data with CRC control. Can be managed up to 126
bytes.
5 DisablePSC TRUE: Disables the PSC control, to use only for the Sle4432 cards avoids that the PSC control
might damage the chip card data.
01 Status
Status bits, the user program can test these bits.
0 CardIn TRUE: The chip card has been inserted in the reader.
1 CardReadEnd It's activated for a program loop at the end of the data reading from the chip card. When it's active
the: Status.WrongATR, Status.NoPSCCard, Status.VirginCard, Status.ReadDataOk, Status.
ReadDataError bits, can be checked.
2 CardWriteEnd It is activated for a program loop at the end of the data writing to the chip card. When it's active
the: Status.PSCFault, Status.WriteDataOk, Status.WriteDataError bits, can be checked.
3 WrongATR TRUE: The inserted chip card has an ATR code different from that one accepted 0xA2, 0x13,
0x10, 0x91, the card it isn't read. It's reset by extracting the card from the reader or setting
Command.Enable=FALSE.
4 VirginCard TRUE: The inserted chip card is virgin, the card it isn't read. It's reset by extracting the card from
the reader or setting Command.Enable=FALSE.
5 NoPSCCard TRUE: The inserted chip card doesn't manage the data protection with the PSC code (it is a
Sle4432). All the access operations are guaranteed anyway. It's reset by extracting the card from
the reader or setting Command.Enable=FALSE.
6 PSCFault TRUE: The card unlock operation with PSC code to allow its writing, have a fault. The PSC value
is not correct.
ATTENTION! After 3 wrong card unlock operations, the card becomes useless. It's reset at every
writing command Command.WriteData=TRUE, by extracting the card from the reader or setting
Command.Enable=FALSE.
8 ReadDataOk TRUE: Ther reading of the card inserted in the reader has been executed, the readed data has
been transferred from the chip card to the memory buffer pointed by CardData. It's reset by
extracting the card from the reader or setting Command.Enable=FALSE.
9 ReadDataError TRUE: Ther reading of the card inserted in the reader has an error. It's reset by extracting the card
from the reader or setting Command.Enable=FALSE.
A WriteDataOk TRUE: Ther writing of the card inserted in the reader has been executed, the data from the
memory buffer pointed by CardData has been write to the chip card. It's reset by extracting the
card from the reader setting Command.Enable=FALSE or at every set of the Command.
WriteData bit.
B WriteDataError TRUE: Ther writing of the card inserted in the reader has an error. It's reset by extracting the card
from the reader setting Command.Enable=FALSE or at every set of the Command.WriteData bit.
03 ChipCardStart
Loaded by the user program, it defines the user data allocation address on the chip card memory (Range da 0x00 a
0xFF).
04 CardDataLength
Loaded by the user program, it defines the user data area length to be managed on the chip card (Range da 0x00 a
0xFF).
05 PSCCheckAddress
Loaded by the user program, it defines the chip card address on wich the PSC control is executed. If the user
program has to manages both the chip card types (with PSC and without) to avoid that the PSC control can
deteriorate the data present on the card, it's possible to define an address outside of the used data area. Not used if
Command.DisablePSC=TRUE (Range from 0x00 to 0xFF).
06 CardData
Loaded by the user program, it defines the memory buffer address where the FB stores the data read or reads the
data to write to the chip card, a buffer with the same length of the data to be managed on the chip card
CardDataLength must be defined on RAM memory (Range from 0x0000 to 0xFFFF).
08 ATRCode[4]
Returns the 4 bytes ATR code read by the chip card, the code is 0xA2, 0x13, 0x10, 0x91.
0C ProtectionMem[4]
Copy buffer protection memory on chip card data. The ProtectionMemoryRead function reads the value of the 32
bits protection memory in this 4 bytes buffer.
10 SecurityMem[4]
Chip card security memory buffer. The PSCVerification function compares the value of the 3 bytes SecurityMem[1-
2-3] to the PSC code of the chip card and if they are the same it unlocks the chip card. The UpdateSecurityMemory
function replaces the current PSC code on the chip card with value in the 3 bytes SecurityMem[1-2-3].
14 CardReset
Returns the address of the chip card reset function. This function reads the ATR code and returns it in ATRCode[4].
The function normally has to be executed on the insertion of the card in the reader.
void CardReset(void);
Parameters
None
Return value
None
16 PSCVerification
Returns the address of the PSC verification function. This functions compares the code reported in SecurityMem[1-2-
3] with the PSC code of the chip card. If the code corresponds the chip card is unlocked. ATTENTION! After 3 wrong
unlock operations the card gets useless.
unsigned char PSCVerification(void);
Parameters
None
Return value
unsigned char 0 PSC code verified 4 Code verify error
1 Write start error 5 Chip card locked
2 Write timeout error 6 Procedure error
3 Write protected area
18 UpdateSecurityMemory
Returns the address of the update security memory function. This function changes the value of the PSC on chip
card using the the value reported in SecurityMem[1-2-3]. Of course, the operation is possible only if the card was
previously unlocked with the PSCVerification function. ATTENTION! After having updated the code, the card
remains unlocked until it is extracted from the reader. At the following insertion you have the use the new PSC code
to unlock it
unsigned char UpdateSecurityMemory(void);
Parameters
None
Return value
unsigned char 0 PSC code verified 2 Write timeout error
1 Write start error 3 Write protected area
1A MainMemoryRead
Returns the address of the main memory read. This functions reads a byte from the chip card main memory.
1C MainMemoryWrite
Returns the address of the main memory write. This function writes a byte to the chip card main memory. The
operation is possible only if the card was previously unlocked with the PSCVerification function. Before execute the
writing it's verified if the data is already present in the chip card, so the write is non executed minimizing the number
of write cycles.
unsigned char MainMemoryWrite(unsigned char Address, unsigned char Data);
Parameters
unsigned char Address Data writing address on chip card (From 0x00 to 0xFF)
unsigned char Data Data to write on chip card (From 0x00 to 0xFF)
Return value
unsigned char 0 Write ok 3 Write protected area
1 Write start error 4 Error improper write
2 Write timeout error
1E ProtectionMemoryRead
Returns the address of the protection memory read function. This function reads the 4 bytes of the protection memory
on the chip card and transfer them to the ProtectionMem[4] buffer.
void ProtectionMemoryRead(void);
Parameters
None
Return value
None
20 ProtectionMemoryWrite
Returns the address of the protection memory write function. This function writes the protection memory on the chip
card.The operation is possible only if the card was previously unlocked with the PSCVerification function.
unsigned char ProtectionMemoryWrite(unsigned char Address, unsigned char Data);
Parameters
unsigned char Address Data writing address on chip card (From 0x00 to 0x1F)
unsigned char Data Data to write on chip card (From 0x00 to 0xFF)
Return value
unsigned char 0 Write ok 2 Write timeout error
1 Write start error 3 Write protected area
RIL example
In the following example a chip card reader is managed. The chip card data are memorized starting from the byte Y 0000
till the byte Y 000F. When the card is inserted in the reader, it is automatically read and if the data in it are correct, the
LED on the reader is switched on. Otherwise it blinks according to the number of error found.
By activating the input I 0000, the data in the buffer are write on the chip card, be sure to have set the right value of the
PSC code in SecurityMem[1-2-3] before execute the command. In the example, we suppose to use a virgin card, whose
PSC is 0xFF, 0xFF, 0xFF.
; ------------------------------------------------------------------------------
; @Section("Local definitions")
; ------------------------------------------------------------------------------
; FbSle44x2Card function block, data structure.
DEFG Y Chc KD 40
DEFG Y ChcCommand Y Chc KH 0000 ;Chc.Command
DEFG W ChcStatus Y Chc KH 0001 ;Chc.Status
; ------------------------------------------------------------------------------
; @Section("Program init")
; ------------------------------------------------------------------------------
; FbSle44x2Card function block, variables settings.
; Set the chip card data buffer at address Y 0000.
ORGR
LODT F PLCFirstLoop
MOVA W ChcCardData Y 0000 ;Chc.CardData
; ------------------------------------------------------------------------------
; @Section("FbSle44x2Card function block management")
; ------------------------------------------------------------------------------
; When card is inseterted in the reader the chip card data from 0x20 to 0x2F are
; automatically copied to the memory from Y 0000 to Y 000F.
ORGR
SETR
TASK L FbSle44x2Card Y Chc ;Sle44x2Card management
; By activating the input I 0000 the data from Y 0000 to Y 000F are stored in the
; chip card from address 0x20 to 0x2F.
ORGR
LODT I 0000
PULS
MOVI DW ChcSecurityMem KH FFFFFF ;Chc.SecurityMem
LTCH Y ChcCommand BD 1 ;Chc.Command.WriteData
; [End of file]
"C" example
In the following example a chip card reader is managed. The chip card data are memorized in the CardData buffer. When
the card is inserted in the reader, it is automatically read and if the data in it are correct, the LED on the reader is
switched on. Otherwise it blinks according to the number of error found.
By activating the input I 0000, the data in the CardData buffer are write on the chip card, be sure to have set the right
value of the PSC code in SecurityMem[1-2-3] before execute the command. In the example, we suppose to use a virgin
card, whose PSC is 0xFF, 0xFF, 0xFF.
By activating the input I 0001 the PSC code of the card is updated, setting it to 0x12, 0x34, 0x56. The new code is valid
only after having extracted the card from the reader. ATTENTION! do not execute the I 0000 writing command on the
card with the PSC updated, after 3 tries the card becomes useless.
By activating the input I 0002, the PSC code is updated, it returns as a virgin card 0xFF, 0xFF, 0xFF.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbSle44x2Card.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// At first program loop initialize all variables.
if (PLCFirstLoop)
{
Chc.CardData=&CardData; //Card data address
Chc.ChipCardStart=0x20; //Chip card start address
Chc.CardDataLength=sizeof(CardData); //Card data length
Chc.PSCCheckAddress=0x20; //PSC check address
Chc.Command.AdvancedMode=TRUE; //Advanced mode selection
Chc.Command.DisablePSC=FALSE; //Disable PSC management
Chc.Command.Enable=TRUE; //Enable chip card management
}
// -------------------------------------------------------------------------
// CHIP CARD MANAGEMENT
// -------------------------------------------------------------------------
// Execute the logic input read and manages the one shot buffer.
// By activating the logic input I 0000 the chip card is written using data
// from "CardData" buffer.
if (((LogInput^OneShot)&LogInput)&0x01)
{
// Set the PSC code to unlock the chip card and command the data write.
// By activating the logic input I 0001 the chip card PSC is modified from
// the previous value 0xFF, 0xFF, 0xFF to the new value 0x12, 0x34, 0x56.
if (((LogInput^OneShot)&LogInput)&0x02)
{
// Set the previous PSC code and unlock the chip card.
// By activating the logic input I 0002 the chip card PSC is modified from
// the previous value 0x12, 0x34, 0x56 to the new value 0xFF, 0xFF, 0xFF.
if (((LogInput^OneShot)&LogInput)&0x04)
{
// Set the previous PSC code and unlock the chip card.
if (ErrorCode)
{
SetTermIOVectors(IOSerialPortA); //Set the serial port A as I/O console
printf("An error is detected.\r\n");
}
}
// [End of file]
DEFL
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
F, T, C, Y, W, DW, FL
DEFL DEFine Local operand None Y KD No A
Y Y KD
The instruction DEFine Local operand has to be used to define a new mnemonic operand, having a local
visibility only inside the file where it's defined. The instruction doesn't have any logical function in the
program so it has to be inserted without any definition of the logical branch, we suggest to insert the
instruction at the beginning of the RIL file. Instructions can access to the defined operand only in the
RIL file in which it is defined.
ATTENTION! You cannot define two operands with the same name even though they are of different type
in the same file, but the same name can be used to define another operand with the same or different type
in other files of the same project. You cannot define local operand with names used before to define global
operands DEFG, backup operands DEFB or operands from external files EXTR.
Examples
In the following example, the F IsGreather is activated if the operand W 0000 is greater that 50, the status
of F IsGreather can be tested only in the file where it is defined. You can define operands IsGreather in
other files, but only if you use local assignment.
DEFG
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
F, T, C, Y, W, DW,
FL
DEFG DEFine Global operand None No A
Y KD
Y Y KD
The instruction DEFine Global operand has to be used to define a new mnemonic operand, having a global
visibility inside the project. The instruction doesn't have any logical function in the program so it has to be
inserted without any definition of the logical branch, we suggest to insert the instruction at the beginning of
the RIL file. Instructions can access to the defined operand from any RIL file of the project by only
indicating its type and name.
ATTENTION! You cannot define two operands with the same name in the same project (even they are in
different files) even they have different type. So you cannot define local operands DEFL, or backup
operands DEFB using names defined as global operands.
Examples
in the following example, the F IsGreather is activated if the operand W 0000 is greater that 50, the status
of F IsGreather can be tested in any RIL file of the project. You cannot define an operand with the name
IsGreather in any other file of the same project.
Macro
ASCIIToHEX
This macro function executes the conversion of an ASCII character to a hexadecimal number. Given to the
macro an ASCII character between 0 to 9 and between A to F, it returns its value expressed as an hexadecimal
number included between 0x00 to 0x0F.
Examples
The ASCII character A hex code 0x41 present in the AsciiValue variable, comes converted in the hexadecimal
value 0x0A and transferred in the HexValue variable.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
AsciiValue='A'; //ASCII value
HexValue=ASCIIToHEX(AsciiValue); //Hexadecimal value
}
// [End of file]
Macro
DISABLEINT
ENABLEINT
These macrofunctions execute the disable and the enable of all interrupt sources. They must be used to prevent the
interruption of normal program execution when it access to a variable managed by an interrupt function.
Examples
In the interrupt function executed every 100 mSec it's increased the InterruptCounter variable, to copy its value to the
MainCounter variable that can be access by the main program, the interrupt must be disabled and enabled at the copy end.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM EXECUTED IN INTERRUPT
// -----------------------------------------------------------------------------
// Function executed on interrupt, it increments the Counter.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM EXECUTED IN MAIN
// -----------------------------------------------------------------------------
void Example(void)
{
// Enable the "InterruptFunct" execution on external interrupt.
if (PLCFirstLoop)
{
SetClockIntTime(100); //Set the clock interrupt time at 100 mSec
SetClockIntVector(TRUE, (code*)&InterruptFunct); //Set the clock interrupt vector
}
// [End of file]
Macro
HEXToASCII
This macro function executes the conversion of a hexadecimal number to an ASCII character. Given to the
macro a hexadecimal number between 0x00 to 0x0F, it returns an ASCII character between 0 to 9 and between
A to F.
Examples
The hexadecimal value 0x0A present in the HexValue variable, comes converted in the ASCII character A and
transferred in the AsciiValue variable.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
HexValue=0x0A; //Hexadecimal value
AsciiValue=HEXToASCII(HexValue); //ASCII value
}
// [End of file]
Macro
HICHAR
This macrofunction returns an unsigned char number that rapresent the high nibble of an unsigned int number.
Examples
It's returned the exadecimal value 0x12 in the HighNibble variable that represent the high nibble of the Value
variable. Please refer also to the example in HIINT macro.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
Value=0x1234; //Value
HighNibble=HICHAR(Value); //High nibble (0x12)
}
// [End of file]
Macro
HIINT
This macrofunction returns an unsigned int number that rapresent the high nibble of an unsigned long number.
Examples
It's returned the exadecimal value 0x1234 in the HighNibble variable that represent the high nibble of the Value
variable.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
Value=0x12345678; //Value
HighNibble=HIINT(Value); //High nibble (0x1234)
// [End of file]
Macro
LOCHAR
This macrofunction returns an unsigned char number that rapresent the low nibble of an unsigned int number.
Examples
It's returned the hexadecimal value 0x34 in the LowNibble variable that represent the low nibble of the Value
variable. Please refer also to the example in LOINT macro.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
Value=0x1234; //Value
LowNibble=LOCHAR(Value); //Low nibble (0x34)
}
// [End of file]
Macro
LOINT
This macrofunction returns an unsigned int number that rapresent the low nibble of an unsigned long number.
Examples
It's returned the hexadecimal value 0x5678 in the LowNibble variable that represent the low nibble of the Value
variable.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
Value=0x12345678; //Value
LowNibble=LOINT(Value); //Low nibble (0x5678)
// [End of file]
Macro
MAKEINT
This macrofunction returns an unsigned int number from two unsigned char numbers.
Examples
The hexadecimal values 0x12 and 0x34 present in the HighNibble and LowNibble variables, are converted in
the hexadecimal value 0x1234 and transferred in the Result variable.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
HighNibble=0x12; //High nibble
LowNibble=0x34; //Low nibble
Result=MAKEINT(HighNibble, LowNibble); //Result value (0x1234)
}
// [End of file]
Macro
MAKELONG
This macrofunction returns an unsigned long number from two unsigned int numbers.
Examples
The hexadecimal values 0x1234 and 0x5678 present in the HighNibble and LowNibble variables, are
converted in the hexadecimal value 0x12345678 and transferred in the Result variable.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
HighNibble=0x1234; //High nibble
LowNibble=0x5678; //Low nibble
Result=MAKELONG(HighNibble, LowNibble); //Result value (0x12345678)
}
// [End of file]
Macro
PLCOp(x)
Special macrofunctions suited for each type of operand allow to read and write to all the numerical operands of
the RIL language, it's necessary to define the operand address in hexadecimal.
The Flag (F), Byte (Y), Word (W), Double (DW) and Float (FL) operands, share the same memory so the
operand PLCOpW(0x0100) uses the same memory location of the operands PLCOpF(0x0100), PLCOpF
(0x0101) or the operands PLCOpY(0x0100), PLCOpW(0x0100).
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES DEFINITION
// -----------------------------------------------------------------------------
BOOL InputValue;
BOOL OutputValue;
BOOL FlagValue;
unsigned char ByteValue;
unsigned int WordValue;
unsigned long DoubleValue;
float FloatValue;
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
InputValue=PLCOpI(0x0001); //To read the input 0001
PLCOpI(0x0001)=InputValue; //To write the input 0001
// [End of file]
Macro
SWCHAR
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
Value=0x12; //Value
Result=SWCHAR(Value); //Result value (0x21)
}
// [End of file]
Macro
SWINT
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
Value=0x1234; //Value
Result=SWINT(Value); //Result value (0x3412)
}
// [End of file]
Macro
SWLONG
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
Value=0x12345678; //Value
Result=SWLONG(Value); //Result value (0x56781234)
}
// [End of file]
Data types
ACSPOINTFUNCTIONS
This data structure it's used to define all the access point function vectors.
typedef struct
{
USERFLAGS (*GetUserFlags)(void);
void (*F01)(void);
void (*F02)(void);
void (*F03)(void);
void (*F04)(void);
void (*F05)(void);
void (*F06)(void);
void (*F07)(void);
void (*F08)(void);
void (*F09)(void);
void (*F0A)(void);
void (*F0B)(void);
void (*F0C)(void);
void (*F0D)(void);
void (*F0E)(void);
void (*F0F)(void);
}ACSPOINTFUNCTIONS;
Some fields of the data structure are not managed in some libraries. In the following table the indication of
the different fields is reported with reference to the supported libraries.
Ofs Description
00 USERFLAGS (*GetUserFlags)(void) - - - - - - D
GetUserFlags device function address
02 void (*F01)(void) - - - - - - D
Space for future allocations.
04 void (*F02)(void) - - - - - - D
Space for future allocations.
06 void (*F03)(void) - - - - - - D
Space for future allocations.
08 void (*F04)(void) - - - - - - D
Space for future allocations.
0A void (*F05)(void) - - - - - - D
Space for future allocations.
0C void (*F06)(void) - - - - - - D
Space for future allocations.
0E void (*F07)(void) - - - - - - D
Space for future allocations.
10 void (*F08)(void) - - - - - - D
Space for future allocations.
12 void (*F09)(void) - - - - - - D
Space for future allocations.
14 void (*F0A)(void) - - - - - - D
Space for future allocations.
16 void (*F0B)(void) - - - - - - D
Space for future allocations.
18 void (*F0C)(void) - - - - - - D
Space for future allocations.
1A void (*F0D)(void) - - - - - - D
Space for future allocations.
1C void (*F0E)(void) - - - - - - D
Space for future allocations.
1E void (*F0F)(void) - - - - - - D
Space for future allocations.
Data types
BLINKBITDATA
This data type (structure) is provided for the use with the BlinkBit function.
typedef struct
{
// --------------------------[Members that can be managed by user program]--
}BLINKBITDATA;
In the following table the indication of the different field are reported with reference to the supported libraries.
"C" functions
BlinkBit
This function executes the blinking of the specified number of a bit variable. The function operates on a
BLINKBITDATA data structure wich address must be passed to the function.
Prototype
ElSystemLib.h
Declaration
void BlinkBit(BLINKBITDATA* S);
Parameters
BLINKBITDATA* S Data structure address (Range da 0x0000 a 0xFFFF)
Return value
None
Examples
Are executed 5 blinks (250 mSec on/off) followed by a off pause of 2 Sec of the logic outputOUT 0000.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables declaration.
// -------------------------------------------------------------------------
// BLINK A LOGIC OUTPUT
// -------------------------------------------------------------------------
// Initialize the data structure.
if (PLCFirstLoop)
Blk.BlinkNr=5; //Number of blinking
BlinkBit(&Blk);
// [End of file]
Data types
CANINITDATA
This data type (structure) is provided for the use with the CANInit function.
typedef struct
{
BOOL FrameFormat; //Frame format selection
unsigned char Baud; //Baud rate
unsigned long Filter; //Acceptance filter
unsigned long Mask; //Acceptance mask
}CANINITDATA;
In the following table the indication of the different field are reported with reference to the supported libraries.
"C" functions
CANInit
This function executes the CAN controller init by setting all the operating parameters. It's necessary to define the
parameters in the CANINITDATA structure wich address is passed to the function.
Prototype
ElSystemLib.h
Declaration
BOOL CANInit(CANINITDATA* S);
Parameters
CANINITDATA* S Data structure address (Range da 0x0000 a 0xFFFF)
Return value
BOOL FALSE: CAN controller init error
TRUE: CAN controller initialized
Esempi
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// CAN init data structure initialization.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// At the first program loop the CAN controller is initialized.
if (PLCFirstLoop)
{
SetTermIOVectors(IOSerialPortA); //Set the serial port A as I/O console
if (!CANInit(&Init))
printf("Error in the CAN module initialization\r\n");
else
printf("The CAN module is correctly initialized\r\n");
}
}
// [End of file]
Data types
I2CMNGFUNCTIONS
This data structure it's used to define all the I2C communication function vectors.
typedef struct
{
void (*I2CSWriteCommand)(void);
unsigned char (*I2CSReadCommand)(void);
void (*I2CSDataReceive)(unsigned char Data);
unsigned char (*I2CSDataSend)(void);
}I2CMNGFUNCTIONS;
Some fields of the data structure are not managed in some libraries. In the following table the indication of
the different fields is reported with reference to the supported libraries.
Ofs Description
00 void (*I2CSWriteCommand)(void) - - - - B C A
I2CSWriteCommand function address, this function is executed when a write
command with correct address has been received from I2C bus.
02 unsigned char (*I2CSReadCommand) - - - - B C A
I2CSReadCommand function address, this function is executed when a read
command with correct address has been received from I2C bus. The function must
return the data to be sent to the master system.
04 void (*I2CSDataReceive)(unsigned char Data) - - - - B C A
I2CSDataReceive function address, this function is executed when a data has been
received from I2C bus. The received data is passed to the function.
06 unsigned char (*I2CSDataSend)(void) - - - - B C A
I2CSDataSend function address, this function is executed when a data is request
on I2C bus. The function must return the data to be sent to the master system.
Data types
MODEMSTRUCT
The modem management requires a data structure of 48 bytes, we report a prototype. The user program
can access to the variable defined in this structure to interact with the modem management.
typedef struct
{
struct
{
BOOL b00:1;
BOOL Dial:1; //Active force the number dial
BOOL SMSSend:1; //Active force the SMS send
BOOL HangUp:1; //Active force the hang up
BOOL b04:1;
BOOL b05:1;
BOOL b06:1;
BOOL ResetError:1; //Active force error field reset
}Command;
struct
{
BOOL b08:1;
BOOL CLIPRxd:1; //Pulse active at every CLIP received
BOOL b0A:1;
BOOL Connect:1; //Active if the modem is connect
BOOL b0C:1;
BOOL b0D:1;
BOOL PowerOn:1; //Active if is powering on the modem
BOOL SwitchModemOn:1; //Used to switch modem On/Off
struct
{
BOOL CLIPReceive:1; //Active if error in CLIP receive
BOOL NoOperator:1; //Active if no operator available
BOOL b0A:1;
BOOL b0B:1;
BOOL b0C:1;
BOOL b0D:1;
BOOL b0E:1;
BOOL b0F:1;
Some fields of the data structure are not managed in some libraries because the type of terminal supported
by the library does not have all the functionality provided. In the table below the indication of the different
fields is reported with reference to the supported libraries.
Data types
NSYSTBUSIODATA
This data type (structure) is provided for the use with the NSYSTBusIO function.
typedef struct
{
unsigned char Module; //NSYST module address
unsigned char Command; //Command to execute
unsigned char TxLength; //Tx buffer length
unsigned char RxLength; //Rx buffer length
void* TxFrame; //Tx frame buffer pointer
void* RxFrame; //Rx frame buffer pointer
}NSYSTBUSIODATA;
In the following table the indication of the different field are reported with reference to the supported libraries.
"C" functions
NSYSTBusIO
This function execute the access to the Netsyst bus, the function completely manages the command write and
the return data read from Netsyst extension modules. The function operates on a NSYSTBUSIODATA data
structure which address must be passed to the function.
Prototype
ElSystemLib.h
Declaration
BOOL NSYSTBusIO(NSYSTBUSIODATA* S);
Parameters
NSYSTBUSIODATA* S Data structure address (Range da 0x0000 a 0xFFFF)
Return value
BOOL FALSE: No errors
TRUE: Access error
Examples
Are managed the logic outputs on the extension module with address 1.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
struct
{
BOOL Out00:1; //Out 00 bit
BOOL Out01:1; //Out 01 bit
BOOL Out02:1; //Out 02 bit
BOOL Out03:1; //Out 03 bit
BOOL Out04:1; //Out 04 bit
BOOL Out05:1; //Out 05 bit
BOOL Out06:1; //Out 06 bit
BOOL Out07:1; //Out 07 bit
}LogOut;
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local definitions.
// -------------------------------------------------------------------------
// COMMAND 09, WRITE LOGIC OUTPUT
// -------------------------------------------------------------------------
// The master system writes to the slave system the command frame:
//
// +-----+---------+-----+
// | CMD | OUT 0-7 | CKS |
// +-----+---------+-----+
//
// The master system reads from the slave system the command frame:
//
// +-----+-----+
// | CMD | CKS |
// +-----+-----+
//
// Where:
// CMD: Command to be executed (0x09).
// OUT 0-7: Output value to be set.
// CKS: Check sum value
//
// CMD: Command to be executed (0x09).
// CKS: Check sum value
// -------------------------------------------------------------------------
// Execute the write logic output command on module "1".
// [End of file]
Data types
NSYSTEXTMODSTS
This data type (structure) it's returned reading the state of a Netsyst extension module.
typedef struct
{
BOOL InputChanged:1; //Logic inputs on module are changed
BOOL b1:1;
BOOL b2:1;
BOOL b3:1;
unsigned char Check:4;
}NSYSTEXTMODSTS;
This data structure is returned by the NSYSTModSts function and contains the information about the state
of the Netsyst extension module.
00 InputChanged TRUE: The state of the logic inputs on the extension module are - - - - - - D
changed from the last reading by the master system with the
NSYSTExtModuleInp function that resets the bit.
Data types
PLCRTCDATA
This data type (structure) is provided for the information inherent the real time clock. It's used in the PLC
section only.
typedef struct
{
unsigned char Year; //Year, range from 0 to 99
unsigned char Month; //Month, range from 1 to 12
unsigned char Day; //Day, range from 1 to 31
unsigned char WeekDay; //Week day, range from 0 to 6
unsigned char Hour; //Hour, range from 0 to 23
unsigned char Minute; //Minute, range from 0 to 59
unsigned char Second; //Second, range from 0 to 59
unsigned char Hundred; //Hundred, range from 0 to 99
}PLCRTCDATA;
In the following table the indication of the different field are reported with reference to the supported libraries.
Data types
RTCDATA
This data type (structure) is provided for the information inherent the real time clock.
typedef struct
{
unsigned char Year; //Year, range from 0 to 99
unsigned char Month; //Month, range from 1 to 12
unsigned char Day; //Day, range from 1 to 31
unsigned char WeekDay; //Week day, range from 0 to 6
unsigned char Hour; //Hour, range from 0 to 23
unsigned char Minute; //Minute, range from 0 to 59
unsigned char Second; //Second, range from 0 to 59
unsigned char Hundred; //Hundred, range from 0 to 99
}RTCDATA;
Some fields of the data structure are not managed in some libraries because the target system has not the
real time clock. In the following table the indication of the different field are reported with reference to the
supported libraries.
Data types
SERIALFUNCTIONS
This data structure it's used to define all the serial device function vectors.
typedef struct
{
void (*GetSerialMode)(SERIALSTRUCT* S);
void (*SetSerialMode)(SERIALSTRUCT* S);
void (*SerialDTRMng)(BOOL Value);
void (*F03)(void);
void (*F04)(void);
void (*F05)(void);
void (*F06)(void);
void (*F07)(void);
void (*F08)(void);
void (*F09)(void);
void (*F0A)(void);
void (*F0B)(void);
void (*F0C)(void);
void (*F0D)(void);
void (*F0E)(void);
void (*F0F)(void);
}SERIALFUNCTIONS;
Some fields of the data structure are not managed in some libraries. In the following table the indication of
the different fields is reported with reference to the supported libraries.
Ofs Description
00 void (*GetSerialMode)(SERIALSTRUCT* S) D E - C A B A
GetSerialMode device function address.
02 void (*SetSerialMode)(SERIALSTRUCT* S D E - C A B A
SetSerialMode device function address.
04 void (*SerialDTRMng)(BOOL Value) D E - C A B A
SerialDTRMng device function address.
06 void (*F03)(void) - - - - E - A
Space for future allocations.
08 void (*F04)(void) - - - - E - A
Space for future allocations.
0A void (*F05)(void) - - - - E - A
Space for future allocations.
0C void (*F06)(void) - - - - E - A
Space for future allocations.
0E void (*F07)(void) - - - - E - A
Space for future allocations.
10 void (*F08)(void) - - - - E - A
Space for future allocations.
12 void (*F09)(void) - - - - E - A
Space for future allocations.
14 void (*F0A)(void) - - - - E - A
Space for future allocations.
16 void (*F0B)(void) - - - - E - A
Space for future allocations.
18 void (*F0C)(void) - - - - E - A
Space for future allocations.
1A void (*F0D)(void) - - - - E - A
Space for future allocations.
1C void (*F0E)(void) - - - - E - A
Space for future allocations.
1E void (*F0F)(void) - - - - E - A
Space for future allocations.
Data types
SERIALSTRUCT
This data type (structure) is provided for the information inherent to the configuration of the serial line, it is used by the
functions of reading serial mode GetSerialMode and set serial mode SetSerialMode.
typedef struct
{
// -----------------------------------------------------------------[Mode]--
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// |F|E|D|C|B|A|9|8|7|6|5|4|3|2|1|0|
// +++++++++++++++++++++++++++++++++
// | +-+-+ | | | | | | | | | +-------------------+
// | | | | | | | | | | +-------------------+ |
// | | | | | | | | | +-------------------+ | |
// | | | | | | | | +-------------------+ | | |
// | | | | | | | | +-+-+-+-+-+---+-------+------+
// | | | | | | | +- 0=Parity disabled| Binary | Hx| Baud | Port |
// | | | | | | | 1=Parity enabled +---------+---+-------+------+
// | | | | | | | | 0 0 0 0 | 0 | 300 | A, 1 |
// | | | | | | +- 0=Odd parity | 0 0 0 1 | 1 | 600 | A, B |
// | | | | | | 1=Even parity | 0 0 1 0 | 2 | 1200 | A, B |
// | | | | | | | 0 0 1 1 | 3 | 2400 | A, B |
// | | | | | +- 0=7 bits data | 0 1 0 0 | 4 | 4800 | A, B |
// | | | | | 1=8 bits data | 0 1 0 1 | 5 | 9600 | A, B |
// | | | | | | 0 1 1 0 | 6 | 19200 | A, B |
// | | | | +- 0=DTR normal | 0 1 1 1 | 7 | 38400 | A, B |
// | | | | 1=DTR complemented | 1 0 0 0 | 8 | 57600 | A, B |
// | | | | | 1 0 0 1 | 9 | 76800 | A, 2 |
// | | | +- 0=Normal | 1 0 1 0 | A |115200 | A, 2 |
// | | | 1=Echo flushed +---------+---+-------+------+
// | | |
// | | +- 0= Rx control characters enabled
// | | 1= Rx control characters disabled
// | |
// | +- 0=Reset DTR, it must be managed by the user program
// | 1=Set DTR, it must be managed by the user program
// | 2=DTR automatically managed without any time
// | 3=DTR automatically managed with defined time
// |
// +- 0:No wait
// 1:Wait
//
// Note: The CPU016A000 module has only the port "A".
// Note 1: The baud rate is not supported on port "B".
// Note 2: The baud rate is valid on port "B" in CPU016A100, CPU016A200 modules.
struct
{
unsigned char DTRComplement:1; //Complement the DTR signal
unsigned char EchoFlush:1; //Flush the echo
unsigned char RxCtrlDisable:1; //Disable Rx control characters
unsigned char NotUsed2:1; //Not used
// -----------------------------------------------------------------[Status]--
// It contains the serial communication status.
struct
{
BOOL RxParityFault:1; //Parity error in received data
BOOL RxOverlapFault:1; //Overlap error in received data
BOOL LostCharOnRead:1; //Lost character on read
BOOL LostCharOnWrite:1; //Lost character on write
}Status;
// --------------------------------------------------------------[DTR Times]--
Some fields of the dates structure are not managed in some libraries. In the table underneath the indication of the
diffrent fields is reported with reference to the supported libraries.
Examples
In the following example at the first loop of program execution the serial lines are set up.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Execute the set serials mode.
if (PLCFirstLoop)
{
// Enable the serial communication on serial port "A" and define
// parameters. Set serial at 19200, e, 8. DTR automatically managed
// without any time.
// [End of file]
Data types
TERMINALFUNCTIONS
This data structure it's used to define all the terminal device function vectors.
typedef struct
{
void (*SetCursorPos)(unsigned char Row, unsigned char Column);
unsigned char (*GetCursorRow)(void);
unsigned char (*GetCursorColumn)(void);
void (*DisplayClear)(unsigned char CharNumber);
void (*F04)(void);
void (*F05)(void);
void (*F06)(void);
void (*F07)(void);
void (*F08)(void);
void (*F09)(void);
void (*F0A)(void);
void (*F0B)(void);
void (*F0C)(void);
void (*F0D)(void);
void (*F0E)(void);
void (*F0F)(void);
}TERMINALFUNCTIONS;
Some fields of the dates structure are not managed in some libraries. In the following table the indication of
the different fields is reported with reference to the supported libraries.
Ofs Description
0E void (*F07)(void) - - - - E - A
Space for future allocations.
10 void (*F08)(void) - - - - E - A
Space for future allocations.
12 void (*F09)(void) - - - - E - A
Space for future allocations.
14 void (*F0A)(void) - - - - E - A
Space for future allocations.
16 void (*F0B)(void) - - - - E - A
Space for future allocations.
18 void (*F0C)(void) - - - - E - A
Space for future allocations.
1A void (*F0D)(void) - - - - E - A
Space for future allocations.
1C void (*F0E)(void) - - - - E - A
Space for future allocations.
1E void (*F0F)(void) - - - - E - A
Space for future allocations.
Data types
TERMINALSTRUCT
The terminal management requires a data structure of 16 bytes, we report a prototype. The user program can
works on the variable defined in this structure to reading the keys, to synchronize the display, to manage the LED
and to execute the data entry.
typedef struct
{
unsigned char TerminalAddress; //Terminal address
struct
{
BOOL LED0:1; //Key [0] led command
BOOL LED1:1; //Key [1] led command
BOOL LED2:1; //Key [2] led command
BOOL LED3:1; //Key [3] led command
BOOL LED4:1; //Key [4] led command
BOOL LED5:1; //Key [5] led command
BOOL LED6:1; //Key [6] led command
BOOL LCDBacklight:1; //LCD backlight command
}LEDCommand;
struct
{
BOOL K0:1; //Key [0] status
BOOL K1:1; //Key [1] status
BOOL K2:1; //Key [2] status
BOOL K3:1; //Key [3] status
BOOL K4:1; //Key [4] status
BOOL K5:1; //Key [5] status
BOOL K6:1; //Key [6] status
BOOL K7:1; //Key [7] status
struct
{
BOOL InputDataSkipped:1; //Set if skipped the input data
BOOL InputDataAborted:1; //Set if aborted the input data
Some fields of the data structure are not managed in some libraries because the type of terminal supported by
the library does not have all the functionalities provided. In the table below the indication of the different fields is
reported with reference to the supported libraries.
00 TerminalAddress It defines the hardware address of the terminal, the default value is - C - - - - A
0x07
01 LEDCommand LED0: Key LED command - C - - - - A
TerminalType
Definition Description
Examples
A PICOFACE terminal is managed with the display and the input of 2 variables.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
// -------------------------------------------------------------------------
// PICOFACE TERMINAL MANAGEMENT
// -------------------------------------------------------------------------
// Set the terminal "A" as standard I/O console.
// Execute the variables init and set the terminal data structure address.
if (PLCFirstLoop)
{
Ts.TerminalAddress=0x07; //Terminal address
Ts.KeyboardTimeOut=5000; //Keyboard timeout definition
Ts.LEDCommand.LCDBacklight=TRUE; //LCD backlight command
Ts.TerminalType=TERMINALTYPEPICOFACE; //Terminal type
SetTermIOData(&Ts); //Terminal data structure
TermIOOpen(); //Open the terminal I/O
// Copy the Keyboard status to the LED for keys [0] and [1].
if (Ts.Status.RefreshEnd)
printf("\nVarInt : %05d VarFloat: %05.1f ", VarInt, VarFloat);
// By pressing the [CLR] key, it's possible to select the parameter must be
// set. Please note that the parameter is select only if the [CLR] key is
// pressed as a first key.
if (Ts.Status.InputDataSkipped)
ParameterPtr^=TRUE; //Input parameter pointer
// If no keys are pressed, after the set timeout time the data input is
// automatically aborted and the parameter pointer is reset.
if (Ts.Status.KeyboardTimeOut)
ParameterPtr=FALSE; //Input parameter pointer
// When the data input is finished the value is stored into the variable.
if (Ts.Status.InputDataEnd)
if (!ParameterPtr)
scanf("%d", &VarInt);
else
scanf("%f", &VarFloat);
}
// [End of file]
Data types
TERMIOFUNCTIONS
This data structure it's used to define all the I/O console function vectors.
typedef struct
{
unsigned char DeviceType[2];
void* LocalVectors;
void (*SetVectors)(void);
void (*SetTermIOData)(void* Address);
void* (*GetTermIOData)(void);
BOOL (*TermIOOpen)(void);
BOOL (*TermIOClose)(void);
BOOL (*TermIOIsOpen)(void);
char (*GetCh)(void);
void (*PutCh)(char Character);
void (*TermIOTick)(void);
unsigned int (*GetRxChars)(void);
unsigned int (*GetTxSpace)(void);
void (*TermIORxClear)(void);
void (*TermIOTxClear)(void);
void (*TermIORxFlush)(void);
void (*TermIOTxFlush)(void);
unsigned int (*InputStream)(char *Destination, unsigned int Length);
unsigned int (*OutputStream)(generic char *Source, unsigned int Length);
void (*F0F)(void);
void (*F10)(void);
void (*F11)(void);
void (*F12)(void);
void (*F13)(void);
void (*F14)(void);
void (*F15)(void);
}TERMIOFUNCTIONS;
Some fields of the data structure are not managed in some libraries. In the following table the indication of
the diffrent fields is reported with reference to the supported libraries.
Ofs Description
04 void (*SetVectors)(void) D E - C A B A
Address of the set device vectors function.
06 void (*SetTermIOData)(void* Address) - - - - E - A
SetTermIOData device function address.
08 void* (*GetTermIOData)(void) - - - - E - A
GetTermIOData device function address.
0A BOOL (*TermIOOpen)(void) D E - C A B A
TermIOOpen device function address.
0C BOOL (*TermIOClose)(void) D E - C A B A
TermIOClose device function address.
0E BOOL (*TermIOIsOpen)(void) D E - C A B A
TermIOIsOpen device function address.
10 char (*GetCh)(void) D E - C A B A
GetCh device function address.
12 void (*PutCh)(char Character) D E - C A B A
PutCh device function address.
14 void (*TermIOTick)(void) D E - C A B A
TermIOTick device function address.
16 unsigned int (*GetRxChars)(void) D E - C A B A
GetRxChars device function address.
18 unsigned int (*GetTxSpace)(void) D E - C A B A
GetTxSpace device function address.
1A void (*TermIORxClear)(void) D E - C A B A
TermIORxClear device function address.
1C void (*TermIOTxClear)(void) D E - C A B A
TermIOTxClear device function address.
1E void (*TermIORxFlush)(void) D E - C A B A
TermIORxFlush device function address.
20 void (*TermIOTxFlush)(void) D E - C A B A
TermIOTxFlush device function address.
22 unsigned int (*InputStream)(char *Destination, unsigned int Length) D E - C A B A
InputStream device function address.
24 unsigned int (*OutputStream)(generic char *Source, unsigned int Length) D E - C A B A
OutputStream device function address.
26 void (*F11)(void) D E - C A B A
Space for future allocations.
28 void (*F12)(void) D E - C A B A
Space for future allocations.
2A void (*F13)(void) - - - - E - A
Space for future allocations.
2C void (*F14)(void) - - - - E - A
Space for future allocations.
2E void (*F15)(void) - - - - E - A
Space for future allocations.
DeviceType
Definition Description
Data types
TERMIOVECTORS
This data structure is used for the definition of the I/O console functions vectors. By using the function
SetTermIOVectors it is possible to set the vector to the desired I/O console, while the function
GetTermIOVectors returns the value of the set vector.
typedef struct
{
xdata void* TermIOData;
code TERMIOFUNCTIONS* TermIOFunctions;
}TERMIOVECTORS;
Some fields of the dates structure are not managed in some libraries. In the following table the indication of
the different fields is reported with reference to the supported libraries.
Ofs Description
Data types
USERFLAGS
typedef struct
{
unsigned char Dummy1:8;
This data structure is returned by the GetUserFlags function, it reports the user flags.
"C" variables
This variable contains the information inherent to all the errors of program execution, to every bit correspond the
indication of an error, the TRUE condition indicates the presence of the related error. The bits are set on the
appearance of the error and they must be reset by user program.
If at least one bit is set the RUN led on the target system will blink irregularly.
typedef struct
{
// ------------------------------------------------[Bit from 0x18 to 0x1F]--
BOOL b05:1;
BOOL b06:1;
BOOL b07:1;
}EXECUTIONERRORS;
In the following table the indication of the different bits is reported with reference to the supported libraries.
14
15
16
17
18 RtcDataError Rtc data error, the data read from the real time clock could be - - - - - - A
wrong. It's managed by the GetRtc function, it becames active if the
battery voltage drops down the 1 Volt. To reset the error in the Rtc
chip the SetRtc function must be called
19 RtcAccess Access error to the Rtc chip. It's managed by the functions that B C - A A A A
access to the real time clock chip GetRtc, SetRtc
1A I2CMClockTimout Timeout error on clock signal on I2C BUS in master mode. It is A A - A A A A
managed by the functions to access to the I2C BUS,
I2CMasterWrite, I2CMasterRead
1B I2CDataError Data signal error on I2C BUS in master mode. It is managed by the D E - C A B A
functions to access to the I2C BUS, I2CMasterWrite,
I2CMasterRead
1C I2CMAckTimout Timeout error on acknowledge by slave system on I2C BUS in A A - A A A A
master mode. It is managed by the functions to access to the I2C
BUS, I2CMasterWrite, I2CMasterRead
1D I2CMasterInit Init I2C BUS in master mode error. At the power on of the system A A - A A A A
the Clock and Data signals on I2C BUS are checked, if the test
does not have positive result error is signaled
1E
1F KernelFctNotPresent It's been called a function that is not present in the system kernel - - - - - - A
"C" variables
This variable contains the information inherent to all the errors of Kernel, to every bit correspond the indication of
an error, the TRUE condition indicates the presence of the related error. The bits are set on the appearance of
the error and they must be reset by user program.
If at least one bit is set the RUN led on the target system will blink irregularly.
typedef struct
{
// ------------------------------------------------[Bit from 0x18 to 0x1F]--
BOOL b18:1;
BOOL b19:1;
BOOL b1A:1;
BOOL b1B:1;
BOOL b1C:1;
BOOL b1D:1;
BOOL b1E:1;
BOOL b1F:1;
BOOL b05:1;
BOOL b06:1;
BOOL b07:1;
}EXECUTIONERRORS;
In the following table the indication of the different bits is reported with reference to the supported libraries.
16
17
18
19
1A
1B
1C
1D
1E
1F
"C" variables
This variable contains the information iherent to all the PLC execution errors, to every bit correspond the
indication of an error, the TRUE condition indicates the presence of the related error. The bits are set on the
appearance of the error and they must be reset by user program.
If at least one bit is set the RUN led on the target system will blink irregularly.
typedef struct
{
// ------------------------------------------------[Bit from 0x18 to 0x1F]--
BOOL b18:1;
BOOL b19:1;
BOOL b1A:1;
BOOL b1B:1;
BOOL b1C:1;
BOOL b1D:1;
BOOL b1E:1;
BOOL b1F:1;
BOOL b00:1;
BOOL b01:1;
BOOL b02:1;
BOOL b03:1;
BOOL b04:1;
BOOL b05:1;
BOOL b06:1;
BOOL b07:1;
}PLCERRORS;
In the following table the indication of the different bits is reported with reference to the supported libraries.
00
01
02
03
04
05
06
07
08 DivaDivisionZero It indicates the execution of a division for "0" in the execution of the - - C - - - -
instruction DIVA
09 FdivDivisionZero It indicates the execution of a division for "0" in the execution of the - - C - - - -
instruction FDIV
0A RestoreFault It indicates error in the restore of the backup data, it's activated at the - - C - - - -
system power on. In presence of this error all the backup data are
cleared
0B BackupFault It indicates error in the backup data - - C - - - -
0C
0D
0E
0F
10 FBParameters It indicates an error on function block parameters. It is managed by the - - D - - - -
FB: FbModbusAsciiSl, FbModbusRtuSl, FbI2CSerial, FbNetlogIIAD,
FbNetlogIIDA
11 FBManagement It indicates an error on function block execution. It is managed by the - - D - - - -
FB: FbI2CSlaveManager
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
"C" variables
This variable contains the information iherent to all the system errors , to every bit correspond the indication of an
error, the TRUE condition indicates the presence of the related error. The bits are set on the appearance of the
error and they must be reset by user program.
If at least one bit is set the RUN led on the target system will blink irregularly.
typedef struct
{
// ------------------------------------------------[Bit from 0x18 to 0x1F]--
BOOL b18:1;
BOOL b19:1;
BOOL b1A:1;
BOOL b1B:1;
BOOL b1C:1;
BOOL b1D:1;
BOOL b1E:1;
BOOL b1F:1;
BOOL b08:1;
BOOL TimerTimeSet:1; //Timer time set
BOOL MemoryType:1; //Memory type range error
BOOL MemoryAddress:1; //Memory address range error
BOOL IODeviceFctMissing:1; //I/O device function missing
BOOL IODeviceNotCorrect:1; //I/O device not correct
BOOL IODeviceLocalFctMissing:1; //I/O device local function missing
BOOL b0F:1;
BOOL b05:1;
BOOL b06:1;
BOOL b07:1;
}SYSTEMERRORS;
In the following table the indication of the different bits is reported with reference to the supported libraries.
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
"C" functions
HardwareConfig
This function returns the value of the configuration hardware word. The value is defined and is not modifiable, it
indicates the configuration present on the system.
Prototype
ElSystemLib.h
Declaration
unsigned int HardwareConfig(void);
Parameters
None
Return value
unsigned int Harware configuration
Example
In the following example it's saved in the HardwareCfg variable the hardware configuration of the system.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
static unsigned int HardwareCfg; //Hardware configuration
if (PLCFirstLoop)
HardwareCfg=HardwareConfig(); //Hardware configuration
}
// [End of file
"C" functions
ExecuteKernelFct
This function allows to execute a kernel function, it's possible to pass a value to the function and to receive a
return value from the function.
Prototype
ElSystemLib.h
Declaration
unsigned int ExecuteKernelFct(unsigned char Idx, unsigned int Value);
Parameters
unsigned char Idx Kernel function identifier
unsigned int Value Value to be passed to the function
Return value
unsigned int Value returned from the function
Function identifier
IdxDescription
Force user module error Sets the module error flag. It sets the UserModuleError flag of - - - - E- - A
kernel variables. The call to this function, activating the flag, allows
the user program to force the run led to blink with error code. The
function it's called for example by the ElPLCLib library in case of
01 activation of one of the PLCErrors bit.
Parameter: None
Return: Status 0: Function correctly executed. 1: Execution error
Set run led blink Sets the code the run LED has to blink. The blink has two different - - - - E - -
code frequency, slow that identifies the tens, and fast that identifies the
units.
02
Parameter: Blink
Defines the blink code (Range from 0 to 99).
code
Return: Status 0: Function correctly executed. 1: Execution error
NSyst ready management It sets the ready signal on the Netsyst bus. The signal in the base - - - - E - A
module is managed from the function SetPeripheralReady, but in
the extension modules it must be possible to manage it by the
user program. Normally this management is executed by the
03 FbI2CSlaveManager function block.
Examples
In the following example the run LED is set to blink with the code 32.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Set the RUN led to blink with code 32.
if (PLCFirstLoop)
if (ExecuteKernelFct(0x02, 32)) printf("Error");
}
// [End of file]
"C" functions
GetUserFlags
Prototype
ElSystemLib.h
Declaration
USERFLAGS GetUserFlags(void);
Parameters
None
Return value
USERFLAGS User flags
Example
In the following example it's saved in the UserFlags variable the user flag value. If the user can stop the program
a message is print out.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// USER FLAGS READ
// -------------------------------------------------------------------------
// Execute the user flags read at first program execution loop.
if (PLCFirstLoop)
{
UserFlags=GetUserFlags();
if (UserFlags.CanStop)
printf("The user can stop the program");
}
}
// [End of file]
"C" functions
KernelReadVar
This function reads a variable from the kernel. If an error occurs in reading the function doesn't change the value
in Buffer, returns TRUE and set the KernelReadVar bit in the KernelErrors structure. The variable ID that
generates the error is returned in the KrnReadVarErID variable of the kernel variables.
Prototype
ElSystemLib.h
Declaration
BOOL KernelReadVar(unsigned int VarID, void* Buffer);
Parameters
unsigned int VarID Variable ID to be read, its value will be transferred to Buffer
char* Buffer Memory buffer address were the variable value will be transferred
Return value
BOOL FALSE: Execution ok
TRUE: Execution error
Examples
In the following example the kernel program version will be write in the Kernel variable.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
static char Kernel[11]; //Kernel program version
if (PLCFirstLoop) KernelReadVar(0x0022, &Kernel); //Kernel program version
// [End of file]
"C" functions
KernelWriteVar
This function writes a variable to the kernel. If an error occurs in writing the function doesn't change the
variable, returns TRUE and set the KernelWriteVar bit in the KernelErrors structure. The variable ID that
generates the error is returned in the KrnWriteVarErID variable of the kernel variables.
Prototype
ElSystemLib.h
Declaration
BOOL KernelWriteVar(unsigned int VarID, void* Buffer);
Parameters
unsigned int VarID Variable ID to be write, the valueof Buffer will be transferred to the variable
char* Buffer Memory buffer address were the variable value will be read
Return value
BOOL FALSE: Execution ok
TRUE: Execution error
For the list if variables IDs please refer to the table in KernelReadVar function.
"C" functions
StopUserProgram
This function stops the user program and returns the control to the kernel.
Prototype
ElSystemLib.h
Declaration
void StopUserProgram(int Value);
Parameters
int
Action to be executed
Value
Return value
None
EXECUTECATCH Stops the user program forcing the kernel to execute a catch sequence. If the catch
doesn't be executed the user program will restarts.
STOPTOKERNEL Stops the user program and forces the kernel execution.
RESTARTPROGRAM Stops and restarts the user program.
STOPBYCOMMAND Stops the user program identifying it as an stop by command.
Example
In the following example on StopCmd set the user program is stopped and is returned the control to the kernel.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// STOP USER PROGRAM
// -------------------------------------------------------------------------
if (StopCmd) StopUserProgram(STOPTOKERNEL);
}
// [End of file]
"C" functions
UserPrgConfig
Prototype
ElSystemLib.h
Declaration
unsigned long UserPrgConfig(void);
Parameters
None
Return value
unsigned User program
long configuration
Example
In the following example the user configuration is stored in the UserConfig variable.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// USER CONFIGURATION READ
// -------------------------------------------------------------------------
// Execute the user configuration read at first program execution loop.
if (PLCFirstLoop)
UserConfig=UserPrgConfig();
}
// [End of file]
"C" functions
ArrayBitCount
This function executes the count of the bits set inside of an array, maximum 32 bytes array are managed (256
bit).
Prototype
ElSystemLib.h
Declaration
unsigned char ArrayBitCount(void* Array, unsigned char Length);
Parameters
void* Array It defines the array address (Range from 0x0000 to 0xFFFF)
unsigned char Length It defines the array length expressed in bytes (Range from 1 to 32)
Return value
unsigned char Number of bits set (Range da 0 a 255)
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
if (PLCPulse1000)
{
SetTermIOVectors(IOSerialPortA); //Set the serial port A as I/O console
Variable=0x00000000; //Variable
BitNr=ArrayBitCount(&Variable, sizeof(Variable)); //Number of bit set
printf("The value %08lX, has: %2d bits set.\n\r", Variable, BitNr);
Variable=0x80000000; //Variable
BitNr=ArrayBitCount(&Variable, sizeof(Variable)); //Number of bit set
printf("The value %08lX, has: %2d bits set.\n\r", Variable, BitNr);
Variable=0x80000001; //Variable
BitNr=ArrayBitCount(&Variable, sizeof(Variable)); //Number of bit set
printf("The value %08lX, has: %2d bits set.\n\r", Variable, BitNr);
Variable=0x01010101; //Variable
BitNr=ArrayBitCount(&Variable, sizeof(Variable)); //Number of bit set
printf("The value %08lX, has: %2d bits set.\n\r", Variable, BitNr);
Variable=0xFFFFFFFF; //Variable
BitNr=ArrayBitCount(&Variable, sizeof(Variable)); //Number of bit set
printf("The value %08lX, has: %2d bits set.\n\r", Variable, BitNr);
}
}
// [End of file]
"C" functions
ArrayBitSet
This function permits to force the logical status of a bit in the inside of an array, maximum 32 bytes array are managed (256 bit).
Prototype
ElSystemLib.h
Declaration
void ArrayBitSet(void* Array, unsigned char Length, unsigned char Bit, BOOL Status);
Parameters
void* Array It defines the array address (Range from 0x0000 to0xFFFF)
unsigned char Length It defines the array length expressed in bytes (Range from 1 to 32)
unsigned char Bit It defines the number of bit to be forced (Range from 0 to 255)
BOOL Status It defines the status to which the bit will be forced
TRUE: The bit will be set.
FALSE: The bit will be reset.
Return value
None
Examples
4 bits of a long variable are set, the variable initially cleared, will take the value 0x01010101.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
Variable=0; //Variable
ArrayBitSet(&Variable, sizeof(Variable), 0x00, TRUE); //Set the bit 0x00 of the variable
ArrayBitSet(&Variable, sizeof(Variable), 0x08, TRUE); //Set the bit 0x08 of the variable
ArrayBitSet(&Variable, sizeof(Variable), 0x10, TRUE); //Set the bit 0x10 of the variable
ArrayBitSet(&Variable, sizeof(Variable), 0x18, TRUE); //Set the bit 0x18 of the variable
// [End of file]
"C" functions
ArrayBitStatus
This function returns the logical status of a bit in the inside of an array, maximum 32 bytes array are managed
(256 bit).
Prototype
ElSystemLib.h
Declaration
BOOL ArrayBitStatus(void* Array, unsigned char Length, unsigned char Bit);
Parameters
void* Array It defines the array address (Range from 0x0000 to 0xFFFF)
unsigned char Length It defines the array length expressed in bytes (Range from 1 to 32)
unsigned char Bit It defines the number of the bit to be tested (Range from 0 to 255)
Return value
BOOL FALSE: Bit is reset
TRUE: Bit is set
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
if (PLCPulse1000)
{
Variable=0x80010101; //Variable
// [End of file]
"C" functions
AsciiStringConvert
Prototype
ElSystemLib.h
Declaration
BOOL AsciiStringConvert(unsigned char* Value, unsigned char* String, unsigned char Length);
Parameters
unsigned char* Value It defines the address of the converted hexadecimal value (Range from 0x0000 to 0xFFFF)
unsigned char* String It defines the address of the SourceCode ASCII string (Range from 0x0000 to 0xFFFF)
unsigned char Length It defines the length of string to be converted (Range from 0 to 255)
Return value
BOOL FALSE: Conversion correctly executed
TRUE: Conversion error
Example
It executes the conversion of an ASCII string in a 3 hexadecimal values on 3 different types of variables, at the
end of the conversion the variables will have the following values.
CharValue=0x12
IntValue=0x1234
LongValue=0x12345678
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
AsciiStringConvert(&CharValue, &String, 2);
AsciiStringConvert(&IntValue, &String, 4);
AsciiStringConvert(&LongValue, &String, 8);
}
// [End of file]
"C" functions
Linearize
This function executes a value linearization. It is necessary pass to the function the linearization data table address, the
function searches the value in the table executing the linear interpolation between two points of the table.
Prototype
ElSystemLib.h
Declaration
float Linearize(LINEARIZERECORD *Table, unsigned char Records, float Value);
Parameters
LINEARIZERECORD *Table It is the linearization data table address (Range from 0x0000 to 0xFFFF)
unsigned char Records It is the number of records defined in the linearization data table (Range da 0 a 255)
float Value It is the value to be linearized
Return value
float It is the linearized value
The linearization data, should be defined in a table mapped in code memory. The table must contains a sequence
of LINEARIZERECORD type records, where every record indicates the value in input to be linearized and the corresponding value
in output linearized. It is necessary to define the data in increasing way, so the data will be defined starting from the smallest value.
If the input value is smaller of the smaller definite value in the linearization table, the output value is calculated by considering a
slope calculated by the interpolation of the first two values of the table. If the input value is greater of the greatest definite value in
the linearization table, the output value is calculated by considering a slope calculated by the interpolation of the last two values of
the table.
// -----------------------------------------------------------------------------
// LINEARIZERECORD DATA STRUCTURE TYPE DEFINITION
// -----------------------------------------------------------------------------
// Each record reports the input value to be linearized and the corresponding
// linearized output value.
typedef struct
{
float Input; //Input value
float Output; //Output value
}LINEARIZERECORD;
Examples
In the following example it's executed a PTC temperature sensor linearization. In the table are defined the PTC resistance and
the corresponded temperature values.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// TEMPERATURE CONVERSION TABLE
// -----------------------------------------------------------------------------
// In the following table are reported the PTC resistance values at different
// temperatures and the corresponding temperature values.
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
Temperature=Linearize(&PTCTemperature, sizeof(PTCTemperature)/sizeof(LINEARIZERECORD), PTCResistance); //Temperature (Degree)
}
// [End of file]
"C" functions
MemCrc
This function calculates the 16 bits CRC on a memory area, it is possible to define also an initial CRC value so
that you can divide the calculation in several parts.
Prototype
ElSystemLib.h
Declaration
unsigned int MemCrc(unsigned char* StartAdd, unsigned int ByteNr, unsigned int CrcIni);
Parameters
unsigned char* StartAdd It defines the address of the memory area of which you want to calculate the CRC
(Range from 0x0000 to 0xFFFF)
unsigned int ByteNr It defines the number of bytes of the memory area on which you want to execute the
calculation (Range from 0x0000 to 0xFFFF)
unsigned int CrcIni It defines the initial CRC value (Range from 0x0000 to 0xFFFF)
Return value
unsigned int Calculated CRC value (Range from 0x0000 to 0xFFFF)
Examples
The 16 bit CRC value of the MemoryBuffer area it is calculated and the result value 0xC849, it is transferred in
the CRC1st variable. The same calculation divided in 3 parts it is transferred in the CRC2nd variable. The
calculation it is initialized with 0XFFFF value.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
struct
{
unsigned char Variable1;
unsigned int Variable2;
unsigned long Variable3;
}MemoryBuffer=
{
0x01,
0x0002,
0x00000003,
};
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Here the CRC of the "MemoryBuffer" is calculated. The calculation is
// started with 0xFFFF init value.
// The same result can be reached with the following. The calculation is
// started with 0xFFFF init value.
CRC2nd=MemCrc(&MemoryBuffer.Variable1, 1, 0xFFFF);
CRC2nd=MemCrc((unsigned char*)&MemoryBuffer.Variable2, 2, CRC2nd);
CRC2nd=MemCrc((unsigned char*)&MemoryBuffer.Variable3, 4, CRC2nd);
}
// [End of file]
"C" functions
ModbusCrc
This function calculates the 16 bits CRC on a memory area according to the format of the MODBUS Rtu protocol,
it's possible to define also an initial CRC value so that you can divide the calculation in several parts.
Prototype
ElSystemLib.h
Declaration
unsigned int ModbusCrc(unsigned char* StartAdd, unsigned int ByteNr, unsigned int CrcIni);
Parameters
unsigned char* StartAdd It defines the address of the memory area of which you want to calculate the CRC
(Range from 0x0000 to 0xFFFF)
unsigned int ByteNr It defines the number of bytes of the memory area on which you want to execute the
calculation (Range from 0x0000 to 0xFFFF)
unsigned int CrcIni It defines the initial CRC value (Range from 0x0000 to 0xFFFF)
Return value
unsigned int Calculated CRC value (Range from 0x0000 to 0xFFFF)
Examples
It's sent to the selected I/O console the MODBUS Rtu Read Holding Registers command. The CRC calculation
in initialized with the 0XFFFF value.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables declaration.
// Prepare the Modbus command frame for the "03, Read Holding Registers",
// command. The command is:
// [Node][03][Register address][Number of registers][CRC]
OutputStream((char*)&FrameBuf,8);
}
// [End of file]
"C" functions
Random
This function return a random number. At every function call a random number in the range from 0 to 255 is
returned.
Prototype
ElSystemLib.h
Declaration
unsigned char Random(void);
Parameters
None
Return value
unsigned char Random number (Range from 0 to 255)
Examples
At every second to the serial line the acquired random number is sent with a string as which reported below:
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables declaration.
// -------------------------------------------------------------------------
// PRINTOUT A RANDOM NUMBER
// -------------------------------------------------------------------------
// Read a random number and printout it.
if (PLCPulse1000)
{
RandomNr=Random(); //Random number
// [End of file]
"C" functions
NSYSTExtModuleAbort
This function sends an abort sequence to the extension module addressed. The reception of the abort
sequences causes the init of the extension module that returns to be waiting for a new order.
Prototype
ElSystemLib.h
Declaration
void NSYSTExtModuleAbort(unsigned char ModuleAdd);
Parameters
unsigned char ModuleAdd It defines the address of the extension module to which the abort sequence is sent
(Range from 1 to 7)
Return value
None
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
NSYSTExtModuleAbort(0x03);
}
// [End of file]
"C" functions
NSYSTExtModuleInp
This function executes the acquisition of the logical inputs from a peripheral modules of the Netsyst family. In
case of module address error the function ends by returning 1 and setting the NSYSTModuleAddress bit in the
SystemErrors data structure. In case of acquisition error the function ends by returning 3 and setting the
NSYSTBusAccess, NSYSTInputFault bits in the ExecutionErrors data structure.
Prototype
ElSystemLib.h
Declaration
unsigned char NSYSTExtModuleInp(unsigned char Module, unsigned int* Value);
Parameters
unsigned char Module It defines the address of the peripheral module (Range from 1 to 7)
unsigned int* Value It defines the address of the memory buffer where the acquisition value must be
transferred (Range from 0x0000 to 0xFFFF)
Return value
unsigned char It returns the acquisition error
0: No error
1: Addresse module error
3: Acquisition error
Examples
The acquisition of all the 12 digital inoput from the extension module with addresse 1 is managed. The acquired
value is memorized in a date structure to permit an easier management of every single enrty.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable declarations.
struct
{
BOOL Inp08:1; //Inp 08 bit
BOOL Inp09:1; //Inp 09 bit
BOOL Inp0A:1; //Inp 0A bit
BOOL Inp0B:1; //Inp 0B bit
BOOL Inp0C:1; //Not used
if (LogInp.Inp01)
printf("Input 01 is set.\r\n");
}
// [End of file]
"C" functions
NSYSTExtModuleNumber
This function returns the number of Netsyst extension modules connected to the system. The extension modules
are authomatically recognized with the execution of the SetPeripheralReady function, which automatically gives
an address from 1 to 7 to every extension module.
Prototype
ElSystemLib.h
Declaration
unsigned char NSYSTExtModuleNumber(void);
Parameters
None
Return value
unsigned char Number of extension modules connected to the system (Range from 0 to 7)
Examples
The number of Netsyst extension modules at present connected to the system returns in the variable Modules.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Read the number of attached extensions.
// [End of file]
"C" functions
NSYSTExtModuleOut
This function executes the management of the logic outputs of the peripheral modules of the Netsyst family. In case
of error of module address the function ends by returning 1 and setting the NSYSTModuleAddress bit in the
SystemErrors data structure. In case of management error the function ends by returning 3 and setting the
NSYSTBusAccess, NSYSTOutputFault bits in the ExecutionErrors data structure.
Prototype
ElSystemLib.h
Declaration
unsigned char NSYSTExtModuleOut(unsigned char Module, unsigned char Value);
Parameters
unsigned char Module It defines the address of the peripheral module (Range from 1 to 7)
unsigned char Value It defines the value to be transferred on the logic outputs
Return value
unsigned char It returns the error
0: No error
1: Module address error
3: Management error
Examples
The 8 digital ouputs of the module with address 1 are managed. The value transferred on the output is read from a
data structure to permit an easier management of every single exit.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
struct
{
BOOL Out00:1; //Out 00 bit
BOOL Out01:1; //Out 01 bit
BOOL Out02:1; //Out 02 bit
BOOL Out03:1; //Out 03 bit
BOOL Out04:1; //Out 04 bit
BOOL Out05:1; //Out 05 bit
BOOL Out06:1; //Out 06 bit
BOOL Out07:1; //Out 07 bit
}LogOut;
unsigned char Error; //Peripheral output management error
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
LogOut.Out00=PLCTimeBase400; //Out 00 bit
Error=NSYSTExtModuleOut(0x01, *(unsigned char*)&LogOut); //Outputs from 0 to 7
}
// [End of file]
"C" functions
NSYSTExtReadVar
This function reads a variable from the peripheral modules of the Netsyst family. In case of error of module
address the function ends by returning 1 and sets the NSYSTModuleAddress bit in the SystemErrors data
structure. In case of error of variable read the function ends by returning 3 and sets the NSYSTBusAccess bit in
the ExecutionErrors data structure.
Prototype
ElSystemLib.h
Declaration
unsigned char NSYSTExtReadVar(unsigned char Module, unsigned int VarAddress, unsigned char ByteNr, void*
Value);
Parameters
unsigned char Module It defines the address of the peripheral module (Range from 1 to 7)
unsigned int VarAddress It defines the variable address in the module memory (Range from 0x0000 to 0xFFFF)
unsigned char ByteNr It defines the bytes number of variable length (Range from 1 to 4)
void* Value It defines the address of the memory buffer where the variable value must be
transferred (Range from 0x0000 to 0xFFFF)
Return value
unsigned char It returns the acquisition error
0: No error
1: Module address error
3: Read variable error
Note
La funzione utilizza il comando 04: Memory read su bus I2C gestito dal blocco funzione FbI2CSlaveManager sul
sistema slave. L'indirizzo della variabile VarAddress corrisponde all'indirizzo dell'operando numerico sul sistema
slave, pertanto se VarAddress=0x0010 e ByteNr=0x02 verrà ritornato il valore dell'operando W 0010 del
sistema slave. ATTENZIONE! Se l'indirizzo della variabile è maggiore del range definito sul sistema slave la
funzione ritornerà errore.
Examples
The reading of an unsigned long variable mapped at the addresse 0x200 is managed from the extension
module 1. The variable value is memorized in the ReadValue buffer.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Here un "unsigned long" variable at address "0x200" is read from the
// Netsyst extension module "1".
// [End of file]
"C" functions
NSYSTExtWriteVar
This function writes a variable on the peripheral modules of the Netsyst family. In case of error of module
address the function ends by returning 1 and sets the NSYSTModuleAddress bit in the SystemErrors data
structure. In case of error of variable write the function ends by returning 3 and sets the NSYSTBusAccess bit in
the ExecutionErrors data structure.
Prototype
ElSystemLib.h
Declaration
unsigned char NSYSTExtWriteVar(unsigned char Module, unsigned int VarAddress, unsigned char ByteNr, void*
Value);
Parameters
unsigned char Module It defines the address of the peripheral module (Range from 1 to 7)
unsigned int VarAddress It defines the variable address in the module memory (Range from 0x0000 to 0xFFFF)
unsigned char ByteNr It defines the bytes number of variable length (Range from 1 to 4)
void* Value It defines the address of the memory buffer which contains the value to be transferred
to the variable. (Range from 0x0000 to 0xFFFF)
Return value
unsigned char It returns the management error
0: No error
1: Module address error
3: Write variable error
Note
La funzione utilizza il comando 05: Memory write su bus I2C gestito dal blocco funzione FbI2CSlaveManager
sul sistema slave. L'indirizzo della variabile VarAddress corrisponde all'indirizzo dell'operando numerico sul
sistema slave, pertanto se VarAddress=0x0010 e ByteNr=0x02 verrà scritto il valore nell'operando W 0010 del
sistema slave. ATTENZIONE! Se l'indirizzo della variabile è maggiore del range definito sul sistema slave la
funzione ritornerà errore.
Examples
The writing of an unsigned long variable mapped at the addresse 0x200 is executed on the extension module 1.
The value to be written is in the WriteValue buffer.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Here un "unsigned long" variable at address "0x200" is write to the
// Netsyst extension module "1".
// [End of file]
"C" functions
NSYSTModSts
This function returns the Netsyst extension module status, it returns a NSYSTEXTMODSTS data structure.
Prototype
ElSystemLib.h
Declaration
NSYSTEXTMODSTS NSYSTModSts(unsigned char Module);
Parameters
unsigned char Module Module address (Range from 0 to 7)
Return value
NSYSTEXTMODSTS Module status data structure
Examples
It's read the state of the extension module with address 1, and if the logic inputs are changed, they are read and
the value is sent out to the serial line.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable declarations.
// -------------------------------------------------------------------------
// CHECK EXTENSION STATUS AND ACQUIRE LOGIC INPUTS
// -------------------------------------------------------------------------
// Read the extension module status and check if logic inputs are changed.
if (Sts.InputChanged)
{
// Acquire the logic inputs and print the value.
// [End of file]
"C" functions
NSYSTReadyIn
This function returns the status of the RDYIN-N signal on the Netsyst extension bus. The signal has worthless
valence, so the function returns TRUE when the signal is active, that means that the signal is in the FALSE
status.
Prototype
ElSystemLib.h
Declaration
BOOL NSYSTReadyIn(void);
Parameters
None
Return value
BOOL FALSE: Ready signal on the Netsyst extension bus is not active
TRUE: Ready signal on the Netsyst extension bus is active
Examples
The status of the ready signal on the Netsyst extension bus is stored in the ReadySignal variable.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Here the ready in signal is stored in the "ReadySignal" variable.
// [End of file]
"C" functions
PeripheralInp
This function executes the acquisition of logic inputs from the peripheral modules. In case of access error to the peripheral
bus, on the Picosyst target the PSYSTInputFault bit is set, on the Netsyst targets the NSYSTInputFault bit is set, in the
ExecutionErrors data structure.
Prototype
ElSystemLib.h
Declaration
unsigned char PeripheralInp(unsigned char Module, unsigned char Input, unsigned char* Value);
Parameters
unsigned char Module It defines the address of the peripheral module (Range from 1 to 7)
unsigned char Input It defines the bank of input to be acquired (Range from 0 to 3)
unsigned char* Value It defines the address of the memory buffer where the acquired value must be transferred (Range
from 0x0000 to 0xFFFF)
Return value
unsigned char It returns the acquisition error
0: No error
1: Acquisition error
Examples
The acquisition of the 16 digital input from the module with addresse 0 is managed. The acquired value is memorized in a
data structure to permit an easier management of every single entry.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
struct
{
BOOL Inp08:1; //Inp 08 bit
BOOL Inp09:1; //Inp 09 bit
BOOL Inp0A:1; //Inp 0A bit
BOOL Inp0B:1; //Inp 0B bit
BOOL Inp0C:1; //Inp 0C bit
BOOL Inp0D:1; //Inp 0D bit
BOOL Inp0E:1; //Inp 0E bit
BOOL Inp0F:1; //Inp 0F bit
BOOL Inp00:1; //Inp 00 bit
BOOL Inp01:1; //Inp 01 bit
BOOL Inp02:1; //Inp 02 bit
BOOL Inp03:1; //Inp 03 bit
BOOL Inp04:1; //Inp 04 bit
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
if (LogInp.Inp01)
printf("Input 01 is set.\r\n");
}
// [End of file]
"C" functions
PeripheralOut
This function executes the management of the logic outputs on the peripheral modules. In case of access error to the
peripheral bus, on the Picosyst targets the PSYSTOutputFault bit is set, on the Netsyst targets the NSYSTOutputFault bit
is set, in the ExecutionErrors data structure.
Prototype
ElSystemLib.h
Declaration
unsigned char PeripheralOut(unsigned char Module, unsigned char Output, unsigned char Value);
Parameters
unsigned char Module It defines the address of the peripheral module (Range from 1 to 7)
unsigned char Output It defines the output bank to be managed (Range from 0 to 3)
unsigned char Value It defines the value to be tranferred to the output bank (Range from 0x00 to 0xFF)
Return value
unsigned char It returns the acquisition error
0: No error
Examples
The management of the 16 digital outputs on the module with address 0 is managed. The value to be transferred to the
outputs is read by a data structure to permit an easier management of every single output.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
struct
{
BOOL Out08:1; //Out 08 bit
BOOL Out09:1; //Out 09 bit
BOOL Out0A:1; //Out 0A bit
BOOL Out0B:1; //Out 0B bit
BOOL Out0C:1; //Out 0C bit
BOOL Out0D:1; //Out 0D bit
BOOL Out0E:1; //Out 0E bit
BOOL Out0F:1; //Out 0F bit
BOOL Out00:1; //Out 00 bit
BOOL Out01:1; //Out 01 bit
BOOL Out02:1; //Out 02 bit
BOOL Out03:1; //Out 03 bit
BOOL Out04:1; //Out 04 bit
BOOL Out05:1; //Out 05 bit
BOOL Out06:1; //Out 06 bit
BOOL Out07:1; //Out 07 bit
}LogOut;
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// [End of file]
"C" functions
RunLEDMng
Prototype
ElSystemLib.h
Declaration
void RunLEDMng(BOOL Command);
Parameters
BOOL Command FALSE: The LED is switched off
TRUE: The LED is switched on
Return value
None
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Here Run yellow LED is blinking.
RunLEDMng(PLCTimaBase400);
}
// [End of file]
"C" functions
SetPeripheralReady
This function manages the Ready signal on the peripheral bus, this signal is used to enable the modules
connected to the bus. The signal status is displayed by a green led on every target. In case of management error
the NSYSTBusAccess bit is set in the ExecutionErrors data structure.
The function also provides the automatical numbering of the Netsyst extension modules connected to the I2C
bus, the first module connected will take address 1, the second one 2 and so on until the module 7. the
numbering taken is a numbering used as reference in all the funcions of access to the peripheral modules, the
real I2C addresse of the module is 0x21 for the first module, 0x22 for the second one and so on.
Note: The operating system automatically provides the management of the Ready signal, with the user program
in run the signal is activated.
Prototype
ElSystemLib.h
Declaration
void SetPeripheralReady(BOOL Command);
Parameters
BOOL Command It defines the status in which the signal must be put
FALSE: The signal is inactivated, disabling the peripheral modules (Led off)
TRUE: The signal is activated, enabling the peripheral modules (Led on)
Return value
None
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Here the "Ready" signal is disabled.
// [End of file]
"C" functions
SystemMemoryRead
This function allows the reading of the system memory. In case of error on the memory type range the
MemoryType bit is set, in case of error on the memory address the MemoryAddress bit is set in the
SystemErrors data structure. In case of access error to the memory the MemoryAccess bit is ser in the
ExecutionErrors data structure.
Setting the bit MemoryAccessWait in the SystemConfig data structure, can be defined the behavior of the
function in case of access to EEPROM and FLASH memories when they are not ready.
FALSE: The read operation is not executed and the function returns error code 3.
TRUE: It is waited the memory ready and then the read operation is executed, if timeout error the function
returns error code 4.
Prototype
ElSystemLib.h
Declaration
unsigned char SystemMemoryRead(unsigned char Type, unsigned long Address, unsigned int Bytes, void*
Buffer);
Parameters
unsigned char Type 0: User data memory
1: User code memory
2: User storage memory
3: PCB088 mass memory module
4: PCB111 mass memory module
5: User I data memory
11: Kernel code memory
12: Kernel configuration memory
22: System configuration memory
Target 0 1 2 3 4 5 11 12 22
Netlog
Picosyst
Netreader T89C51ED2 Temic
NetlogII Lite
Netreader P89C664 Philips
PicosystME II
NetlogII
unsigned long Address It defines the reading address, its range changes according to the target system
unsigned int Bytes It defines the number of bytes to be read (Range from 0x0001 to 0xFFFF)
void* Buffer It defines the address where the read data is transferrred to (Range from 0x0000 to
0xFFFF)
Return value
Examples
At any second a memory dump of 32 bytes of user data memory is executed with a message like this:
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GENERAL DEFINITIONS
// -----------------------------------------------------------------------------
#define DATA 0
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
if (PLCPulse1000)
{
SetTermIOVectors(IOSerialPortA); //Set the serial port A as I/O console
printf ("DATA memory dump from 0x0000 to 0x001F\r\n");
Address=0x0000; //Memory address
if ((i&0X0F) == 0)
printf ("\r\n%02X: ", i);
if ((i&0X0F) == 6)
PutCh (' ');
}
printf ("\r\n\n");
}
}
// [End of file]
"C" functions
SystemMemoryWrite
This function allows the writing of the system memory.In case of error on the memory type range the
MemoryType bit in the SystemErrors data structure is set. In case of error on the memory address the
MemoryAddress bit in the SystemErrors data structure is set. In case of access error to the memory the
MemoryAccess bit in the ExecutionErrors data structure is set.
Setting the bit MemoryAccessWait in the SystemConfig data structure, can be defined the behavior of the
function in case of access to EEPROM and FLASH memories when they are not ready.
FALSE: The write operation is not executed and the function returns error code 3.
TRUE: It is waited the memory ready and then the write operation is executed, if timeout error the function
returns error code 4.
Prototype
ElSystemLib.h
Declaration
unsigned char SystemMemoryWrite(unsigned char Type, unsigned long Address, unsigned int Bytes, void*
Buffer);
Parameters
unsigned char Type 0: User data memory
1: User code memory
2: User storage memory
3: PCB088 mass memory module
4: PCB111 mass memory module
5: User I data memory
11: Kernel code memory
12: Kernel configuration memory
22: System configuration memory
Target 0 1 2 3 4 5 11 12 22
Netlog
Picosyst
Netreader T89C51ED2 Temic
NetlogII Lite
Netreader P89C664 Philips
PicosystME II
NetlogII
unsigned long Address It defines the reading address, its range changes according to the target system
unsigned int Bytes It defines the number of bytes to be written (Range from 0x0001 to 0xFFFF)
voidr* Buffer It defines the addrese of the buffer that contains the data to be written (Range from
0x0000 to 0xFFFF)
Return value
Examples
To every second it is incremented the value of an one unsigned long variable, its value it is written in user data
memory. The memory is read back and the written value and the read value are printout.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GENERAL DEFINITIONS
// -----------------------------------------------------------------------------
#define DATA 0
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
if (PLCPulse1000)
{
WriteValue++; //Value to be written
SystemMemoryWrite(DATA, (unsigned long)&Buffer, 4, &WriteValue);
SystemMemoryRead(DATA, (unsigned long)&Buffer, 4, &ReadValue);
// [End of file]
"C" functions
GetRtc
This function returns the time structure read from the real time clock. The value read from the real time clock
registers is transferred in the RTCDATA data structure whose address is passed to the function. If access error
to the real time clock chip the function returns TRUE and sets the RtcAccess bit in the ExecutionErrors data
structure without updating the data structure defined. If the real time clock are wrong, the RtcDataError bit in the
ExecutionErrors data structure is set, anyway the functions transfers the Rtc data in the data structure and
returns FALSE.
Prototype
ElSystemLib.h
Declaration
BOOL GetRtc(RTCDATA *Rtc);
Parameters
RTCDATA *Rtc Data structure address where value read from the RTC will be trasferred (Range from 0x0000 to
0xFFFF)
Return value
BOOL FALSE: RTC read executed
TRUE: RTC read error
Examples
The time data structure is read from the real time clock and a message is sent to the serial with the the current
date and time so as follows.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variables definition.
// Read the time data structure. To avoid loosing time the read is executed
if (PLCPulse500)
GetRtc(&RtcData);
if (RtcData.Second != SaveSecond)
{
SaveSecond=RtcData.Second; //Save the second buffer
// [End of file]
"C" functions
SetRtc
This function set the time in the real time clock. The value read by the RTCDATA data structure whose address
is passed to the function is transferred to the registers of the real time clock. If access error to the real time clock
the function returns TRUE and sets the RtcAccess bit in the ExecutionErrors data structure, the time value set in
the real time chip is not determined.
Prototype
ElSystemLib.h
Declaration
BOOL SetRtc(RTCDATA *Rtc);
Parameters
RTCDATA *Rtc Data structure address that contains the values to be written to the RTC (Range from 0x0000 to
0xFFFF)
Return value
BOOL FALSE: RTC write executed
TRUE: RTC write error
Examples
The reception of a charachter from a serial line is controlled, if a charachter is received, the reading of the time
structure from the real time clock is managed and a message is sent on serial with indication of current date and
time so as follows.
If the received charachter is "+", the value of the hour in the real time clock is increased.
If the received charachter is "-", the value of the hour in the real time clock is decreased.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variables definition.
if (GetRxChars())
{
// Read the received character.
switch (GetCh())
{
GetRtc(&RtcData); //Read the current RTC registers
// -----------------------------------------------------------------
// If the "+" is received the RTC hour is increased by 1.
case '+':
if (RtcData.Hour != 23)
RtcData.Hour++; //Current hour
else
RtcData.Hour=0; //Current hour
// -----------------------------------------------------------------
// If the "-" is received the RTC hour is decreased by 1.
case '-':
if (RtcData.Hour != 0)
RtcData.Hour--; //Current hour
else
RtcData.Hour=23; //Current hour
// If a char has been received the current data and time is printed out.
// [End of file]
"C" functions
GetClockIntTime
This function returns the execution time of the interrupt clock function, the time is set with tthe
SetClockIntTime function.
Prototype
ElSystemLib.h
Declaration
unsigned cha GetClockIntTime(void);
Parameters
None
Return value
unsigned char Returns the execution time of the interrupt clock function (Range da 1 a 255 mSec)
Examples
"C" functions
GetSystemTime
This function returns the system time increased at every tick (1 mSec). The returned value is expressed on a 16 bit
variable and reached its maximum value it restarts automatically from the value 0.
Prototype
ElSystemLib.h
Declaration
unsigned int GetSystemTime(void);
Parameters
None
Return value
unsigned int System time (Range from 0x0000 to 0xFFFF)
Examples
The use of this function permits to calculate the duration of an event, in the following example it is calculed the time in
which the logic input 0 remains active. The time calculation it is correct only in the range from 0 to 65535 mSec.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
if ((LogInp&0x01) != InputState)
{
InputState=(LogInp&0x01); //Save the input state
if (LogInp&0x01)
SetTimeBuf=GetSystemTime(); //Save the time when input becomes active
if (!(LogInp&0x01))
{
OnTime=GetSystemTime()-SetTimeBuf; //The time while the input still active
// [End of file]
"C" functions
IsMsecTimeOver
This function controls if a defined time is passed from the reference time, you need to save the reference time
with the GetSystemTime function. The function permits the management of programmable delay times and/or the
control on defined timeouts. If you desire to make the control on times longer than 65 seconds using a risolution
in seconds, it is possible to use the IsSecTimeOver function.
Prototype
ElSystemLib.h
Declaration
BOOL IsMsecTimeOver(unsigned int* Reference, unsigned int mSecDelay);
Parameters
unsigned int* Reference It defines the address of the buffer where the reference time has been memorized
(Range from 0x0000 to 0xFFFF)
unsigned int mSecDelay It defines the time to be controlled (Range from 0 to 65535 mSec)
Return value
BOOL FALSE: Time not yet passed
TRUE: Time is passed
Examples
In the example is executed the inversion at every second (Blinking) of the logic output 0 status. To be noted the
init of the reference time executed at the first program loop to guarantee the correct time also at the system on.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
if (PLCFirstLoop)
RefTimeBuf=GetSystemTime(); //Save the reference time
// Check if the time is passed and invert the logic output 0 state.
if (IsMsecTimeOver(&RefTimeBuf, 1000))
{
RefTimeBuf=GetSystemTime(); //Save the reference time
LogOut^=0x01; //Logical output buffer
}
// [End of file]
"C" functions
IsSecTimeOver
This function controls if a defined time is passed from the reference time, you need to save the reference time
with the GetSystemTime function. The function permits the management of programmable delay times and/or the
control on defined timeouts. If you desire to make the control on time shorter than 65 seconds disposing of a
risolution in thousandseconds, it is possible to use the IsMsecTimeOver function.
Prototype
ElSystemLib.h
Declaration
BOOL IsSecTimeOver(unsigned long* Reference, unsigned int SecDelay);
Parameters
unsigned long* Reference It defines the address of the buffer where the reference time has been memorized
(Range from 0x0000 to 0xFFFF)
unsigned int SecDelay It defines the time to be controlled (Range from 0 to 65535 Sec)
Return value
BOOL FALSE: Time not yet passed
TRUE: Time is passed
Examples
In the example is executed the inversion at every second (Blinking) of the logic output 0 status. To be noted the
init of the reference time executed at the first program loop to guarantee the correct time also at the system on.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
if (PLCFirstLoop)
RefTimeBuf=GetSystemTime(); //Save the reference time
// Check if the time is passed and invert the logic output 0 state.
if (IsSecTimeOver(&RefTimeBuf, 1))
{
RefTimeBuf=GetSystemTime(); //Save the reference time
LogOut^=0x01; //Logical output buffer
}
// [End of file]
"C" functions
SetClockIntTime
This function defines the execution time of the interrupt clock function. The address of the function to be
executed on interrupt must be defined with the SetClockIntVector function.
Prototype
ElSystemLib.h
Declaration
void SetClockIntTime(unsigned char Time);
Parameters
unsigned char Time It defines the execution time of the interrupt clock function (Range da 1 a 255 mSec)
Return value
None
Examples
"C" functions
SetClockIntVector
This function enables the clock interrupt and defines the address of the function to be executed on interrupt at the execution
time defined by the SetClockIntTime function. If the interrupt become active while the user function is still in execution, the
function is not executed and the ClockInterruptLatency bit in the ExecutionErrors variable is set. The user function will
continue to to be executed at the successive interrupts.
The user function it's executed with the microcontroller not in interrupt state, so all the interrupts independently from
their priority will be able to interrupt the execution of the function.
Prototype
ElSystemLib.h
Declaration
void SetClockIntVector(BOOL Enable, code *Address);
Parameters
BOOL Enable FALSE: Disables the interrupt.
TRUE: Enables the interrupt.
code *Address It defines the address of program to be executed on interruption (Range da 0x0000 a 0xFFFF)
Return value
None
Examples
The execution of the InterruptFunct function is executed every 1 mSec. In the function executed on interrupt the Counter
variable is increased, at every second the variable will be increased of 1000. In the main program are calculated the impulses
counted at every second (Frequency impulses), the value in the Frequency variable should be 1000 but it's possible to note
slightly different values due to the program loop execution time.
The functions executed in interrupt must not use memory overlays, they must be preceded by #pragma AUTO and
followed by #pragma NOAUTO.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM EXECUTED IN INTERRUPT
// -----------------------------------------------------------------------------
// Function executed on interrupt, it increases the counter.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM EXECUTED IN MAIN
// -----------------------------------------------------------------------------
// Function executed on main, it calculates how many pulses per second.
void Example(void)
{
static unsigned long AuxCounter; //Auxiliary counter buffer
if (PLCFirstLoop)
{
SetClockIntTime(1); //Set the clock interrupt time at 1 mSec
SetClockIntVector(TRUE, (code*)&InterruptFunct); //Set the clock interrupt vector
}
// To use in the main program the "Counter" variable, the interrupt must
// be disabled.
if (PLCPulse1000)
{
DISABLEINT; //Disable interrrupt
Frequency=(Counter-AuxCounter)*GetClockIntTime(); //Pulses frequency
AuxCounter=Counter; //Auxiliary counter buffer
ENABLEINT; //Enable interrrupt
}
}
// [End of file]
"C" functions
SetTimerEnable
This function enables and/or disables the timer, the timer can be used as times base to execute an
interruption function. If the Time value is out range the function sets the TimerTimeSet bit in the
SystemErrors data structure without changing the time value set. The address of the function to be
executed on interrupt must be defined with the SetTimerIntVector function.
Prototype
ElSystemLib.h
Declaration
void SetTimerEnable(BOOL Command, unsigned int Time);
Parameters
BOOL Command FALSE: Disables the timer
TRUE: Enables the timer
unsigned int Time It defines the interrupt interval time (Range from 0 to 65536 uSec)
Return value
None
Following we supply a table wich reports the maximum value to be set on the different target devices in
function of the microprocessor used. We remember that the version of the microprocessor can be known
from the product code or from the value reported in the SystemConfig variable.
In the target devices that have more than one serial port the use of the timer disables the operation of
the serial port reported in the table.
Examples
"C" functions
SetTimerIntVector
This function enables the interrupt on timer and defines the address of the user function to be executed on interrupt at the
execution time defined by the SetTimerEnable function. The user function will be executed with the microcontroller in interrupt
status, therefore no interrupts with the same priority will be able to interrupt the execution of the function.
The user function it's executed with the microcontroller in interrupt state, so only the interrupts with greather priority will
be able to interrupt the execution of the function.
Prototype
ElSystemLib.h
Declaration
void SetTimerIntVector(BOOL Enable, code *Address);
Parameters
BOOL Enable FALSE: Disables the timer 1interrupt.
TRUE: Enables the timer 1 interrupt.
code *Address It defines the address of program to be executed on interruption (Range from 0x0000 to 0xFFFF)
Return value
None
Examples
The timer is enabled and set to execute cyclically every 1 mSec on interrupt the InterruptFunct function. In the function
executed in interrupt the Counter variable is increased, at every second the variable will be increased of 1000.
The functions executed in interrupt must not use memory overlays, they must be preceded by #pragma AUTO and
followed by #pragma NOAUTO.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM EXECUTED IN INTERRUPT
// -----------------------------------------------------------------------------
// Function executed at every 1 mSec, it increments the Counter.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM EXECUTED IN MAIN
// -----------------------------------------------------------------------------
void Example(void)
{
// Enable the "InterruptFunct" execution at every 1 mSec.
if (PLCFirstLoop)
{
SetTimerEnable(TRUE, 1000); //Set the timer interrupt time at 1 mSec
SetTimerIntVector(TRUE, (code*) &InterruptFunct); //Set the timer interrupt vector
}
}
// [End of file]
"C" functions
SetEIntVector
This function enables the interrupt on external signal and defines the address of the user function to be executed on
interrupt. If the interrupt happens while the user function is still in execution the ExtInterruptLatency bit in the
ExecutionErrors variable is set and when the function ends it will be recalled. In the user function by checking this bit it's
possible to take all the necessary actions.
In case of interrupt overlap if the bit ExtInterruptLatency flag it's not reset by the user program in the function
executed on interrupt, the external interrrupt it's disabled. To enable it it's necessary to execute the SetEIntVector
function again.
The user function it's executed with the microcontroller not in interrupt state, so all the interrupts independently from
their priority will be able to interrupt the execution of the function.
Prototype
ElSystemLib.h
Declaration
void SetEIntVector(BOOL Enable, code *Address);
Parameters
BOOL Enable FALSE: Disables the interrupt.
TRUE: Enables the interrupt.
code *Address It defines the address of program to be executed on interruption (Range from 0x0000 to 0xFFFF)
Return value
None
Examples
In the following example we assume to have joined to the external interrupt a pulses generator, the interrupt function provide
to the pulses count, while in the main it's calculated the number of pulses at every second (Pulses frequency) the value is
returned in the Frequency variable.
The functions executed in interrupt must not use memory overlays, they must be preceded by #pragma AUTO and
followed by #pragma NOAUTO.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM EXECUTED IN INTERRUPT
// -----------------------------------------------------------------------------
// Function executed on interrupt, it count the pulses.
if (!ExecutionErrors.ExtInterruptLatency)
OvlCtr=0; //Overlaps counter
else if (++OvlCtr > 2)
IsOverlap=TRUE; //Interrupt overlap
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM EXECUTED IN MAIN
// -----------------------------------------------------------------------------
// Function executed on main, it calculates how many pulses per second.
void Example(void)
{
static unsigned long AuxCounter; //Auxiliary counter buffer
if (PLCFirstLoop)
SetEIntVector(TRUE, (code*)&InterruptFunct); //Set the external interrupt vector
// To use in the main program the "Counter" variable, the interrupt must
// be disa?bled.
if (PLCPulse1000)
{
DISABLEINT; //Disable interrrupt
Frequency=Counter-AuxCounter; //Pulses frequency
AuxCounter=Counter; //Auxiliary counter buffer
ENABLEINT; //Enable interrrupt
}
}
// [End of file]
"C" functions
SetPwDownIntVector
This function enables and defines the execution address of the program to be executed on power down.
Prototype
ElSystemLib.h
Declaration
void SetPwDownIntVector(BOOL Enable, code *Address);
Parameters
BOOL Enable FALSE: Disables the interrupt.
TRUE: Enables the interrupt.
code *Address It defines the address of program to be executed on interruption (Range from 0x0000 to 0xFFFF)
Return value
None
Examples
The vector for the power down interrupt management is set to execute on interrupt the InterruptFunct function. When the power
supply come down under to the threshold value the function will be automatically executed. The use of this function is suggested to
expert users.
WARNING! The functions executed in interrupt must not use memory overlays, they must be preceded by #pragma AUTO and
followed by #pragma NOAUTO.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM EXECUTED ON INTERRUPT
// -----------------------------------------------------------------------------
// Function executed on power down interrupt, it increments the Counter.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM EXECUTED ON MAIN
// -----------------------------------------------------------------------------
void Example(void)
{
// Enable the "InterruptFunct" execution on power down interrupt.
if (PLCFirstLoop)
SetPwDownIntVector(TRUE, (code*)&InterruptFunct); //Set the power down interrupt vector
}
// [End of file]
"C" functions
GetWDogTime
Prototype
ElSystemLib.h
Declaration
unsigned int GetWDogTime(void);
Parameters
None
Return value
unsigned int Watch dog defined time (Range from 0 to 65535 mSec)
Examples
At the first program execution loop the watch dog defined time is read and its value is sent to the serial line with a
message like this:
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Print out the watch dog time currently set.
if (PLCFirstLoop)
{
SetTermIOVectors(IOSerialPortA); //Set the serial port A as I/O console
printf("The watch dog time is set to:%5d mSec\r\n", GetWDogTime());
}
}
// [End of file]
"C" functions
HwWDogRefresh
This function executes the hardware refresh of the watch dog circuit. This function must be used only in
special cases, normally we suggest to use the WDogRefresh.
Prototype
ElSystemLib.h
Declaration
void HwWDogRefresh
(void);
Parameters
None
Return value
None
"C" functions
SetWDogTime
This function sets the watch dog time. If the watch dog circuit is not refreshed by the user program with a call to
the function WDogRefresh, within the defined time, all the logical exits are cleared and the system is reset. The
default watch dog time is set at 1400 mSec.
Prototype
ElSystemLib.h
Declaration
void SetWDogTime(unsigned int Time);
Parameters
unsigned int Time Watch dog time (Range from 0 to 65535 mSec)
Return value
None
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Set the wdog time a 1 second.
if (PLCFirstLoop)
SetWDogTime(1000);
}
// [End of file]
"C" functions
WDogRefresh
This function executes the refresh of the watch dog circuit. If the watch dog circuit is not refreshed by the
user program with a call to this function, within the defined time, all the logical exits are cleared and the
system is reset.
The program execution is ciclical, and the operating system provides automatically to the refreshning of the
watch dog circuit with a call to this function before the execution of the program loop. Therefore the use of
this function is needed just in certain cases when for example the user program stops itself in a waiting loop.
Prototype
ElSystemLib.h
Declaration
void WDogRefresh
(void);
Parameters
None
Return value
None
"C" functions
I2CMasterNodeCheck
This functions checks if the specified peripheral device is connected to the I2C BUS. Passing to the function the
peripheral device address, it checks if the peripheral is connected to the BUS and returns the connection status.
Prototype
ElSystemLib.h
Declaration
BOOL I2CMasterNodeCheck(unsigned char I2CAddress);
Parameters
unsigned char I2CAddress It defines the address of the peripheral connected to the I2C bus (Range from 0x00
to 0X7F)
Return value
BOOL FALSE: Peripheral device not connected
TRUE: Peripheral device connected
Examples
Is checked the presence of the real time clock and the PCB111 memory mass module. If both the devices are
connected a string like this reported is sent from the serial line.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Execute the test every 1 second.
if (PLCPulse1000)
{
SetTermIOVectors(IOSerialPortA); //Set the serial port A as I/O console
printf("\n\n\nHere the list of the available devices.\r\n\n");
if (I2CMasterNodeCheck(0x51))
printf("The Real Time Clock is present.\r\n");
// Check the presence of the PCB111 mass memory module (Address 0x52).
if (I2CMasterNodeCheck(0x52))
printf("The PCB111 mass memory module is present.\r\n");
}
}
// [End of file]
"C" functions
I2CMasterRead
This function allows the reading from peripherals connected to the I2C bus. The function manages the peripherals
stretching. In the case in which the peripheral does not returns the acknowledge of the sent date the function ends by
returning 1 and setting the I2CMNoAck bit in the SystemErrors data structure. In the case in which the peripheral
forces the low clock signal for a time longer than 1mSec the function ends by returning 2 and setting the
I2CMClockTimout bit in the SystemErrors data structure.
Prototype
ElSystemLib.h
Declaration
unsigned char I2CMasterRead(unsigned char I2CAddress, unsigned char NrOfBytes, unsigned char *DataBuffer);
Parameters
unsigned char I2CAddress It defines the address of the peripheral connected to the I2C bus (Range from 0x00 to
0X7F)
unsigned char NrOfBytes It defines the number of bytes to be read (Range from 0x00 to 0xFF)
unsigned char *DataBuffer It defines the address of the data buffer where the data read from the peripheral are
stored (Range from 0x0000 to 0xFFFF)
Return value
unsigned char 0: Ok, command executed
1: No Ack, the peripheral has not sent the acknowledge signal
2: BusFault, the I2C bus is busy
Examples
The logic input status is read from Netsyst extension module connected to the I2C bus. We remind you that the
Netsyst extension modules automatically take their address in function of their related position on the bus, the
module directly connected to the base module will have addresse 0x21, the following one 0x22 and so on.
CMD CKS Command frame to send to Netsyst extension to read logic input
CMD MSBVALUE LSBVALUE CKS Answer frame with logic inputs status
Where:
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL DEFINITIONS
// -----------------------------------------------------------------------------
// I2C device address definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Here create the command frame to be sent.
FrameBuf[0]=0x06; //Command
FrameBuf[1]=-(MODULEADD+FrameBuf[0]); //Checksum
if (!I2CMasterWrite(MODULEADD, 2, &FrameBuf))
{
// If the command frame has been correctly sent the answer is read.
if (!I2CMasterRead(MODULEADD, 4, &FrameBuf))
{
// If the answer frame has been correctly received the data is checked.
// [End of file]
"C" functions
I2CMasterWrite
This function allows the writing on peripheral connected to the I2C bus. The function manages the stretching of the
peripherals. In the case in which the peripheral does not returns the acknowledge of the sent date the function ends
by returning 1 and setting the I2CMNoAck bit in the SystemErrors data structure. In the case in which the peripheral
forces the low clock signal for a time longer than 1mSec the function ends by returning 2 and setting the
I2CMClockTimout bit in the SystemErrors data structure.
Prototype
ElSystemLib.h
Declaration
unsigned char I2CMasterWrite(unsigned char I2CAddress, unsigned char NrOfBytes, unsigned char *DataBuffer);
Parameters
unsigned char I2CAddress It defines the address of the peripheral connected to the I2C bus (Range from 0x00 to
0X7F)
unsigned char NrOfBytes It defines the number of bytes to be write (Range from 0x00 to 0xFF)
unsigned char *DataBuffer It defines the address of the data buffer where the data written to the peripheral are read
(Range from 0x0000 to 0xFFFF)
Return value
unsigned char 0: Ok, command executed
1: No Ack, the peripheral has not sent the acknowledge signal
2: BusFault, the I2C bus is busy
Examples
At every second the Value variable is increased and its value is transferred on the logical exits of a Netsyst extension
module connected to the I2C bus. We remind you that the Netsyst extension modules automatically take their
address in function of their related position on the bus, the module directly connected to the base module will have
addresse 0x21, the following one 0x22 and so on.
CMD VALUE CKS Frame of order I2C to be sent to the extension module to set its logical exits
CMD CKS Frame of answer from extension module
Where:
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL DEFINITIONS
// -----------------------------------------------------------------------------
// I2C device address definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Here the output value is increased every second.
if (PLCPulse1000)
Value++; //Output value
FrameBuf[0]=0x09; //Command
FrameBuf[1]=Value; //Value to be set to the ouptut
FrameBuf[2]=-(MODULEADD+FrameBuf[0]+FrameBuf[1]); //Checksum
if (!I2CMasterWrite(MODULEADD, 3, &FrameBuf))
{
// If the command frame has been correctly sent the answer is read.
if (!I2CMasterRead(MODULEADD, 2, &FrameBuf))
{
// If the answer frame has been correctly received the data is checked.
// [End of file]
"C" functions
I2CSlaveAddress
We remember that all the Netsyst family modules have address between 0x21 and 0x27.
Prototype
ElSystemLib.h
Declaration
void I2CSlaveAddress(unsigned char Address);
Parameters
unsigned char Address I2C module address (Range from 0x00 to 0x7F)
Return value
None
Examples
"C" functions
I2CSlaveEnable
Prototype
ElSystemLib.h
Declaration
void I2CSlaveEnable(BOOL command);
Parameters
BOOL Command FALSE: Disables the I2C interrupt disabling the communication
TRUE: Enables the I2C interrupt enabling the communication
Return value
None
"C" functions
I2CSlaveInit
Prototype
ElSystemLib.h
Declaration
void I2CSlaveInit
(void);
Parameters
None
Return value
None
"C" functions
I2CSlaveVectors
This function set the address to the I2CMNGFUNCTIONS data structure, it defines the vectors to the bus
I2C communication management functions.
Prototype
ElSystemLib.h
Declaration
void I2CSlaveVectors(code I2CMNGFUNCTIONS* Address);
Parameters
code I2CMNGFUNCTIONS* Address It defines the data structure address (Range from 0x0000 to
0xFFFF)
Return value
None
"C" functions
GetSerialMode
This function returns the communication mode set on the selected port. The value is transferred in the
SERIALSTRUCT data structure whose address is passed to the function.
Prototype
ElSystemLib.h
Declaration
void GetSerialMode(SERIALSTRUCT* S);
Parameters
SERIALSTRUCT* S IData structure address where the serial mode will be transferred (Range from 0x0000 to 0xFFFF)
Return value
None
Examples
The presence of possible errors of parity and overrun on reception from serial line "A" is checked.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Read the serial "A" parameters.
// [End of file]
"C" functions
SerialDTRMng
This function permits to set the status of the DTR signal available on the serial portc onnector, this signal is
usually used to command devices connected to the serial line. In the targets equipped with RS485 line in
multidrop connection, the DTR signal is used to connect the transmission driver to the line.
WARNING! The management of the DTR signal by using this function is possible only if DTRManagement in the
SERIALSTRUCT structure is defined with the value 0 or 1. On the contrary there is a conflict between the
automatical management of the signal and the value defined by the function.
Prototype
ElSystemLib.h
Declaration
void SerialDTRMng(BOOL Value);
Parameters
BOOL Value FALSE: The signal is set in the inactive logic
status
TRUE: The signal is set in the active logic status
Return value
None
Examples
It is managed the blinking every 400 mSec of the DTR signal on the "A" serial line.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// The DTR signal blink according to the "Toggle400" bit.
// [End of file]
"C" functions
SetSerialMode
This function sets the communication mode on the selected serial port. You need to define the communication
mode by properly setting the SERIALSTRUCT data structure whose addresse is passed to the function.
Prototype
ElSystemLib.h
Declaration
void SetSerialMode(SERIALSTRUCT* S);
Parameters
SERIALSTRUCT* S Serial configuration data structure address (Range from 0x0000 to 0xFFFF)
Return value
None
Examples
At the first loop of program execution loop the communication on the "A" serial line is set at 19200 baud, even
parity , 8 bits of date, DTR signal authomatically managed without times. At every second the "Hello world!"
message is sent on the serial.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// SET SERIAL PORT PARAMETERS AND SEND A MESSAGE
// -------------------------------------------------------------------------
// Define the serial port must be used A as I/O console.
// Enable the serial communication on serial port "A" and define parameters.
// Set serial at 19200, e, 8. DTR automatically managed without any time
if (PLCFirstLoop)
{
GetSerialMode(&SerialStruct); //Get communication mode
SerialStruct.Mode.DTRComplement=FALSE; //Complement the DTR signal
SerialStruct.Mode.EchoFlush=FALSE; //Flush the echo
SerialStruct.Mode.RxCtrlDisable=TRUE; //Disable Rx control characters
SerialStruct.Mode.DTRManagement=2; //Define the DTR management
SerialStruct.Mode.WaitLoop=FALSE; //FALSE:No wait, TRUE:Wait
SerialStruct.Mode.ParityEnabled=TRUE; //Enables the parity management
SerialStruct.Mode.ParityType=TRUE; //FALSE:Odd parity, TRUE:Even parity
SerialStruct.Mode.BitNumber=TRUE; //FALSE:7 bit, TRUE:8 bit
SerialStruct.Mode.Baud=6; //Baud rate
SerialStruct.DTROnTime=0; //DTR On wait time
SerialStruct.DTROffTime=0; //DTR Off delay time
SetSerialMode(&SerialStruct); //Set communication mode
TermIOOpen(); //Open the set I/O console
}
// [End of file]
"C" functions
DisplayClear
This function clears the display (shows space 0x20 character) starting from the current position of the cursor for
the number of defined characters.
Prototype
ElSystemLib.h
Declaration
void DisplayClear(unsigned char CharNumber);
Parameters
unsigned char CharNumber Number of characters to be cleared (Range from 1 to 32)
Return value
None
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
if (PLCFirstLoop)
{
Ts.TerminalAddress=0x07; //Terminal address
Ts.KeyboardTimeOut=5000; //Keyboard timeout definition
Ts.LEDCommand.LCDBacklight=TRUE; //LCD backlight command
}
// Set the terminal as standard I/O console and call the I/O tick.
// Cursor positioning and blink the string "Hello world!" on the display.
if (Ts.Status.RefreshEnd)
{
SetCursorPos(0, 2); //Set cursor position
if (!PLCTimeBase800)
DisplayClear(12);
else
printf("Hello world!");
}
}
// [End of file]
"C" functions
GetCursorColumn
This function returns the column where the cursor is located on the display.
Prototype
ElSystemLib.h
Declaration
unsigned char GetCursorColumn(void);
Parameters
None
Return value
unsigned char Column where the cursor is located (Range from 0 to 15)
Examples
The cursor is located on the line 0 and column 10 of the display and the "Hello world!" text is displayed. The text
starting from the line 0 will continue in the line 1, the real position of the cursor is read now will be located on line
1 and column 6.
At the first program execution loop the variables of the terminal are initialized. The TermIOTick function must be
executed at every program loop. The writing on the display must be sinchronized with the Status.RefreshEnd bit
to avoid flickering of the text on the display.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
if (PLCFirstLoop)
{
Ts.TerminalAddress=0x07; //Terminal address
Ts.KeyboardTimeOut=5000; //Keyboard timeout definition
Ts.LEDCommand.LCDBacklight=TRUE; //LCD backlight command
}
// Set the terminal as standard I/O console and call the I/O tick.
// Execute the cursor positioning on the top line of the display, write
// "Hello world!" and read the new cursor position.
if (Ts.Status.RefreshEnd)
{
SetCursorPos(0, 10); //Set cursor position
printf("Hello world!");
CursorRow=GetCursorRow(); //Row where the cursor is positioned
CursorColumn=GetCursorColumn(); //Column where the cursor is positioned
}
}
// [End of file]
"C" functions
GetCursorRow
This function returns the row where the cursor is located on the display.
Prototype
ElSystemLib.h
Declaration
unsigned char GetCursorRow(void);
Parameters
None
Return value
unsigned char Row where the cursor is located (Range from 0 to 1)
Examples
The cursor is located on the line 0 and column 10 of the display and the "Hello world!" text is displayed. The text
starting from the line 0 will continue in the line 1, the real position of the cursor is read now will be located on line
1 and column 6.
At the first program execution loop the variables of the terminal are initialized. The TermIOTick function must be
executed at every program loop. The writing on the display must be sinchronized with the Status.RefreshEnd bit
to avoid flickering of the text on the display.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
if (PLCFirstLoop)
{
Ts.TerminalAddress=0x07; //Terminal address
Ts.KeyboardTimeOut=5000; //Keyboard timeout definition
Ts.LEDCommand.LCDBacklight=TRUE; //LCD backlight command
}
// Set the terminal as standard I/O console and call the I/O tick.
// Execute the cursor positioning on the top line of the display, write
// "Hello world!" and read the new cursor position.
if (Ts.Status.RefreshEnd)
{
SetCursorPos(0, 10); //Set cursor position
printf("Hello world!");
CursorRow=GetCursorRow(); //Row where the cursor is positioned
CursorColumn=GetCursorColumn(); //Column where the cursor is positioned
}
}
// [End of file]
"C" functions
SetCursorPos
This function permits to locate the cursor on the display. The following functions of writing on the display will work
starting from the current position of the cursor.
Prototype
ElSystemLib.h
Declaration
void SetCursorPos(unsigned char Row, unsigned char Column);
Parameters
unsigned char Row Row where the cursor must be located (Range from 0 to 1)
unsigned char Column Column where the cursor must be located (Range from 0 to 15)
Return value
None
Examples
The cursor is located in two different positions on the display and the "Hello!" and "Hello world!" texts are shown.
At the first program execution loop the variables of the terminal are initialized. The TermIOTick function must be
executed at every program loop. The writing on the display must be sinchronized with the Status.RefreshEnd bit
to avoid flickering of the text on the display.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
if (PLCFirstLoop)
{
Ts.TerminalAddress=0x07; //Terminal address
Ts.KeyboardTimeOut=5000; //Keyboard timeout definition
Ts.LEDCommand.LCDBacklight=TRUE; //LCD backlight command
// Set the terminal as standard I/O console and call the I/O tick.
if (Ts.Status.RefreshEnd)
{
SetCursorPos(0, 5); //Set cursor position
PutCh('H');
PutCh('e');
PutCh('l');
PutCh('l');
PutCh('o');
PutCh('!');
}
if (Ts.Status.RefreshEnd)
{
SetCursorPos(1, 2); //Set cursor position
printf("Hello world!");
}
}
// [End of file]
"C" functions
GetCh
This function returns a charachter from the selected I/O console. If the selected I/O console is the serial line, in function of the
setting of the Mode.WaitLoop bit of the SERIALSTRUCT structure, the function has a different behaviour the character reception.
If the bit is FALSE, the function is not blocking, if no characters are available in the reception buffer, the function returns 0. If the
bit is TRUE, the function is blocking, if no characters are available in the reception buffer, it blocks waiting for a charachter from
the serial line.
WARNING! In the blocking mode, the calling to the function, if no charachters are available in the reception buffer, blocks the
program execution loop with intervention of the watch dog circuit. We suggest you before to call the function to check the
availability of at least one charachter in the reception buffer by using the GetRxChars function.
Prototype
ElSystemLib.h
Declaration
char GetCh(void);
Parameters
None
Return value
char Character received from the selected I/O console (Range from 0x00 to 0xFF)
Examples
The reception of a character from the serial line is controlled and a message with indication of the received character is sent. If the
ASCII A character is received a message like this reported below is sent to the serial line.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Manage the serial port "A" tick.
if (GetRxChars())
{
// Read the received character.
printf("The \"%c\" character, 0x%02X ASCII, has been received\r\n", RxChar, RxChar);
}
}
// [End of file]
"C" functions
GetRxChars
This function returns the number of available characters from the selected I/O console. The function can be used to control if there
are available character in reception before executing the reading functions of the charachters.
Prototype
ElSystemLib.h
Declaration
unsigned int GetRxChars(void);
Parameters
None
Return value
unsigned int Number of available characters from the selected I/O console (Range from 0x0000 to 0xFFFF)
Examples
The reception of a character from the serial line is controlled and a message with indication of the received character is sent. If the
ASCII A character is received a message like this reported below is sent to the serial line.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// -------------------------------------------------------------------------
// SET SERIAL PORT AND WAIT FOR A CHARACTER
// -------------------------------------------------------------------------
// Define the serial port must be used A as I/O console and open it.
if (GetRxChars())
{
// Read the received character.
printf("The \"%c\" character, 0x%02X ASCII, has been received\r\n", RxChar, RxChar);
}
}
// [End of file]
"C" functions
GetTermIOData
This function returns the allocation address of the selected device data structure.
Prototype
ElSystemLib.h
Declaration
void* GetTermIOData(void);
Parameters
None
Return value
void* Allocation address of the selected device data structure (Range from 0x0000 to 0xFFFF)
Examples
In the example the function it's used to return the TERMINALSTRUCT terminal data structure allocation address. The user program
will be able to work on the variables defined in this structure to the reading the keys status, to the display synchronization, to the
LED management and for the data input.
The program displays the "Hello world!" text blinking on the display.
At the first program execution loop the variables of the terminal are initialized. The TermIOTick function must be executed at every
program loop. The writing on the display must be sinchronized with the Status.RefreshEnd bit to avoid flickering of the text on the
display.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
if (PLCFirstLoop)
{
Ts.TerminalAddress=0x07; //Terminal address
Ts.KeyboardTimeOut=5000; //Keyboard timeout definition
Ts.LEDCommand.LCDBacklight=TRUE; //LCD backlight command
}
// Set the terminal as standard I/O console and call the I/O tick.
// Cursor positioning and blink the string "Hello world!" on the display.
if (((TERMINALSTRUCT*)GetTermIOData())->Status.RefreshEnd)
if (!PLCTimeBase800)
printf("\n");
else
printf("\nHello world!");
}
// [End of file]
"C" functions
GetTermIOVectors
This function returns the address of the TERMIOVECTORS data structure that defines the vectors to the I/O
console functions. Are defined I/O console functions all the functions that allow to manage the reading and the
writing of characters from and to the consoles for the interface with the user. Different types of I/O console are
provided like the serial lines, terminals or drivers made as function blocks.
Prototype
ElSystemLib.h
Declaration
TERMIOVECTORS* GetTermIOVectors(void);
Parameters
None
Return value
TERMIOVECTORS* Defined I/O console function vectors data structure address (Range from 0x0000 to 0xFFFF)
Examples
Are alternately defined as I/O console both the serial ports and a message is sent to any port.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Manage the serial port "A" tick.
SetTermIOVectors(IOSerialPortB);
TermIOTick();
if (PLCPulse1000)
{
// Set the serial "A" as I/O console and print out a message.
// Set the serial "B" as I/O console and print out a message.
// Set the serial "A" again as I/O console and print out a message.
// Sets the serial "B" again as I/O console and print out a message.
// [End of file]
"C" functions
GetTxSpace
This function returns the available space in the transmission buffer of the selected I/O console. The function can
be used to control if there is space in the transmission buffer before executing the characters writing functions.
Prototype
ElSystemLib.h
Declaration
unsigned int GetTxSpace(void);
Parameters
None
Return value
unsigned int Number of characters tranferable in the transmission buffer of the selected I/O console (Range from
0x0000 to 0xFFFF). 0xFFFF: Means buffer empty.
Examples
Every 1 Sec if space in the serial transmission buffer the charachter 'a 'is tranfered.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// -------------------------------------------------------------------------
// SET SERIAL PORT AND SEND A CHARACTER
// -------------------------------------------------------------------------
// Define the serial port must be used A as I/O console and open it.
if (PLCPulse1000)
if (GetTxSpace()) PutCh('a');
}
// [End of file]
"C" functions
InputStream
This function returns a characters string from the selected I/O console. The function ends after the reading of the
number of defined characters or after having read all the available characters in the reception buffer.
Prototype
ElSystemLib.h
Declaration
unsigned int InputStream(char *Destination, unsigned int Length);
Parameters
char *Destination It defines the buffer address of the read from the I/O console string destination (Range from
0x0000 to 0xFFFF)
unsigned int Length It defines the number of characters to be read from the I/O console (Range from 0x0000 to
0xFFFF)
0: Executes the reading of all the available characters in the reception buffer.
Return value
unsigned int Number of characters read from the I/O console. If an equal or higher number of charachters
to be read are available in the reception buffer a value equal to the Length is returned.
Examples
It is executed the reception of a number of characters equal to the length of the desired string. The received
string is read and compared with the reference stringh . If the comparison has positive result a message is sent
on serial line. It is managed a timeout of 5 seconds, if for this time no strings are received the reception buffer is
cleared.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Timeout management, after 5 second with no string received the input
// buffer is cleared.
if (PLCFirstLoop)
TimBuf=GetSystemTime(); //Timeout buffer
if (IsMsecTimeOver(&TimBuf, 5000))
TermIORxClear(); //Clear the Rx buffer
if (GetRxChars() >= 4)
{
TimBuf=GetSystemTime(); //Timeout buffer
InputStream(&RxString, 4);
printf("The string \"%s\" has been received\r\n", RxString);
// [End of file]
"C" functions
OutputStream
This function sends a characters string to the selected I/O console. The function ends when the defined number
of characters are sent or if the transmission buffer is full.
Prototype
ElSystemLib.h
Declaration
unsigned int OutputStream(generic char *Source, unsigned int Length);
Parameters
char *Source It defines the buffer address of the of string to be sent to the I/O console (Range from
0x0000 to 0xFFFF)
unsigned int Length It defines the number of characters to be sent to the I/O console (Range from 0x0000 to
0xFFFF)
0: It executes writing until the transmission buffer is full.
Return value
unsigned int Number of characters written to the I/O console (Range from 0x0000 to 0xFFFF). If the
transmission buffer has an equal or bigger space available than the number of characters to
be written a value equal to Length is returned.
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Manage the serial port "A" tick.
if (PLCPulse1000)
OutputStream("This is a string\r\n", 18);
// [End of file]
"C" functions
PutCh
This function sends a character to the selected I/O console. If the selected I/O console is the serial line, in
function of the setting of the Mode.WaitLoop bit of the SERIALSTRUCT structure, the function has a different
behaviour on character transmission. If the bit is FALSE, the function is not blocking, if there is no space in the
transmission buffer, the character to be transmitted is lost. If the bit is TRUE, the function is blocking, if there is
no space in the transmission buffer, it blocks waiting for the buffer becomes free.
WARNING! In the blocking mode, the calling to the function, if there is no space in the tansmission buffer, blocks
the program execution loop with intervention of the watch dog circuit. We suggest you before to call the function
to check the space availability in the tansmission buffer by using the GetTxSpace function.
Prototype
ElSystemLib.h
Declaration
void PutCh(char Value);
Parameters
char Value Character to be sent to the selected I/O console (Range from 0x00 to 0xFF)
Return value
None
Examples
If space available in the serial transmission buffer charachter 'a' is trasferred every 1 Sec.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Manage the serial port "A" tick.
if (PLCPulse1000)
if (GetTxSpace())
PutCh('a');
}
// [End of file]
"C" functions
SetTermIOData
This function sets the allocation address of the selected device data structure.
Prototype
ElSystemLib.h
Declaration
void SetTermIOData(void* Address);
Parameters
void* Allocation address of the selected device data structure (Range from 0x0000 to 0xFFFF)
Return value
None
Examples
In the example the function it's used to set the TERMINALSTRUCT terminal data structure allocation address.
The user program will be able to work on the variables defined in this structure to the reading the keys status, to
the display synchronization, to the LED management and for the data input.
The program displays the "Hello world!" text blinking on the display.
At the first program execution loop the variables of the terminal are initialized. The TermIOTick function must be
executed at every program loop. The writing on the display must be sinchronized with the Status.RefreshEnd bit
to avoid flickering of the text on the display.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definition.
if (PLCFirstLoop)
{
Ts.TerminalAddress=0x07; //Terminal address
Ts.KeyboardTimeOut=5000; //Keyboard timeout definition
Ts.LEDCommand.LCDBacklight=TRUE; //LCD backlight command
}
// Set the terminal as standard I/O console and call the I/O tick.
// Cursor positioning and blink the string "Hello world!" on the display.
if (Ts.Status.RefreshEnd)
if (!PLCTimeBase800)
printf("\n");
else
printf("\nHello world!");
}
// [End of file]
"C" functions
SetTermIOVectors
This function sets the pointer to the TERMIOVECTORS data structure which defines the vectors to the I/O
console functions. Are defined I/O console functions all the functions that allow to manage the reading and the
writing of characters from and to the consoles for the interface with the user. Different types of I/O console are
provided like the serial lines, terminals or drivers made as function blocks. In the case in which the defined vector
does not point to a valid device, a default device is defined and the IODeviceNotCorrect bit is set in the
SystemErrors data structure.
Prototype
ElSystemLib.h
Declaration
void SetTermIOVectors(TERMIOVECTORS* TermIOVectors);
Parameters
TERMIOVECTORS* TermIOVectors I/O console to be used function vectors data structure address (Range from
0x0000 to 0xFFFF)
Return value
None
Examples
Are alternately defined as I/O console both the serial ports and a message is sent to any port.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Manage the serial port "A" tick.
if (PLCPulse1000)
{
// Sets the serial "A" as I/O console and print out a message.
// Sets the serial "B" as I/O console and print out a message.
// [End of file]
"C" functions
TermIOClose
This function closes the selected I/O console. We remind you that the calling to the function is not needed
for some I/O consoles.
Prototype
ElSystemLib.h
Declaration
BOOL TermIOClose(void);
Parameters
None
Return value
BOOL FALSE: I/O console close error
TRUE: I/O console closed
"C" functions
TermIOOpen
This function opens the selected I/O console. The I/O console has to be open before executing operations
on it, otherwise the operation executed will not have any effect.
It's possible to execute the function cyclically, it opens the I/O console only if it's closed, if it's already
open no operations are executed.
Prototype
ElSystemLib.h
Declaration
BOOL TermIOOpen(void);
Parameters
None
Return value
BOOL FALSE: I/O console open error
TRUE: I/O console opened
"C" functions
TermIORxClear
This function empties the reception buffer and cleares all the errors in the selected I/O console.
Prototype
ElSystemLib.h
Declaration
void TermIORxClear
(void);
Parameters
None
Return value
None
"C" functions
TermIORxFlush
This function flushes all the characters available in the reception buffer in the selected I/O console.
Prototype
ElSystemLib.h
Declaration
void TermIORxFlush
(void);
Parameters
None
Return value
None
"C" functions
TermIOTick
This function manages the operations needed for the working of the selected I/O console. After having selected
the console with the SetTermIOVectors function you need to execute this function at least once per program loop.
Prototype
ElSystemLib.h
Declaration
void TermIOTick
(void);
Parameters
None
Return value
None
Examples
Both the serial ports are alternatively defined as I/O console and the tick function is executed.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Manage the serial port "A" tick.
// [End of file]
"C" functions
TermIOTxClear
This function empties the transmission buffer and cleares all the errors in the selected I/O console.
Prototype
ElSystemLib.h
Declaration
void TermIOTxClear
(void);
Parameters
None
Return value
None
"C" functions
TermIOTxFlush
This function flushes all the charachters available in the transmission buffer in the selected I/O console.
Prototype
ElSystemLib.h
Declaration
void TermIOTxFlush
(void);
Parameters
None
Return value
None
"C" functions
CANRx
Prototype
ElSystemLib.h
Declaration
BOOL CANRx(unsigned long* Idf, unsigned char* Length, unsigned char* RxData);
Parameters
unsigned long* Idf It defines the address of the CAN frame identifier buffer. The function at the reception of
a frame stores in the buffer the received frame identifier. If standard frame 11 bits are
returned. If extended frame 29 bits are returned.
unsigned char* Length It defines the address of the CAN frame length buffer. The function at the reception of a
frame stores in the buffer the received frame length.
unsigned char* RxData It defines the address of the CAN frame received data buffer. The function at the
reception of a frame stores in the buffer the received data.
Return value
BOOL FALSE: No frame received
TRUE: Frame received
Examples
The following example manages a Beckhoff system with a digital input and a digital output module connected to
the CAN controller. The system is set with NodeID 1. The state of input 0 is copied to the output 0 while to the
output 1is copied the state of an internal time base.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES DEFINITION
// -----------------------------------------------------------------------------
// Logic I/O definition.
struct
{
BOOL I0:1; //Input 0
BOOL I1:1; //Input 1
}CANInput;
struct
{
BOOL O0:1; //Output 0
BOOL O1:1; //Output 1
}CANOutput;
// -----------------------------------------------------------------------------
// BECKHOFF I/O MODULE MANAGEMENT
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variables definition.
// -------------------------------------------------------------------------
// I/O MANAGEMENT
// -------------------------------------------------------------------------
// Here the I/O are managed.
CANOutput.O0=CANInput.I0; //Output 0
CANOutput.O1=PLCTimeBase400; //Output 1
// -------------------------------------------------------------------------
// CAN CONTROLLER INIT
// -------------------------------------------------------------------------
// The CAN controller is initialized.
if (PLCFirstLoop)
{
CANInit(&Init);
IsStarted=FALSE; //Module is started
}
// -------------------------------------------------------------------------
// FRAMES RECEPTION
// -------------------------------------------------------------------------
// The 11 bit frame identifier is divided as reported below:
// +---+---+---+---+---+---+---+---+---+---+---+
// | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
// +---+---+---+---+---+---+---+---+---+---+---+
// | Function | Node ID |
// -------------------------------------------------------------------------
// Check if a frame has been received.
case 0x81:
IsStarted=TRUE; //Module is started
// -----------------------------------------------------------------
// Logic input from the module.
// Function=0011
// Node ID=000001
case 0x181:
*(unsigned char*)&CANInput=RxBuffer[0]; //Logic input
break;
}
}
// -------------------------------------------------------------------------
// OUTPUTS MANAGEMENT
// -------------------------------------------------------------------------
// If the module is initialized the output are written.
if (IsStarted)
{
// The output write is executed only if they are changed.
// Function=0100
// Node ID=000001
TxBuffer[5]=*(unsigned char*)&CANOutput;
CANTx((unsigned long*)&TxBuffer[0], &TxBuffer[4], &TxBuffer[5]);
}
}
}
// [End of file]
"C" functions
CANTest
This function executes the test of the CAN communication. The execution of the test checks the functionality of
the CAN driver and bus executing the transmission of a frame of 8 bytes long using as id the value of definite in
Filter member of CANINITDATA structure. The received frame is compared with the transmitted and if are equal
the test passed is returned.
Prototype
ElSystemLib.h
Declaration
BOOL CANTest(void)
Parameters
None
Return value
BOOL FALSE: Test not
passed
TRUE: Test passed
Examples
In the following example at every 1 Sec the CAN test is executed and a message with the result report is
returned.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variables definitions.
// -------------------------------------------------------------------------
// TEST EXECUTION
// -------------------------------------------------------------------------
// Initialize the CAN controller.
if (PLCFirstLoop)
CANInit(&Init);
if (PLCPulse1000)
{
SetTermIOVectors(IOSerialPortA); //Set the serial port A as I/O console
if (!CANTest())
printf("CAN BUS test error\r\n");
else
printf("CAN BUS test executed\r\n");
}
}
// [End of file]
"C" functions
CANTx
Prototype
ElSystemLib.h
Declaration
BOOL CANTx(unsigned long* Idf, unsigned char* Length, unsigned char* TxData);
Parameters
unsigned long* Idf It defines the address of the CAN identifier buffer, the transmit frame identifier must
be loaded. If standard frame 11 bits are transmit. If extended frame 29 bits are
transmit.
unsigned char* Length It defines the address of the CAN frame length buffer. The transmit frame length
must be defined.
unsigned char* TxData It defines the address of the CAN frame transmit data buffer. The transmit frame
data must be defined.
Return value
BOOL FALSE: Frame not transmit
TRUE: Frame transmit
Examples
"C" functions
PLCDebouncing
This function executes the debouncing of a 8 bit value. It can be used to eliminate the rebounds of reading on
digital inputs.
Prototype
ElPLCLib.h
Declaration
unsigned char PLCDebouncing(unsigned char Value, unsigned char Time, unsigned char* Buffer);
Parameters
unsigned char Value It represents the 8 bits value to be debounced (Range from 0x00 to 0xFF)
unsigned char Time It represents the debouncing time (Range from 0 to 127 mSec)
unsigned char* Buffer It is the debouncing buffer address (Range from 0x0000 to 0xFFFF)
Return value
unsigned char It is the 8 bits value debounced (Range from 0x00 to 0xFF)
Examples
In the following example the logic inputs from 0 to 7 are acquired. On their status a 20 mSec debouncing are
executed and the result is transferred on the logic outputs from 0 to 7.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Local variable declarations.
// Here the logic input from 0 to 7 are acquired, their status is debounced
// and transferred to the logic outputs from 0 to 7.
// [End of file]
printf
This function allows to send formatted data to the selected I/O console.
Prototype
stdio.h
Declaration
int printf(const char *format, …);
Parameters
const char *format Pointer to the format string
... The optional values that are to be printed under the control of format
Return value
int Function executed: The number of characters written
Execution error: A negative value
The format string can contain two types of elements, the first one consists in characters that are sent to the I/O
console unchanged. The second consists in conversion directives that describe how the arguments should be
visualized. The conversion directives begin with the % symbol and continue according to the format:
n No output, but store the number of characters written so far in the integer pointed to by the next
argument.
% % character.
Examples
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Here assign values to some variables.
if (PLCPulse1000)
{
Rc[0x00]=printf("%c",p[1]); //Output "quot;B" and return "1"
printf("\r\n");
// [End of file]
scanf
This function read formatted data from the selected I/O console.
Prototype
stdio.h
Declaration
int scanf(const char *format, …);
Parameters
const char *format Pointer to a format string
... Argument list they must be readed according to the format string
Return value
int Function executed: It returns the number of conversion executed
Execution error: It returns a negative value
The format is a string consisting of a sequence of ordinary characters and conversion specifications. Each
ordinary character reads a matching character from the input. Each conversion specification accepts input
meeting the specification, converts it, and assigns it to the object pointed to by the next successive argument
following format.
If the format string contains white-space characters, input is scanned until a non-white-space character is found.
The conversion specifications start with the % symbol followed by the directions as the format:
n No read, but store number of characters read so far in the integer pointed to by the next
argument.
[ Any number of characters matching any of the characters before the terminating ]. For
example, [abc] means a, b, or c.
[] Any number of characters matching ] or any of the characters before the further, terminating ].
For example, []abc] means ], a, b, or c.
[^ Any number of characters not matching any of the characters before the terminating ]. For
example, [^abc] means not a, b, or c.
[^] Any number of characters not matching ] or any of the characters before the further,
terminating ]. For example, [^]abc] means not ], a, b, or c.
% % character.
Examples
It has been used the sscanf function, it works exactly as the scanf function but it reads the input data
from a string variable instead of the selected I/O console.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Here define some variables.
if (PLCPulse1000)
{
// ---------------------------------------------------------------------
// ---------------------------------------------------------------------
// In the following example please note that the number 123 is read but
// not passed into the variables due the "%*d" format.
// ---------------------------------------------------------------------
// [End of file]
malloc
Allocates a memory block for an object of the specified size, the functions returns NULL if the request cannot be satisfied.
To use this function, the dinamic memory buffer must be initialized. Please refer to mempool_init function.
Prototype
stdlib.h
Declaration
void *malloc(size_t size);
Parameters
size_t size Dimension of the memory to allocate (bytes)
Return value
void* Pointer to the allocated memory
NULL if the request cannot be satisfied
Examples
In the following example at every second will be send on the serial line a message like:
String is: Hello!, IntVar[0]=0066, IntVar[1]=0067
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Specify the alloc buffer length.
// -----------------------------------------------------------------------------
// MALLOC EXAMPLE
// -----------------------------------------------------------------------------
void MallocTest(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Check if first program loop.
if (PLCFirstLoop)
{
mempool_init((void *)AllocBuf, sizeof(AllocBuf)); //Initializes the memory pool
StringVar=(char*)malloc(10); //Allocates a 10 bytes string
IntVar=(int*)calloc(2, sizeof(int)); //Allocates an array of 2 variables
// -------------------------------------------------------------------------
// PROGRAM EXECUTION
// -------------------------------------------------------------------------
// At every 1 second, print out a message.
if (PLCPulse1000)
{
printf("String is: %s, IntVar[0]=%04X, IntVar[1]=%04X\r\n", StringVar, IntVar[0], IntVar[1]);
IntVar[0]++; //Increases the integer at position [0]
IntVar[1]++; //Increases the integer at position [1]
}
}
// [End of file]
Operands
Bit
the operand Bit can be used by the RIL language in the logic instructions to address a bit of an operand
Byte (Y), Word (W) o Double (DW).
Numerical range
Type Description
PSYST NSYST Netreader
Decimal bit address, allows to define the operand bit in decimal mode
For operand Byte (Y) range from 0 to 7
BD Decimal bit
For operand Word (W) range from 0 to 15
For operand Double (DW) range from 0 to 31
Hexadecimal bit address, allows to define the operand bit in hexadecimal
mode
BH Hexadecimal bit For operand Byte (Y) range from 0 to 7
For operand Word (W) range from 0 to F
For operand Double (DW) range from 0 to 1F
Example
Ladder RIL
ORGR
LODT Y 0000 BD 1
ANDT W 0002 BD 8
ANDT DW 0004 BD 10
OUTT DW 0004 BD 31
ORGR
LODT Y 0000 BH 0001
ANDT W 0002 BH 0008
ANDT DW 0004 BH 000A
OUTT DW 0004 BH 001F
Operands
Constant
The Constant operand can be used when it is necessary to define a constant value, it can be used in
different forms:
Numerical range
Type Description
PSYST NSYST Netreader
"Enum" operands
The Enum KE operand identifies the default values according to the table below:
Operands
Label
The Label operand represents a mnemonic label of program, it can be defined by the RIL language by
using the LABL instruction, allowing to insert a mnemonic name instead of a numerical. The use of this
operand it is necessary to allow the access from the RIL program to functions written in assembler and C
languages.
Examples
Serial instructions
SRXC
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Serial RX Characters received loads in AccA, the number of the characters received by the
serial line and transferred to the reception buffer, if the reception buffer is empty the Flag (F)
PLCRxBufEmpty of reserved operands is activated. The instruction is referred to the serial line, defined by
the SETV instruction.
We remind that the characters received by the serial line are buffered by the operating system, the user
program can read them from the reception buffer with the instruction SRXD, only if inside the buffer there
are characters.
Examples
In the following example the number of received characters on the serial line is placed in Y 0000.
Serial instructions
STXC
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Serial TX Characters space loads in AccA the available space in the serial transmission
buffer, the space is expressed in number of characters you can transfer. The instruction is referred to the
serial line, defined by the SETV instruction. The instruction execution operates on two reserved operands. It
sets the Flag (F) PLCTxBufEmpty if the transmission buffer is empty, It sets the Flag (F) PLCTxBufFull if
the transmission buffer is full.
To better understand the use of this instruction we remind that to transmit to the serial line, the characters
must be transferred to the transmission buffer by using the SRXD and STXI instructions. The operating
system will automatically provide to their transmission to the serial line.
Examples
In the following example the the available space in the serial transmission buffer is placed in Y 0000.
Serial instructions
SRXD
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Serial RX Data is to be used every time you want receive data from the serial line. When the
instruction is activated, the data present in the reception buffer is transferred to AccA. If a data is
transferred, the Flag (F) PLCChrReceived of reserved operands is activated, so you need to check this
flag, if it's set the data has been received. The instruction is referred to the serial line, defined by the SETV
instruction.
Examples
In the following example, when I 0000 gets activated if a data is received from the serial line, the received
character is transferred to Y 0000.
ORGR
LODT I 0000
ANDT F PLCChrReceived
STRA Y 0000
SUBA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction SUBtract Accumulators allows to subtract the value in AccB (subtrahend) from the value in
AccA (minuend), the result replaces the value in AccA. The instruction executes the operation
AccA=AccA-AccB.
If the value contained in AccA (minuend) is less than the value contained in AccB (subtrahend), the Flag
(F) PLCSubIsNegative of reserved operands is set.
Examples
In the following example, when I 0000 is activated, the value of W 0002 is subtracted from the value of
W 0000 and the result replaces the value in W 0004. W 0004=(W 0000-W 0002).
FSUB
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float SUBtract Accumulators allows to subtract the value in AccB (subtrahend) from the
value in AccA (minuend) (AccA-AccB), the result replaces the value in AccA. The instruction executes the
operation AccA=AccA-AccB.
If the value contained in AccA (minuend) is less than the value contained in AccB (subtrahend), the Flag
(F) PLCSubIsNegative of reserved operands is set.
Examples
In the following example, when I 0000 is active the value of FL 0004 is subtracted to the value of FL 0000
and the result replaces the value in FL 0008. FL 0008=(FL 0000-FL 0004).
CPRA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction ComPaRe Accumulators compares the values of the two accumulators without change
them. The instruction manages thre reserved operands, the user program can test their status. To compare
operands directly without transfer them to the accumulators you can use the LESC, EQUC, GRTC
instructions.
ATTENTION! The status of the reserved operands will be valid until another CPRA or FCPR or any other
instruction that manage these operands will be executed.
Examples
In the following example, when I 0000 gets activated, the value 100 is loaded in AccB, while the value in
W 0000 is loaded in AccA. The values of the two accumulators are compared and if the value in W 0000 is
bigger than 100, the output O 0000 gets activated.
ORGR
LODT I OOO0
ANDT F PLCGrtFlag
OUTT O 0000
FCPR
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float ComPaRe accumulators compares the float values in the two accumulators without
change them. The instruction manages thre reserved operands, the user program can test their status.To
compare operands directly without transfer them to the accumulators you can use the LESC, EQUC, GRTC
instructions.
ATTENTION! The status of the reserved operands will be valid until another CPRA or FCPR or any other
instruction that manage these operands will be executed.
Examples
In the following example, when I 0000 gets activated, the value 100 is loaded in AccB, while the value in
FL 0000 is loaded in AccA. The values of the two accumulators are compared and if the value in FL 0000
is bigger than 100, the output O 0000 gets activated.
ORGR
LODT I OOO0
ANDT F PLCGrtFlag
OUTT O 0000
EXTR
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction EXTeRn operand has to be used to allow the access from RIL file to external mnemonic
operand in the same project defined in assembler or C. The instruction doesn't have any logical function in
the program so it has to be inserted without any definition of the logical branch, we suggest to insert the
instruction at the beginning of the RIL file. Instructions can access to the defined operand from any RIL file
of the project by only indicating its type and name.
ATTENTION! You cannot define two operands with the same name in the same project (even they are in
different files) even they have different type. So you cannot define local operands DEFL, global operands
DEFG or backup operands DEFB using names defined as extern operands.
Examples
In the following example, the W Counter operand defined in a file written in C language, is increased from
RIL language.
SVIW
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Simbol VIeW has to be used to allow the visibility of a numerical operand. Unlike the
mnemonic operands that have to be defined before to be used in a RIL program, the numerical operand are
automatically defined when they are used. The instruction doesn't have any logical function in the program
so it has to be inserted without any definition of the logical branch, we suggest to insert the instruction at the
beginning of the RIL file.
Examples
In the following example, every time I 0000 is activated, the value of the W 0000 is increased, in the
example it is used the operand W 0000 without using the two operands Y 0000 MSB part and Y 0001 LSB
part of the word. If it is necessary to run the debug of the Byte (Y) operands or run their display on the
terminal, the operation would be impossible not using the SVIW instruction, because the operands are not
defined.
ORGR
LODT I 0000
PULS
INCO W 0000
Logic instructions
ORGR
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction ORiGin Rung should be used to begin a new rung. Every rung has to begin with an
ORGR instruction and end with one or more Close rung type instructions.
Logic instructions
LODT
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
C, F, I, O, T
LODT LOaD True Open branch No A
Y, W, DW K, BD, BH
The instruction LOaD True should be used to begin a new branch with a normally open contact. The
instruction has to be placed after the ORGR instruction or at the beginning of a new branch, that will be
closed with ANDR or ORLR instruction.
Examples
In the following example, if you activate the I 0000, O 0000 becomes active.
Logic instructions
LODF
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
C, F, I, O, T
LODF LOaD False Open branch No A
Y, W, DW K, BD, BH
The instruction LOaD False should be used to begin a new branch with a normally close contact. The
instruction has to be placed after the ORGR instruction or at the beginning of a new branch, that will be
closed with ANDR or ORLR instruction.
Examples
In the following example, if you activate the I 0000, O 0000 becomes inactive.
Logic instructions
ANDT
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
C, F, I, O, T
ANDT AND logic True Modify branch No A
Y, W, DW K
The instruction AND logic True should be used to insert a normally open contact in series to the previous circuit.
Examples
In the following example, if you activate the I 0000 and deactivate I 0001, O 0000 becomes active.
Logic instructions
ANDF
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
C, F, I, O, T
ANDF AND logic False Modify branch No A
Y, W, DW K, BD, BH
The instruction AND logic False should be used to insert a normally close contact in series to the previous circuit.
Examples
In the following example, if you activate the I 0000 and deactivate I 0001, O 0000 becomes active.
Logic instructions
ORLT
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
C, F, I, O, T
ORLT OR Logic True Modify branch No A
Y, W, DW K
The instruction OR Logic True should be used to add a normally open contact in parallel with the previous circuit.
Examples
In the following examples, if you activate the I 0000 or activate I 0001, O 0000 becomes active.
Logic instructions
ORLF
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
C, F, I, O, T
ORLF OR Logic False Modify branch No A
Y, W, DW K
The instruction OR Logic False should be used to add a normally closed contact that in parallel with the previous
circuit.
Examples
In the following example, if you activate the I 0000 or disactivate I 0001, O 0000 becomes active.
Logic instructions
ANDR
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction AND logic Rungs should be used every time you want to link two logical branches in series each other.
Examples
In the following example, if you deactivate the I 0000 and activate I 0002 if I 0001 is active or if I 0003 is not active, O 0000
becomes active.
Logic instructions
ORLR
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction OR logic Rungs should be used to link two logical branches in parallel each other.
Examples
In the following example, if you deactivate the I 0000 and activate I 0002 if I 0001 is active or if I 0003 is not active, O 0000
becomes active.
Logic instructions
OUTT
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
F, O
OUTT OUT True Close rung No A
Y, W, DW K
The instruction OUT True should be used activate an operand Output (O), Flag (F), or a bit of a Byte (Y),
Word (W) or Double (DW) when the rung is active. When the rung becomes inactive the operand is
deactivated.
Examples
In the following example, if you activate the I 0000, O 0000 becomes active.
Logic instructions
OUTF
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
F, O
OUTF OUT False Close rung No A
Y, W, DW K
The instruction OUT False should be used to deactivate an operand Output (O), Flag (F), or a bit of a Byte
(Y), Word (W) or Double (DW) when the rung is active. When the rung becomes inactive the operand is
activated.
Examples
In the following example, if you activate the I 0000, O 0000 becomes active.
Logic instructions
LTCH
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
F, O
LTCH LaTCH Close rung No A
Y, W, DW K, BD, BH
The instruction LaTCH should be used to activate an operand Output (O), Flag (F), or a bit of a Byte (Y),
Word (W) or Double (DW) when the rung is active. The operand will remain active even if the rung
becomes inactive. To reset the operand, the UTCH instruction with the same operand must be used.
Examples
In the following example, if you activate the I 0000, O 0000 becomes active and remains active even if the
I 0000 becomes inactive.
Logic instructions
UTCH
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
F, O
UTCH UnlaTCH Close rung No A
Y, W, DW K
The instruction UnlaTCH should be used to deactivate an operand Output (O), Flag (F), or a bit of a Byte
(Y), Word (W) or Double (DW) when the rung is active. The operand will remain inactive even if the rung
becomes inactive. To set the operand, the LTCH instruction with the same operand must be used.
Examples
In the following example, if you activate the I 0000, O 0000 becomes inactive.
Logic instructions
MCRS
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Master Control Relay Start should be used to condition the execution and the activation of
the program branches included between the instruction and the MCRE instruction. The program branches
betweenMCRS and MCRE are conditioned to the branch status where the instruction MCRS is. This means
that these branches have a true logical meaning only if the branch, activating the MCRS instruction is true.
The use of this instruction allows to reduce the program execution time, indeed the logical branches
between MCRS and MCRE are not executed if the MCRS instruction is not active. The MCRS instructions
can be nested without limits.
ATTENTION! If between MCRS and MCRE there are branches containing PULS instructions it's necessary
to condition the PULS instruction at the status of the MCRS instruction.
Examples
In the following example, the operand I 0000 status conditions the execution of all the branches between
the MCR and MCRE instructions. If you activate I 0000 the the following branches are executed, when
I 0000 becomes inactive, O 0001 becomes inactive independently from the status of I 0001.
Please note the use of F 0000, it was inserted only to test the status of the branch that conditions the
MCRS instruction so it's possible to insert it in all the branches between MCRS and MCRE where that use
puls type instructions.
ORGR
LODT I 0001
OUTT O 0001
ORGR
LODT I 0002
ANDT F 0000
PULS
LTCH F 0001
ORGR
MCRE
Logic instructions
MCRE
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Master Control Relay End should be used to define the end of the program part conditioned
to the instruction MCRS.
Examples
Logic instructions
SBSR
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
F, O
SBSR Step By Step Relay Close rung Yes A
Y, W, DW K
The instruction Step By Step Relay should be used to implement the step by step relay function. At every
rung activation the operand status changes.
Examples
In the following example, every time there is a transition from off to on status of the I 0000, O 0000 change
its status.
Logic instructions
INRG
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction INvert RunG allows to invert the logical status of the branch. If the instruction is inserted
after an active branch, it will invert the status and the branch will becomes inactive, and vice versa.
Examples
In the following examples, if you activate the I 0000, O 0000 becomes inactive.
Logic instructions
PULS
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction PULSe allows to make impulsive (active for a program loop) the activation of the branch that
follow the instruction.
Examples
In the following example, if you activate the I 0000, O 0000 becomes active for a single program loop.
Logic instructions
SETR
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction SET bRanch allows to unconditionally activate the logical status of the branch.
Examples
Logic instructions
RESR
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction RESet bRanch allows to unconditionally deactivate the logical status of the branch.
Examples
Logic instructions
OUTM
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
T KD, KH, Y, W, DW
OUTM OUt TiMer Close rung No A
KD, KH, Y, W, DW KE
The instruction OUt TiMer allows to create delays in the program. When the timer is activated, its contacts
will get activated after the programmed delay time. When the timer is deactivated its contacts will get
deactivated immediately.
The delay time value can be expressed as a decimal constant (KD) or hexadecimal (KH), or it can be
defined by using a Byte (Y), Word (W) or Double (DW) operand. The instruction can manage delays from
1 mSec to 4294967295 mSec (About 50 days).
The delay time is saved at the instruction activation, so if it's expressed in an operand it's possible to
change it the value only when the logical branch is not active.
You can define the base time by using the 3rd operand (KE) with the values reported in the following table.
If the 3rd operand is omitted, the time base is automatically fixed to 100mSec to maintain compatibility with
the previous versions.
Base1mS 1 Millisecond
Base10mS 10 Milliseconds
Base100mS 100 Milliseconds
Base1S 1 Second
Base10S 10 Seconds
Base60S 60 Seconds
Examples
In the following example, if you activate the I 0000, the T 0000 starts the time delay counting. O 0000 will
becomes active only after 1000x0,001S (1 Second). When you deactivate I 0000, T 0000 becomes inactive
immediately causing the deactivation of O 0000.
ORGR
LODT I 0000
OUTM T 0000 KD 1000 KE Base1mS
ORGR
LODT T 0000
OUTT O 0000
Logic instructions
CTUP
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction CounTer UP allows to increase the counter every time you activate the rung. The contacts
of the counter will becomes active when the counter reach the defined value. The value can be expressed
as a Constant (K) or it can be contained in a Byte (Y). To reset the counter the CTRS instruction must be
used. Obsolete instruction, we suggest to not use it in the new projects, in alternative use the INCO, DECO,
GRTC, EQUC, LESC instructions.
Examples
In the following example, every time the I 0000 is activated, the counter C 0000 is increased. After 10 times,
O 0000 will becomes active.
ORGR
LODT C 0000
OUTT O 0000
Logic instructions
CTRS
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction CounTer ReSet allows to reset the counting value of a counter. Obsolete instruction, we
suggest to not use it in the new projects, in alternative use the INCO, DECO, GRTC, EQUC, LESC
instructions.
Examples
In the following examples, if you activate the I 0000, the counter C 0000 becomes reset.
Logic instructions
SHFT
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction SHiFT should be used to implement the shift register function. This function operates on 8
consecutive operands starting from the defined one. Every time you activate the rung, you will have the shift
of the status of an operand into the next one, with 7 passages from off to on status of the rung, the content
of the defined operand will be in the operand n+7. The operand status is determined by the instruction
OUTT or OUTF inserted before the instruction. You can create a cascade of more shift. See SHRS to reset
the used operands.
ATTENTION! The address of the first operand has to be necessarily the less significant of the bench
(O xxx0, F xxx8).
Examples
The instruction operates on 8 consecutive operand, however you can realize cascades of more instructions
to have shift register with a bigger number of operands. The example reported represents a cascade of 2
SHFT instructions to have the shift of 16 logical outputs, with a time base of 800 mSec. The program is
realized to have the data reported on the first operand at the end of the 16th shift. If you run the program on
a target with at least 16 logical outputs, you can see them flashing in sequence.
ORGR
LODT F PLCPulse500
ANDT O 0007
LTCH O 0008
ORGR
LODT F PLCPulse500
SHFT O 0000
UTCH O 0000
ORGR
LODF O 000F
PULS
ANDT F PLCPulse500
ORLT F PLCFirstLoop
LTCH O 0000
Logic instructions
SHRS
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction SHift ReSet allows to reset 8 consecutive operands, the first one of them is that one
defined. This instruction is used in the shift register management. See the SHFT instruction.
ATTENTION! The address of the first operand has to be necessarily the less significant of the bench
(O xxx0, F xxx8).
Examples
In the following example, by activating I 0000, the O 0000, O 0001, O 0002, O 0003, O 0004, O 0005,
O 0006, O 0007 are deactivated. The status of I 0001 is transferred to the output O 0000, every 500 mSec
the status of output O 0000 is transferred to the following outputs.
ORGR
LODT I 0001
OUTT O 0000
ORGR
LODT F PLCPulse500
SHFT O 0000
Logic instructions
LODB
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction LOaD Bit should be used to begin a new branch testing the status of an operand bit. The
instruction has to be placed after the ORGR instruction or at the beginning of a new branch, that will be
closed with ANDR or ORLR instruction. Obsolete instruction, we suggest to not use it in the new projects, in
alternative use the LODT instruction.
Examples
In the following examples, if the bit 4 of the byte Y 0000 is on, O 0000 becomes active.
Logic instructions
OUTB
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction OUT Bit should used to to set a bit into a Byte (Y) operand when the rung is active.
Obsolete instruction, we suggest to not use it in the new projects, in alternative use the OUTT instructionsn.
Examples
In the following example, if you activate the I 0000, the bit 4 of the byte Y 0000 becomes active.
Logic instructions
FSGN
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float SiGN should be used to identify the sign of the float data in the accumulator AccA.
The instruction has to be placed after the ORGR instruction or at the beginning of a new branch, that will
have to be closed with ANDR or ORLR instruction. if the float data in AccA is positive, the instruction will be
active, if the data is negative the instruction will be inactive.
ATTENTION! The instruction works correctly only if the data in AccA is a float type, otherwise a non
identified status it's returned.
Examples
In the following examples, if you activate the I 0000, if the float data in AccA is positive O 0000 becomes
active, if the float data in AccA is negative, O 0000 becomes inactive.
Logic instructions
INCO
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
Y, W,
DW
Y, W,
INCO INCrement Operand Close rung KD, KH, KO, KB No C
DW
FL
FL KF
The instruction INCrement Operand should be used to increment the value of an operand. By defining as
2nd operand a Constant (K) it's possible to specify the increment value. Reached the maximum the value
will rollover to the minimum value.
Examples
In the following example every time the I 0000 is activated, the W 0000 is incremented of 1. Every time the
I 0001 is activated the DW 0004 is incremented of 10.
Logic instructions
DECO
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
Y, W,
DW
Y, W,
DECO DECrement Operand Close rung KD, KH, KO, KB No C
DW
FL
FL KF
The instruction DECrement Operand should be used to decrement the value of an operand. By defining as
2nd operand a Constant (K) it's possible to specify the decrement value. Reached the minimum the value
will rollover to the maximum value.
Examples
In the following example every time the I 0000 is activated, the W 0000 is decremented of 1. Every time the
I 0001 is activated the DW 0004 is decremented of 10.
Logic instructions
GRTC
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction GReaTer Compare should be used to begin a new branch testing if an operand value is
greater than defined value. The instruction has to be placed after the ORGR instruction or at the beginning
of a new branch, that will be closed with ANDR or ORLR instruction.
Examples
in the following instruction, if the operand W 0000 is greater than 10, O 0000 becomes active.
Logic instructions
LESC
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction LESs Compare should be used to begin a new branch testing if an operand value is less
than defined value. The instruction has to be placed after the ORGR instruction or at the beginning of a new
branch, that will be closed with ANDR or ORLR instruction.
Examples
In the following examples, if the operand W 0000 is less than 10, O 0000 becomes active.
Logic instructions
EQUC
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction EQUal Compare should be used to begin a new branch testing if an operand value is equal
to a defined value. The instruction has to placed after the ORGR instruction or at the beginning of a new
branch, that will be closed with ANDR or ORLR instruction.
Examples
In the following example, if the operand W 0000 is equal to 10, O 0000 becomes active.
Logic instructions
NTQC
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction NoT eQual Compare should be used to begin a new branch testing if an operand value is
not equal to a defined value. The instruction has to placed after the ORGR instruction or at the beginning of
a new branch, that will be closed with ANDR or ORLR instruction.
Examples
In the following example, if the operand W 0000 is not equal to 10, O 0000 becomes active.
LODA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
LODA LOaD Accumulator Close rung K, KD, KH, KF, KO, KB, Y, W, DW, FL No A
The instruction LOaD Accumulator allows to load a value in AccA. The value can be defined by a constant
or it can be contained in an operand. When the instruction is executed the current content of AccA is
transferred to AccB replacing the existing value.
Examples
In the following example, when I 0000 gets activated, the content of the byte Y 0000 is transferred to AccA.
STRA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction SToRe Accumulator allows to transfer the value from AccA to the defined operand, the
content of the two accumulators is not changed.
Examples
In the following example, when I 0000 gets activated, the content AccA is transferred to the byte Y 0000.
XCHA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction eXCHange Accumulators allows to exchange each other the content of the two
accumulators AccA and AccB.
Examples
In the following example, when I 0000 gets activated, the content of the 2 accumulators AccA and AccB is
exchanged.
ANDA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction AND Accumulators allows to place the values of two accumulators in logical AND, the result
replaces the value in AccA. The instruction executes the operation AccA=AccA&AccB.
Examples
In the following example, when I 0000 gets activated, the value of W 0000 is placed in AND with the value
of W 0002 and the result replaces the value in W 0004. W 0004=(W 0000&W 0002).
ORLA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction OR Accumulators allows to place the values of two accumulators in logical OR, the result
replaces the value in AccA.The instruction executes the operation AccA=AccA|AccB.
Examples
In the following example,when I 0000 gets activated, the value of W 0000 is placed in OR with the value of
W 0002 and the result replaces the value in W 0004. W 0004=(W 0000|W 0002).
XORA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction XOR Accumulators allows to place the values of two accumulators in logical XOR, the result
replaces the value in AccA. The instruction executes the operation AccA=AccA^AccB.
Examples
in the following example,when I 0000 gets activated, the value of W 0000 is placed in XOR with the value of
W 0002 and the result replaces the value in W 0004. W 0004=(W 0000^W 0002).
RORA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction ROtate Right Accumulator allows to rotate to the right the value in AccA. The number of
rotations to be executed is expressed by the operand, it can be a Constant (K) or a Byte (Y). At every
rotation, the least significant bit of AccA is transferred to the most significant. To execute the full rotation of
a digit, you have to execute 4 rotations.
ATTENTION! The accumulator has 32 bits, in the versions 7.x it had only 16 bits, so the instruction has a
different behavior. Loading the value 0x8000 in the accumulator and executing a RORA K 0001, saving the
result in a Word (W), you obtain 0x0000, with the previous versions you obtain 0x1000.
Examples
In the following example, when I 0000 gets activated, the value 0x12345678 is loaded in AccA and then is
rotated to the right for a digit, the result 0x81234567 is transferred in DW 0000.
SHRA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction SHift Right Accumulator allows to shift to the right the value in AccA. The number of shifts
to be executed is expressed by the operand, it can be a Constant (K) or a Byte (Y). At every shift, the least
significant bit of AccA is lost and a 0 is transferred to the most significant. To execute the full shift of a digit,
you have to execute 4 shifts.
Examples
In the following example, when I 0000 gets activated, the value 0x12345678 is loaded in AccA and then is
shifted to the right for a digit, the result 0x01234567 is stored in DW 0000.
ROLA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction ROtate Left Accumulator allows to rotate to the left the value in AccA. The number of
rotations to be executed is expressed by the operand, it can be a Constant (K) or a Byte (Y). At every
rotation, the most significant bit of AccA is transferred to the least significant. To execute the full rotation of
a digit, you have to execute 4 rotations.
ATTENTION! The accumulator has 32 bits, in the versions 7.x it had only 16 bits, so the instruction has a
different behavior. Loading the value 0x8000 in the accumulator and executing a ROLA K 0001, saving the
result in a Word (W), you obtain 0x0000, with the previous versions you obtain 0x0001.
Examples
In the following example, when I 0000 gets activated, the value 0x12345678 is loaded in AccA and then is
rotated to the left for a digit, the result 0x23456781 is stored in DW 0000.
SHLA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction SHift Left Accumulator allows to shift to the left the value in AccA. The number of shifts to
be executed is expressed by the operand, it can be a Constant (K) or a Byte (Y). At every shift, the most
significant bit of AccA is lost and a 0 is transferred to the least significant. To execute the full shift of a digit,
you have to execute 4 shifts.
Examples
In the following example, when I 0000 gets activated, the value 0x12345678 is loaded in AccA and then is
shifted to the left for a digit, the result 0x23456780 is stored in DW 0000.
ASHX
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction AScii to HeXadecimal conversion allows to convert the ASCII character in the LSB of AccA
to the hexadecimal format, the value obtained is placed in the 4 low bits of AccA.
ATTENTION! This instruction accepts ASCII characters from 0 to 9 and from A to F different characters are
not converted and the Flag (F) PLCConvError gets activated.
Examples
In the following example, when I 0000 gets activated, the ASCII character A is loaded in AccA, converted
in hexadecimal and the result 0x0A is transferred in the operand Y 0000.
HXAS
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction HeXadecimal to AScii conversion allows to convert the hexadecimal number contained in
the 4 low bits of AccA into ASCII format, the value obtained is placed in AccA.
Examples
In the following example, when I 0000 gets activated, the hexadecimal character 0x0A is loaded in AccA,
converted in ASCII and the result 0x41 is transferred to the operand Y 0000.
FIXC
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction float to FIXed Conversion allows to convert the float number in AccA to fixed format, the
value obtained replaces the value in AccA.
ATTENTION! The conversion to fixed of a floating data causes the loss of resolution of the variable value,
because the fractional part of the value gets lost.
Examples
In the following example, when I 0000 gets activated, the float data in AccA is converted in fixed and the
result transferred in the variable DW 0004.
FLTC
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction fixed to FLoaTing Conversion allows to convert the fixed number in AccA to float format, the
value obtained replaces the value in AccA.
Examples
In the following example, when I 0000 gets activated, the fixed data in AccA is converted in float and the
result transferred in the variable FL 0004.
BCDH
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction BCD to Hexadecimal conversion allows to convert the value AccA from BCD format, the
value obtained replaces the value in AccA.
The math accumulator is 32 bit, the grater hexadecimal value is 0xFFFFFFFF equal to a decimal value
greater than the highest number you can express in BCD format 99999999. So the conversion is always
possible.
Examples
In the following example, when I 0000 gets activated, the value 100000 is loaded in AccA, converted in the
hexadecimal vale 0x186A0 and transferred in the operand DW 0000.
HBCD
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Hexadecimal to BCD conversion allows to convert the value AccA from hexadecimal format
to BCD format, the value obtained replaces the value in AccA.
The math accumulator is 32 bit, the grater BCD value is 99999999 equal to a hexadecimal value
0x5F5E0FF. In case of a conversion of a hexadecimal number that is greater than the highest number you
can express, 99999999 will be returned and the flag (F) PLCConvError of the reserved operands gets
activated.
Examples
In the following example, when I 0000 gets activated, the hexadecimal value 0x186A0 is loaded in AccA,
converted in a 100000 BCD value and transferred in the operand DW 0000.
POPA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction POP Accumulator allows to copy the value of AccB to AccA, the previous value of AccA
gets lost. At the end of the instruction execution the two accumulators will have the same values.
Examples
In the following example, when I 0000 gets activated the data of AccB is copied to AccA.
ADDA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction ADD Accumulators allows to add the values of the two accumulators, the result replaces the
value in AccA. The instruction executes the operation AccA=AccA+AccB.
Examples
In the following example, when I 0000 is activated, the value of W 0000 is added to the value of W 0002
and the result replaces the value in W 0004. W 0004=(W 0000+W 0004).
MULA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction MULtiply Accumulators allows to multiply the values of two accumulators, the result replaces
the value in AccA. The instruction executes the operation AccA=AccA*AccB.
Examples
In the following example, when I 0000 is activated the value of W 0000 is multiplied to the value of W 0002
and the result replaces the value in W 0004. W 0004=(W 0000*W 0002)
DIVA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction DIVide Accumulators allows to divide the value in AccA (dividend) for the value in AccB
(divisor), the result replaces the value in AccA. The instruction executes the operation AccA=AccA/AccB.
When The value in AccB (divisor) is 0, the instruction returns as a result in AccA the greatest positive
number 0xFFFFFFFF, sets the Flag (F) PLCMathError of the reserved operands and the bit
DivaDivisionZero in the PLCErrors data structure.
Examples
In the following example, when I 0000 is activated, the value of W 0000 is divided by the value of W 0002
and the result replaces the value in W 0004. W 0004=(W 0000/W 0002).
INCA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction INCrement accumulator allows to increase the value in AccA of the value defined by a
Constant (K).
Examples
In the following example, when I 0000 is activated, the value of DW 0000 increases of a unit.
DECA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction DECrement accumulator allows to decrease the value in AccA of the value defined by a
Constant (K).
Examples
In the following example, when I 0000 is activated, the value of DW 0000 is decreased of a unit.
FADD
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction ADD Accumulators allows to add the values of the two accumulators, the result replaces the
value in AccA. The instruction executes the operation AccA=AccA+AccB.
Examples
In the following example, when I 0000 is activated, the value of FL 0000 is added to the value of FL 0004
and the result replaces the value in FL 0008. FL 0008=(FL 0000+FL 0004).
FMUL
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float MULtiply Accumulators allows to multiply the values of two accumulators, the result
replaces the value in AccA. The instruction executes the operation AccA=AccA*AccB.
Examples
In the following example, when I 0000 is activated the value of FL 0000 is multiplied to the value of FL 0004
and the result replaces the value in FL 0008. FL 0008=(FL 0000*FL 0004).
FDIV
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float DIVide Accumulators allows to divide the value in AccA (dividend) for the value in
AccB (divisor), the result replaces the value in AccA. The instruction executes the operation AccA=AccA/
AccB.
When The value in AccB (divisor) is 0, the instruction returns as a result in AccA the greatest positive
number 3.4028233e+38F or negative -3.4028233e+38 according to the value in AccA (dividend), sets the
Flag (F) PLCMathError of the reserved operands and the bit FdivDivisionZero in the PLCErrors data
structure.
Examples
In the following example, when I 0000 is activated, the value of FL 0000 is divided by the value of FL 0004
and the result replaces the value in FL 0008. FL 0008=(FL 0000/FL 0004).
FCHS
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float CHange Sign accumulator changes the sign of the value contained in AccA. If the
value is positive, the instruction changes it in negative and vice versa. You can use the instruction FSGN, to
know the value in AccA.
Examples
In the following example, when I 0000 is activated, the sign of the value FL 0000 is changed and the result
is transferred to FL 0004.
FINC
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float INCrement accumulator allows to increase the value in AccA of the value defined by a
Constant (K).
Examples
In the following example, when I 0000 is activated the value of FL 0000 increases of a unit.
FDEC
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float DECrement accumulator allows to decrease the value in AccA of the value defined by
a Constant (K).
Examples
In the following example, when I 0000 is activated, the value of FL 0000 is decreased of a unit.
FCLG
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float Common LoGaritm calculates the common logarithm of the value present in AccA.
The result replaces the value in AccA.
Examples
In the following example, when I 0000 is activated the logarithm of FL 0000 is calculated and the result
replaces the value in FL 0004.
FPPI
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float Push PI loads the PiGreco value (3.141592653589) in AccA.
Example
In the following example, when I 0000 is active, the calculation of the circumference of a circle, whose
diameter is in FL 0000, the result replaces the FL 0004. The calculus is: FL 0004=(FL 0000*PiGreco).
FNLG
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float Natural LoGaritm calculates the natural logarithm of the value present in AccA. The
result replaces the value in AccA.
Examples
In the following example, when I 0000 is activated the natural logarithm of the number in FL 0000 is
calculated and the result replaces the value in FL 0004.
FSIN
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float Sine calculates the sine of the value present in AccA. The result replaces the value in
AccA.
Examples
In the following example, when I 0000 is active the sine of the angle in FL 0000 is calculated and the result
replaces the value in FL 0004.
FCOS
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float COSine calculates the cosine of the value present in AccA. The result replaces the
value in AccA.
Examples
In the following example, when I 0000 is activated, the cosine of the angle in FL 0000 is calculated and the
result replaces the value in FL 0004.
FTAN
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float TANgent calculates the tanget value in AccA. The result replaces the value in AccA.
Examples
In the following example, when you activate I 0000, the tangent of the angle in FL 0000 is calculated and
the result replaces the value in FL 0004.
FSQR
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float SQuare Root calculates the square root of the value in AccA. The result replaces the
value in AccA.
Examples
In the following example, when I 0000 is active it is calculated the sqaure root of the number in FL 0000 and
the result replaces the value in FL 0008.
FPOW
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Float raise to POWer calculates the power of the value in AccA (AccA AccB). The result
replaces the value in AccA.
Examples
In the following example, when I 0000 is active the value in FL 0000 is powered to the value in FL 0004 and
the result replaces the value in FL 0008. FL 0008=(FL 0000 FL 0004).
Serial instructions
STXD
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Serial TX Data is to be used every time you want to transmit data to the serial line. When
the instruction is activated, the data in the LSB of AccA is transferred to the serial transmission buffer, to
represent the characters the Ascii code is used. The instruction is referred to the serial line, defined by the
SETV instruction.
Examples
In the following example, if you activate the I 0000, the character A code hex 0x41 is transferred to the
serial line.
Serial instructions
STXI
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Serial TX data Immediate is to be used every time you want to transmit immediate data to
the serial line. When the instruction is activated, the constant operand is transferred to the serial
transmission buffer, to represent the characters the Ascii code is used. The instruction is referred to the
serial line, defined by the SETV instruction.
Examples
In the following example, when I 0000 gets activated, the A character code hex 0x41 is transferred to the
transmission buffer.
Serial instructions
SMOD
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Serial MODe allows to set the communication parameters of the serial port using a 8 bit
hexadecimal value. Every bit has a specific meaning according to the table below. The instruction is
referred to the serial line, defined by the SETV instruction.
To completely parameterizes the serial line the FbSetSerialPar function block can used.
7 6 5 4 3 2 1 0
0 0 0 0 0 300
0 0 0 1 1 600
0 0 1 0 2 1200
0 0 1 1 3 2400
0 1 0 0 4 4800
0 1 0 1 5 9600
0 1 1 0 6 19200
0 1 1 1 7 38400
1 0 0 0 8 57600
1 0 0 1 9 76800
1 0 1 0 A 115200
1 0 1 1 B 115200
1 1 0 0 C 115200
1 1 0 1 D 115200
1 1 1 0 E 115200
1 1 1 1 F 115200
0=Parity disabled
1=Parity enabled
0=Odd parity
1=Even parity
0=7 bits data
1=8 bits data
0=Control characters enabled
1=Control characters disabled
For instance, you need to define a binary constant of 10000101, equal to the hexadecimal value of 0x85 to
set the serial line at 9600, n, 7, control characters disabled. The serial lines is set as default 19200, e, 8,
control characters disabled.
Examples
In the following example, at the first program loop the serial line A is set at 9600, n, 7, control charcters
disabled. The set made will remain valid until another setting will be executed on the same serial port.
Serial instructions
DTRE
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction Data Terminal Ready Enable allows to set the type of working of the DTR signal of the serial
port, according to the table below. The DTR signal is available on the serial port connector, it is used to
control the devices connected to the serial line. In target systems that have the RS485 line connected in
multidrop, the DTR signal is used to connect the transmission driver to the line. The instruction is referred to
the serial line, defined by the SETV instruction.
To completely parameterizes the serial line the FbSetSerialPar function block can used.
K KE Funzione
Examples
In the following example, at the first program loop the DTR signal is set as automatic working without time
interposition, on the serial port A. The set made will remain valid until another setting will be executed on
the same serial port.
LABL
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction LABeL allows to label a section of program with a number or a mnemonic label. You can
reach the label section either with JUMP or with CALL to function instruction if the label defines a function.
Examples
JUMP
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction JUMP to label allows to jump to defined logical blocks of program (rung). The jump depends
on the status of the logical branch before the instruction and it is executed only if it is active. When the
instruction is executed, the logical blocks after the LABL, which the instruction is referred to are immediately
executed, ignoring those between the instruction and the label.
ATTENTION! Jumps to labels on program blocks before the JUMP instruction create close program loops,
that can cause the block of the program.
Examples
In the following example, the status of I 0000 is transferred to O 0000, and if the I 0000 is active the
program execution jumps to the rung where the LABL K 0004 is.
ORGR
LODT I 0001
OUTT O 0001
JUMP L Label
ORGR
LABL K 0004
SETR
OUTT O 0002
ORGR
LABL L Label
SETR
OUTT O 0003
CALL
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction CALL function should be used to calls blocks of program (rung), defined as functions. The
call depends on the status of the logical branch where the instruction is and is executed only if it is active.
When the instruction is active, the block after the LABL, which the instruction is referred to is executed. The
RETN instruction stops the execution of the called function and restore the running of the blocks after the
instruction. You can nesting CALL instructions without any limit.
ATTENTION! All the functions have to be written after a main program termination branch, otherwise they
would be executed as a program part.
The program blocks called by the CALL instruction must be terminated with a RETN instruction, otherwise
the program doesn't run correctly.
Examples
In the following example, the status of I 0000 is transferred to O 0000, if the I 0000 is active, the subroutine
K 0004 is executed, it manages the flashing of O 0002. The subroutine terminates with the RETN
instruction.
The status of I 0001 is transferred to O 0001, if the I 0001 is active the subroutine L Label is executed, it
manages the flashing of O 0003. The subroutine terminates with the RETN instruction.
Please note, that if you disable the CALL instructions, the routines are not longer executed, and the logical
outputs them manage, will remain in the status they have.
ORGR
LODT I 0000
CALL K 0004
OUTT O 0000
ORGR
LODT I 0001
CALL L Label
OUTT O 0001
ORGR
SETR
RETN
ORGR
LABL K 0004
LODT F PLCTimeBase400
OUTT O 0002
ORGR
SETR
RETN
ORGR
LABL L Label
LODT F PLCTimeBase800
OUTT O 0003
ORGR
SETR
RETN
RETN
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction RETurN from function should be used to define the end of the logical blocks of program
(rung) that form a function. The instruction is also used to define the end of the main program before the
defintion of the subroutines.
Examples
TINE
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
K, KH, KD
TINE Temporal INterrupt Enable Close rung No A
K, KH, KD KE
The instruction Temporal INterrupt Enable allows to define the running time of the label function
LABL K 0000, it will be executed on interruption. The range of the time is from 1 to 255 milliseconds. The
Constant (KE) defines the automatic storing of the mathematical operands according to the following table.
The exclusion of the KE operands is equivalent to to the definition KE SaveEnable.
SaveEnable It defines the automatic storing of the mathematical operands. Before execute the function
the mathematical accumulators and the flags F PLCMathError, F PLCConvError, F
PLCLesFlag, F PLCGrtFlag, F PLCEquFlag are saved. It must be used when the executed
function use mathematical instructions.
SaveDisable it disables the saving (for expert users only)
Expert users: before execute the function the interrupt saves all the microcontroller registers, then
according to the KE operand, the mathematical operands are saved or not. If the function doesn't use any
mathematical instructions, it is possible to exclude it the saving with consequent saving of execution time.
Examples
In the following example, the function LABL K 0000, is automatically executed at every 10 mSec.
ORGR
SETR
TINE KD 10 KE SaveEnable
ORGR
SETR
RETN
ORGR
LABL K 0000
SETR
LODA W 0000
INCA KD 1
STRA W 0000
RETN
Utility instructions
CMPA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction CoMPress Accumulator allows the transfer of the operand byte and of the 7 operands with
adjoining address in the 8 LSB bits of AccA. When the instruction is active the bit 0 of the addressed
operand it's transferred to the bit 0 of AccA, the bit 0 of the operand with the next address it's transferred to
the bit 1 and so on until the transfer of all the 8 operands.
This instruction is a useful completion to the IOAQ, indeed it allows to join 8 operands in a single byte to be
transferred to the hardware device.
Examples
In the following example, when I 0000 gets activated, the status of the 8 inputs is transferred to LSB of
AccA, if the inputs are in the status shown after the transfer the AccA will has the value 0xAA.
"C"
Ladder RIL
language
ORGR
LODT I 0000
CMPA I 0008
Utility instructions
EXPA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction EXPand Accumulator allows the transfer of the 8 bits of LSB of AccA, in the operand byte
and in the successive 7 operands with adjoining address. When the instruction is active the bit 0 of AccA is
transferred to the bit 0 of the operand, the bit 1 is transferred to the bit 0 of the operand with the next
address and so on until the transfer of all the 8 bits.
This instruction is a useful completion to the IOAQ, it allows after the reading of a byte value from the
hardware device to transfer it to 8 operands.
Examples
In the following example, when I 0000 gets activated, the data 0x55 contained in AccA is transferred to the
8 byte of output.
"C"
Ladder RIL
language
ORGR
LODT I 0000
LODA KH 0055
EXPA O 0000
Utility instructions
IOAQ
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction I/O AcQuisition allows the direct access to the hardware structure allowing the the fast logic I/O
management in the interruption subroutines. Using this instruction it's possible to read the logic inputs and to write
the logic outputs directly independently from process image. The instruction can address all the hardware that can be
addressed by the CPU, allowing the management of any peripherals connected to the BUS.
ATTENTION! The instruction has the access to all the hardware structure, so accesses to areas that are not
documented can cause program crash.
Examples
In the following example, when I 0000 gets activated, the data 0x55 is transferred to the 8 byte of logic outputs.
"C"
Ladder RIL
language
ORGR
LODT I 0000
LODA KH 0055
IOAQ K 0100
Utility instructions
MOVM
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
I, O, F, C I, O, F, C
Y I, O, F, C, Y
MOVM MOVe Memory Close rung W I, O, F, C, Y, W No A
DW I, O, F, C, Y, W, DW
FL FL
The instruction MOVe Memory allows the transfer of the value of the second operand to the first one.
Examples
In the following example, when I 0000 gets activated, the value of the byte Y 0001 is transferred to the byte
Y 0000.
Utility instructions
MOVA
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction MOVe Address allows the transfer of the address of the second operand to the first one. All
the addresses of the operands are considered as numbers in 16 bits (Range 0x0000-0xFFFF), so the
destination operand is always a Word (W).
ATTENTION! The instruction loads the address of the second operand in the first one but not its value, to
transfer the value you need to use the MOVM instruction.
Examples
In the following example, when I 0000 gets activated, the value of the byte address Y 0010 is transferred to
the word W 0000.
Utility instructions
MOVI
Operands
RIL Symbol Description Function Puls
1st 2nd 3rd
The instruction MOVe Immediate allows the transfer of the value of the second operand to the first one.
Examples
In the following example, when I 0000 gets activated, the value 10 is transferred to the word W 0000.
How to
It is described hot possible it is to make a network MODBUS ASCII between a master system where the function
block FbModbusAsciiMs is made and two or more slave systems where the function block FbModbusAsciiSl is made. The
master system and the slave systems authomatically exchange between themselves memory banks. To test its working you need
to connect the master system with two slave systems on which a program that manages the function block FbModbusAsciiSl must
be executed.
RIL example
; ------------------------------------------------------------------------------
; @Section("Communication buffer")
; ------------------------------------------------------------------------------
; Here define the data buffer to communicate with the slave 0 system.
DEFL Y ToSlave0 KD 4
DEFL Y S0Y0000 Y ToSlave0 KD 0 ;ToSlave0, Y 0000
DEFL Y S0Y0001 Y ToSlave0 KD 1 ;ToSlave0, Y 0001
DEFL W S0W0002 Y ToSlave0 KD 2 ;ToSlave0, W 0002
DEFL Y FromSlave0 KD 2
DEFL Y S0Y0004 Y FromSlave0 KD 0 ;FromSlave0, Y 0004
DEFL Y S0Y0005 Y FromSlave0 KD 1 ;FromSlave0, Y 0005
; Here define the data buffer to communicate with the slave 1 system.
DEFL Y ToSlave1 KD 2
DEFL Y S1Y0000 Y ToSlave1 KD 0 ;ToSlave1, Y 0000
DEFL Y S1Y0001 Y ToSlave1 KD 1 ;ToSlave1, Y 0001
DEFL Y FromSlave1 KD 4
DEFL Y S1Y0002 Y FromSlave1 KD 0 ;FromSlave1, Y 0002
DEFL Y S1Y0003 Y FromSlave1 KD 1 ;FromSlave1, Y 0003
DEFL W S1W0004 Y FromSlave1 KD 2 ;FromSlave1, W 0004
; ------------------------------------------------------------------------------
; @Section("Local variables definition")
; ------------------------------------------------------------------------------
; FbSetSerialPar function block, data structure.
DEFL Y SetS KD 16
DEFL Y SetSMode Y SetS KH 0000 ; SetS.Mode
DEFL Y SetSBaud Y SetS KH 0001 ; SetS.Baud
DEFL Y SetSDTRMng Y SetS KH 0002 ; SetS.DTRMng
DEFL W SetSDTROnTime Y SetS KH 0004 ; SetS.DTROnTime
DEFL W SetSDTROffTime Y SetS KH 0006 ; SetS.DTROffTime
DEFL Y Mdb KD 64
DEFL Y MdbCommand Y Mdb KH 0000 ;Mdb.Command
DEFL Y MdbStatus Y Mdb KH 0001 ;Mdb.Status
DEFL Y MdbNodeAdd Y Mdb KH 0002 ;Mdb.NodeAdd
DEFL W MdbWrLcStAd Y Mdb KH 0004 ;Mdb.WrLcStAd
DEFL W MdbWrRmStAd Y Mdb KH 0006 ;Mdb.WrRmStAd
DEFL Y MdbWrBytes Y Mdb KH 0008 ;Mdb.WrBytes
DEFL W MdbRdLcStAd Y Mdb KH 000A ;Mdb.RdLcStAd
DEFL W MdbRdRmStAd Y Mdb KH 000C ;Mdb.RdRmStAd
DEFL Y MdbRdBytes Y Mdb KH 000E ;Mdb.RdBytes
DEFL W MdbCommndWt Y Mdb KH 0010 ;Mdb.CommndWt
DEFL W MdbTimeOutCk Y Mdb KH 0012 ;Mdb.TimeOutCk
DEFL W MdbRxTimeout Y Mdb KH 0014 ;Mdb.RxTimeout
DEFL W MdbTimeouts Y Mdb KH 0016 ;Mdb.Timeouts
DEFL W MdbOverruns Y Mdb KH 0018 ;Mdb.Overruns
DEFL W MdbCommErrs Y Mdb KH 001A ;Mdb.CommErrs
DEFL Y FrameBuf KD 40
; ------------------------------------------------------------------------------
; @Section("Program init")
; ------------------------------------------------------------------------------
; Local variables init.
ORGR
LODT F PLCFirstLoop
MOVI Y LastNode K 0001 ;Last node to communicate
MOVM Y NodeSequencer Y LastNode ;Slave nodes sequencer
; Here the serial parameters "19200, e, 8" are set on the serial port "A".
; Please note the set of the "EchoFlush" bit to avoid echo.
; ------------------------------------------------------------------------------
; @Section("Node sequencer management")
; ------------------------------------------------------------------------------
; Slave nodes sequencer increment.
ORGR
LODT F PLCFirstLoop
ORLT F CommOk ;Communication with node ok
ORLT F CommError ;Communication with node error
INCO Y NodeSequencer ;Slave nodes sequencer
; The command enable is disabled for a program loop to reset the status bits, so
; if any error bit in the "MdbStatus" is set it will be reset.
MCRS
ORGR
GRTC Y NodeSequencer Y LastNode ;Slave nodes sequencer
MOVI Y NodeSequencer KD 0 ;Slave nodes sequencer
; ------------------------------------------------------------------------------
; @Section("Slave node 0, communication parameter settings")
; ------------------------------------------------------------------------------
; A memory buffer of 6 bytes that starts at "ToSlave0" address in the master is
; sent to the slave 0 node and data is stored from Y 0000 to Y 0003.
;
; +--------------------+ +-------------+
; ToSlave0 | To slave node 0 | -- | From master | Y 0000 - Y 0003
; FromSlave0 | From slave node 0 | -- | To master | Y 0004 - Y 0005
; +--------------------+ +-------------+
ORGR
EQUC Y NodeSequencer KD 0 ;Slave nodes sequencer
MOVI Y MdbNodeAdd KD 0 ;Mdb.NodeAdd
; ------------------------------------------------------------------------------
; @Section("Slave node 1, communication parameter settings")
; ------------------------------------------------------------------------------
; A memory buffer of 6 bytes that starts at "ToSlave1" address in the master is
; sent to the slave 1 node and data is stored from Y 0000 to Y 0007.
;
; +--------------------+ +-------------+
; ToSlave1 | To slave node 1 | -- | From master | Y 0000 - Y 0001
; FromSlave1 | From slave node 1 | -- | To master | Y 0002 - Y 0005
; +--------------------+ +-------------+
ORGR
EQUC Y NodeSequencer KD 1 ;Slave nodes sequencer
MOVI Y MdbNodeAdd KD 1 ;Mdb.NodeAdd
ORGR
MCRE
; ------------------------------------------------------------------------------
; @Section("MODBUS communication, master management")
; ------------------------------------------------------------------------------
; FbModbusAsciiMs, management.
ORGR
SETR
SETV KE IOSerialPortA
TASK L TermIOTick
TASK L FbModbusAsciiMs Y Mdb ;MODBUS master management
LTCH Y MdbCommand K 0000 ;Command.Enable
ORGR
LODT Y MdbStatus K 0001 ;Status.Command executed
OUTT F CommOk ;Communication with node ok
ORGR
LODT Y MdbStatus K 0004 ;Status.Timeouts
ORLT Y MdbStatus K 0005 ;Status.Overruns
ORLT Y MdbStatus K 0006 ;Status.CommErrs
ORLT Y MdbStatus K 0007 ;Status.Parameters
OUTT F CommError ;Communication with node error
; ------------------------------------------------------------------------------
; @Section("Slave node 0, communication counters management")
; ------------------------------------------------------------------------------
; The communication ok counter is managed.
ORGR
EQUC Y NodeSequencer KD 0 ;Slave nodes sequencer
ANDT F CommOk ;Communication with node ok
INCO W Node0CommOk ;Node 0 comm ok counter
ORGR
EQUC Y NodeSequencer KD 0 ;Slave nodes sequencer
ANDT F CommError ;Communication with node error
INCO W Node0CommError ;Node 0 comm error counter
; ------------------------------------------------------------------------------
; @Section("Slave node 1, communication counters management")
; ------------------------------------------------------------------------------
; The communication ok counter is managed.
ORGR
EQUC Y NodeSequencer KD 1 ;Slave nodes sequencer
ANDT F CommOk ;Communication with node ok
INCO W Node1CommOk ;Node 1 comm ok counter
ORGR
EQUC Y NodeSequencer KD 1 ;Slave nodes sequencer
ANDT F CommError ;Communication with node error
INCO W Node1CommError ;Node 1 comm error counter
; [End of file]
"C" example
#include <ElSystemLib.h>
#include <ElPLCLib.h>
#include <FbModbusAsciiMs.h>
// -----------------------------------------------------------------------------
// GENERAL DEFINITIONS
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// DATA BUFFER DEFINITIONS
// -----------------------------------------------------------------------------
// Here define the data buffer to communicate with the slave 0 system.
struct
{
struct
{
unsigned char Byte0; //To slave system, byte 0
unsigned char Byte1; //To slave system, byte 1
unsigned int Word2; //To slave system, word 2
}ToSlave; //Data buffer to slave
struct
{
unsigned char Byte0; //From slave system, byte 0
unsigned char Byte1; //From slave system, byte 1
}FromSlave; //Data buffer from slave
}Slave0;
// Here define the data buffer to communicate with the slave 1 system.
struct
{
struct
{
unsigned char Byte0; //To slave system, byte 0
unsigned char Byte1; //To slave system, byte 1
}ToSlave; //Data buffer to slave
struct
{
unsigned char Byte0; //From slave system, byte 0
unsigned char Byte1; //From slave system, byte 1
unsigned int Word2; //From slave system, word 2
}FromSlave; //Data buffer from slave
}Slave1;
// -----------------------------------------------------------------------------
// GLOBAL VARIABLE DEFINITIONS
// -----------------------------------------------------------------------------
// Here all the global variables are defined.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// -------------------------------------------------------------------------
// SLAVE NODE PARAMETERS
// -------------------------------------------------------------------------
// Here the slave node parameters are defined.
// By changing the values loaded in this data structure, the communication
// parameters can be set for any slave node for the desired requirements.
{
0x02, //Comand to execute (0:Write, 1:Read, 2:Write/Read)
0x00, //Node address
{
0x02, //Comand to execute (0:Write, 1:Read, 2:Write/Read)
0x01, //Node address
// -------------------------------------------------------------------------
// PROGRAM INIT
// -------------------------------------------------------------------------
// Here define the serial line must be used.
SetTermIOVectors(IOSerialPortA);
TermIOTick(); //Execute the tick
if (PLCFirstLoop)
{
// Local variables init.
// -------------------------------------------------------------------------
// NODES SEQUENCER MANAGEMENT
// -------------------------------------------------------------------------
// Increment the node sequencer and set the "FbModbusAsciiMs" parameters.
if (PLCFirstLoop|CommOk|CommError)
{
Mdb.Command.Enable=FALSE; //Enable
switch (NodePar[NodeNr].CmdToExecute)
{
case 0:
Mdb.Command.DoWrite=TRUE; //Write memory bytes
break;
case 1:
Mdb.Command.DoRead=TRUE; //Read memory bytes
break;
case 2:
Mdb.Command.DoWrRd=TRUE; //Write/read memory bytes
break;
}
// -------------------------------------------------------------------------
// MODBUS MASTER COMMUNICATION
// -------------------------------------------------------------------------
// FbModbusAsciiMs communication call.
if (CommOk=Mdb.Status.JobDone)
NodesCommOk[NodeNr]++; //Nodes comm ok counter
if (CommError=(Mdb.Status.Timeouts|Mdb.Status.Overruns|Mdb.Status.CommErrs|Mdb.Status.Parameters))
NodesCommError[NodeNr]++; //Nodes CommError counter
}
// [End of file]
How to
By using a simple mathematic function it is possible to execute the average on a value. This possibility is very
useful in the cases in which for example it is acquired an analogic value that presents some ripple, by using the
function you will be able to obtain the average value. The used function is: Average=((Value-Average)/
Coefficient)+Average. If Coefficient has value 1 you have no average of the value, while by increasing the
value you obtain average effect always more accentuated.
Example RIL
The reported example executes the average of the value FL Value by using as coefficient FL Coefficent and
returns the averaged value in FL Average.
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; ------------------------------------------------------------------------------
; @Section("Mediate the value")
; ------------------------------------------------------------------------------
; Average=((ValueToMediate-Average)/Coefficent)+Average.
ORGR
SETR
LODA FL Average ; Average value
LODA FL ValueToMediate ; Value to mediate
FSUB
LODA FL Coefficent ; Average coefficent
XCHA
FDIV
LODA FL Average ; Average value
FADD
STRA FL Average ; Average value
; [End of file]
Ecample "C"
The reported example executes the average of the value float ValueToMediate by using as coefficient
float Coefficent and returns the averaged value in float Average.
#include <ElSystemLib.h>
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
void Example(void)
{
// Average=((ValueToMediate-Average)/Coefficent)+Average.
// [End of file]
How to
One of the most important peculiarity of Remoter is the easyness of migration of a project between the
different target systems, making it posssible to adapt easily a project on different targets in function of one's
own needs. To migrate a project from a target system to anothe, you need after having opened the project
define its new settings, choose the Settings voice from the Project menu, or place yourself with the mouse
on the project icon and with the right key select the Settings option , a window that will lead you between
all the needed settings will open.
The first window that will open will show the target device currently selected.
At this point you will need to select with the mouse the new hardware device desired. It is important to
define correctly the target device, so an image of the selected device is presented. However to avoid errors
we remind you to check the code reported on the identification label of the product,the presence of the
asterisks indicates that whatever number or letter appears in that position it is valid anyway.
Selected the new device by pressing the Next key, a message is shown that reminds us that the hardware
device has been modified and that all the other settings will be set at their default values requesting a
further confirmation.
By corfirming you will procede in the settings of all the other project settings so as indicated in the related
chapter.
Normally it will be enough to confirm all the advised settings by pressing the Next key, until you end all the
requested settings. At this point it will be possible to recompile the project and transfer it on the new target
system.
How to
To compile the Remoter projects use a series of libraries that are provided with the installation. System
libraries, PLC libraries, libraries for the management of the functions blocks , libraries for particular uses
exist.
The addition libraries are provided in a zip file that contains a directory (Named with the library code), in
which inside all the files that make up the library will be.
To install a new version of an existing library and/or to install a new library, you need to copy the provided
library directory, in the installation directory of the Remoter program, in the Lib directory, in the compiler
directory for which the library is made, we remind you that the only compiler currently supported is the
Raisonance compiler.
Ended the copy the new library will be available in the libraries list and will be able to be included in the
project by the definition panel of the libraries.
How to
Here follow the string to digit on the terminal to do the working tests of
the MODEM.
Figure 1
Check camp
It permits to check the level of GSM signal available, the answer string from the MODEM reports two
values.
aa: It indicates the value of the camp intensity, values lower than 9 indicates a scarce reliability of the
connection.
b: It indicates an error status, the value must not exceed the 3.
Data call
It permits to execute a data connection with another MODEM both GSM or PSTN.
Warning! if the number called belongs to a digital line (GSM or ISDN) the possibility of the called
device to answer a dates call is checked automatically and in the case it is not possible the MODEM
aborts the call by returning the string NO CARRIER.
The data call is possible only if your SIM is enabled to a data traffic, otherwise it will be
originated a voice call.
1 Send the command "ATD nnn" followed by return (nnn is the number to call comprehensive of
prefix).
When the number called answers the negotiation of the connection speed starts at which end the
MODEM answers "CONNECT".
Voice call
It permits to execute a voice connection with a telephone both GSM and analog one connected to the
telephone network commuted. The difference from a dates call is indicated by the character";" located
after the number to call.
1 Send the command "ATD nnn;" followed by return (nnn is the number to call comprehensive of
prefix).
The MODEM answers "OK".
MODEM profile
Is called profile of a MODEM all its settings. The MODEM is supplied with a default profile that can be
changed with specifics AT commands. To display the actual profile the "AT&V" string followed by
return must be send to the MODEM, the MODEM answers with its setting profile. The "AT&F"
command restores the default profile. In the following table we report the the default settings of the
TC35i MODEM:
How to
Figure 1
Starting
It permits to start the MODEM by setting the correct working settings.
1 Send the command "AT&F" followed by return.
The MODEM answers "OK". This permits to shape the MODEM with the default parameters, the
default shape changes between the different dodels of MODEM, so we advice you to send anyway a
starting string .
2 Send the command "ATH0X0E1V1L1" followed by return.
The MODEM answers "OK". This command disconnects the line, sets the base answer codes, the
textual dialog, the echo of the commands and activates the loudspeaker on a medium volume.
3 Send the command "AT&K0" followed by return.
The MODEM answers "OK". This command unqualifies the stram control on the serial line.
4 Send the command "AT%C3" followed by return.
The MODEM answers "OK". This command qualifies the compression of the dates V42 bis and
MNP5.
It is possible that some modem do not manage this command, in that case the answer string will be
"Error". Refere to the MODEM handbook to sent the alternative command to be sent.
Data call
It permits to execute a data connection with another MODEM both analogic connected to telephone
network commuted and GSM.
1 Send the command "ATDT nnn" followed by return (nnn is the number to call comprehensive of
prefix).
When the called number answers the negotiation of the connection speed starts at which end the
MODEM answers "CONNECT".
MODEM pofile
Is called MODEM profile all its settings. The MODEM is supplied with a default profile that can be
changed with specifics AT commands. The "AT&F" command restores the default profile. To display
the actual profile the "AT&V" string followed by return must be send to the MODEM, the MODEM
answers with its setting profile. In the following table we report the the default settings of standard
MODEM.
How to
The Siemens Sle4442, the Gemplus GPM2K and the Philips PCB2024 are some smart cards with
protected memory, to use them on the Netreader systems a proper function block is provided. The three
types of card are compatible and their main features are:
The PSC is needed to be able to modify the dates available on the smart card, the reading, instead, is
always possible. The memory map of the smart card Sle4442 (and compatibles) is the following.
PSC code
The Sle4442 smart cards always have a three bytes PSC. When you buy a Sle4442 it is therefore
necessary that the seller tells you this PSC (PIN or secret code). However, generally, the Sle4442 have, at
the moment of the distribution, a PSC equal to 0xFF, 0xFF, 0xFF. The GPM2K instead have PSC 0xAA,
0xAA, 0xAA. Obviously, the PSC can be modified when the card is started by the application that uses it.
The card inserted in the reader is always readable, but it is not possible to modify the dates contained in it if
you haven't locked it before by defining the the correct PSC value in SecurityMem[1-2-3] and executing
the function PSCVerification. WARNING! After three wrong attempts the card locks itself unreversibly.
Dates protection
As already said, to change the dates in a Sle4442 or compatibles, it is necessary to present the PSC with
the proper sequence. Moreover, it is also possible to protect permanently and unreversibly the dates in the
first 32 bytes of the smart card. This is possible by writing in a particular area of the card (out of the 256
bytes) called Protection Memory.
This area is formed by 4 bytes, in which every bit corresponds to a byte of the card, and if the
correspondent bit is 1, the byte is not changeble. To protect a byte in the zone 0-31, you need to execute
the function ProtectionMemoryWrite by defining the addresse of the byte to be protected (From 0x00 to
0x31) and its current value.
Modify PSC
To modify the PSC you need to unlock the chip card by defining the correct PSC value in SecurityMem[1-2-
3] and executing the function PSCVerification. Define then the new PSC value in SecurityMem[1-2-3] and
execute the function UpdateSecurityMemory.
Note
The information on this page are reported to help or understand better the nature of these cards, and have
a general view on its functions. We do not assume on ourselves the responsibility on the use of these
information, and on their exactness, even though we have done all the possible to create a correct profile.
How to
Remoter allows to execute functions written in RIL language on interrupt events. The execution of the normal program
is interrupted and is executed the defined function. This allows to know exactly the scanning time of a function, this can
be useful when is necessary to manage fast vents. To be able to perform a function written in RIL language on
interrupt it's necessary to remember that:
The RIL program operates on a process image of the logic inputs, this means that the inputs are acquired before
execute the program loop and are transferred in the Input (I) operands. So to have their state in real time, in the
interrupt function will be necessary to acquire the logic inputs on which to operate.
The RIL program operates on a process image of the logic outputs, this means that the Output (O) operands are
managed during the program loop but they are transferred to the hardware only at the end of the loop execution.
So to manage their state in real time, in the interrupt function will be necessary to acquire the state of the Output
operands on which to operate, and after to have operated on them, will be necessary to transfer the the new state
in the operands used by main program and then to manage hardware
RIL example
; ------------------------------------------------------------------------------
; @Section("Main program")
; ------------------------------------------------------------------------------
; Enable the timing interrupt, it's executed every 1 mSec.
ORGR
SETR
TINE KD 1
ORGR
LODT I 0000
OUTT O 0000
; [End of file]
In the following table the Interrupt file, it will be executed on interrupt at every 1 mSec.
; ------------------------------------------------------------------------------
; @Section("Local variable definitions")
; ------------------------------------------------------------------------------
; Local variable definitions.
; ------------------------------------------------------------------------------
; @Section("Program executed on interrupt")
; ------------------------------------------------------------------------------
; Here the logic inputs are acquired directly from the hardware and the buffer
; of the logic outputs where they are managed by the main program is copied.
ORGR
LABL K 0000
SETR
IOAQ K 0000
STRA Y LogInput ;Logic inputs acquisition
CMPA O 0000
STRA Y LogOutput ;Logic output copy
ORGR
LODT Y LogInput BD 1
OUTT Y LogOutput BD 1
; Here the logic output copy is directly transferred to hardware outputs and are
; copied in the buffer managed by the main program.
ORGR
SETR
LODA Y LogOutput ;Logic output copy
EXPA O 0000
IOAQ K 0100
RETN
; [End of file]
How to
Program backup
The program backup could be executed either manual or automatic, please refer to the table:
Manual By using a PC connected to the target system with the mass memory manager procedure.
Automatic With the system in power off insert a formatted mass memory module. To format the
module use the mass memory manager procedure.
At the system power on, 5 consecutive blinks alternated from a pause of the RUN led
indicates that the backup module has been recognized by the system.
After about 30 seconds the program backup will start automatically, 8 consecutive blinks
alternated from a pause of the RUN led indicates that the procedure is in execution.
The backup procedure takes about 2 minutes. 10 consecutive blinks alternated from a
pause of the RUN led indicates that backup is ended, now it's possible to switch off the
system and extract the mass of memory module. It now contains a copy of the user
program present in your system.
9 consecutive blinks alternated from a pause of the RUN led indicates that the procedure is
an error. Verify if the module is well inserted in the connector and that the switch on the
module doesn't be in Write protect position. It's necessary to repeat the procedure.
The automatic backup, store only the data that were defined in the Data to manage during the mass
of memory module format. Please refer to the mass memory manager procedure.
Program restore
The program restore could be executed either manual or automatic, please refer to the table:
Manual By using a PC connected to the target system with the mass memory manager procedure.
Automatic With the system in power off, insert a mass of memory module on which it's stored a
program with the backup procedure.
At the system power on, 6 consecutive blinks alternated from a pause of the RUN led
indicates that the restore module has been recognized by the system.
After about 30 seconds the program restore will start automatically, 8 consecutive blinks
alternated from a pause of the RUN led indicates that the procedure is in execution.
The backup procedure takes about 2 minutes. 10 consecutive blinks alternated from a
pause of the RUN led indicates that restore is ended, now it's possible to switch off the
system and extract the mass of memory module. The user program present on it it's been
loaded in your system.
9 consecutive blinks alternated from a pause of the RUN led indicates that the procedure is
an error. Verify if the module is well inserted in the connector. It's necessary to repeat the
procedure.
How to
The I2C addresses of the Netsyst family extension modules are defined in the range from 0x21 to 0x27, that
correspond to the module addresses from 0x01 to 0x07 in the bus access functions, NSYSTExtModuleAbort,
NSYSTExtModuleInp, NSYSTExtModuleOut, NSYSTExtReadVar and NSYSTExtWriteVar. The address are
automatically defined by the master system that assigns them following the connection order of the module to the
extension bus. The nearest module to the master system will take address 0x21, the successive one 0x22 and so on,
the allocation finish when no more module are been recognized by the master.
However it's possible to define the module I2C address by the user program, refer to the AddressForce bit of the
Command byte of the FbI2CSlaveManager function block. To define the address it's necessary to follow the
allocation order the system master adopts. Example to the 2nd module joined to the bus must be defined the address
0x22, otherwise the modules automatic addressing will be compromised.
It's possible to define I2C addresses different from those defined but the modules must be the last joined to the bus. In
that case case the modules will be accessible only by the I2CMasterRead and I2CMasterWrite functions.
The 10 I/O extension module, instead of the other extension modules presents only one extension bus connector, so
it can be joined only one of this type of module to the bus and it must be the last one.
If more than one module must be used it's possible to store in one of them the SWM135 standard program, while on
the other will be necessary to realize a dedicated program for every module on wich the module address is defined.
RIL example
In the following example it's reported the program of a 10 I/O extension module SWM135 modified for the definition of
the module address. In the example the module has the address forced to 0x22.
; ------------------------------------------------------------------------------
; @Section("External variable definitions")
; ------------------------------------------------------------------------------
EXTR Y SystemConfig
EXTR W IOSerialPortA
DEFG Y SCTargetDevice Y SystemConfig KH 0002 ;SystemConfig.TargetDevice
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; Program variables.
; ------------------------------------------------------------------------------
; @Section("Welcome message management")
; ------------------------------------------------------------------------------
; For 5 Sec at power up a welcome message is displayed.
ORGR
SETR
OUTM T MessageDly KD 5000 KE Base1mS ;Welcome message delay
ORGR
LODF T MessageDly ;Welcome message delay
PULS
MOVI W MessageNr KD 0 ;Message number
ORGR
LODT T MessageDly ;Welcome message delay
PULS
MOVI W MessageNr KD 1 ;Message number
; ------------------------------------------------------------------------------
; @Section("I2C slave manager execution")
; ------------------------------------------------------------------------------
; Here the I2C slave manager function block parameters are set.
; The module address 0x22 (Module 2) is set.
ORGR
LODT F PLCFirstLoop
LTCH Y SlmCommand BD 0 ;Slm.Command.Enable
LTCH Y SlmCommand BD 1 ;Slm.Command.AddressForce
MOVI Y SlmI2CSAddress KH 0022 ;Slm.I2CSAddress
MOVM W SlmSerial W IOSerialPortA ;Slm.Serial
ORGR
SETR
TASK L FbI2CSlaveManager Y Slm
IOAQ K 0000
STRA Y SlmI2CSLLogInp ;Slm.I2CSLLogInp
ORGR
SETR
RETN
; ------------------------------------------------------------------------------
; @Section("User startup function")
; ------------------------------------------------------------------------------
; This function is automatically called once before to execute the user program.
; Configure the system as "NETREADER_P89C664_SLAVE_EXT".
ORGR
LABL L PLCUserStartUp
SETR
MOVI Y SCTargetDevice KH 0022 ;SystemConfig.TargetDevice
RETN
; [End of file]
How to
Le termoresistenze più usate in ambito industriale sono le Pt100, cioè termoresistori al platino da 100 Ohm a 0 °C
(Pt100). L’elemento sensibile è costruito mediante deposizione sotto vuoto di platino su un substrato di ceramica e
definito al laser. Le sonde possono avere una precisione di acquisizione compresa tra 0.1 ed 1 grado. Pertanto se si
desiderano acquisizioni di temperatura estremamente precise occorre provvedere ad una taratura della sonda.
Per soluzionare il problema viene fornito un programma dimostrativo che permette utilizzando il corretto valore di
temperatura rilevato con una sonda di precisione di tarare l'acquisizione delle sonde Pt100. Il programma permette:
Il programma è stato realizzato per un sistema NetlogII, per il suo utilizzo occorre connettere due sonde di temperatura
Pt100 agli ingressi analogici. Occorre poi disporre di uno strumento indicatore di temperatura di riferimento. Per
mantenere un perfetto scambio termico tra le sonde Pt100 di rilevamento ed lo strumento di riferimento si consiglia di
immergere sia le sonde che lo strumento in un bicchiere di acqua.
RIL example
In the following example it's reported the program of a 10 I/O extension module SWM135 modified for the definition of
the module address. In the example the module has the address forced to 0x22.
; ------------------------------------------------------------------------------
; @Section("External variable definitions")
; ------------------------------------------------------------------------------
EXTR Y SystemConfig
EXTR W IOSerialPortA
DEFG Y SCTargetDevice Y SystemConfig KH 0002 ;SystemConfig.TargetDevice
; ------------------------------------------------------------------------------
; @Section("Global variables definition")
; ------------------------------------------------------------------------------
; Program variables.
; ------------------------------------------------------------------------------
; @Section("Welcome message management")
; ------------------------------------------------------------------------------
; For 5 Sec at power up a welcome message is displayed.
ORGR
SETR
OUTM T MessageDly KD 5000 KE Base1mS ;Welcome message delay
ORGR
LODF T MessageDly ;Welcome message delay
PULS
MOVI W MessageNr KD 0 ;Message number
ORGR
LODT T MessageDly ;Welcome message delay
PULS
MOVI W MessageNr KD 1 ;Message number
; ------------------------------------------------------------------------------
; @Section("I2C slave manager execution")
; ------------------------------------------------------------------------------
; Here the I2C slave manager function block parameters are set.
; The module address 0x22 (Module 2) is set.
ORGR
LODT F PLCFirstLoop
LTCH Y SlmCommand BD 0 ;Slm.Command.Enable
LTCH Y SlmCommand BD 1 ;Slm.Command.AddressForce
MOVI Y SlmI2CSAddress KH 0022 ;Slm.I2CSAddress
MOVM W SlmSerial W IOSerialPortA ;Slm.Serial
ORGR
SETR
TASK L FbI2CSlaveManager Y Slm
IOAQ K 0000
STRA Y SlmI2CSLLogInp ;Slm.I2CSLLogInp
ORGR
SETR
RETN
; ------------------------------------------------------------------------------
; @Section("User startup function")
; ------------------------------------------------------------------------------
; This function is automatically called once before to execute the user program.
; Configure the system as "NETREADER_P89C664_SLAVE_EXT".
ORGR
LABL L PLCUserStartUp
SETR
MOVI Y SCTargetDevice KH 0022 ;SystemConfig.TargetDevice
RETN
; [End of file]
How to
I sistemi NetlogII e Psyst MEIII sono dotati di un programma kernel che gestisce le comunicazioni con il Modem.
Il Kernel gestisce autonomamente l'accesso da remoto via Modem al sistema, permettendo di effettuare tutte le
operazioni di debug e programmazione. Esistono casi in cui però è necessario da programma utente gestire il
Modem per la ricezione o l'invio di SMS, per il controllo del CLIP del chiamante, e per la gestione di chiamate in
uscita.
Per utilizare il Modem da programma utente occorre configurare il kernel in modo oppurtuno. Selezionando la
configurazione target nelle impostazioni di progetto, definire:
Modem... Impostare tutti i parametri desiderati per il Modem ed il terminale di I/O a cui il Modem è
connesso.
Porta seriale... Impostare i corretti parametri di comunicazione supportati dal Modem utilizzato.
Modbus... Selezionare Modem come terminale di I/O a cui il modbus verrà connesso. Disabilitare il tick
abilitazione debug utente. In questo modo da Modem sarà possibile eseguire le operazioni di
caricamento programma, mentre con il programma utente in esecuzione il Modem sarà
completamente gestito da programma utente.
Programma utente
Viene riportato un esempio di programma utente per la gestione di un modem con ricezione ed invio messaggi
SMS.
// -----------------------------------------------------------------------------
// FILE INCLUSIONS
// -----------------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include <ElSystemLib.h>
#include <ElPLCLib.h>
// -----------------------------------------------------------------------------
// GLOBAL VARIABLES
// -----------------------------------------------------------------------------
// Global variables definition.
// -----------------------------------------------------------------------------
// EXAMPLE PROGRAM
// -----------------------------------------------------------------------------
// Example program executed on main.
void Example(void)
{
// Local variable definitions.
// -------------------------------------------------------------------------
// LOGIC I/O MANAGEMENT
// -------------------------------------------------------------------------
// Here acquire the 8 logic input from I 0000 to I 0007.
PeripheralInp(0, 0, &LogInput);
// -------------------------------------------------------------------------
// MODEM MANAGEMENT
// -------------------------------------------------------------------------
// Set the modem data structure address.
if (PLCFirstLoop)
{
Mdm.CLIPRxNumber=&CLIPRxNumber; //CLIP received number
Mdm.CLIPRxLgt=sizeof(CLIPRxNumber); //CLIP received number length
Mdm.DialNumber=&DialNumber; //Number to be dialed
if (Mdm.Status.SMSReceived)
{
if (!strcmp(SMSRxBuf, "Set flag")) SMSFlag=TRUE;
if (!strcmp(SMSRxBuf, "Reset flag")) SMSFlag=FALSE;
}
if (LogInput&0x01)
{
strcpy(&SMSNumber, "+39335217595");
strcpy(&SMSTxBuf, "Input 0 is set");
if (LogInput&0x02)
{
strcpy(&SMSNumber, "+39335217595");
strcpy(&SMSTxBuf, "Input 1 is set");
Mdm.Command.SMSSend=TRUE; //Active force the SMS send
}
}
// [End of file]
Error list
Scanner errors
The scanner considers all the project RIL files examining the instructions and the operands contained. The
possible errors are returned with a message, following the possible errors.
Code Description
Error list
Parser errors
The parser considers all the project RIL files examining the instructions and the operands contained. The
possible errors are returned with a message, following the possible errors.
Code Description
RME216 RME216
The extern @ operand has already been stated local in the # file
The extern @ operand in the # file has already been defined local in the # file. It' necessary to
rename one of the two operands.
RME217 The global @ operand is duplicated in the # file
The global @ operand has been duplicated in the # file. It's necessary to rename one of the two
operands
RME218 The local @ operand is duplicated
The local @ operand is defined more than one time in the file.
RME219 The @ operand must be stated
The @ operand has been used but it isn't been defined, it's necessary to define it.
RME220 CALL to @ without LABL
A CALL instruction has been done to the @ label but the label isn't been defined.
RME221 It's not permitted to define @. The definition is automatic
The @ operand has been defined but this operand is already defined automatically. It's
necessary to remove the definition.
RME222 IN THE @ LINE: the previous rung must be closed
The previous logic branch to the @ line has not been closed correctly.
RME223 IN THE @ LINE: the rung must be opened
The previous logic branch to the @ line has not been opened correctly.
RME224 N THE @ LINE: not all the previous branches have been closed
The logic branch previous to the @line contains one or more branch not correctly closed.
RME225 IN THE @ LINE: too many branches opened
The previous logic branch to the @line contains too many opened branches.
RME226 IN THE @ LINE: the branch must be opened
The closing branch instruction to the @ line does not correspond to an opened branch.
RME227 IN THE @ LINE: it's necessary to have at least two branches opened
The closing branch instruction to the @ line does not correspond to at least two opened branch.
RME228 IN THE @ LINE: it's necessary to have no branch opened
At the moment of the instruction to the @ line must be there no branch opened.
RME229 IN THE @ LINE: to the end of the file there is a rung left opened
In the @ line of the file end there is still a rung opened.
RME230 IN THE @ LINE: to the end of the file there is at least a branch left opened
In the @ line of end file there is still one or more rung opened.
RME231 IN THE @ LINE: The # operand can not be written because is in CODE
In the @ line the # operand that has been located in memory code can not be written.
RME232 IN THE @ LINE: All the MCRS must be closed with MCRE
In the @ line of end file there is still some MCRS instructions that haven't been closed with the
respective MCRE instructions.
RME233 The @ operand is related to the # operand that has a visibility different than the stated one.
This error advises that the @ operand has been defined different than the related # array.
It reminds that in the array definition all the operands have to be defined in the same way. For
example they all have to be DEFG, DEFL o DEFB.
RME234 The @ operand can not be contained in the # operand. Verify dimension and offset.
This error advises that there is not enough space in the # array to locate the @ operand
Error list
The RFB converter converts the project FB graphics considering the instructions and the operands
contained. The possible errors are returned with a message, following the possible errors.
Code Description
Error list
The RLD converter converts all the files written in Ladder diagram considering the instructions and the
operands contained. The possible errors are returned with a message, following the possible errors.
Code Description
Error list
The AOF converter converts the file created by the linker in the Intel-hex format to be transferred on the
target system. The possible errors are returned with a message, following the possible errors.
Code Description
Error list
Linker errors
The linker merges the different project files in one program file to be passed to the AOF converter. The
possible errors are returned with a message, following the possible errors.
Code Description
Error list
Assembler errors
The assembler converts the files written in assembler language in the format to be interpreted by the linker.
The possible errors are returned with a message, following the possible errors.
Code Description
Error list
Compiler errors
The compiler converts the files written in C language in the format to be interpreted by the linker. The
possible errors are returned with a message, following the possible errors.
Code Description
Error list
Project errors
Before to compile the project, all its settings are checked. The possible errors are returned with a message,
following the possible errors.
Code Description
Libraries
SFR025B000
SFR025C000
Renamed library with ElSystemLib alias and create version for Remoter 8.1.
SFR025D000
A
The SetPeripheralReady function resets the logic outputs on all the modules at the ready signal
disable. In the previous versions the reset was executed also on the ready signal enable.
Defined two new global variables FLASHWriteCtr and EEPROMWriteCtr for the accesses count to
the FLASH and EEPROM memories.
The TermIOOpen and TermIOClose functions if referred to the serial line I/O device now allows the
enable and disable of the management interrupt.
Added ArrayBitCount, ArrayBitSet, ArrayBitStatus functions.
Defined in the SERIALSTRUCT data structure the Mode.WaitLoop member.
Modified SystemMemoryRead e SystemMemoryWrite functions, the bytes number operand is
passed on a unsigned int variable instead of unsigned char.
Added ASCIIToHEX and HEXToASCII macros, they allow the ASCII to HEX e HEX to ASCII
conversion.
Added Random function.
The system functions IODeviceFctReturn and IODeviceFctMissing are defined as global.
Eliminated the BUS_TERMINALSTRUCT definition and created the TERMINALSTRUCT data
structure.
Added the AsciiStringConvert function.
Added the GetCharEchoEnable variable.
Added the NSYSTExtModuleInp and NSYSTExtModuleOut functions, to maintain compatibility with the
Picosyst system.
Added a 30 mSec debouncing on the terminal keyboard acquisition.
SFR025E000
Libraries
SFR026C000
SFR026D000
Renamed library with ElSystemLib alias and create version for Remoter 8.1.
Modified the SystemMemoryRead and SystemMemoryWrite functions, added the access to PCB088
mass memory module (From 0x00000000 to 0x07FFFFFF)
Added NSYSTExtReadVar e NSYSTExtWriteVar functions.
The interrupt timer 1 and 2 is executed with the microcontroller in interrupt condition, before was
executed with the microcontroller in user program condition.
SFR026E000
A
The SetPeripheralReady function resets the logic outputs on all the modules at the ready signal
disable. In the previous versions the reset was executed also on the ready signal enable.
Defined two new global variables FLASHWriteCtr and EEPROMWriteCtr for the accesses count to
the FLASH and EEPROM memories.
The TermIOOpen and TermIOClose functions if referred to the serial line I/O device now allows the
enable and disable of the management interrupt.
Added ArrayBitCount, ArrayBitSet, ArrayBitStatus functions.
Defined in the SERIALSTRUCT data structure the Mode.WaitLoop member.
Modified SystemMemoryRead e SystemMemoryWrite functions, the bytes number operand is
passed on a unsigned int variable instead of unsigned char.
Added ASCIIToHEX and HEXToASCII macros, they allow the ASCII to HEX e HEX to ASCII
conversion.
Added Random function.
The system functions IODeviceFctReturn and IODeviceFctMissing are defined as global.
Eliminated the BUS_TERMINALSTRUCT definition and created the TERMINALSTRUCT data
structure.
Added the AsciiStringConvert function.
Added the GetCharEchoEnable variable.
Added a 30 mSec debouncing on the terminal keyboard acquisition.
SFR026F000
SFR026G000
A
Modified SystemMemoryRead and SystemMemoryWrite functions, added the management of type 5
to access to the DATA memory inside to the microprocessor and disabled interrupt on memory access.
Eliminated the XON and XOFF character management in serial line.
Addded ModbusCRC function.
Eliminated bug on data input, if the [ENT] key was pressed without any data given the system locks.
SFR026H000
E
Version realized to have the same behavior of the libraries that interface with the Kernel. Changed the
TERMIOFUNCTIONS, SERIALFUNCTIONS and TERMINALFUNCTIONS data structures.
Eliminated the SetDataAddress and GetDataAddress functions, the SetTermIOData e
GetTermIOData functions must be used.
Modified the BlinkBit function and the relate BLINKBITDATA data structure.
The user program is executed allowing the return to the library where the run led blink is managed.
SFR026H100
E
Solved the bug in ArrayBitCount, ArrayBitSet and ArrayBitStatus functions. They don't work properly if
the given array was long 32 bytes.
SFR026H200
E
Solved the bug in SystemMemoryWrite function on PCB111 mass memory module management.
Changed the hexadecimal data entry, it's not longer used the [FUN] key but now it' managed the
double function for the keys from [0] to [5]. The [FUN] key is used to input the "-" character in the
binary enhanced data entry.
Managed two new data entry types: 5: Binary, are accepted only 0 and 1. 6: Binary enhanced, range
from 0 to F and '-'.
Libraries
SFR037A000
SFR037B000
Renamed library with ElSystemLib alias and create version for Remoter 8.1.
SFR037C000
A
The SetPeripheralReady function resets the logic outputs on all the modules at the ready signal
disable. In the previous versions the reset was executed also on the ready signal enable.
Defined two new global variables FLASHWriteCtr and EEPROMWriteCtr for the accesses count to
the FLASH and EEPROM memories.
The TermIOOpen and TermIOClose functions if referred to the serial line I/O device now allows the
enable and disable of the management interrupt.
Added ArrayBitCount, ArrayBitSet, ArrayBitStatus functions.
Defined in the SERIALSTRUCT data structure the Mode.WaitLoop member.
Modified SystemMemoryRead e SystemMemoryWrite functions, the bytes number operand is
passed on a unsigned int variable instead of unsigned char.
Added ASCIIToHEX and HEXToASCII macros, they allow the ASCII to HEX e HEX to ASCII
conversion.
Added Random function.
The system functions IODeviceFctReturn and IODeviceFctMissing are defined as global.
Eliminated the BUS_TERMINALSTRUCT definition and created the TERMINALSTRUCT data
structure.
Added the AsciiStringConvert function.
Added the GetCharEchoEnable variable.
Added the NSYSTExtModuleInp and NSYSTExtModuleOut functions, to maintain compatibility with the
Picosyst system.
SFR037D000
Libraries
SFR038A000
Created the ElSystemLib and realized version for the Remoter 8.1.
SFR038B000
SFR038C000
SFR038D000
A
Modified SystemMemoryRead and SystemMemoryWrite functions, added the management of type 5
to access to the DATA memory inside to the microprocessor and disabled interrupt on memory access.
SystemMemoryWrite function, managed the FLASH memory write access.
Eliminated the XON and XOFF character management in serial line.
Addded ModbusCRC function.
SFR038E000
A
Version realized to have the same behavior of the libraries that interface with the Kernel. Changed the
TERMIOFUNCTIONS, SERIALFUNCTIONS and TERMINALFUNCTIONS data structures.
Eliminated the SetDataAddress and GetDataAddress functions, the SetTermIOData e
GetTermIOData functions must be used.
Modified the BlinkBit function and the relate BLINKBITDATA data structure.
The user program is executed allowing the return to the library where the run led blink is managed.
Increased the serial reception buffer dimension, now is 256 bytes, this allows the upload of the
programs on NetlogII sistems on "B" port at maximum baud rate of 115200.
SFR038E200
A
Solved the bug in ArrayBitCount, ArrayBitSet and ArrayBitStatus functions. They don't work properly if
the given array was long 32 bytes.
Solved the bug in SystemMemoryWrite function on PCB111 mass memory module management.
Changed the hexadecimal data entry, it's not longer used the [FUN] key but now it' managed the
double function for the keys from [0] to [5]. The [FUN] key is used to input the "-" character in the
binary enhanced data entry.
Managed two new data entry types: 5: Binary, are accepted only 0 and 1. 6: Binary enhanced, range
from 0 to F and '-'.
Libraries
SFR039A000
Created the ElSystemLib and realized version for the Remoter 8.1.
SFR039B000
A
The SetPeripheralReady function resets the logic outputs on all the modules at the ready signal
disable. In the previous versions the reset was executed also on the ready signal enable.
Defined two new global variables FLASHWriteCtr and EEPROMWriteCtr for the accesses count to
the FLASH and EEPROM memories.
The TermIOOpen and TermIOClose functions if referred to the serial line I/O device now allows the
enable and disable of the management interrupt.
Added ArrayBitCount, ArrayBitSet, ArrayBitStatus functions.
Defined in the SERIALSTRUCT data structure the Mode.WaitLoop member.
Modified SystemMemoryRead e SystemMemoryWrite functions, the bytes number operand is
passed on a unsigned int variable instead of unsigned char.
Added ASCIIToHEX and HEXToASCII macros, they allow the ASCII to HEX e HEX to ASCII
conversion.
Added Random function.
The system functions IODeviceFctReturn and IODeviceFctMissing are defined as global.
Eliminated the BUS_TERMINALSTRUCT definition and created the TERMINALSTRUCT data
structure.
Added the AsciiStringConvert function.
Added the GetCharEchoEnable variable.
SFR039C000
Libraries
SFR039A000
Libraries
SFR036A000
B C A A A
SFR036B000
B C A A A
Renamed library with alias ElPLCLib and realized version for Remoter 8.1.
Modified DTRE instruction to adapt it to the modified ElSystemLib system libraries.
Insert the PLCTxBufEmpty flag management in the STXC instruction.
SFR036C000
D E C A B
Modified the backup and restore management, now they use the SystemMemoryRead and
SystemMemoryWrite system functions to access to the backup memory. In this way it is possible to
use also EEPROM memory and mass memory to backup data.
Added PLCBackupEnd flag management, it is activated for a program loop at every backup cycle.
Modified macro for access to the numerical operands from C programs, statements like: PLCOpW
(0x0000)++; did not work correctly.
Added functions to manage the TASK instruction at relative address
Added PLCRemoterProjectInfo variable definition for the project information.
Inserted PLCRTCDATA prototype definition for the management of the real time clock. In this way it is
possible from Remoter to allocate to known address the Rtc values to be able to be accessed from
MODBUS
Modified the logic input acquisition function, now it acquires the input by executing a debouncing on
them. The debouncing time can be set in the project settings.
The loop time calculation is always executed, it isn't possible to disable it in the project settings.
All the blinking flag now are managed synchronously with the program execution.
In the FDIV floating division when a division for 0 occurs it returns the maximum value with the proper
sign.
Defined the PLCErrors data structure, it reports al the PLC program execution errors.
Modified the RunLED management, it blinks regularly if non errors are present, and irregularly if any
error is present in the SystemErrors, ExecutionErrors and PLCErrors data structures.
SFR036D000
D E C A B
Memory map
Picosyst systems
Memory map
Picosyst ME II systems
Memory map
Netlog systems
Memory map
Memory map
Memory map
Memory map
NetlogII systems
Loaders
SFW142A000
First version
Loaders
SFW147A000
First version
Loaders
SFW152A000
First version
Loaders
SFW154A000
First version
Kernels
SFW146A000
First version
SFW146B300
Solved the bug in SystemMemoryWrite function on PCB111 mass memory module management.
Changed the hexadecimal data entry, it's not longer used the [FUN] key but now it' managed the
double function for the keys from [0] to [5]. The [FUN] key is used to input the "-" character in the
binary enhanced data entry.
Managed two new data entry types: 5: Binary, are accepted only 0 and 1. 6: Binary enhanced, range
from 0 to F and '-'.
Kernels
SFW149A000
First version
SFW149B500
Solved the bug in ArrayBitCount, ArrayBitSet and ArrayBitStatus functions. They don't work properly if
the given array was long 32 bytes.
SFW149B510
Solved the bug in SystemMemoryWrite function on PCB111 mass memory module management.
Changed the hexadecimal data entry, it's not longer used the [FUN] key but now it' managed the
double function for the keys from [0] to [5]. The [FUN] key is used to input the "-" character in the
binary enhanced data entry.
Managed two new data entry types: 5: Binary, are accepted only 0 and 1. 6: Binary enhanced, range
from 0 to F and '-'.
Kernels
SFW153A000
First version
P4
4 Identificazione prodotto
Product identification
2 10
1 9 LBL052B000
Code: MPS022***0
P4 - 12C BUS EXT.
Serial nr.: 000437
Pin Signal
1
2
+5VCC
+5VCC
MPS022 * * * 0
3 SUPPLY-R
4 SUPPLY-R Livello scheda 0 = Without keyboard/display
5 RDYOU-N
6 GND Board release 1 = With keyboard/display
7 SCLK
6 = Relais
8 GND
9 SDATA 9 = Static
10 GND
=
Cavo schermato
+ ~ Shielded cable LED segnalazione stato
~/=
~
STATO CPU RUN RDY
_ ~ VOUT 1 Status LED CPU STATE (GIALLO - YELLOW) (VERDE - GREEN)
MNL104B100
ON
0 - 2.5V RUN
Vmax= 30VDC OFF
COM ON
RUN/TEST
OFF
0 - 2.5V ELECTRONIC SYSTEMS
Massima tensione modulo relè: 150VDC/270VAC ON
Massima tensione modulo statico: 60VDC/60VAC STOP/TEST
VOUT 0 OFF
Relay module maximum voltage: 150VDC/270VAC Via G. Brodolini, 15 (Z.I.) 15033 CASALE M.TO (AL) ITALY
AVARIA INDETERMINATO INDETERMINATO Phone +39-0142-451987 Fax +39-0142-451988
Static module maximum voltage: 60VDC/60VAC FAILURE INDETERMINATE INDETERMINATE Internet: http://www.elsist.net; email: elsist@elsist.net
Alimentazione (Fig. 8) Uscite analogiche (Fig. 7) Compatibilità elettromagnetica Technical specifications Procedura di avviamento
NetLog è conforme alla direttiva compatibilità Start
NETLOG può essere alimentato con una tensione continua Le uscite analogiche disponibili sono 2 riferite verso un solo Power supply requirements MPS022**00 (10-30Vdc, 4.5W) Starting procedure
compresa nell’intervallo 10-30V; la presenza della tensione sui comune presente sul pin 2 del connettore P11. elettromagnetica in riferimento alle norme CEI EN 50081-1 (EMC: Power supplied to the Ext. Bus 5Vdc 1A
morsetti 1 (+) e 2 (-) del connettore P12, è segnalata dal LED La tensione in uscita è compresa tra 0 e +2,5V, la norma generica sull’emissione riguardante ambienti residenziali,
CPU
verde contrassegnato dalla scritta “POWER ON LED”. risoluzione di ogni singola uscita è di 12bit. commerciali e dell’industria leggera) e CEI EN 50082-2 (EMC: Microprocessor Analog Device ADuC812 (MCS51
norma generica sull’immunità riguardante gli ambienti industriali). Family)
ATTENZIONE! Il collegamento delle uscite deve essere
Collegamento di terra effettuato utilizzando cavi schermati.
2
IC TM
è un marchio registrato di Philips Semiconductors. Flash memory 128 KBytes Collegare alimentazione
(+, -, PE fig.8)
Ram memory 32 KBytes non volatile
Il dispositivo deve essere collegato direttamente a terra Connect power supply
Data Retension Min. 10 years @ 25°C
mediante l'apposito morsetto del connettore di alimentazione P12 Bus di estensione (Fig. 9) Real Time Clock Calendar Yes (+, -, PE fig.8)
(Vedi Fig. 8). Il collegamento deve essere eseguito mediante una Il bus di comunicazione con i moduli di estensione sfrutta Optional
KEYBOARD/DISPLAY
cordina con sezione di almeno 1,5 mmq, ad una barra l’interfaccia I2CTM ed è disponibile su connettore IDC 10 poli (P4). I Display LCD STN Alphanumeric 2x16 characters
equipotenziale di rame di adeguata sezione. moduli di estensione devono essere collegati in cascata tramite gli with fixed backlight
Al fine di garantire una buona rejezione ai disturbi, è appositi cavetti CBL045**00 (da ordinare separatamente). Keyboard 6 keys with tactile feedback
necessario che questo collegamento sia mantenuto il più corto L'indirizzamento dei moduli di estensione avviene in modo
Led POWER ON acceso?
INTERFACE No (fig.8)
possibile e non venga fatto passare con altri cavi. automatico: il software riconosce se un modulo di estensione è RS232 (Port “A & B”) Is POWER ON led light?
collegato alla unità base e gli assegna l’indirizzo di quello • Baud rate 300 - 115200 Baud (fig.8)
Ingressi logici (Fig. 3) precedente +1. Il modulo base ha indirizzo 00Hex. • Galvanic insulation None
Gli ingressi logici disponibili sono 12, tutti optoisolati e • Maximum cable length 15mt Yes
attivabili mediante una tensione continua di 10-30Vdc. E' previsto ATTENZIONE! Prima di collegare al modulo base i moduli di Field Bus (optional) RS485
• Maximum speed 115.2 Kbps
un comune per tutti gli ingressi (pin 1 connettore P6); lo stato di estensione, accertarsi che questo non sia alimentato. In caso
• Maximum cable length 1200m - 4000ft
contrario i dispositivi potrebbero essere irrimediabilmente Verificare tensione Led RUN lampeggiante?
ogni ingresso è visualizzato tramite LED (Vedi Fig. 3). La tensione • Galvanic insulation Yes No
di alimentazione. (fig.5)
di attivazione degli ingressi deve essere continua e filtrata. danneggiati. Verify power supply Is flashing RUN Led ?
I/Os voltage. (fig.5)
Ingressi analogici (Fig. 3) Porte seriali (Fig. 1) Logic inputs 12 with one common
Gli ingressi analogici disponibili sono 4, la tensione NETLOG dispone di due porte seriali di tipo “DTE” (Data • Voltage range 10 - 30Vdc Yes
Terminal Equipment). Il collegamento con altri dispositivi dello • Input current 5mA @ 24Vdc
applicabile è compresa nell’intervallo tra 0 e +10V riferita verso il
Analog inputs 4 with one common
comune presente sul pin 9 del connettore P7. La risoluzione del stesso tipo, quali personal computer o terminali operatore in • Input voltage range 0 - 10 Volt Programma già in Led RDY acceso?
convertitore è di 12bit. L’impedenza di ingresso è di 47Kohm. genere, deve essere eseguito con un cavo di tipo Null-Modem • Input impedance 43Kohm esecuzione. Yes (fig.5)
ATTENZIONE! Il collegamento degli ingressi deve essere della lunghezza massima di 15 mt, come prescritto dalle specifiche • Resolution 12 bit Program already in Is RDY led light?
execution.
EIA RS232C. Per la programmazione di NETLOG deve essere Logic outputs 8 with one common, static or relais (fig.5)
effettuato utilizzando cavi schermati. • Maximum voltage (static) 60Vac/dc
usata la porta “B”.
• Maximum current (static) 350mA No
Uscite logiche (Fig. 6) Entrambe le porte: A e B, non sono galvanicamente isolate, • Maximum voltage (relay) 250Vac, 110Vdc
Sono disponibili 8 uscite logiche, a relè oppure statiche. Le quindi è opportuno verificare, prima di collegare tra di loro • Maximum current (relay) 5A
uscite statiche possono comandare carichi sia in c.a. che in c.c.. dispositivi diversi, che il potenziale di massa di questi ultimi sia lo • Max. switching power (relay) 750 VA 90W Collegare linea seriale
stesso. • UL/CSA rating (relay) 3A @ 250Vac; 3A @30Vdc e trasferire il programma.
Le uscite sono galvanicamente isolate dal sistema. È previsto un • Electrical life @ 20cpm
4
5x10 Operat. @ 5A 250Vac, 3A 30Vdc Connect serial line and
comune per tutte le uscite (pin 1 connettore P5); lo stato di ogni ATTENZIONE!: Differenze di potenziale eccessive tra punti di (relay) 2x107 Operations minimum transfer the program.
uscita è visualizzato tramite LED (Vedi Fig. 6). massa diversi, possono causare danneggiamenti irreversibili • Mechanical life (relay)
Le uscite vengono forzate a “0” all'accensione del sistema, Analog outputs 2 with one common
ai dispositivi.
• Output voltage range 0-2.5 Volt
e comunque ogni qualvolta lo stato del LED "RDY" è “0”. • Resolution 12 bit
ATTENZIONE! Usare sempre i soppressori in parallelo ai Bus di campo - opzionale (Fig. 2) Absolute wire size 0,13 - 1,5 mm 2
Il ponticello LK3 in posizione 0-2 consente di inserire la Mandare in esecuzione
• UL 22 - 14 AWG
carichi induttivi, la mancata osservanza di questa il programma.
resistenza di terminazione di 120 ohm prevista per le reti RS485; • DIN 46 228/1 0,5 - 1,5 mm
2
prescrizione può produrre alterazioni funzionali e ridurre la Run program.
l’assenza del ponticello esclude la terminazione. La posizione 0-1 Case Standard DIN 43880 9M
vita dei relè interni dell’apparecchio. • Dimensions 90x160x58 mm
non è consentita.
Weight 0,4 Kg
Operating temperure 0 to +60 °C
Relative humidity Max. 90%
anomalies and reduce the internal relays expected life. the termination is excluded. Never use 0-1 position, this position
Power supply (Fig. 8) may be used only if present the CAN Bus interface.
NETLOG can be powered with DC voltage at range 10-30V. Analog output (Fig. 7)
The presence of the power supply is signalized by the green LED The module is equipped with 2 analog outputs; output Electromagnetic Compatibility
marked “POWER ON LED”. voltage range is 0-2.5V. The analog outputs common is available NetLog is conforming to the EMC directive in reference to
on P11-2 connector. the norms CEI EN 50081-1 (EMC: Generic norm on the issue Modalità di collegamento Full-Duplex
Ground connection regarding residential environments, commercial and of the light IMPORTANTE! NETMASTER Full-Duplex configuration NETMASTER
The device must be connected directly to GND by means of WARNING! The analog output connection must be executed industry) and CEI EN 50082-2 (EMC: Generic norm on immunity Le reti RS485 devono essere SCH
the specific terminal of power connector P12 (See Fig. 1). The using shielded cables. regarding the industrial environments). realizzate utilizzando cavi Bianco Bianco
1 Tx+ 1 3 Rx+ 1
connection must be performed through a wire with section at least 2
IC
TM
is a trade mark of Philips Semiconductors. schermati e twistati. In caso LK1
0
Nero Nero
0
LK1
2 2
of 1.5 sq. mm to a copper equipotential bar of adeguate section. contrario la comunicazione Tx- 2 4 Rx-
To guarantee a good noise rejection, keep this connection
Extension bus (Fig. 9) 1
Rosso Rosso
1
The communication bus with the extension modules potrebbe essere compromessa. LK2
0
2 Rx+ 3 1 Tx+ 0
2 LK2
as short as possible an take care to place it fa away to the other
overworks the I2C™ interface and it’s available on IDC 10 1
Rx- 4
Giallo Giallo
2 Tx- 1
cables. IMPORTANT! 0 0
connector (P4). The extension modules must be connected LK3 2 2 LK3
through the the special cables CLB045**00 (to be ordered The RS485 nets must be created 5 5
Logic inputs (Fig. 3)
separately). using shelded and twisted cable. Lunghezza massima cavo: 1200mt
The module is equipped with 12 logic optoisolated inputs.
The addressing of extension modules is automatic: the The communication is not Cable maximum length: 4000 feet
These inputs can be activated by means of a DC source in the
range 10-30V. A unique common is provided for all 12 inputs (pin software recognise if an extension module is connected or not and guaranteed in other cases.
1 of connector P6). The state of each input is shown by a LED assign it an address equal to the previous module address +1. The
(See Fig. 3). The voltage applied at inputs must be filtered. base module has address 00Hex.
WARNING! Before to connect the extension modules to the NETMASTER Modalità di collegamento Half-Duplex multipunto NETMASTER
Analog inputs (Fig. 3) NETLOG Half-Duplex multidrop configuration NETLOG
base module, be sure that it’s unpowered. Missing this rule
The module is equipped with 4 analog inputs, the voltage may produce failures in the modules. SCH
applicable included in range 0-10V, common mode referred to the Bianco Bianco
1 Tx+ 1 1 Tx+ 1
common on pin 9 of connector P7. The converter resolution is 0 0
LK1 Nero Nero LK1
12bit, the input impedance is 47Kohm. Serial Ports (Fig. 1) 2
Tx- 2 2 Tx- 2
1 1
WARNING! The analog input connection must be executed NETLOG is provided of two serial ports DTE (Data Terminal 0 0
Equipment). The connection between DTEs, such as Personal LK2 2 Rx+ 3 3 Rx+ 2 LK2
using shielded cables.
Computers, Operator Terminals etc., must be done through a 1
0 Rx- 4 4 Rx- 1
0
Null-modem cable of maximum cable lenght of 15mt, according to LK3 2 2 LK3
Logic outputs (Fig. 6) EIA RS232C specifications. NetMaster must be programmed using 5 5
The module is equipped with 8 relays or static outputs. The serial port “A”. These ports aren’t galvanically insulated from the NETMASTER
static outpus can drive a.c. or d.c. loads indifferently. The outputs system, is recommended to verify, before to connect toghether Nero Bianco NETLOG
are galvanically isolated from the system. There is unique common different devices, the difference of potential on the ground.
connection for every 8 outputs (pin 1 of P5); The state of every
output is shown by a LED (See Fig. 6). WARNING!: An excess of difference of potential on ground 1 Tx+ 1
The calbe maximum length between the
All outputs are reseted at each system power on, and
0
LK1 first one and the last of the devices does
loop may cause damages to the devices. 2 Tx- 2
however every time the state of the "RDY" LED is 0. La lunghezza massima del cavo tra il primo e l’ultimo not exceed 4000 feet.
1
dei dispositivi non deve superare i 1200 mt. 3 Rx+ 0
LK2
The termination resistor must be enabled
2
Field bus (Fig. 2) La resistenza di terminazione deve essere abilitata solo on to the first one and the last device only:
WARNING! Interference suppressors must be connected in The Jumper LK3 allow to connect the termination resistor sul primo e l’ultimo dei dispositivi: LK3 pos. 0-2 4 Rx- 1
0 LK3 pos. 0-2.
parallel to inductive loads, according to manufacturer 2 LK3
needed for these networks. The positions 0-2 of the jumper allows La resistenza di terminazione di tutti i dispositivi inter- Termination resistor of all middle devices
suggestions. Missing this rule may produce functional 5
to insert the termination resistor on RS485; If jumper is removed medi deve essere disabilitata: LK3 non presente. must be disabled: LK3 Off.
1 Porta seriale e bus estensione I2C 2 Interfaccia Smart-Card 3 Circuito di alimentazione 4 Inseritore Smart Card (opzionale)
2
Serial port and I C extension bus Smart-Card interface P4 - SMART CARD EXT. Power supply circuit Smart Card reader (optional)
Pin Signal
ATTENZIONE! Max. 30Vdc/20Vac
1 Switch (+5REG) Codice scheda: PCB105**00
WARNING! Max. 30Vdc/20Vac
RS232 LINE OUT EXT. MODULE 2 Switch (P0.4) Board code: PCB105**00
9 1 FUSE 1A T
=/~
Contatti Smart Card:
3 C8 - NC +/~ ~ lato inferiore
P4 Smart Card pad:
LK2 10 2 4 C4 - LED (+) POWER ON LED
bottom side
2 10 /~ ~
5 C7 - SDA (RD-N)
P2 P3
1 9 OUT EXT. MODULE 6 C3 - CLK (WR-N)
7 C6 - NC P1 1 3
POWER RUN RDY
8 C2 - RST (P2.5) POWER EARTH
1 3 5 7
2 4 6 8 9 C5 - GND ~ ~
10-20VAC PE
10 C1 - VCC OUT0 OUT1 OUT2 OUT3
10-30VDC
- t (thickness with connector inserted) = 20mm 8 C2 - RST
7 CTS (PSEN) 9 SDATA (P1.7)
- 9 C5 - GND
8 RTS (INT1) 10 GND
10 C1 - VCC
P6 1 8
Si raccomanda l'uso di cavi ELSIST.
The use of ELSIST cables is recommended. Led di segnalazione stato
State signalling led COM-L
CBL054*000 DB9F/RJ45 Null-Modem Adapter
CBL055**00 DB9M/RJ45 Modem Adapter L 0 1 2 3 4 5
CBL057*300 RJ45 8/8 Unshielded Cable (2m) COM LOGIC INPUT
6 Logic Inputs
CBL045*200 NETSYST I2C Extens. Cable (20cm) 10-30VDC
CBL045*300 NETSYST I2C Extens. Cable (50cm)
Logic inputs (Fig. 5) WARNING!: An excess of difference of potential on ground loop may cause damages
to the devices. Port P1 0-5 Port P2 0-3
The module is equipped with 6 logic optoisolated inputs. These inputs can be activated by
means of a DC source in the range 10-30V. The voltage applied at inputs must be filtered. A unique Tx
common is provided for all 6 inputs (pin 1 of connector P6). Inputs INP04-05 are Fast type, able to TxD X1-X2 OSCILLATOR
acquire signals at frequencies up to 50KHz. The state of each input is shown by a LED (See Fig. 5). Smart-Card interface Rx
To P4 connector may be connected, optionally, a smart-card reader our code PCB105**00 or,
RS232 RxD
Logic outputs (Fig. 7) P2 SERIAL LINE DTR uP
one of the following AMPHENOL codes: INT1
The module is equipped with 4 relays or static outputs with one common (See the table on side C702 10M008 7012, C702 10M008 7002, C702 10M008 5142,
for characteristics). Outputs are galvanically isolated from the system and the state of each one is
CTS RESET RESET
In case of use of PCB105*000, the connection must be done using the special cable, suitable for PSEN
displayed through a LED. All outputs are reset at each system power on, and however every time the extension modules also, CBL045*000.
state of the "RDY" LED is 0. INT0 PWDown
The static output module is provided of two extrarapid fuses to protect the device against shorts. LK2
Electromagnetic Compatibility
F1 protects OUT00-01, F2 protects OUT02-03. Static outputs may be used on DC or AC loads. WR RD P1.6 P1.7
The device meets the EMC directive in reference to the standards CEI EN 50081-1 (generic
standard on the issue regarding residential environments, commercial and of the light industry) and CEI
EN 50082-2 (generic standard on immunity regarding the industrial environments).
WARNING! Interference suppressors must be connected in parallel to inductive loads, SCL1 SDA1 SCL SDA
according to manufacturer suggestions. Missing this rule may produce functional
anomalies and reduce the relays expected life. 2 TM
IC is a trade mark of Philips Semiconductors
5 RXD0
4
6
5 B RS485 Settings P9 P6 P7
8
7
Jumper Status 1 2 3 4 5 1 6 1 6
6 TXD0 Pin RS485
7 CTS0 P9 1 9 1
LK1 Full duplex 1 TX+ P14 P14
8 RTS0 2 TX- LK55 LK59 LK55 LK59
1 2 Half duplex
Si raccomanda l'uso di cavi Null-Modem ELSIST, codice: CBL054*000+CBL057**00 1 LK1 2 1 LK2 2 1 LK3 2 3 RX+ COM-L
The use of ELSIST Null-modem cables is recommended, code: CBL054*000+CBL057**00
LK2 Receiver always ready 4 RX-
ATTENZIONE! La porta B è condivisa con il bus RS485 ove presente
1
Receiver ready if DTR Off FIELD BUS 5 GND
WARNING! Port B is shared with RS485 bus if exist 1 2
4 Analog input
12 Digital Input 0 - 10V, 16bit 2 RTD
10-30VDC
I1 +
5 Bus di estensione I0 +
Extension bus Cavo schermato
Shielded cable
Analog inputs configuration
IN EXT. MODULE OUT 62R 62R Jumper ON OFF
6 Identificazione prodotto 1 6
Product identification LK55 Ch0 0-10Vdc Ch0 0-1.25Vdc
P14 LK56 Ch1 0-10Vdc Ch1 0-1.25Vdc
LK55 LK59
P4 - I2C BUS EXT. 2 10 LK57 Ch2 0-10Vdc Ch2 0-1.25Vdc
Pin Signal LK24 LBL052B000
LK58 Ch3 0-10Vdc Ch3 0-1.25Vdc
1 9
LK59 P14-6=GND P14-6=SHUNT
1 +5VCC P4 Code: MPS029A000
Serial nr.: 00004 2*0-20mA
2 +5VCC 2*4-20mA
5 Bus di estensione I0 +
Extension bus Cavo schermato
Shielded cable
Analog inputs configuration
IN EXT. MODULE OUT 62R 62R Jumper ON OFF
6 Identificazione prodotto 1 6
LK17 LK41 LK42 Product identification LK55 Ch0 0-10Vdc Ch0 0-1.25Vdc
2 10 P14 LK56 Ch1 0-10Vdc Ch1 0-1.25Vdc
1 2
LK36 LK10 P13 LK24 LK55 LK59
1 9
LK57 Ch2 0-10Vdc Ch2 0-1.25Vdc
P4 LK58 Ch3 0-10Vdc Ch3 0-1.25Vdc
LBL052B000
LK36 LK10 LK17 1-Wire STATUS P13 - 1-Wire Interface LK59 P14-6=GND P14-6=SHUNT
Pin Signal Code: MPS033A002 2*0-20mA
ON ON ON 1-Wire DISABLED Serial nr.: 00024 2*4-20mA
1 DATA (OWIO)
OFF OFF OFF 1-Wire ENABLED 2 GND (OWRTN)
MPS031 * * * * (SNAP Version)
P4 - I2C BUS EXT. MPS033 * * * * (TStik Version)
Pin Signal
LK41 LK42 I/Os Management Livello scheda 1 = RS485
1 +5VCC
Network I/O only,
ON ON
No Field I/O programming 2 +5VCC Board release 2 = CAN
OFF OFF Field I/O programming 3 SUPPLY-R Relè = 0 0 = Without keyboard/display
PLC like through Remoter
4 SUPPLY-R
Static = 3 1 = With keyboard/display
5 RDYOU-N
LK24 Field I/F programming 6 GND
7 SCLK
ON ENABLED
8 GND
OFF DISABLED 9 SDATA
8 Uscite analogiche 9 Uscite logiche 10 Segnalazione anomalie
10 GND Analog outputs Logic outputs Signalling anomalies
RUN LED (Yellow)
OUTPUT COM RDY LED (Green)
COM ANALOG OUTPUT 0 1 2 3 4 5 6 7
0 1 PE
7 Circuito di alimentazione OUT0 OUT1 OUT2 OUT3 OUT4 OUT5 OUT6 OUT7 COM
10-30VDC
- +
Power supply circuit
9 1 P5
4 1 P11
10-30VDC PE
P11 OUT0 OUT7 P12
- + OUT0 OUT7
POWER 0N LED (Green) Cavo schermato Led di segnalazione stato STATO FIELD CPU RUN RDY
Shielded cable
State signalling led
~/= FIELD CPU STATE (GIALLO - YELLOW) (VERDE - GREEN)
MNL094E100
ON
P12 3 1 RUN
VOUT 1 OFF
OUT0
FUSE 1A T 0 - 10V (PWM) ON
POWER EARTH RUN/WARN
COM
+
= ~
COM Massima tensione modulo relè: 150VDC/270VAC
OFF
STOP
ON
ELECTRONIC SYSTEMS
_
~ ~ 0 - 10V (DAC) Massima tensione modulo statico: 60VDC/60VAC
Relay module maximum voltage: 150VDC/270VAC
OFF
AVARIA
FAILURE
INDETERMINATO
INDETERMINATE
INDETERMINATO
INDETERMINATE
Via G. Brodolini, 15 (Z.I.) 15033 CASALE M.TO (AL) ITALY
VOUT 0 Phone +39-0142-451987 Fax +39-0142-451988
Vmax= 30VDC Static module maximum voltage: 60VDC/60VAC Internet: http://www.elsist.net; email: elsist@elsist.it
ATTENZIONE!: L’abilitazione del canale 1-Wire, esclude Technical specifications
Connessioni Uscite logiche (Fig. 9) l’utilizzo della porta CAN/RS485 sui codici Netmaster TStik Procedura di avviamento
Power supply requirements 10-30Vdc 5W (Base module only) Start
NETMASTER è dotato di morsetti estraibili per la connessione Il modulo base è dotato di 8 uscite logiche a relè oppure statiche, (MPS033****). Starting procedure
Power supplied to the Ext. Bus 5Vdc 300mA
dell’alimentazione, degli I/O e del bus di campo; di connettori IDC per il è previsto un comune per tutte le uscite. Per la portata commutabile
collegamento dei moduli di estensione e di connettori RJ45 per il riferirsi alla tabella caratteristiche tecniche. Lo stato di ogni uscita è CPU
collegamento delle porte RS232 e Ethernet. visualizzato tramite LED. Porte seriali RS232 (Fig. 1) Microprocessor Dallas DS80C400 (TStik version)
Imsys Cjip (SNAP version)
Le uscite vengono forzate a 0 all'accensione del sistema, e NETMASTER dispone di due porte seriali di tipo “DTE” (Data
System memory FLASH 1.5MBytes (TStik version)
Alimentazione (Fig. 7) comunque ogni qualvolta lo stato del LED "RDY" è 0 (Fig. 10). Terminal Equipment). Il collegamento con altri dispositivi DTE, quali FLASH 2MBytes (SNAP version) Collegare alimentazione
NETMASTER può essere alimentato con una tensione continua La versione statica monta 4 fusibili di protezione extrarapidi (1 personal computer o terminali operatore in genere, deve essere User memory SRAM 1MBytes non vol. (TStik version) (+, -, PE fig.7)
compresa nell’intervallo 10-30V. La connessione della alimentazione ogni due uscite). eseguito con un cavo di tipo Null-Modem della lunghezza massima di DRAM 8MBytes (SNAP version) Connect power supply
deve essere effettuata su P12. Le uscite sono galvanicamente isolate dal sistema. 15 mt, come prescritto dalle specifiche EIA. Per la programmazione Data Retention Tipical 10 years @ 25°C (+, -, PE fig.7)
La presenza della tensione di alimentazione è segnalata dal LED della sezione “Network Interface”, deve essere usata la porta “A”, Real Time Clock Calendar Yes
verde contrassegnato “POWER ON ”. ATTENZIONE! Usare sempre i soppressori in parallelo ai mentre la porta “B” deve essere usata per la programmazione della KEYBOARD/DISPLAY Optional
carichi induttivi, la mancata osservanza di questa Parte “Field Interface” (vedi MNL100*100). Display LCD STN Alphanumeric 2x16 characters
ATTENZIONE! Il superamento del valore massimo di prescrizione può produrre alterazioni funzionali e ridurre la Le porte RS232, non sono galvanicamente isolate dal sistema, with fixed backlight
tensione indicato può provocare il danneggiamento vita dei relè interni dell’apparecchio. quindi è opportuno verificare, prima di collegare tra di loro dispositivi Keyboard 6 keys with tactile feedback
Led POWER ON acceso?
irreversibile dell’apparato. RS232 diversi, che il loro potenziale di massa sia lo stesso. INTERFACE No (fig.7)
ATTENZIONE!: Differenze di potenziale eccessive tra punti RS232 (Port “A”) Is POWER ON led light?
Collegamento di terra (Fig. 7) Uscite analogiche (Fig. 8) di massa diversi, possono causare danneggiamenti • Baud rate 12800 - 115200 Baud (fig.7)
ll dispositivo deve essere collegato direttamente a terra Le uscite analogiche disponibili sono 2. L’uscita analogica 0 è • Galvanic insulation None
irreversibili ai dispositivi.
mediante l'apposito morsetto del connettore di alimentazione (Fig. 7). Il realizzata tramite DAC a 12bit, l’uscita analogica 1 è invece realizzata 1-Wire® Interface Shared with CAN bus (TStik version) Yes
con tecnica PWM ed ha risoluzione 16bit Always available (SNAP version)
collegamento deve essere eseguito mediante una cordina con sezione
di almeno di 1.5 mmq, ad una barra equipotenziale di rame di adeguata La tensione in uscita è compresa tra 0 e +10Vdc. Ethernet e Bus di campo (Fig. 2) • Field Bus RS485
• Maximum speed 115.2 Kbps Led RUN lampeggiante?
sezione. ATTENZIONE! Il collegamento delle uscite analogiche deve NETMASTER è dotato di una porta ethernet 10/100-BaseT a Verificare la tensione
• Maximum cable length 1200mt, 4000ft No (fig.10)
Al fine di garantire una buona rejezione ai disturbi, è necessario 100 Mbps disponibile sul connettore P8 di tipo RJ45; le connessioni, di alimentazione.
essere effettuato utilizzando cavi schermati. • Galvanic insulation Yes Verify power supply Is flashing RUN Led ?
che questo collegamento sia mantenuto il più corto possibile e non evidenziate in figura 2, sono compatibili con lo standard ethernet IEEE
802.3 100-BaseT. Per l’inserimento di NETMASTER in una rete Ethernet 100Base-T voltage. (fig.10)
venga fatto passare con altri cavi. Bus di estensione (Fig. 5) • Protocol TCP/IP
ethernet devono essere utilizzati cavi UDP Cat. 5 RJ45 ed un
Il bus di comunicazione con i moduli di estensione sfrutta concentratore (HUB), mentre, per un collegamento punto-punto, è • Maximum speed 100 Mbps Yes
Ingressi logici (Fig. 3) 2 TM
l’interfaccia I C ed è disponibile su connettore IDC 10 poli (P4). I • Maximum cable length According to Ethernet spec.
Il dispositivo è dotato di 12 ingressi logici optoisolati attivabili con sufficiente utilizzare un cavo incrociato RJ45 senza utilizzo di HUB. • Galvanic insulation Yes
moduli di estensione devono essere collegati in cascata tramite gli Il connettore P9 rende disponibile una interfaccia field bus che,
segnali compresi nel range 10-30Vdc. E’ previsto un comune per tutti Programma già in Led RDY acceso?
appositi cavetti CBL045**00 (da ordinare separatamente). in funzione del codice ordinato, può essere di tipo CAN oppure RS485.
I/Os esecuzione. Yes
gli ingressi come illustrato in Fig. 3. Gli ingressi logici possono essere Logic inputs 12 PNP/NPN with one common (fig.10)
L'indirizzamento dei moduli di estensione avviene in modo La figura 2 mostra la nomenclatura dei segnali presenti su P9 in Program already in
sia di tipo PNP che NPN. Lo stato di ogni ingresso è visualizzato • Voltage range 10 - 30Vdc Is RDY led light?
automatico: il software riconosce se un modulo di estensione è funzione del tipo di interfaccia disponibile. execution.
tramite LED. La tensione di alimentazione degli ingressi deve essere • Input current 5mA @ 24Vdc (fig.10)
collegato alla unità base e gli assegna l’indirizzo di quello precedente Il ponticello LK3 consente di inserire o meno la resistenza di
continua e filtrata, non è necessario che sia stabilizzata, ma non deve +1. Il modulo base ha indirizzo 0x20. Analog inputs 4 common mode or 2 differential
superare il valore massimo di 30Vdc. terminazione prevista per le reti CAN/RS485. • Input range 0-10 V, 0-1.25V, -200-+300°C (PT1000) No
parallel to inductive loads, according to manufacturer Null-modem cable of maximum cable lenght of 15mt, according to EIA Bianco Bianco
The presence of the power is signalled by the green LED marked contrario la comunicazione 1 Tx+ 1 3 Rx+ 1
“POWER ON ”. suggestions. Missing this rule may produce functional specifications. For the programming of the section “Network interface” 0 0
the port A must be used, to program the “Field interface” section must potrebbe essere compromessa. LK1 2 Nero Nero 2 LK1
anomalies and reduce the internal relays expected life. Tx- 2 4 Rx-
WARNING! Values greater than the maximum specified be used the port “B”. These ports aren’t galvanically insulated from the 1
0 Rosso Rosso
1
0
system, it is recommended to verify, before to connect toghether IMPORTANT! LK2 2 Rx+ 3 1 Tx+ 2 LK2
may destroy the device.
Analog output (Fig. 8) different devices, the difference of potential on the ground. The RS485 net must be created 1
0 Rx- 4
Giallo Giallo
2 Tx- 1
0
The module is equipped with 2 analog outputs. Analog out 0 is using shielded and twisted cable, LK3 2 2 LK3
Ground connection made through a 12bit DAC, the analog out 1 is made through a 16bit WARNING!: An excess of difference of potential on ground 5 5
otherwise the communication is
The device must be connected directly to Ground using the PWM. loop may cause damages to the devices.
not guaranteed. Lunghezza massima cavo: 1200mt
terminal block on the power supply connector (Fig. 7). The connection The output voltage range is 0-10Vdc. T Cable maximum length: 4000 feet
must be performed through a wire with section at least of 1.5 mm2, to a
copper equipotential bar of adeguate section. WARNING! The analog output connection must be executed Ethernet and Field bus (Fig. 2)
To guarantee a good noise rejection, keep this connection as using shielded cables. NETMASTER is provided of a 10/100-BaseT ethernet port
NETMASTER Modalità di collegamento Half-Duplex multipunto NETMASTER
short as possible and take care to place it far away to the other cables. available on connector (P8). The connections, as described in Fig. 2, Half-Duplex multidrop configuration
are compatible with the standard ethernet IEEE 802.3 100-BaseT. To NETLOG NETLOG
Digital inputs (Fig. 3) Extension bus (Fig. 5) connect one or more NETMASTER into an ethernet Local Area
SCH
The communication bus with the extension modules uses the Network must be used cables UDP Cat. 5 and an HUB, while to made Bianco Bianco
The device is equidded with 12 optoisolated digital inputs to be 1 Tx+ 1 1 Tx+ 1
I2C™ interface and it’s available on IDC 10 connector (P4). The a point to point connection its enough to use a cross cable RJ45 without 0 0
activated with signals in the range 10-30Vdc. A common for all the HUBs. LK1 2 Nero Nero 2 LK1
inputs is provided as described in Fig. 3. The inputs may be PNP or extension modules must be connected through the the special cables Tx- 2 2 Tx-
CLB045**00 (to be ordered separately). On connector P9 is available a field bus interface that, 1 1
NPN. The state of each one is displayed with LED. The voltage to depending of the ordered code, may be CAN or RS485 type. In Fig. 2 is LK2
0
Rx+ 3 3 Rx+ 0
LK2
activate the inputs must be DC and filtered and be below the maximum The addressing of extension modules is automatic: the software 2 2
recognise if an extension module is connected or not and assign it an shown the list of signals on P9 for the both types of interface. 1 1
allowed. The Jumper LK3 allows to connect or not the termination resistor 0 Rx- 4 4 Rx- 0
address equal to the previous module address +1. The base module LK3 2 2 LK3
has address 0x20. needed for these networks.
Analog Inputs (Fig. 4) 5 5
The available analog inputs are 4, with a common mode WARNING! Before to connect the extension modules to the Electromagnetic Compatibility NETMASTER
connection or 2 in differential connection. The voltage applicable is base module, be sure that it’s unpowered. Missing this rule The device meets the EMC directive in reference to the Nero Bianco NETLOG
included in the range 0-10V. The converter resolution is 16bit. The input may produce failures in the modules. standards CEI EN 50081-1 (generic standard on the issue regarding
impedance is 37.7 Kohm in 0-10Vdc mode.
residential environments, commercial and of the light industry) and CEI The maximum cable length between the
The system is able to acquire PT100 or PT1000 RTSs directly 1 Tx+ 1
with a 0.01°C of resolution and Kallendar-Van Dusen linearization, and EN 50082-2 (generic standard on immunity regarding the industrial 0 first and the last device doesn’t exceed
1-Wire® Interface (Fig. 5) environments). 2 Tx- 2 LK1
may acquire current sensors in the range 0-20 mA (external 62 Ohm NETMASTER is provided of a 1-Wire® interface that allows to La lunghezza massima del cavo tra il primo e l’ultimo 4000 feet.
1
shunt is required). connect all the devices compatible with this interface. These devices 2 TM
I C is a trade mark of Philips Semiconductors
dei dispositivi non deve superare i 1200 mt. 3 Rx+ 0
LK2
The termination resistor must be inserted
2
made for different purposes, can be reached on the Maxim/Dallas and 1-Wire® is a trade mark of Maxim/Dallas Semiconductors La resistenza di terminazione deve essere abilitata solo on to the first and on the last device only
WARNING! The analog input connection must be executed 1
Ibutton internet sites, togheter with the Java classes needed. Look at Java™ is a trade mark of Sun Microsystems sul primo e l’ultimo dei dispositivi (LK3-2). 4 Rx- 0 (LK3-2).
using shielded cables. 2 LK3
Fig. 5 to connect P13 and to enable this interface. La resistenza di terminazione di tutti i dispositivi inter- Termination resistor of all middle devices
5 must be disabled (Jumper LK3 off).
medi deve essere disabilitata: (LK3 non presente).
1 Porte seriali 2 Bus di campo CAN Bus Termination
3 Ingressi logici 4 Ingressi analogici
Serial ports Field bus Digital inputs Analog inputs
LK3 Status
DTE CONFIGURATIONS +/-10-30VDC
PT100-PT1000
124 Ohm termitated
1 2
A B
Pin Network I/F Field I/F 1
2
3 P8 Not terminated
1 NC NC 4
6
5 A Pin Signal
1 2
+ V0 + V2
7 Cavo schermato
2 DCD NC 8
1 ETH1 8 6 4 2
7 5 3 1 1 2
NOT ALLOWED Shielded cable
3 NC DTR0 + V1 + V3
1 2 ETH2 P9
4 GND GND 2 1 2 3 4 5
3 P9
3 ETH3 Pin CAN P6 P7
5 RXD1 RXD0
4
6
5 B 1 6 1 6
7 4 NC 1 GND
6 TXD1 TXD0 8 P8 1 9 1 P14 P14
5 NC 2 CANL
7 NC CTS0 CAN Bus LK55 LK59 LK55 LK59
6 ETH6 1 LK3 2 3 NC
8 NC RTS0 COM-L
7 NC 4 CANH
Si raccomanda l'uso di cavi Null-Modem ELSIST, codice: CBL054*000+CBL057**00 ETHERNET FIELD BUS 1
The use of ELSIST Null-modem cables is recommended, code: CBL054*000+CBL057**00
8 NC 5 NC
4 Analog input
0 - 10V, 16bit 2 RTD
12 Digital Input
10-30VDC
I1 +
5 Bus di estensione I0 +
Extension bus Cavo schermato
Shielded cable
Analog inputs configuration
IN EXT. MODULE OUT 62R 62R Jumper ON OFF
6 Identificazione prodotto 1 6
LK17 LK41 LK42 Product identification LK55 Ch0 0-10Vdc Ch0 0-1.25Vdc
2 10 P14 LK56 Ch1 0-10Vdc Ch1 0-1.25Vdc
1 2
LK36 LK10 P13 LK24 LK55 LK59
1 9
LK57 Ch2 0-10Vdc Ch2 0-1.25Vdc
P4 LK58 Ch3 0-10Vdc Ch3 0-1.25Vdc
LBL052B000
LK36 LK10 LK17 1-Wire STATUS P13 - 1-Wire Interface LK59 P14-6=GND P14-6=SHUNT
Pin Signal Code: MPS033A002 2*0-20mA
ON ON ON 1-Wire DISABLED Serial nr.: 00024 2*4-20mA
1 DATA (OWIO)
OFF OFF OFF 1-Wire ENABLED 2 GND (OWRTN)
MPS031 * * * * (SNAP Version)
P4 - I2C BUS EXT. MPS033 * * * * (TStik Version)
Pin Signal
LK41 LK42 I/Os Management Livello scheda 1 = RS485
1 +5VCC
Network I/O only,
ON ON
No Field I/O programming 2 +5VCC Board release 2 = CAN
OFF OFF Field I/O programming 3 SUPPLY-R Relè = 0 0 = Without keyboard/display
PLC like through Remoter
4 SUPPLY-R
Static = 3 1 = With keyboard/display
5 RDYOU-N
LK24 Field I/F programming 6 GND
7 SCLK
ON ENABLED
8 GND
OFF DISABLED 9 SDATA
8 Uscite analogiche 9 Uscite logiche 10 Segnalazione anomalie
10 GND Analog outputs Logic outputs Signalling anomalies
RUN LED (Yellow)
OUTPUT COM RDY LED (Green)
COM ANALOG OUTPUT 0 1 2 3 4 5 6 7
0 1 PE
7 Circuito di alimentazione OUT0 OUT1 OUT2 OUT3 OUT4 OUT5 OUT6 OUT7 COM
10-30VDC
- +
Power supply circuit
9 1 P5
4 1 P11
10-30VDC PE
P11 OUT0 OUT7 P12
- + OUT0 OUT7
POWER 0N LED (Green) Cavo schermato Led di segnalazione stato STATO FIELD CPU RUN RDY
Shielded cable
State signalling led
~/= FIELD CPU STATE (GIALLO - YELLOW) (VERDE - GREEN)
MNL092D100
ON
P12 3 1 RUN
VOUT 1 OFF
OUT0
FUSE 1A T 0 - 10V (PWM) ON
POWER EARTH RUN/WARN
COM
+
= ~
COM Massima tensione modulo relè: 150VDC/270VAC
OFF
STOP
ON
ELECTRONIC SYSTEMS
_
~ ~ 0 - 10V (DAC) Massima tensione modulo statico: 60VDC/60VAC
Relay module maximum voltage: 150VDC/270VAC
OFF
AVARIA
FAILURE
INDETERMINATO
INDETERMINATE
INDETERMINATO
INDETERMINATE
Via G. Brodolini, 15 (Z.I.) 15033 CASALE M.TO (AL) ITALY
VOUT 0 Phone +39-0142-451987 Fax +39-0142-451988
Vmax= 30VDC Static module maximum voltage: 60VDC/60VAC Internet: http://www.elsist.net; email: elsist@elsist.it
ATTENZIONE!: L’abilitazione del canale 1-Wire, esclude Technical specifications
Connessioni Uscite logiche (Fig. 9) l’utilizzo della porta CAN/RS485 sui codici Netmaster TStik Procedura di avviamento
Power supply requirements 10-30Vdc 5W (Base module only) Start
NETMASTER è dotato di morsetti estraibili per la connessione Il modulo base è dotato di 8 uscite logiche a relè oppure statiche, (MPS033****). Starting procedure
Power supplied to the Ext. Bus 5Vdc 300mA
dell’alimentazione, degli I/O e del bus di campo; di connettori IDC per il è previsto un comune per tutte le uscite. Per la portata commutabile
collegamento dei moduli di estensione e di connettori RJ45 per il riferirsi alla tabella caratteristiche tecniche. Lo stato di ogni uscita è CPU
collegamento delle porte RS232 e Ethernet. visualizzato tramite LED. Porte seriali RS232 (Fig. 1) Microprocessor Dallas DS80C400 (TStik version)
Imsys Cjip (SNAP version)
Le uscite vengono forzate a 0 all'accensione del sistema, e NETMASTER dispone di due porte seriali di tipo “DTE” (Data
System memory FLASH 1.5MBytes (TStik version)
Alimentazione (Fig. 7) comunque ogni qualvolta lo stato del LED "RDY" è 0 (Fig. 10). Terminal Equipment). Il collegamento con altri dispositivi DTE, quali FLASH 2MBytes (SNAP version) Collegare alimentazione
NETMASTER può essere alimentato con una tensione continua La versione statica monta 4 fusibili di protezione extrarapidi (1 personal computer o terminali operatore in genere, deve essere User memory SRAM 1MBytes non vol. (TStik version) (+, -, PE fig.7)
compresa nell’intervallo 10-30V. La connessione della alimentazione ogni due uscite). eseguito con un cavo di tipo Null-Modem della lunghezza massima di DRAM 8MBytes (SNAP version) Connect power supply
deve essere effettuata su P12. Le uscite sono galvanicamente isolate dal sistema. 15 mt, come prescritto dalle specifiche EIA. Per la programmazione Data Retention Tipical 10 years @ 25°C (+, -, PE fig.7)
La presenza della tensione di alimentazione è segnalata dal LED della sezione “Network Interface”, deve essere usata la porta “A”, Real Time Clock Calendar Yes
verde contrassegnato “POWER ON ”. ATTENZIONE! Usare sempre i soppressori in parallelo ai mentre la porta “B” deve essere usata per la programmazione della KEYBOARD/DISPLAY Optional
carichi induttivi, la mancata osservanza di questa Parte “Field Interface” (vedi MNL100*100). Display LCD STN Alphanumeric 2x16 characters
ATTENZIONE! Il superamento del valore massimo di prescrizione può produrre alterazioni funzionali e ridurre la Le porte RS232, non sono galvanicamente isolate dal sistema, with fixed backlight
tensione indicato può provocare il danneggiamento vita dei relè interni dell’apparecchio. quindi è opportuno verificare, prima di collegare tra di loro dispositivi Keyboard 6 keys with tactile feedback
Led POWER ON acceso?
irreversibile dell’apparato. RS232 diversi, che il loro potenziale di massa sia lo stesso. INTERFACE No (fig.7)
ATTENZIONE!: Differenze di potenziale eccessive tra punti RS232 (Port “A”) Is POWER ON led light?
Collegamento di terra (Fig. 7) Uscite analogiche (Fig. 8) di massa diversi, possono causare danneggiamenti • Baud rate 12800 - 115200 Baud (fig.7)
ll dispositivo deve essere collegato direttamente a terra Le uscite analogiche disponibili sono 2. L’uscita analogica 0 è • Galvanic insulation None
irreversibili ai dispositivi.
mediante l'apposito morsetto del connettore di alimentazione (Fig. 7). Il realizzata tramite DAC a 12bit, l’uscita analogica 1 è invece realizzata 1-Wire® Interface Shared with CAN bus (TStik version) Yes
con tecnica PWM ed ha risoluzione 16bit Always available (SNAP version)
collegamento deve essere eseguito mediante una cordina con sezione
di almeno di 1.5 mmq, ad una barra equipotenziale di rame di adeguata La tensione in uscita è compresa tra 0 e +10Vdc. Ethernet e Bus di campo (Fig. 2) • Field Bus CAN Bus
• Maximum speed 125 Kbps Led RUN lampeggiante?
sezione. ATTENZIONE! Il collegamento delle uscite analogiche deve NETMASTER è dotato di una porta ethernet 10/100-BaseT a Verificare la tensione
• Maximum cable length See note below No (fig.10)
Al fine di garantire una buona rejezione ai disturbi, è necessario 100 Mbps disponibile sul connettore P8 di tipo RJ45; le connessioni, di alimentazione.
essere effettuato utilizzando cavi schermati. • Galvanic insulation Yes Verify power supply Is flashing RUN Led ?
che questo collegamento sia mantenuto il più corto possibile e non evidenziate in figura 2, sono compatibili con lo standard ethernet IEEE
802.3 100-BaseT. Per l’inserimento di NETMASTER in una rete Ethernet 100Base-T voltage. (fig.10)
venga fatto passare con altri cavi. Bus di estensione (Fig. 5) • Protocol TCP/IP
ethernet devono essere utilizzati cavi UDP Cat. 5 RJ45 ed un
Il bus di comunicazione con i moduli di estensione sfrutta concentratore (HUB), mentre, per un collegamento punto-punto, è • Maximum speed 100 Mbps Yes
Ingressi logici (Fig. 3) 2 TM
l’interfaccia I C ed è disponibile su connettore IDC 10 poli (P4). I • Maximum cable length According to Ethernet spec.
Il dispositivo è dotato di 12 ingressi logici optoisolati attivabili con sufficiente utilizzare un cavo incrociato RJ45 senza utilizzo di HUB. • Galvanic insulation Yes
moduli di estensione devono essere collegati in cascata tramite gli Il connettore P9 rende disponibile una interfaccia field bus che,
segnali compresi nel range 10-30Vdc. E’ previsto un comune per tutti Programma già in Led RDY acceso?
appositi cavetti CBL045**00 (da ordinare separatamente). in funzione del codice ordinato, può essere di tipo CAN oppure RS485.
I/Os esecuzione. Yes
gli ingressi come illustrato in Fig. 3. Gli ingressi logici possono essere Logic inputs 12 PNP/NPN with one common (fig.10)
L'indirizzamento dei moduli di estensione avviene in modo La figura 2 mostra la nomenclatura dei segnali presenti su P9 in Program already in
sia di tipo PNP che NPN. Lo stato di ogni ingresso è visualizzato • Voltage range 10 - 30Vdc Is RDY led light?
automatico: il software riconosce se un modulo di estensione è funzione del tipo di interfaccia disponibile. execution.
tramite LED. La tensione di alimentazione degli ingressi deve essere • Input current 5mA @ 24Vdc (fig.10)
collegato alla unità base e gli assegna l’indirizzo di quello precedente Il ponticello LK3 consente di inserire o meno la resistenza di
continua e filtrata, non è necessario che sia stabilizzata, ma non deve +1. Il modulo base ha indirizzo 0x20. Analog inputs 4 common mode or 2 differential
superare il valore massimo di 30Vdc. terminazione prevista per le reti CAN/RS485. • Input range 0-10 V, 0-1.25V, -200-+300°C (PT1000) No
RS232 LINE OUT EXT. MODULE 2 Switch (P0.4) Board code: PCB105**00
9 1 Contatti Smart Card:
3 C8 - NC lato inferiore
P4 Smart Card pad:
LK2 10 2 4 C4 - LED (+) bottom side
2 10 5 C7 - SDA (RD-N)
P2 P3
1 9 OUT EXT. MODULE 6 C3 - CLK (WR-N)
7 C6 - NC
8 C2 - RST (P2.5)
1 3 5 7
2 4 6 8 9 C5 - GND
10 C1 - VCC
10-30VDC
- t (thickness with connector inserted) = 20mm 8 C2 - RST
7 CTS (PSEN) 9 SDATA (P1.7)
- 9 C5 - GND
8 RTS (INT1) 10 GND
10 C1 - VCC
P6 1 8
Si raccomanda l'uso di cavi ELSIST.
The use of ELSIST cables is recommended. Led di segnalazione stato
State signalling led COM-L
CBL054*000 DB9F/RJ45 Null-Modem Adapter
CBL055**00 DB9M/RJ45 Modem Adapter L 0 1 2 3 4 5
CBL057*300 RJ45 8/8 Unshielded Cable (2m) COM LOGIC INPUT
6 Logic Inputs
CBL045*200 NETSYST I2C Extens. Cable (20cm) 10-30VDC
CBL045*300 NETSYST I2C Extens. Cable (50cm)
Fuse 1 A EF
OUTPUT COM RUN RDY
F1 F2
0 1 2 3 P5
Code: PCB104A020
5 1 COM Serial nr.: 00024
RUN RDY OUT0 OUT1
OUT0 OUT1 OUT2 OUT3
STATO CPU RUN RDY
ON
RUN/TEST Module release
OFF
ON
STOP/TEST
Massima tensione modulo relè: 150VDC/270VAC Relay Out = 0 ELECTRONIC SYSTEMS
OFF Massima tensione modulo statico: 60VDC/60VAC
AVARIA Relay module maximum voltage: 150VDC/270VAC Static Out = 3 Via G. Brodolini, 15 (Z.I.) 15033 CASALE M.TO (AL) ITALY
INDETERMINATO INDETERMINATO
FAILURE INDETERMINATE INDETERMINATE Static module maximum voltage: 60VDC/60VAC Phone +39-0142-451987 Fax +39-0142-451988
Internet: http://www.elsist.net email: elsist@elsist.it
tra di loro dispositivi diversi, che il potenziale di massa di questi ultimi sia lo stesso.
Alimentazione
Il modulo estensione non richiede alimentazione esterna poichè alimentato dal bus di sistema.
ATTENZIONE!: Differenze di potenziale eccessive tra punti di massa diversi, possono
causare danni irreversibili ai dispositivi.
Technical specifications
Ingressi logici (Fig. 5) Power supply requirements 5Vdc 150mA Max from I2C bus (All Out ON, All Inp ON)
Il modulo base è dotato di 6 ingressi logici optoisolati attivabili con segnali compresi nel range Interfaccia Smart-Card (Fig. 2) CPU
10-30Vdc, la tensione deve essere filtrata. E’ previsto un comune per tutti gli ingressi. Gli ingressi 04-05 Al connettore P4 può essere connesso, opzionalmente, un lettore di smart card ns cod.
sono di tipo veloce e possono acquisire segnali con frequenza max. di 50KHz. PCB105**00 o, in alternativa i cod. AMPHENOL: Microprocessor Philips P89C664 (MCS51 Family)
Lo stato di ogni ingresso è visualizzato tramite LED. C702 10M008 7012, C702 10M008 7002, C702 10M008 5142, Fornibili con l'apposita cornice
C702 N1114 1E2. System memory FLASH EPROM 64 KBytes
Uscite logiche (Fig. 7) Nel caso di utilizzo del Cod. PCB105*000, il collegamento deve essere effettuato tramite User memory SRAM 2 KBytes
Il modulo base è dotato di 4 uscite logiche a relè o statiche, dotate di un comune. Per la portata l’apposito cavetto, utilizzabile anche per i moduli di estensione, CBL045*000. INTERFACE
commutabile riferirsi alla tabella caratteristiche tecniche. Lo stato di ogni uscita è visualizzato tramite
LED. Le uscite vengono forzate a 0 all'accensione del sistema, e comunque ogni qualvolta lo stato del Compatibilità elettromagnetica RS232
LED "RDY" è 0 (Fig. 8). Il dispositivo è conforme alla direttiva compatibilità elettromagnetica in riferimento alle norme CEI • Baud rate 12800 - 115200 Baud
Il modulo con uscite statiche dispone di fusibili extrarapidi di protezione ogni 2 Out. F1 è EN 50081-1 (norma generica sull’emissione riguardante ambienti residenziali, commerciali e
• Galvanic insulation None
destinato alla protezione di OUT00-01, F2 alla protezione di OUT02-03. Le uscite statiche sono in dell’industria leggera) e CEI EN 50082-2 (norma generica sull’immunità riguardante gli ambienti
industriali). • Maximum cable length 15mt
grado di commutare carichi sia AC che DC.
I/Os
ATTENZIONE! Usare sempre i soppressori in parallelo ai carichi induttivi, la mancata 2
IC
TM
è un marchio registrato di Philips Semiconductors
osservanza di questa prescrizione può produrre alterazioni funzionali e ridurre la vita Logic inputs 6 with one common
dei relè del dispositivo. • Voltage range 10 - 30Vdc
• Input current 5mA @ 24Vdc
Bus di estensione (Fig. 1) Logic outputs 4 with one common, static or relay
Il modulo di estensione può essere collegato a qualunque modulo base della famiglia Netsyst e/o • Maximum voltage (static) 60Vac/dc
della famiglia Picosyst ME. Non essendo previsto bus passante, può essere inserito un solo modulo di • Maximum current (static) 350mA
questo tipo per ogni base, a meno che la connessione con il modulo base non venga effettuata con un
• Maximum voltage (relay) 250Vac, 110Vdc
cavo passante. Per il collegamento del modulo di estensione devono essere utilizzati gli appositi cavetti
• Maximum current (relay) 5A
CBL045**00 (da ordinare separatamente).
• Max. switching power (relay) 750 VA 90W
ATTENZIONE! Prima di collegare al modulo base i moduli di estensione, accertarsi che • UL/CSA rating (relay) 3A @ 250Vac; 3A @30Vdc
questo non sia alimentato. In caso contrario i dispositivi potrebbero essere 4
• Electrical life @ 20cpm (relay) 5x10 Operat. @ 5A 250Vac, 3A 30Vdc
irrimediabilmente danneggiati. 7
• Mechanical life (relay) 2x10 Operations minimum
Porta seriale (Fig. 1)
2
Il modulo estensione è dotato di una porta seriale di tipo “DTE” (Data Terminal Equipment) Absolute wire size 0,13 - 1,5 mm
disponibile sul connettore P2 di tipo RJ45. Il collegamento con altri dispositivi DTE, quali personal • UL 22 - 14 AWG
computer o terminali operatore in genere, deve essere eseguito con un cavo di tipo Null-Modem della 2
• DIN 46 228/1 0,5 - 1,5 mm
lunghezza massima di 15 mt, vedi ns Cod. CBL054*000 + CBL057**00.
Se il dispositivo collegato è di tipo DCE (Data Communication Equipment), come ad esempio un Case Standard DIN 43880 6M
modem, si dovrà utilizzare un cavo Modem, o l’adattatore CBL055*000 in luogo del CBL054*000.
• Dimensions 90x106x58 mm
Il segnale CTS presente sul pin 7 di P2 non è utilizzabile come segnale di controllo flusso, esso
serve unicamente nelle fasi di caricamento del programma, rimuovendo LK2 tale operazione non è più Weight 0,20 Kg
possibile. Operating temperature 0 to +60 °C
La porta seriale non è galvanicamente isolata, quindi è opportuno verificare, prima di collegare
Relative humidity Max. 90%
9
la compatibilità con i vecchi dispositivi, in con-
ON
5 RDYOU-N 9 COM00÷03 dizioni di default, essi sono presenti.
RUN
OFF 6 GND LK4 LK4 10
- +
10 COM04÷07
ON 7 SCLK
RUN/TEST LD17 1 INP08 LD17 PLC P6 FIELD
All inputs can either PNP or NPN type with a
8 GND +
OFF
LD18 2 INP09 +/-
1 common for every four:
ON 9 SDATA - INP 00-03 > COM 00-03
STOP/TEST 2
10 GND LD19 3 INP0A LD19
INP 04-07 > COM 04-07
OFF
+
3 INP 08-0B> COM 08-0B
LD20 4 INP0B +/-
Power On Led AVARIA INDETERMINATO INDETERMINATO
FAILURE INDETERMINATE INDETERMINATE -
4 INP 0C-0F > COM 0C-0F
LD21 5 INP0C
102
LD21
+
The inputs “INP 0C÷0F” are fast; they read
5
LD22 6 INP0D +/- A signals with maximum frequency of 50KHz.
-
6 B
LD23 7 INP0E LD23 The jumpers LK4 and LK5 connect respecti-
+
LD24 8 INP0F +/-
7 A + vely the common COM 00-03 with COM 04-07
9 Uscite logiche P4 9 COM08÷0B
-
8 B
- and the common COM 08-0B with COM
Logic outputs LK5
9
0C-0F, to guarantee the compatibility with the
OUT00 1 10 COM0C÷0F + - previous Picolog devices. These jumpers, are
P6 LK5 10 factory set plugged in.
OUT01 2
OUT02 3
OUT03 4
4 Porta JTAG
COM00÷03 5 JTAG port 1 2
RESERVED USE 9 10
OUT06 8
OUT07 9
COM04÷07 10
7 OUT05
=
8 OUT06 8 Indirizzo modulo 7 Bus di estensione 6 Porte seriali
Module address Extension bus Serial ports
9 OUT07
ADD 0 ADD 1 ON= Half Duplex mode
10 LK8:
~
LK1 LK1
Solo modulo base
LK2 LK2
1 2 OFF=Full Duplex mode
5REG 5REG LK8 P2
Base module only LK3 LK3 3 4
UNRG UNRG 1
1 0 2 1 0 2 ON= TX Line terminated (120Ohm)
LK1 5 6
2 LK6:
EINT-N EIOR-N
ADD 2 ADD 3 LK6 OFF= TX Line unterminated
LK2
LK1 LK1
EIOW-N
7 8
EAB0 A RS485 3
LK3 9 10
4
LK2 LK2 EAB1 EAB2 LK5 ON= RX Line terminated (120Ohm)
1 0 2 12
LK5: MNL110A100
LK3 LK3
11
5
EAB3 EAB4 OFF= RX Line unterminated
1 0 2 1 0 2 13 14
ERDY RESERVED 8
LD1 LD2 LD3 LD4 7
ADD 4 ADD 5 15 16 6
visualizzato tramite LED. al PC è necessario un cavo null-modem, si consiglia l'utilizzo dei Timers (1) no limits
Le uscite vengono forzate a 0 all'accensione del sistema, e cavi precablati da noi forniti (codici CBL054**00+CBL057*300). La Counters (1) no limits
Alimentazione (Fig. 1) lunghezza massima del cavo prescritta dalle EIA RS232C è di Floating point operations (1) Yes
Il modulo base può essere alimentato con tensione comunque ogni qualvolta lo stato del LED "RDY" è 0 (Fig. 2).
15mt. Interface Base module: 1x RS232 Led POWER ON acceso?
continua od alternata rispettivamente nei range 10-30Vdc o 8- PICOLOG RS485 è dotato di un port seriale RS422/485 Fast module: 2 x RS232 No (fig.1)
20Vac e frequenze di 50 o 60 Hz indifferentemente. La presenza Collegamento estensioni (Fig. 7) galvanicamente isolato dal sistema. Il modulo può essere RS485 mod.:1xRS485/232 + 1xRS232 Is POWER ON led light?
dell’alimentazione è segnalata dal LED LD1 (Fig. 1). Il modulo base è dotato di un connettore IDC a 26 poli per la • Baud rate 300 ÷ 115200 Baud (fig.1)
configurato per le modalità Full-Duplex o Half-Duplex variando la • Galvanic insulation RS232C: No
connessione di un max. di 7 moduli di estensione della famiglia posizione del jumper LK8. Il dispositivo è dotato di resistenze di
ATTENZIONE! Il superamento del valore massimo di RS422/485: Yes (1600Vrms 1Min) Yes
PICOSYST. Per il collegamento dei moduli di estensione si terminazione 120 Ohm inseribili separatamente sulle linee Tx • Dataformat 7/8 bit, E/O/N parity
tensione indicato può provocare il danneggiamento consiglia l'utilizzo dei cavetti precablati da noi forniti (codici • Maximum cable length RS232C 15mt
irreversibile dell’apparato. (LK6) ed RX (LK5).
CBL024*000). RS422/485 1200 mt Verificare tensione Led RUN lampeggiante?
Logic inputs 16 (insulated in group of 4) di alimentazione. No (fig.7)
ATTENZIONE! Prima di inserire i cavi di estensione Programmazione • Polarity PNP or NPN (selectable for each
Verify power Is RUN Led flashing?
• Voltage range group)
togliere alimentazione al dispositivo. In caso La programmazione del dispositivo può avvenire supply. (fig.7)
• Input current 10 ÷ 30Vdc
Collegamento di terra contrario i dispositivi potrebbero essere unicamente tramite PC, attraverso i pacchetti di sviluppo da noi 5mA @ 12 Vdc
Il modulo base deve essere collegato direttamente a terra irrimediabilmente danneggiati. forniti. Per ulteriori informazioni al riguardo si prega di visitare il ns Logic outputs 8 (insulated in group of 4) Yes
mediante l'apposito morsetto del connettore di alimentazione (Fig. sito internet www.elsist.net. • Nominal switching capacity 3A @ 250Vac, 3A @ 30Vdc
Il raggiungimento delle caratteristiche segnate con (1) • Maximum switching power 831VA (AC), 90W (DC)
1). Il collegamento deve essere eseguito mediante una cordina Programma già in Led RDY acceso?
• Maximum switching voltage 250Vac, 30Vdc
con sezione di almeno di 1.5 mmq, ad una barra equipotenziale di Settaggi indirizzo (Fig. 8) elencate in tabella sono subordinate all’utilizzo di Remoter 8.0 o • Maximum switching current 3A
esecuzione. Yes (fig.7)
rame di adeguata sezione. Il modulo base viene fornito già settato con l'indirizzo per il superiore. • Electrical life @ 20cpm
5
2x10 Operations @ 3A 125Vac, 3A
Program already Is RDY led light?
running. (fig.7)
Al fine di garantire una buona rejezione ai disturbi, è normale funzionamento (ADD 0). In Fig. 8 è riportata la vista dei 30Vdc
• Mechanical life 1x105 Operations @ 180cpm
necessario che questo collegamento sia mantenuto il più corto ponticelli presenti sull’apparecchiatura, con evidenza del loro LED di stato (Fig. 2) No
possibile e non venga fatto passare con altri cavi. legame con l'indirizzo del modulo (ADD 0-7). In Fig. 2 è riportata la dislocazione dei led di stato presenti 2
I moduli di estensione vengono forniti settati ad indirizzo 1 Absolute wire size 0,13 ÷ 1,5 mm
sul modulo base, con un diagramma che evidenzia le condizioni di • UL 22 ÷ 14 AWG
Ingressi logici (Fig. 3) (ADD 1). Nel caso vengano usati più moduli di estensione sarà funzionamento della CPU. • DIN 46 228/1 0,5 ÷ 1,5 mm 2 Collegare linea seriale
Il modulo base è dotato di 16 ingressi logici optoisolati necessario settarne l’indirizzo in conformità con il programma e trasferire il programma.
sviluppato. Connections Connect serial line and
attivabili con segnali compresi nel range 10-30Vdc. I comuni degli Compatibilità elettromagnetica • Power supply 3 +2 pin 5,08 mm extractable TB transfer the program.
ingressi sono raggruppati a gruppi di 4 come illustrato in Fig. 3. Gli ATTENZIONE! Non utilizzare lo stesso indirizzo su PICOLOG è conforme alla direttiva compatibilità • Inputs Two 10 pin 5,08 mm extractable TB
ingressi logici possono essere configurati PNP o NPN. Al fine di elettromagnetica in riferimento alle norme CEI EN 50081-1 • Outputs 10 pin 5,08 mm extractable TB
più di un modulo. • Serial Interface RS232: RJ45/8
mantenere la compatibilità con i prodotti precedenti sono stati (norma generica sull’emissione riguardante ambienti residenziali, RS422/485: 5 pin 3,81 mm extractable
predisposti 2 ponticelli che raggruppano i comuni a gruppi di 8; commerciali e dell’industria leggera) e CEI EN 50082-2 (norma
per sfruttare il raggruppamento a 4 è necessario perciò rimuovere generica sull’immunità riguardante gli ambienti industriali). Dimensions 110 x 170 x 80 mm Mandare in esecuzione
il ponticello del banco relativo. Gli ingressi 0C-0F sono di tipo il programma.
Porte seriali (Fig 6) Weight 0,4 Kg Run program.
veloce e possono acquisire segnali con frequenza max. di 50KHz.
PICOLOG è dotato di una (versione Base) o due (versioni
Questa caratteristica rende il dispositivo idoneo, attraverso Op. temper. range -20 - +70 °C
Fast e RS485) porte seriali (Fig. 6). Picolog versione base è
l’installazione di apposite opzioni, alla acquisizione di segnali
dotato di una sola porta seriale RS232 connessa al port A, Picolog Relative humidity Max. 90%
provenienti da encoders e/o righe ottiche. Lo stato di ogni
Electromagnetic Compatibility CEI EN50081-1
CEI EN50082-2
1 OUT00 OUT06
OUT07 PORTA DI PROGRAMMAZIONE SCHEDA I/O 3 4
P4
2 OUT01 UTILIZZO RISERVATO
F1 5 6
3 OUT02
OUT00
1 2
I/O CARD PROGRAMMING PORT 7 8
1A F OUT01
4 OUT03
OUT02
3 4
RESERVED USE 10
OUT03 5 6
9
OUT04
OUT05
5 OUT04
OUT06
7 8
OUT07 9 10
OUT08
6 OUT05
OUT09
F2 OUT0A
11 12
OUT0B
7 OUT06
OUT0C
13 14
1A F
OUT0D 15 16
8 OUT0E
5 Identificazione prodotto
OUT07
MPS026*3*0
OUT0F 17 18
COUT1 +/-
9 OUT08 COUT2 -/+ 19 20
10 OUT09
COUT1 +/-
COUT2 -/+ Product identification
F3 Livello modulo
OUT08
11 OUT0A
OUT09
Module release
1A F
OUT0A
12 OUT0B OUT0B LBL052B000 Relay Out = 0
F3
13 OUT0C
Static Out = 3
F4 Code: MPS026A300 Base 1*RS232 = 0
OUT0C
14 OUT0D
Serial nr.: 00142
F4 OUT0D
OUT0E Fast 2*RS232 = 1
15 OUT0E OUT0F
1A F Fast 1*RS232 + 1*RS232/RS485 = 2
16 OUT0F
COUT1 +/-
17 P6
COUT2 -/+
18
~/=
19
OUT0C
OUT0D
OUT08
OUT09
8 Indirizzo modulo 7 Bus di estensione 6 Porte seriali
20
OUT0E
OUT0F
OUT0A
OUT0B
Module address Extension bus Serial ports
ADD 0 ADD 1 ON= Half Duplex mode
FIELD P6 PLC LK1 LK1 LK8:
Solo modulo base
LK2 LK2
1 2 OFF=Full Duplex mode
5REG 5REG LK8 P2
COUT1 +/- Base module only LK3 LK3 3 4
UNRG UNRG 1
ON= TX Line terminated (120Ohm)
COUT2 -/+ 1 0 2 1 0 2
5 6 LK6:
EINT-N EIOR-N 2
ADD 2 ADD 3 LK6 OFF= TX Line unterminated
LED OFF = CONTACT OPEN
LK1 LK1
EIOW-N
7 8
EAB0 A RS485 3
9 10
LK5 4 ON= RX Line terminated (120Ohm)
LK2 LK2 EAB1 EAB2
= LK5: MNL112B100
12
LK3 LK3
11
5
20 EAB3 EAB4 OFF= RX Line unterminated
LED ON = CONTACT CLOSED 1 0 2 1 0 2
PCB082*000
13 14
ERDY RESERVED 8
7
11 ADD 4 ADD 5 15 16 6
= 10 LK1
LK1 LK1
EDB0
18
EDB1
A RS232 4
5
3
RS232 RS485
LK2 17
2
EDB2 EDB3 1 Pin Signal Pin Signal
LK3 LK2 LK2
20
1 19
1 N.C. 1 Tx+
1 0 2 LK3 LK3 EDB4 EDB5
8
1 0 2 1 0 2 EDB6
21 22
EDB7 6
7 2 DCD 2 Tx- ELECTRONIC SYSTEMS
3 DTR (1) 3 Rx+
Adattatore IDC 20 pin ADD 6 ADD 7 GND
23 24
GND B RS232 4
5
3 4 GND 4 Rx-
Opzionale, non incluso 2
Mod. di estensione LK1 LK1 GND
25 26
GND
1
5 RX 5 EGND Via G. Brodolini, 15 (Z.I.) 15033 CASALE M.TO (AL) ITALY
20 pin IDC adapter LK2 LK2 6 TX Phone +39-0142-451987 Fax +39-0142-451988
Optional, not included Extension modules LK3 LK3 (1) LED on DTR port A
Internet: http://www.elsist.net email: elsist@elsist.it
7 N.C.
1 0 2 1 0 2 8 RTS
che sia stabilizzata, ma non deve superare il valore massimo di Technical specifications Procedura di avviamento
Connessioni 30Vdc. Porte seriali (Fig 6) Start
Il dispositivo può fornire l’alimentazione agli ingressi logici,
Power supply requirements MPS026*0*0 (10-30Vdc 8-20Vac, 1.2W Starting procedure
PICOLOG statico è dotato di connettori IDC per il PICOLOG è dotato di una (versione Base) o due (versioni Min, 4W Max) (base module alone)
collegamento degli I/O e del bus di estensione, e di morsetti come mostra la Fig. 1. Fast e RS485) porte seriali (Fig. 6). Picolog versione base è
estraibili per il collegamento dell’alimentazione. dotato di una sola porta seriale RS232 connessa al port A, Picolog Power supplied to the bus 5Vdc 1500mA
10-30Vdc 1A (unregulated)
Sul modulo base sono presenti 5 blocchi di connettori: Uscite logiche (Fig. 9) Fast e RS485 sono invece dotati di due porte seriali connesse Program memory 64K FlashEPROM
Alimentazione Il modulo base è dotato di 16 uscite logiche statiche. Per la rispettivamente, la principale al port A e la secondaria al port B. Data memory 32K (backed-up) Collegare alimentazione
Ingressi logici portata commutabile riferirsi alla tabella caratteristiche tecniche. I Picolog RS485 condivide il port A RS232 con l’interfaccia RS485, Battery life Tip. 10 years
(AC1-AC2-PE fig.1)
Uscite logiche driver di uscita sono protetti dal cortocircuito attraverso fusibili e, se questa non è connessa, il port A RS232 può essere utilizzato Connect power supply
Scansion rate (AC1-AC2-PE fig.1)
Bus di estensione extrarapidi (1 ogni 4 uscite). Lo stato di ogni uscita è visualizzato come sulle versioni Base e Fast, a patto che il ponticello LK5 sia
Internal flags (1) no limits (Flags, Bytes or Words)
Porte seriali RS232C e/o RS422/485 tramite LED. disinserito. Le porte RS232 sono configurate come DTE e dotate
Le uscite possono commutare carichi sia DC che AC e Timers (1) no limits
di connettori RJ45/8. Per realizzare la totale compatibilità di
sono galvanicamente isolate dal sistema. connessione con i Picolog precedenti sono disponibili gli Counters (1) no limits
Alimentazione (Fig. 1) Floating point operations (1) Yes
Il modulo base può essere alimentato con tensione Le uscite vengono forzate a 0 all'accensione del sistema, e adattatori cod. CBL055*000+CBL057*000 (da acquistare a parte).
comunque ogni qualvolta lo stato del LED "RDY" è 0 (Fig. 2). Interface Base module: 1x RS232 Led POWER ON acceso?
continua od alternata rispettivamente nei range 10-30Vdc o 8- Attraverso la/le porte seriali ed i ns tools di sviluppo, il Fast module: 2 x RS232 No (fig.1)
20Vac e frequenze di 50 o 60 Hz indifferentemente. La presenza dispositivo può essere programmato e testato. Per il collegamento RS485 mod.:1xRS485/232 + 1xRS232 Is POWER ON led light?
ATTENZIONE! In caso di utilizzo su carichi induttivi al PC è necessario un cavo null-modem, si consiglia l'utilizzo dei • Baud rate 300 ÷ 115200 Baud
dell’alimentazione è segnalata dal LED LD1 (Fig. 1). (fig.1)
è opportuno montare adeguati soppressori sul cavi precablati da noi forniti (codici CBL054**00+CBL057*300). La • Galvanic insulation RS232C: No
ATTENZIONE! Il superamento del valore massimo di carico stesso. lunghezza massima del cavo prescritta dalle EIA RS232C è di RS422/485: Yes (1600Vrms 1Min) Yes
• Dataformat 7/8 bit, E/O/N parity
tensione indicato può provocare il danneggiamento 15mt. • Maximum cable length RS232C 15mt
irreversibile dell’apparato. PICOLOG RS485 è dotato di una porta seriale RS422/485 RS422/485 1200 mt
Collegamento estensioni (Fig. 7) galvanicamente isolata dal sistema. Il modulo può essere Logic inputs 16 (insulated in group of 4)
Verificare tensione
No
Led RUN lampeggiante?
di alimentazione. (fig.7)
Il modulo base è dotato di un connettore IDC a 26 poli per la configurato per le modalità Full-Duplex o Half-Duplex variando la • Polarity PNP or NPN (selectable for each
Verify power Is RUN Led flashing?
Collegamento di terra connessione di un max. di 7 moduli di estensione della famiglia posizione del jumper LK8. Il dispositivo è dotato di resistenze di • Voltage range group)
supply. (fig.7)
• Input current 10 ÷ 30Vdc
Il modulo base deve essere collegato direttamente a terra PICOSYST. Per il collegamento dei moduli di estensione si terminazione 120 Ohm inseribili separatamente sulle linee Tx 5mA @ 12 Vdc
mediante l'apposito morsetto del connettore di alimentazione (Fig. consiglia l'utilizzo dei cavetti precablati da noi forniti (codici (LK6) ed RX (LK5). Logic outputs 16 (protected in group of 4) Yes
1). Il collegamento deve essere eseguito mediante una cordina CBL024**00). • Nominal switching capacity 0.4A @ 60V, (0.25A 4Out ON)
• Maximum switching voltage 60Vac/dc
con sezione di almeno di 1.5 mmq, ad una barra equipotenziale di ATTENZIONE! Prima di inserire i cavi di estensione Programmazione Programma già in Led RDY acceso?
• Maximum switching current 0.4A
rame di adeguata sezione. togliere alimentazione al dispositivo. In caso La programmazione del dispositivo può avvenire esecuzione. Yes (fig.7)
Al fine di garantire una buona rejezione ai disturbi, è Program already Is RDY led light?
contrario i dispositivi potrebbero essere unicamente tramite PC, attraverso i pacchetti di sviluppo da noi Absolute wire size 0,13 ÷ 1,5 mm
2
running.
necessario che questo collegamento sia mantenuto il più corto (fig.7)
irrimediabilmente danneggiati. forniti. Per ulteriori informazioni al riguardo si prega di visitare il ns • UL 22 ÷ 14 AWG
possibile e non venga fatto passare con altri cavi. sito internet www.elsist.net. • DIN 46 228/1 0,5 ÷ 1,5 mm 2
No
Il raggiungimento delle caratteristiche segnate con (1) Connections
Ingressi logici (Fig. 3) Settaggi indirizzo (Fig. 8) elencate in tabella sono subordinate all’utilizzo di Remoter 8.0 o • Power supply 3 +2 pin 5,08 mm extractable TB
Il modulo base è dotato di 16 ingressi logici optoisolati Il modulo base viene fornito settato con l'indirizzo per il superiore. • Inputs 1 IDC 20Poles Collegare linea seriale
• Outputs 1 IDC 20Poles e trasferire il programma.
attivabili con segnali compresi nel range 10-30Vdc. I comuni degli normale funzionamento (ADD 0). In Fig. 8 è riportata la vista dei • Serial Interface RS232: RJ45/8 Connect serial line and
ingressi sono raggruppati a gruppi di 4 come illustrato in Fig. 3. Gli ponticelli presenti sull’apparecchiatura, con evidenza del loro LED di stato (Fig. 2) RS422/485: 5 pin 3,81 mm extractable transfer the program.
ingressi logici possono essere configurati PNP o NPN. Al fine di legame con l'indirizzo del modulo (ADD 0-7). In Fig. 2 è riportata la dislocazione dei LED di stato presenti
mantenere la compatibilità con i prodotti precedenti sono stati Dimensions 110 x 170 x 80 mm
I moduli di estensione vengono forniti settati ad indirizzo 1 sul modulo base, con un diagramma che evidenzia le condizioni di
predisposti 2 ponticelli che raggruppano i comuni a gruppi di 8; (ADD 1). Nel caso vengano usati più moduli di estensione sarà funzionamento della CPU. Weight 0,4 Kg
per sfruttare il raggruppamento a 4 è necessario perciò rimuovere necessario settarne l’indirizzo in conformità con il programma
il ponticello del banco relativo. Gli ingressi 0C-0F sono di tipo Op. temper. range -20 - +70 °C
sviluppato. Compatibilità elettromagnetica Mandare in esecuzione
veloce e possono acquisire segnali con frequenza max. di 50KHz. Relative humidity Max. 90% il programma.
PICOLOG è conforme alla direttiva compatibilità Run program.
Questa caratteristica rende il dispositivo idoneo, attraverso ATTENZIONE! Non utilizzare lo stesso indirizzo su
elettromagnetica in riferimento alle norme CEI EN 50081-1 Electromagnetic Compatibility CEI EN50081-1
l’installazione di apposite opzioni, alla acquisizione di segnali più di un modulo.
(norma generica sull’emissione riguardante ambienti residenziali, CEI EN50082-2
provenienti da encoders e/o righe ottiche. Lo stato di ogni
ingresso è visualizzato tramite LED. La tensione di alimentazione commerciali e dell’industria leggera) e CEI EN 50082-2 (norma
degli ingressi deve essere continua e filtrata, non è necessario generica sull’immunità riguardante gli ambienti industriali).
INP *3 4
INP *4 5
N.B.: Le posizioni di LK2 sono invertite nel caso in cui esso sia di
colore Rosso e Grigio. INP *5 6
Beware: The positions of LK2 are reversed in the case in which it is of
INP *6 7
Red and Grey color. 13
INP *7 8
P4
COM 0 INP *8 9
INP *B
Settaggi indirizzo INP *A 10
8 Addresses setting INP *9
INP *8
INP *9
11
ADD 0 ADD 1 ADD 2 ADD 3 INP *7 INP *A
INP *6
LK3 LK3 LK3 LK3 12 fmax=50KHz
LK3 INP *5 INP *B
LK2 LK2 LK2 LK2 INP *4
LK2
LK1 LK1 LK1 LK1
1 INP *3 COM 0 13
INP *2 - +
LK1 INP *1
INP *0
ADD 4 ADD 5 ADD 6
LK3 LK3 LK3
LK2 LK2 LK2
LK1 LK1 LK1
Le uscite vengono forzate a 0 all'accensione del sistema, • La resistenza di terminazione deve essere collegata solo sul Logic inputs 12
• Voltage range
LBL052B000
e comunque ogni qualvolta lo stato del LED "RDY" è 0. primo e l’ultimo dei dispositivi. 10 ¸ 30Vdc Collegare linea seriale
Code: MPS018A300
• Input current 5mA @ 24 Vdc e trasferire il programma.
Connect serial line and
Bus per estensioni (Fig. 8) Serial nr.: 000104 Logic Outputs 8
Indirizzo (Fig. 9)
• Maximum voltage
transfer the program.
FACELOG è dotato di un connettore transition a 26 poli per 30Vdc
la connessione di un max. di 6 moduli di estensione della famiglia
FACELOG viene fornito già settato con l'indirizzo per il MPS018 A 300 • Output current 125mA/OUT @70°C 8 OUT ON
PICOSYST. Per il collegamento dei moduli di estensione si
normale funzionamento (Add 0).
Nel caso in cui il dispositivo venga abbinato ad una
• Switching power 3.75W @ 30 Vdc
2
consiglia l'utilizzo dei cavetti precablati da noi forniti (codici configurazione dove siano presenti più moduli di estensione, è Uso interno Absolute wire size 0,13 ¸ 1 mm
CBL024**00). opportuno considerare che l’indirizzo “7” è impegnato • UL 22 ¸ 16 AWG Mandare in esecuzione
internamente, quindi eventuali estensioni con tale indirizzo
Livello
• DIN 46 228/1 0,5 ¸1 mm
2 il programma.
Run program.
devono essere eliminate. Ne consegue che i moduli di I/O Codice MPS Connections
• Power supply 3 pin 5,08mm extractable
• Inputs 13 pin 3.81mm extractable
• Outputs 9 pin 3.81mm extractable
• Serial Interface RS232C: Delta 9 pin male
RS422/485: 5 pin 5,08 mm extractable
Dimensions MPS018*300 137x88x76 mm Dispositivo Seriale
Power supply (Fig. 3) Serial Line (Fig. 1) Signalings and anomalies (Fig. 2) MPS019*300 137x88x84 mm PICOLOG
FACELOG could be powered with 12 or 24V continuous The Fig. 2 shows leds position and diagram witch display FACELOG
FACELOG RS232 is endowed with a "D" 9 poles socket Weight 0,5Kg
Serial Device Linea seriale RS232
RS232 Serial line
tension, or with 9 or 18V alternate tension; tolerances tensions is RS232C serial port (Fig. 1). all CPU statements. max. 15 mt
AC1
+/-10% and frequency range is 50-60 Hz. By this port it is possible the connection to the PC (to The DTR led present in the RS485 version, show if the Enviromental protection IP 65 (front) AC2
PE
transfer programs and/or debug) or to any RS232C devices. transmission is active. Operating temperature 0 ¸ 60°C
Ground connection To connect base module to the Pc a standard Null Modem Relative umidity range Max. 90%
PICOFACE must be connected directly to GND by means cable is required (our codes CBL025** 00). EMC
RS232 Line RS232 Line
of the specific clamp of feeding connector (Fig. 3). The The maximum length of the shelded cable prescribed by FACELOG is conforming to the EMC directive in reference
connection must be performed by means of a wire with section at EIA RS232C is of 15mt. to the norms CEI EN 50081-2 (emission generic norm regarding
least of 1.5 sq. mm, to a copper equipotential bar of adequate
section.
BEWARE! All care on using the RS232 serial port industrial environments) and CEI EN 50082-2 (immunity generic Collegamenti seriali
norm regarding the industrial environments).
must be taken refered to as examples: respect of Serial connections
BEWARE! It is necessary which FACELOG RS232 is GND connection, respect of galvanic insulation and
respect of wire passages to prevent noise troubles. Encoding product
connected to the same ground of the remote
device; possible differences of potential between Modalità di collegamento Full-Duplex CONVERFACE
FACELOG RS422/485 is endowed with RS422/485 LBL052B000 FACELOG PICOLOG
different ground points , can cause irreversible optoisolated serial port (Fig. 1). The LK2 switch allow to Full-Duplex configuration
hardware damages. configurate the communication mode: Full-Duplex or Half- R=100 ohm SCH
Code: MPS018A300 Rx+ 3 1 Tx+
Duplex. The EGND signal is insulated to the FACELOG ground.
Serial nr.: 000104
• The maximum distance between the first one and the last of Rx- 4 2 Tx-
Logical inputs (Fig. 4) the devices does not exceed 4000 feet. MPS018 A 300 Tx+ 1 3 Rx+
FACELOG is endowed with 12 logical optoisolated inputs • The termination resistor must be connected on to the first one
(DC range 12V to 24V). Input feeding tension not necessary must and the last device only. Tx- 2 4 Rx-
be stabilized, but continuous and filtered is required. Internal use R=100 ohm
EGND 5 Lunghezza massima cavo: 1200mt 5 EGND
Level Cable maximum length: 4000 feet
Logical output (Fig. 6) Addresses (Fig. 9)
The FACELOG address is predisposed for the normal MPS Code
FACELOG is endowed with 8 static logical outputs . The
maximum supplied current is 125mA. All outputs are reseted at operation (Add 0). Modalità di collegamento Half-Duplex multipunto
each system power on, or however every time the state of the Possible extension modules inserted in hardware Half-Duplex multidrop configuration
"RDY" LED is equal to 0. configuration, must not be setted with address “0” or “7” FACELOG R=120 ohm R=120 ohm PICOLOG
because internally used .
SCH SCH
Plug in bus module extensions (Fig. 8) Tx+ 1 1 Tx+
FACELOG is fitted a 26 poles transition connector to be Programming Tx- 2 2 Tx-
used to link the going-through bus of each extension module. The programming of the device can happen entirely via PC
Max number of extension supported is up to 6 unit. Rx+ 3 PICOLOG 3 Rx+
with the REMOTER (Cod.: SFW040*100) and PROFACE (Cod.:
Expecially designed cables for the bus module extension SFW047*100) sotware. For the use it is postponed to the users Rx- 4 4 Rx-
ready to be plug in thus socket (Fig. 5) are available (code handbook (Cod.: MNL041*100 and MNL045*100). 1 Tx+
EGND 5 5 EGND
CBL024** 00). FACELOG RS485, in programming phase, must be setted in 2 Tx-
Full-Duplex mode using the LK2 switch (Fig. 1). The PC must be
BEWARE! Before insert the bus module extension 3 Rx+
endowed with CONVERFACE or any RS232/RS485 converter.
cable, the base module power supply must be
4 Rx-
switched-off to prevent serious devices demage.
5 EGND
http://192.168.0.61/Destination/Ftp/Mnl115a1.pdf
Worspaces list
Application programs
Example programs
"CLIPAndSMSManager"
This example program allows to verify the operation of the FbModemMng modem management FB using
all of its functions. In the Workspace are present different projects, everyone arranged for a specific system
target. It will be necessary to define as active project the project for the target on whose will be upload. The
program allows to:
To identify the number of the calling CLIP. It's possible at the ring, before to answer, to verify the
number of the calling and to be able to decide how to operate in function of it.
To execute command on reception of SMS messages. It's possible to send to the system messages
like Set output or Reset output and the system set or reset a logic output.
To send SMS messages on events. On logic change of an input signal it's possible to send a messages
like Input is active.
To activate the data communication on call, it's possible from a central system to call the device
activating the data communication, allowing to connect SCADA systems and/or to execute the program
debug.
The Modem management is realized in C language, all the logic I/O are managed in RIL language. This
solution allows to be easily modify the program also for the users not expert in C language programming.
Below the files included in the program.
Start.ril Defines all the external and global variables, executes the call of all the functions written in
C language. The file contains also the logic I/O management.
SetSerialMode Executes the serial communication parameters.
Definitions.h Contains definitions for the C file.
ModemFcts Executes the Modem management.
Debug Manages the program debug from serial line. This can be executed only on target systems
whose have two serial lines.
ModemDebug Manages the program debug from Modem. After a phone data call it's possible to debug
the program by Modem.
Terminal Manages the operator terminal, only for target systems whose have operator terminal.
The program manages some logic I/O, below a list of the I/O managed.
I 0000 Send SMS message 0, it forces the system to O 0000 Modem OK, it blinks during the Modem
send a SMS message with the text init.
Input 0 active. O 0001 Ring, incoming call, it's on for a second
I 0001 Send SMS message 1, it forces the system to at every ring.
send a SMS message with the text O 0002 Ring from CLIP, incoming call from the
Last call number: nnn defined CLIP, it's on for a second at
I 0002 Debug input 2 every ring.
I 0003 Debug input 3 O 0003 Command from SMS, it became on on
a reception of SMS message
Set command, it became off on a
reception of SMS message
Reset command.
After to have uploaded the program on target system, join to the serial port A the Modem and switch on the
system. The other Modem must be joined to a PC in which is in execution Remoter with terminal emulation
active. Follow we report the indications on how to execute the test of the program, please follow the steps
exactly in the chronological order defined.
Step 11:
To use the data communication function, a SIM card enabled to data transmission must be used.
Please ask to your phone service provider.
2 Check the status of the LED present on the two Modems.
1 second off and 1 second on: The Modem is out of bridge, there's not the SIM card inserted or
the SIM card has a enable PIN.
5 seconds off and 1 second on: The Modem is correctly initialized.
Always on : The Modem is connected.
3 Verify the state of the output O 0000 on the target system. The output flashes during the Modem init,
after the init if all the operations is correctly executed the output is switched on. If it is not switched on,
please verify:
Check the connection between the Modem and the serial line.
Try to switch off an on the Modem.
Verify that the Modem settings are correct. If necessary join the Modem to a PC and by using the
terminal emulation:
Send to the Modem the AT&F command followed by carriage return. This command sets the
default profile.
The Modem answers OK.
4 Call the Modem connected to the target system by using a cellular phone or by using the Modem joined
to the PC sending the command ATD nnn followed by a carriage return (nnn is the number to call
inclusive of area code). Verify the set of the output O 0001 on the target system, it's switched on for 1
second at every ring. Attention! at the fifth ring the system will answer to the call.
5 Send a SMS message with the text Set command and verify the set of the output O 0003.
6 Send a SMS message with the text Reset command and verify the set of the output O 0003.
7 Send a SMS message with the text Accept nn, where nnn is the number to that the system send the
SMS messages. You could define the number of a cellular phone. Attention! To every reception of this
message will be changed the number to that the system send the SMS messages. The number must be
exactly the same with the CLIP, that it is wanted to verify (put before the number also the international
prefix, example +39).
8 Call the Modem connected to the target system by using a cellular phone or by using the Modem joined
to the PC, if the number of the SIM that makes the call is the number set to the point 7 beyond to
activate the output O 0001 will be activated also the output O 0002. Attention! at the fifth ring the
system will answer to the call.
9 Activate the input I 0000, the system sends to the phone number set to the point 7 a SMS message with
the text Input 0 active. Deactivating the input and activating it again the message will be resent.
10 Activate the input I 0001, the system sends to the phone number set to the point 7 a SMS message with
the text Last call number: nnn, where nnn is the last received CLIP.
11 Execute a call from the Modem joined to the PC, sending the command ATD nnn followed by a
carriage return (nnn is the number to call inclusive of area code). After five rings (indicated from five
flash of the output O 0001), starts the data connection. If connection succeeded on the terminal window
appears CONNECT. At this point it's possible to terminate the terminal emulation and start the debug
sequence it will be executed on the target system. Attention! until the sequence of debug remains active
remains active also the connection. Deactivating the debug after about 30 seconds will be deactivated
also the connection.
Function block
PFB042H000
B C A A A A A
PFB042I000
B C A A A A A
Disabled the Ready signal before forcing the system reset on reset diagnostic command.
Modified the management of the MODBUS command 43 Extended read memory bytes and 44
Extended write memory bytes allowing the access in writing and in reading to the FLASH memory,
to the EEPROM memory and to the mass memory modules. Now the addressing range on this
commands is:
RAM memory: From 0x000000 to 0x0FFFFF
FLASH memory : From 0x100000 to 0x1FFFFF
EEPROM memory : From 0x200000 to 0x2FFFFF
Mass memory (PCB088) module 4: From 0x400000 to 0x4FFFFF
Mass memory (PCB088) module 5: From 0x500000 to 0x5FFFFF
Mass memory (PCB088) module 6: From 0x600000 to 0x6FFFFF
Mass memory (PCB088) module 7: From 0x700000 to 0x7FFFFF
Insert the management of the MODBUS diagnose command, it allows to read the project information.
Error reset bits management modified in StatusBit they are cleared at the FB disable instead of at the
enable.
Answer to the diagnose command 02 modified, the StatusBit value is returned.
Insert the bit CmdBit.ResetCtrs for the reset of all the counters which now are not cleared on the bit of
CmdBit.Enable.
Function and data structure names modified for compatibility with new version of Remoter 8.1. Pfb042
becomes FbModbusAsciiSl, PFB042_DATASTRUCT becomes FBMODBUSASCIISLDATA.
PFB042J000
D E C C A B A
Eliminated the Pfb042 function, lost the compatibility with the previous versions whose use a numerical
addressing.
Insert the management of the MODBUS command 06 Preset Single Register.
External buffer management for frame reception and transmission, this allow to manage longer data
frames. FrameLength and FrameBuf members added in data structure.
Managed the MODBUS reception timeout bit. StatusBit.CmActive and CmActiveDelay members
added in data structure.
PFB042K000
D E C C A B A
PFB042L000
D E D C A B A
Insert the management of the MODBUS commands 47 Flat read memory variables and 48 Flat write
memory variables, to manage the access to all the memory the system can address.
Function block
PFB060A000
B C A A A A A
PFB060B000
B C A A A A A
PFB060C000
D E C C A B A
PFB060D000
D E C C A B A
Insert the management of the MODBUS commands 47 Flat read memory variables and 48 Flat write
memory variables, to manage the access to all the memory the system can address.
Used the system function ModbusCRC to calculate the CRC.
PFB060E000
D E C C A B A
Insert the management of the MODBUS command 01 Read coil status, 02 Read input status and 05
Force single coil.
Function block
PFB054A000
B C A A A A A
PFB054B000
B C A A A A A
Bug solved on displaying message not belonging to a page, after a certain time the message 0xFFFF
was shown.
Bug solved on showing number message not found, if 0xFFFF was shown -0001.
Pages scroll with the keys and , eliminatedin the Picosyst systems.
PFB054C000
B C A A A A A
Function and data structure names modified for compatibility with new version of Remoter 8.1. Pfb054
becomes FbSysTerminal, PFB054_DATASTRUCT becomes FBSYSTERMINALDATA.
PFB054D000
D E A C A B A
PFB054E000
D E A C A B A
Added the DisableAutoscroll parameter in data structure so the user program can disable the the
automaric page message scroll.
Modified the alarms and warnings management, now they are not memorized by the function, the user
program must memorize them by using a LTCH instruction to active the bit. When the display page is
left al the alarms or warnings are cleared.
In the string variables display, if the variable length is greater than the definite number of characters,
only the defined number of characters are displayed.
Function block
PFB035B000
B C A A A A A
PFB035B100
B C A A A A A
Function block
PFB076A000
- - - - - - A
Function block
PFB062A000
B C A A A A A
PFB062B000
B C A A A A A
Function block
PFB018B000
B C A A A A A
PFB018C000
B C A A A A A
Modified names of function and data structure for compatibility with new version of Remoter 8.1.
Pfb018 becomes FbEncoderOverIO, PFB018_DATASTRUCT becomes
FBENCODEROVERIODATA.
Function block
PFB057A000
B C A A A A A
PFB057B000
B C A A A A A
Modified I/O functions table to adapt it to the last system libraries version.
PFB057C000
B C A A A A A
Function block
PFB064A000
- - A - B C A
PFB064B000
- - A - B C A
Changed the management of I2C commands 0C: Analog input acquisition and 0D: Analog output
management.
PFB064C000
- - A - B C A
Function block
PFB043C000
B C A A A A A
PFB043D000
B C A A A A A
Function and data structure names modified for compatibility with new version of Remoter 8.1. Pfb043
becomes FbIOComm, PFB043_DATASTRUCT becomes FBIOCOMMDATA.
Function block
PFB044H000
B C A A A A A
PFB044I000
D E C C A B A
PFB044J000
D E C C A B A
Eliminated the Pfb044 function, lost the compatibility with the previous versions whose use a numerical
addressing.
Reduced the data structure length, now is 64 bytes.
Inserted global variable FbModbusAsciiMsVersion.
External buffer management for frame reception and transmission, this allow to manage longer data
frames. FrameLength and FrameBuf members added in data structure.
Modified timeout management, timeout error is activated if no reply has been received from the slave
system after the command is sent.
Eliminated the RxTimeout member from the data structure.
Function block
PFB069A000
E F A D C A A
PFB069A100
E G A D D A A
The library function ModbusCRC is used.
PFB069B000
E G A D D A A
Defined a new bit Command.FctSelect to select the modbus function to be used to read data from the
slave device. The function Code 03: Read holding registers or Code 04: Read input registers can
be select.
Function block
PFB053B000
B C A A A A A
PFB053C000
B C A A A A A
PFB053D000
B C A A A A A
Changed the management of initialization strings, now it considered as separator the '\r' character
instead of the ',' character.
Added in the data structure the Status.RingFlag bit. This bit was added to allow the debug, it remains
active for 1 second to every ring received
Added the CLIP reception.
Added new membrs in MODEM configuration data structure FBMODEMMNGCONFIG.
Modified the SMS messages reception, now it returns the sender number and the message body
without the header and tail.
PFB053D100
B C A A A A A
Added a 5 Sec delay after the SMS message send to avoid to send another message immediately.
PFB053D200
B C A A A A A
Function block
PFB050C000
B C A A A A A
PFB050D000
B C A A A A A
Function and data structure names modified for compatibility with new version of Remoter 8.1. Pfb050
becomes FbNetlogAD, PFB050_DATASTRUCT becomes FBNETLOGADDATA.
PFB050E000
B C A A A A A
Function block
PFB051C000
B C A A A A A
PFB051D000
B C A A A A A
Function and data structure names modified for compatibility with new version of Remoter 8.1. Pfb051
becomes FbNetlogDA, PFB051_DATASTRUCT becomes FBNETLOGDADATA.
PFB051E000
B C A A A A A
Redefined FBNETLOGDAPROTOTYPES was erroneusly defined as the A/D acquisition FB
FBNETLOGADPROTOTYPES.
Bug solved in the extension modules.management.
Function block
PFB065A000
- F A D C A A
PFB065A100
- F A D C A A
Added a control on the target system. The base module can be accessed only if the target system is
based on ADuC845 microcontroller, otherwise the module is not managed and FBParameters bit of
PLCErrors is set.
PFB065A200
- F A D C A A
PFB065A300
- F A D C A A
PFB065A600
- F A D F A A
Managed the external current generator on RTD acquisition. It can be used on hardware versions
"PCB099H***", "MPS031B***", "MPS033B***" and "MPS034B***".
Function block
PFB066A000
- F A D C A A
PFB066A100
- F A D C A A
Added a control on the target system. The base module can be accessed only if the target system is
based on ADuC845 microcontroller, otherwise the module is not managed and FBParameters bit of
PLCErrors is set.
Function block
PFB055B000
D E A C A B A
PFB055C000
D E D C A B A
PFB055C100
D E D C A B A
Eliminated bug on data input, if the [ENT] key was pressed with any data given the system locks.
PFB055D000
D E D C A B A
Changed the hexadecimal data entry, it's not longer used the [FUN] key but now it' managed the
double function for the keys from [0] to [5]. The [FUN] key is used to input the "-" character in the
binary enhanced data entry.
Managed two new data entry types: 5: Binary, are accepted only 0 and 1. 6: Binary enhanced, range
from 0 to F and '-'.
Function block
PFB056A000
B C A A A A A
PFB056B000
B C A A A A A
Function and data structure names modified for compatibility with new version of Remoter 8.1. Pfb056
becomes FbPIDMng, PFB056_DATASTRUCT becomes FBPIDMNGDATA.
Function block
PFB047G000
- C A - - - A
PFB047H000
- C A - - - A
Function and data structure names modified for compatibility with new version of Remoter 8.1. Pfb047
becomes FbPsystADSubm, PFB047_DATASTRUCT becomes FBPSYSTADSUBMDATA.
PFB047I000
- C A - - - A
Eliminated the Pfb047 function, lost the compatibility with the previous versions whose use a numerical
addressing.
Used the FbPsystAnaCpDMARead and FbPsystAnaCpDMAWrite functions, they are defined global
in the coprocessor module management FB.
Function block
PFB033F000
- C A - - - A
PFB033G000
- C A - - - A
Function and data structure names modified for compatibility with new version of Remoter 8.1. Pfb033
becomes FbPsystAnaCp, PFB033_DATASTRUCT becomes FBPSYSTANACPDATA.
PFB033H000
- C A - - - A
Eliminated the Pfb033 function, lost the compatibility with the previous versions whose use a numerical
addressing.
Changed the names of the DMARead and DMAWrite functions that become
FbPsystAnaCpDMARead and FbPsystAnaCpDMAWrite. The functions become global to be used
from the function blocks that manage the A/D and the D/A submodules.
Function block
PFB048E000
- C A - - - A
PFB048F000
- C A - - - A
Function and data structure names modified for compatibility with new version of Remoter 8.1. Pfb048
becomes FbPsystDASubm, PFB048_DATASTRUCT becomes FBPSYSTDASUBMDATA.
PFB048G000
- C A - - - A
Eliminated the Pfb048 function, lost the compatibility with the previous versions whose use a numerical
addressing.
Used the FbPsystAnaCpDMARead and FbPsystAnaCpDMAWrite functions, they are defined global
in the coprocessor module management FB.
Function blocks
PFB072A000
E F A D C A A
Function block
PFB059A000
B C A A A A A
PFB059B000
B C A A A A A
Function block
PFB061D000
D E C C A B A
PFB061D100
D E C C A B A
Function block
PFB058A000
B C A A A A A
PFB058B000
B C A A A A A
Function block
PFB063A000
- - A A - A A
PFB063B000
- - A A - A A
PFB063B100
- - A A - A A
Modified the Command.WriteData management, now it's reset at the chip card write operation end.
Modified Status.CardDataOk bit noum in Status.CardReadEnd and Status.WriteDataOk in Status.
CardWriteEnd.
Added Status.ReadDataOk, Status.ReadDataError, Status.WriteDataOk e Status.WriteDataError
bits management.
PFB063B200
- - A A - A A
Solved bug on PSC check when the Sle4432 chip card is used.
"C" functions
TermIOIsOpen
Prototype
ElSystemLib.h
Declaration
BOOL TermIOIsOpen(void);
Parameters
None
Return value
BOOL FALSE: I/O console not open
TRUE: I/O console open