Page 2
Introduction Logic Machine is your easiest way to program complex logic in KNX/EIB, Modbus, BACnet, EnOcean networks. The Logic Machine will enable you to efficiently customize building automation processes, easily delivering unlimited flexibility benefit to end users in a cost- effective way.
Page 3
Caution Security advice The installation and assembly of electrical equipment may only be performed by skilled electrician. The devices must not be used in any relation with equipment that supports, directly or indirectly, human health or life or with application that can result danger of people, animals or real value Mounting advice The devices are supplied in operational status.
Page 6
7.3. TCP) ......................128 SAGE EXAMPLE ODBUS 7.4. RTU) ......................129 SAGE EXAMPLE ODBUS 7.5........................130 ODBUS LAVE EXAMPLES 7.6. RS485 ........133 ODBUS WORKING WITH SEVERAL SLAVES ON THE SAME CONNECTION BACNETIP INTERCONNECTION WITH LM2 ..................136 ENOCEAN INTERCONNECTION WITH REACTOR ................138 7.1.
10BaseT/100BaseTX RS485 USB2.0 TPUART2 KNX/EIB compatible Digital output 16 (380 mA continues current on output). Optoislated from KNX/EIB bus. Additional 24V power source is supported. Resistive sensor inputs 6 (PT100, PT1000, 0 ...20M ) Analog/binary inputs 7 (0-30V with configurable...
Page 11
RS485 The EIA-485 differential line consists of two pins: A aka '-' aka TxD-/RxD- aka inverting pin B aka '+' aka TxD+/RxD+ aka non-inverting pin...
Standards supported Logic Machine is compatible with the following standards: • KNX/EIB TP, KNXnet/IP • Modbus TCP, Modbus RTU • BACnet IP, BACnet MS/TP (in development) • GSM (Huawei E173 and similar modem support through USB) for sending SMS notifications and controlling the installation by receiving SMS commands.
Page 19
The system is made so that each of the standards can be used with each other, so Logic Machine can act as BACnet to Enocean gateway or Modbus to GSM etc.
Quick startup guide 1) Mount the device on DIN rail 2) Connect the KNX bus cable 3) Connect 24V power supply to the device (red pole to 24V+, grey pole to GND) 4) Connect Ethernet cable coming from the PC...
Page 21
Protocol– specific protocol used for addressing specific protocol used for addressing o Static IP – static IP address. By default 192.168.0.10 static IP address. By default 192.168.0.10 o DHCP – use DHCP protocol to get IP configuration. use DHCP protocol to get IP configuration. Current IP Current IP –...
Discover Logic Machine IP address Windows PC Easiest way is by using the utility ServiceBrowser which can be downloaded here: http://marknelson.us/2011/10/25/dns-service-discovery-on-windows/ Linux PC The utility called Avahi, can be downloaded here: www.avahi.org Android The freely available app called ZeroConf Browser, can be downloaded in Play Store: https://play.google.com/store/apps/details?id=com.grokkt.android.bonjour&hl=en...
iOS/Mac OS The freely available app called Discovery, can be downloaded in App Store: https://itunes.apple.com/en/app/discovery-bonjour-browser/id305441017?mt=8 For iPad install the iPhone/iPod version of the utility. Firmware upgrade Note! Before each upgrade please backup your visualization, scripts and object in Logic Backup, as the database is cleaned during the upgrade. Machine Tools Note! After each upgrade, we strongly recommend to clean your browser cache.
5 seconds and new firmware will be installed. Logic Machine for KNX/EIB network configuration management with ETS To use Logic Machine with KNXnet/IP functionality and program other KNX bus devices, the device should be added into ETS Connection Manager.
Page 25
• Put some freely chosen Name for the connection • Chose Type = KNXnet/IP • Press Rescan button and then choose from the drop down menu found Logic Machine • Press OK • Back in Options Communication window select newly created interface as Communication Interface from the drop-down menu.
Page 26
• Make sure that bus status is Online – press button in ETS.
Parameter–KNX corresponding interface in OS of the system KNX address – KNX physical address of the device KNX IP features – Use this device with KNX IP features e.g. for KNXnet/IP network configuration Multicast interface – multicast interface to use when sending KNX telegrams to other KNX networks over TCP/IP Multicast IP –...
Page 28
Address list – list of group addresses. One address per line. Use * (e.g. 1/1/*) to filter all addresses in the given line. Note! KNX IP features should be on for filter to work...
Page 29
Address list – list of individual addresses. One address per line. Use * (e.g. 1.1.* ) to filter all addresses in the given line. Note!KNX IP features should be on for filter to work...
Page 30
Secure tunnel tab You can make a secure tunnel between two KNX networks. In comparison with standard tunnels, which use UDP protocol, this tunneling uses TCP what makes it very reliable thanks to package delivery acknowledgement. This ensures that sender always knows if the package is delivered to the recipient.
Quick guide - create visualization for iPad/PC Import objects Fastest way is to import *.ESF file from ETS in Utilities Import ESF file. Or connect LM to the bus and it will detect objects automatically in Objects tab once they are activated.
Page 32
Create “floor” structure and add objects to the map Connect to Logic Machine (Logic Machine) with default access parameters (IP: 192.168.0.10; login/password: admin/admin) Create “building/floor” structure and add objects to the map In Vis.structure menu the structure of the visualization is defined and visualization backgrounds are uploaded.
Page 33
Add objects to newly created visualization map After the building and floor structure is defined in Buildings tab, it is visualized in Visualization tab. Controlled and monitored objects can be added and managed in this section. Both side bars can be minimized by pressing on left/right arrow icon making the map more visible especially on small displays.
Page 34
When all necessary objects and cameras are added, press Save and reload floor plan button so everything starts functioning. Launching visualization on touch device (iPad in this case) • Make sure your iPad is connected wirelessly to the Logic Machine (either through separate access point or directly to Logic Machine’s USB WiFi adapter).
Page 35
o Then minimize side bar by pressing on left-arrow icon to make the map more visible.
Graphical User Interface Login KNX/EIB Logic Machine has IP address 192.168.0.10 set by default to LAN interface. Use this address as www address in the browser's address field. Note! Make sure that the PC connecting to the Logic Machine has IP set from the same subnet.
Utilities – utilities including import from ETS, reset object DB, backup, update system installation Alerts – alert messages defined with alert function Logs – log messages defined with log function Error log – error messages in KNX bus Help – documentation for scripting syntaxes...
1.1. Reactor Reactor IO configuration and mapping to KNX is done under Reactor tab. No additional software is needed to configure KNX mapping of IO ports.
1.1.1. Digital output You can set up digital output either as binary output or PWM. Binary output is usually used to control external relays/contactors. PWM output is used to control external devices like thermoelectric valves. Binary (On/Off) output Name – name of the port Link to object –...
Page 40
PWM (0-100%) output Name – name of the port Link to object – group address to link the object with. By pressing the button, the field will be automatically filled with the next free group address. Status object – status object group address. Lock object –...
1.1.2. Analog output Analog output can be used either as 1byte (0-100%) or 2byte (voltage) output. Name – name of the port Link to object – group address to link the object with. By pressing the button, the field will be automatically filled with the next free group address. Status object –...
1.1.3. Resistive input Resistive input can be either PT1000 temperature sensor, PT100 temperature sensor or show the data in raw form. Name – name of the port Link to object – group address to link the object with. By pressing the button, the field will be automatically filled with the next free group address.
1.1.4. Analog input Analog inputs can be used either as Voltage, Binary On/Off, Binary Short/Long or Step dimmer. Voltage input Name – name of the port Link to object – group address to link the object with. By pressing the button, the field will be automatically filled with the next free group address.
Page 44
Binary On/Off Name – name of the port Link to object – group address to link the object with. By pressing the button, the field will be automatically filled with the next free group address. Status object – status object group address. Lock object –...
Page 45
Binary Short/Long Name – name of the port Link to object – group address to link the object with. By pressing the button, the field will be automatically filled with the next free group address. Status object – status object group address. Lock object –...
Page 46
Step dimmer Name – name of the port Link to object – group address to link the object with. By pressing the button, the field will be automatically filled with the next free group address. Status object – status object group address. Lock object –...
1.2. Scripting Scripting menu allows adding and managing various scripts, depending on the type of the script. Lua programming language is used to implement user scripts. Most of the Lua language aspects are covered in the first edition of "Programming in Lua" which is freely available at http://lua.org/pil/ Note!Data format —...
Page 48
Active– specifies whether the script is active (green circle) or disabled (red circle) Execute on group read– specifies whether the script is executed on KNX group read telegram Category – a new or existing name of the category the script will be included. This...
Page 49
Script name – the name of the script Sleep interval (seconds) – interval after which the script will be executed. Active– specifies whether the script is active (green circle) or disabled (red circle) Category – a new or existing name of the category the script will be included. This will not affect on script action, helps only by grouping the scripts and watching by categories in Tools Print script listings page...
List of scripts There are five actions you can do with each of the script: Duplicate – Duplicate the script with its source code Editor – Enter scripting editor to write specific code for the particular program Active – Make script active (green) or deactivate it (red) Edit –...
Note! To get event value in scripts, use the following command: a = event.getvalue() 1.2.3. Resident scripting Resident scripts are executed infinite amount of times. Scripts are put into inactive state after each call and are resumed after delay timer expires. Note!even though resident scripts are executed in parallel they should not have infinite loops or it will not be possible to reload scripts after editing.
Loops and iterators – Array, Repeat..Untiletc Math – Random value, Ceiling, Absolute value, Round etc. Objects/KNX bus – Get object value, Group read, Group write, Update interval etc. Storage – Get data from storage, Save data to storage Script control – Get other script status, enable or disable other scripts Alerts and logs –...
Most functions use alias parameter — object group address or unique object name. (e.g. '1/1/1' or 'My object') grp.getvalue(alias) Returns value for the given alias or Lua when object cannot be found. grp.find(alias) Returns single object for the given alias. Object value will be decoded automatically only if the data type has been specified in the 'Objects' module.
object:read() Sends group read request to object's group address. Note: this function returns immediately and cannot be used to return the result of read request. Use event-based script instead. object:update(value, datatype) Similar to object:write, but does not send new value to the bus. Useful for objects that are used only in visualization.
Converts hex-encoded data to Lua variable based on given data type. Data type is specified either as KNX primary data type (integer between 1 and 16) or a secondary data type (integer between 1000 and 16000).Return values: • success — decoded data as Lua variable (type depends on data type), value length in bytes •...
• The following examples shows the basic syntax of storage.get. Assuming that key value was not found, first call will return while second call will return number which was specified as a default value. 1. result storage.get ('my_stored_value_3')-- returns nil if value is not found 2.
Example -- log function accepts Lua nil, boolean, number and table (up to 5 nested levels) type variables 2. a key1 , key2 ='value1' 3. b ='test' 4. c =123.45 -- logs all passed variables a, b, c log( 1.2.15. Scheduled scripting date/time format Scheduled scripting uses standard cron format for date/time parameters.
1.2.18. String functions This library provides generic functions for string manipulation, such as finding and extracting substrings, and pattern matching. When indexing a string in Lua, the first character is at position 1 (not at 0, as in C). Indices are allowed to be negative and are interpreted as indexing backwards, from the end of the string.
Page 60
"a string with \"quotes\" and \ new line" The options c, d, E, e, f, g, G, i, o, u, X, and x all expect a number as argument, whereas q and s expect a string. This function does not accept string values containing embedded zeros, except as arguments to the q option.
Page 61
string.gmatch (s, pattern) Returns an iterator function that, each time it is called, returns the next captures from pattern over string s. If pattern specifies no captures, then the whole match is produced in each call. As an example, the following loop 1.
Page 62
string.gsub("$name-$version.tar.gz" "%$(%w+)" --> x="lua-5.1.tar.gz" string.len (s) Receives a string and returns its length. The empty string "" has length 0. Embedded zeros are counted, so "a\000bc\000" has length 5. string.lower (s) Receives a string and returns a copy of this string with all uppercase letters changed to lowercase.
Page 63
• %x: (where x is any non-alphanumeric character) represents the character x. This is the standard way to escape the magic characters. Any punctuation character (even the non magic) can be preceded by a '%' when used to represent itself in a pattern. •...
(and therefore has number 1); the character matching "." is captured with number 2, and the part matching "%s*" has number 3. As a special case, the empty capture () captures the current string position (a number). For instance, if we apply the pattern "()aa()" on the string "flaaap", there will be two captures: 3 and 5.
Enable the script with the name scriptname. script.disable('scriptname') Disable the script with the name scriptname. status = script.status('scriptname') Returns true/false if script is found, nil otherwise 1.2.21. JSON library Note: json is not loaded by default, use require('json') before calling any functions from this library.
cnv.strtohex(str) Converts the given binary string to a hex-encoded string. cnv.hextostr(hexstr) Converts the given hex-encoded string to a binary string. 1.2.23. Bit operators bit.bnot (value) Binary not bit.band (x1 [, x2...]) Binary and between any number of variables bit.bor (x1 [, x2...]) Binary and between any number of variables bit.bxor (x1 [, x2...]) Binary and between any number of variables...
1.2.24. Input and Output Facilities The I/O library provides two different styles for file manipulation. The first one uses implicit file descriptors; that is, there are operations to set a default input file and a default output file, and all input/output operations are over these default files.
io.output ([file]) Similar to io.input, but operates over the default output file. 1.2.25. Mathematical functions This library is an interface to the standard C math library. It provides all its functions inside the table math. math.abs (x) Returns the absolute value of x. math.acos (x) Returns the arc cosine of x (in radians).
Page 69
The value HUGE_VAL, a value larger than or equal to any other numerical value. math.ldexp (m, e) Returns 2 , (e should be an integer). math.log (x) Returns the natural logarithm of x. math.log10 (x) Returns the base-10 logarithm of x. math.max (x, ···) Returns the maximum value among its arguments.
math.tanh (x) Returns the hyperbolic tangent of x. 1.2.26. Table manipulations This library provides generic functions for table manipulation. It provides all its functions inside the table table. Most functions in the table library assume that the table represents an array or a list.
Page 71
When called without arguments, date returns a reasonable date and time representation that depends on the host system and on the current locale (that is, os.date() is equivalent to os.date("%c")). os.difftime (t2, t1) Returns the number of seconds from time t1 to time t2. In POSIX, Windows, and some other systems, this value is exactly t2-t1.
1.2.28. Extended function library toboolean(value) Converts given value boolean using following rules: nil, boolean false, 0, empty string, '0' string are treated as false, everything else as true string.split(str, sep) Splits the given string into chunks by the given separator.Returns Lua table. knxlib.decodeia(indaddressa, indaddressb) Converts binary-encoded individual address to Lua string.
An optional argument specifies the base to interpret the numeral. The base may be any integer between 2 and 36, inclusive. In bases above 10, the letter 'A' (in either upper or lower case) represents 10, 'B' represents 11, and so forth, with 'Z' representing 35. In base 10 (the default), the number can have a decimal part, as well as an optional exponent part.
Include the library in the scripts To use functions defined in user library, they should be included in the beginning of the script, for example, user library with the name ‘test’ should be included like this: require('user.test') 1.2.30. Common functions Common functions contains library of globally used functions.
Object name – Name for the object Group address – Group address of this object Data type – KNX data type for the object. This has to be set once the LM sniffs the new object for proper work. Units / suffix – units for the object which will appear on the visualization along with the value Log –...
Export – Make object visible by remote XML requests and in BACnet network (if KNX – BACnet gateway functionality is used) Poll interval (seconds) – perform automatic object read after some time interval Tags – assign this object to some tag which can be later used in writing scripts, for example, All_lights_first_floor.
• Control type – type of the visual control element o Slider o Direct input / Step +/- • Minimum value • Maximum value 1.3.3. Change the object state In the object list, by pressing on the button, you can change the state of the object. The appearance of the New value depends on what visualization parameters are set for specific object.
1.3.5. Object control bar Add new object – Manually add new object to the list Auto update enabled –Specifies either the object list is updated automatically or not Clear – Clear the list of group addresses Next/Previous page – move to next or previous page Refresh –...
1.4. Object logs Object historical telegrams are available in Object logs. Once logging is enabled for object, all it’s further history will be logged. Filtering is available when there is a need to find specific period information Start date – start date and time for log filtering End date –...
1.4.1. Export logs Example Once an hour, make CSV file with all objects logs and send to external FTP server with IP 192.168.1.11, login ‘ftplogin‘, password ‘ftppassword‘. • In Scripting -> Scheduled add the script which will run once an hour Add the following code in Script editor for this particular script.
Page 82
-- get object logs 24. query ='SELECT src, address, datahex, logtime, eventtype FROM objectlog WHERE logtime>= ? ORDER BY id DESC' _, row db:getall query, logtime inipairs( ))do object objects row.address [tonumber( -- found matching object and event type is group write object row.eventtype =='write'then...
Page 83
then alert , err ('FTP upload failed: %s'...
Schedulers Schedulers contain administration of user mode schedulers. Schedulers allow for end user to control KNX group address values based on the date or day of the week. 1.5.1. Add new scheduler Object – the object group address which will be controlled by scheduler Active –...
1.5.2. Scheduler events Event can be added both in administrator interface as well as by end user in the special User mode schedulers interface. Active – define the event active or not Value – value to send to the group address when the event will be triggered Start time –...
Name – the name of the holiday entry Date – date of the holiday 1.6. Trend logs Trends logs are administration of user mode trends, used to see historical object graphical values, compare with other period values. 1.6.1. Add new trend log Object –...
Monthly data – average value of monthly data for specific time interval Note! One trend data point reading takes 8 bytes of flash memory. E.g. reading some value once in every 10 minutes, will consume ~0.4MB of flash each year. 1.7.
Page 88
Plan name – name for the plan Layout – layout for this specific plan. All object from Layout will be duplicated on this particular plan including background color and plan image if they are not defined separately for this specific plan Usermode visualization [Show, Show and make default, Hide] –...
You can duplicate the plan with all its objects and settings by pressing on icon. Levels can be sorted by pressing icons. 1.7.1. Layouts / Widgets Layouts are used as templates for further use when adding Levels in Levels/Plans tab. Layouts will not be visible from the Usermode/Touch visualizations.
Page 90
When you have defined the widget in Layouts/Widgets tab, you can add objects to it in Visualization tab. When you have added necessary objects to the widget, you can choose it when adding objects for main Levels e.g. Bedroom in Main level.
Once added, you can try out the widget in Usermode visualization by clicking on added object (temperature sensor icon on the left), the widget appears on click. 1.8. Visualization After the building and floor structure is defined in Vis.structure tab, it is visualized in Visualization tab.
Page 92
Object – new object to be added to the map Plan link – linking several floors with special icons Camera – IP web camera integration into visualization Graph – Real-time graph to monitor value of scale-type objects Text Label – text label to put on visualization Image –...
1.8.2. Object Main object – list of existing group addresses on KNX/EIB bus, the ones available for configuration in Objects tab Status object – list of status objects on KNX/EIB bus Custom name – Name for the object Read-only – the object is read-only, no write permission Hide in touch–...
1.8.3. Plan link In order to make visualization more convenient, there are floor links integrated. You can add icons or text on the map, which links to other floors. Plan – Linked plan name or link to Schedulers / Trends Custom name –...
Page 95
Source url – source address of the video stream Width – sub-window width for displaying of picture Height– sub-window height for displaying of picture Custom name – name for the object Icon – icon for the object Auto open window – automatically open video window Hide background–...
1.8.5. Graph Real-time graphs can be integrated into visualization system to monitor the current and old value of scale-type objects. Make sure logging is enabled for the object in Object tab which values is planned to be shown in the graph. Data object –...
Once the graph parameters are defined, press Add to plan button and newly created object will appear. You can move the object to the location it will be located. Note that while being in editing mode, the object will not work. Press on Save and reload plan button so the objects starts functioning.
1.8.8. Gauge Gauge allows visualizing and changing object value in the gauge. Data object – KNX group address Size – size of the gauge Custom name – custom name for the object...
Once the gauge parameters are defined, press Add to plan button and newly created object will appear on the map. You can move the object to the location it will be located. Press on Save and reload plan button so the objects starts functioning. 1.8.9.
1.9. Vis. graphics The list of predefined icons, list of images and backgrounds is available in Vis.graphics tab. Press on Add new icon button to add a new entry. The system accepts any size icons. GIF is also supported.
Page 101
Name (optional) – the name of the icon File – Icon file location Images/Backgrounds tab is used to upload image files for visualization purposes...
1.10. Utilities There are following utilities in the tab available: Import ESF file– imports ETS object file. It will be necessary to set correct data types for some imported objects. Existing objects will not be overwritten. Objects with the same name are considered duplicates and might not be imported Reset object/clean-up –...
Page 103
Date and time – data and time settings Install updates – install Logic Machine update file *.lmu. Logic Machine will reboot after successful update Backup – backup all objects, logs, scripts, visualization. Restore– restore configuration from backup...
Page 104
Configuration – by clicking on the arrow, KNX Connection and User Access settings can be access. By clicking on the Configuration button, system general settings appear. Interface language – interface language List items per page –count of lines per page e.g. Objects, Object logs, Alerts etc.
Warning! Excessive object logging degrades Logic Machine performance System – by clicking on the arrow near System button, KNX Connection and User Access settings can be access. By clicking on the System button, network configuration window opens in new browser’s tab.
On the communication panel you can jump by pages and reload the page. Example 1. temperature 25.3 temperature > then -- resulting message: 'Temperature levels are too high: 25.3' 5. alert ('Temperature level is too high: %.1f' , temperature 1.12. Error log Error messages from scripts are displayed in Error log tab.
2. User mode visualization User mode visualization contains created visualization maps. There are three access levels: read, write, admin (password access can be also disabled) Access level Login Password Read-only Visview visview viscontrol viscontrol Write visadmin visadmin Write+admin level...
2.1. Custom design Usermode visualization Through Custom CSS styles it is possible to create different type of visualization maps. 3. Touch visualization Touch visualization is designed for iPhone/iPod/iPad/Android touch screen devices. All objects which are added in Logic Machine configuration by default are visible in touch visualization (if there is no Hide in touch option enabled).
Page 111
The main window is Building view where you can choose which Floor from which Building to control. Once you choose the floor, all objects which are assigned to it, are listed and can be controlled. Launching visualization on touch device (iPad in this case) •...
4. System configuration System configuration allows managing router functionality on KNX/EIB Logic Machine as well as do access control management, upgrade firmware, see network and system status and others. Login Password admin admin 4.1. Changing password The login and password configuration window is located in System...
Access control is separated in 3 tabs: Admin/Remote – access parameters for Logic Machine, Network Configuration, RSS and XML Visualization – access parameters for Touch and User mode visualization 4.2. Packages Packages shows the packages installed in the system. You can add new packaged by System pressing on +...
4.3. Upgrade firmware System Upgrade firmware is used to do a full upgrade of the system (both OS part as well as Logic Machine part). 4.4. Reboot Logic Machine You can restart the Logic Machine by executing System Reboot command. 4.5.
4.6. Interface configuration Ethernet interface is listed in the first tab. There are possibilities to disable/enable or to take a look at the traffic flow graph using special icons on the right side. By clicking on the interface you get to the configuration. Protocol–...
Current IP– the IP address got from DHCP server. This field appears only if the IP address is given otherwise it’s hidden. Network mask – network mask. By default 255.255.255.0 (/24) Gateway IP – gateway IP address DNS server – DNS server IP address MTU–...
4.7. Routing Table System routing table is located in Network Routes menu. The window is divided in two parts – Static routes and Dynamic routes. 4.7.1. Dynamic routes Interface – interface name Destination– destination IP address Network mask – network mask Gateway –...
Interface – interface name Destination– destination IP address Network mask – network mask Gateway – gateway IP address 4.8. ARP table Address Resolution Protocol table is listed in Network ARP table. 4.9. FTP server You can enable access to FTP server of Logic Machine by enabling this service in Service FTP Server.
4.10. System monitoring System monitoring is used to monitor system processes, hardware. In case of failure, the system will be rebooted or specific task restarted. 4.11. NTP client NTP servers can be specified in Service NTP client window.
4.12. System status General system status with CPU usage, Memory usage, Partition information can be seen in System status window. Status 4.13. Network status Network overview of IP setting and transferred data can be seen in Status Network status window.
4.14. Network utilities Ping and Traceroute utilities are located in Status Network utilities window. Both IP address and DNS names are accepted. 4.15. System log Operating system log is available in Status System log.
5. User mode schedulers User mode schedulers contains user-friendly interface for end-user to manage scheduler tasks, for example, specify thermostat values depending of the day of the week, time and holidays. 5.1. Events Each scheduler is mapped to specific group address in administration panel (see section 1.4 of this manual).
By clicking on the hidden blue menu you can change to different trends where each is mapped to a specific KNX group address. Current – Current trend is drawn in blue, you can choose either to show Day, Month or Year view Previous –...
Page 126
Datapoints can be shown also in a way of table which can be later exported as CSV file.
Modbus communication is done directly from scripts (usually resident script is used to read Modbus value after some specific time interval and write them into KNX object). Once script is added, you can add the code in the Script Editor. There are lots of predefined code blocks in the Helpers.
Reads slave internal data. Returns values on success and nil, error description on error. 7.2. Visualizing Modbus objects Use grp.write to assign Modbus object to KNX object and then use this new KNX object in the visualization. 7.3. Usage example (Modbus TCP) Task: read three registers from Modbus TCP device and write the result in Alerts.
Task: read two parameters (3-phase system voltage, 3-phase system current) from Modbus Multimeter 32-bit registers and store the data in the KNX group addresses. Make sure to connect LM2 with Modbus device correctly, RS485 A with -, RS485 B with +.
7.5. Modbus Slave examples Add the following code to Common functions -- modbus proxy mbproxy -- supported function list functions 'readdo' 'readcoils' 'readdi' 'readdiscreteinputs' 'readao' 'readregisters' 'readai' 'readinputregisters' 'writebits' 'writemultiplebits' 'writeregisters' 'writemultipleregisters' 'reportslaveid' 'getcoils' 'getdiscreteinputs' 'getinputregisters' 'getregisters' 'setcoils' 'setdiscreteinputs' 'setinputregisters' 'setregisters' -- new connecton init = function()
Page 131
function mbproxy:setslave slaveid self.slaveid slaveid -- send rpc request for a spefic function function mbproxy:request fn, ... res, err self.rpc:request local params slaveid self.slaveid -- request error then , err return nil -- request ok else -- reply with an error ] == nil then , res...
Page 132
Handler script example -- modbus init if not then require('luamodbus') luamodbus.rtu mb:open ('/dev/ttyS2' 38400 'H') mb:connect -- slave id mb:setslave (10) -- init slave storage for coils, discrete inputs, holding registers and input registers mb:setmapping -- coil write callback mb:setwritecoilcb coil, value (function( coil...
request.params type( ) == 'table' then table.insert( request.params, 1, mb ](unpack( request.params )) } else return server rpc.server ('127.0.0.1' 28002 'mbproxy' , handler, 0.01 mb:handleslave server:step Example: event script which changes modbus slave coil (address 0) Must be mapped to a group address with binary value. value event.getvalue mbproxy.new...
Page 134
-- a/c: 0, id: 1 { addrstat = '8/4/0', addrmode = '8/5/0', addrspeed = '8/6/0', addrtemp = '8/7/0' }, -- a/c: 1, id: 2 { addrstat = '8/4/1', addrmode = '8/5/1', addrspeed = '8/6/1', addrtemp = '8/7/1' }, -- read 8 bits and convert to single byte function readbyte(offset) local bits = mb:readdiscreteinputs(offset, 8) local result = 0...
Page 135
= readbyte(offset + 8) if type(mode) == 'number' and ac.mode ~= mode then ac.mode = mode -- send proper value to knx if 1 <= mode && mode <= 5 then grp.write(ac.addrmode, mode - 1, dt.uint8) -- fan speed speed = readbyte(offset + 16) if type(speed) == 'number' and ac.speed ~= speed then...
To make KNX/EIB objects BACnet readable/writable, mark necessary objects in Logic Machine as “Export object”.Binary objects will appear as Binary Values, other numeric values will appear as Analog Values. Other types are not currently supported. KNX bus writes changes the Relinquish Default property...
Page 137
Note!BACnet service restart and Reinitialize Device requests will reload all objects, priority array will be reset to NULL.
All telegrams received from EnOcean devices appears in Enocean KNX section. Once some specific device has to be mapped to KNX, the corresponding row has to be clicked and profile has to be chosen. There are all main profiles predefined in the list.
Page 139
When EnOcean gateway received telegram from specific device, the respective row gets light green. Respective KNX group addresses get updated with the new values.
Note!EnOcean device should be set in learning mode in order to pair it successfully. Further this device can be mapped with specific KNX addresses. When KNX object value will be updated, the telegram will be sent to respective EnOcean device.
8. DMX interconnection with LM2 DMX protocol support is realized upon RS485 serial port. Usage =DMX:init(parameters) d:run() Parameters • channels – (optional, defaults to 3) number of DMX channels to use • resolution – (optional, defaults to 20) number of DMX updates per second. Larger value gives smoother transitions, but increases CPU usage •...
Page 143
-- set channel count self.dm:setcount(self.params.channels) -- number of transaction ticks self.ticks = math.max(1, self.params.transition * self.params.resolution) -- calculate sleep time self.sleep = 1 / self.params.resolution -- reset channel map self.channels = {} -- fill channel map for chan = 1, self.params.channels do self.channels[ chan ] = { current = 0, target = 0, ticks = 0 } -- turn off by default storage.set(self.params.skey ..
Once the resident script is added we can add the program source in Script Editor if not then =DMX:init({ channels transition d:run() Setter (used in other scripts) DMX.set(channel, value) • channel– DMX channel number [1..512] • value – DMX channel value [0..255] 8.1.
Page 145
-- 3 channel scene scenes 255, 0, 0 }, 0, 255, 0 }, 0, 0, 255 }, 255, 255, 0 }, 0, 255, 255 }, 255, 0, 255 }, 255, 255, 255 }, current -- set current scene values 17. scene = scenes[ current 18.
9. 3Gmodem connection with LM2 Logic Machine 3 has standard 3G modem driver built-in (Huawei and other vendor support). Currently this can be used for SMS notifications only – receiving and sending commands. Further 3G router support will be added. Command syntax: a.
Page 147
modem ifnot then -- allowed numbers, SMS message from other number will be ignored numbers ={'1234567890' '0123456789'} -- replace 0000 with SIM pin number, or remove the line below if PIN check is disabled 6. pincode ='0000' -- modem communication port, ttyUSB2 for Huawei E173 comport ='ttyUSB2' -- open serial port...
-- got value, send response value ~ =nilthen 54. jvalue json.pencode value obj.name then name =string.format('%s (%s)' , obj.name, obj.address 58. cmd =string.format('Value of %s is %s' , name, jvalue 59. modem:sendsms sender, cmd -- incoming sms handler handler =function( alert ('incoming sms from %s (%s)' , sms.sender, sms.data...
Page 149
-- in the message field the number where SMS has to be send should be specified at the beginning event.datahex local ='23335555 1/1/1 changes its value to: ' tonumber( 7. client:sendto msg, '127.0.0.1' 12535) 9. msg ='23335556 1/1/1 changes its value to: ' tonumber( event.datahex 10.
10. HDL protocol integration in Logic Machine 3 Please contact Embedded Systems team to receive a special package to integrate HDL Note! support into your LM2. Once you have the file, add it in Network configuration -> System -> Packages. 10.1.
Page 151
-- split ip address into chunks 39. chunks data.eth0.inetaddr:split ('.') -- add ip address chunks 1, 4 chunk =tonumber( chunks 44. HDL.iphdr HDL.iphdr .. string.char( chunk 48. HDL.decode =function( packet local len, data, src, crc -- primary header packet:sub 5, 14 HDL.magic then returnnil...
10.2. Usage example – HDL dimmer control Task of this example is to change HDL dimmer value on specific KNX group address change. • Add new object in Objects tab • Add Event-based script which will monitor newly created object •...
Page 153
value dpt.decode event.datahex, dt.bool local 2. HDL.chanreg , value Test the program If you change the value for object 4/1/2 in Objects menu with Set Value, it will automatically change the relay state in HDL network.
11. Communication with RS232/RS485 serial ports The following are the naming of Serial ports for different versions of Logic Machine. Functions Include library before calling serial functions: require('serial') Opens given port, returns: port handle, or, in case of error, nil plus error message port, err = serial.open(device, params) Parameters: device port device name, required...
Page 155
port:flush() Closes serial port, no other port functions may be called afterwards port:close() Examples Write to port port: write('test data') Blocking read (script will block until 10 characters are read) data port: read(10) Timeout read (script will wait for 10 characters for 20 seconds) data port: read(10...
• name – object name (e.g. “My object”) • data – decoded object value (e.g 42 or “01.01.2012″) • datatype – object datatype (e.g. 1 or 5.001) – standard KNX data types • time – object update time (UNIX timestamp) •...
Page 157
Login, Password for remote XML request Login and password can be changed in Network Configuration System GUI Login Admin/Remote tab.
12.1. Alerts, Errors values In similar way also Alerts and Errors can be read by XML requests. Alerts XML request: http://remote:remote@192.168.0.10/cgi-bin/scada-remote/request.cgi?m=xml&r=alerts Errors XML request: http://remote:remote@192.168.0.10/cgi-bin/scada-remote/request.cgi?m=xml&r=errors...
13. Read Alerts RSS feeds from Logic Machine It is possible to read Alerts and Errors messages by remote RSS readers. Add new RSS feed in the RSS reader Use the following URL: • http://remote:remote@192.168.1.211/cgi-bin/scada-remote/request.cgi?m=rss&r=alerts • 50 latest alerts will be shown •...
Page 160
Login, Password for remote RSS requests Login and password can be changed in System Configuration System User access Admin/Remote tab.