CAI Networks WebControl PLC User manual

WebControlTM
Programmable Logic
Controller
User Guide
Version: 3.2.17f
Hardware Version: 2.2.2
Firmware Version: 3.02.17f5
Firmware datastamp: 10/15/2013
Doc last modified: 11/1/2013

WebControlTM PLC User Guide Version 3.02.17f
Copyright(C) 2008-2013 CAI Networks, Inc. i
Table of Contents
1Introduction .......................................................................................................... 1
1.1 Scope............................................................................................................ 1
1.2 Table of Definitions ....................................................................................... 1
2WebControlTM I/O................................................................................................. 2
2.1 Power Supply Inputs..................................................................................... 2
2.2 TTL Output Port ............................................................................................ 2
2.3 AUX Input Port.............................................................................................. 3
2.4 1-Wire Sensor Input...................................................................................... 3
2.5 Humidity Sensor Input .................................................................................. 3
3WebControlTM PLC Web GUI Configuration ........................................................ 5
3.1 Network Settings........................................................................................... 5
3.2 Access Settings ............................................................................................ 6
3.3 I/O Setup....................................................................................................... 8
3.4 X10 RF Control ........................................................................................... 10
3.5 Output Control ............................................................................................ 11
3.6 Notification Setup........................................................................................ 12
3.7 General Setup............................................................................................. 15
3.8 Reset Setup ................................................................................................ 16
4AUX System Inputs............................................................................................ 17
4.1 Digital Inputs ............................................................................................... 17
4.2 Analog Inputs.............................................................................................. 18
4.3 DS1822/DS18B20 1 Wire Temperature Sensors ....................................... 18
4.4 Honeywell 4000 Series Relative Humidity Sensor...................................... 19
4.5 Timers......................................................................................................... 19
4.6 Direct Query System Inputs and Outputs ................................................... 20
5Real Time Clock................................................................................................. 21
5.1 Network Requirements to Use the NTP...................................................... 21
5.2 Realtime Clock Use DS2417 ...................................................................... 21
6WebControlTM PLC Programming ...................................................................... 22
6.1 The Basics of PLC Programming ............................................................... 22
6.2 WebControlTM PLC Instructions .................................................................. 23
6.3 WebControlTM PLC I/O Identifiers .............................................................. 27
6.4 WebControl PLC Examples ........................................................................ 30
6.4.1 Example 1 Set Output based on condition .......................................... 30
6.4.2 Example 2: Flash TTL output ............................................................. 31

WebControlTM PLC User Guide Version 3.02.17f
Copyright(C) 2008-2013 CAI Networks, Inc. ii
6.4.3 Example 3: Push Button Input Control Output..................................... 32
6.4.4 Example 4: Send EMAIL ..................................................................... 32
6.4.5 Example 5, Parallel I/O........................................................................ 33
6.4.6 Example 6, Sequential I/O................................................................... 34
6.4.7 Example 7, Traffic Lights..................................................................... 35
6.4.8 Example 8, Time based Control .......................................................... 36
6.4.9 Example 9, Battery Charger ................................................................ 39
6.4.10 Example 10, RFID reader and browser Control .................................. 40
6.4.11 Example 11, Bitwise Operation ........................................................... 41
6.4.12 Example 12, Angle Calculation............................................................ 41
6.4.13 Example 13, Non-Blocking Delay ........................................................ 42
6.4.14 Example 14, Your Examples ............................................................... 42
7WebControlTM PLC FAQ .................................................................................... 45
7.1 Login and Configuration.............................................................................. 45
7.2 Temperature Sensor Support ..................................................................... 45
7.3 Turn on/off TTL output from another programming language..................... 46
7.4 External Analog Chip DS2450.................................................................... 47
7.5 Power Supply Requirement ........................................................................ 47

WebControlTM PLC User Guide Version 3.02.17f
Copyright(C) 2008-2013 CAI Networks, Inc. iii
Table of Figures
Figure 1.0 WebControlTM PCB inputs and outputs diagram........................................ 2
Figure 2.0 WebControlTM sensor connections............................................................. 3
Figure 3.0 WebControlTM PLC system status.............................................................. 5
Figure 4.0 WebControlTM PLC Network configurable.................................................. 6
Figure 5.0 I/O setup .................................................................................................... 8
Figure 6.0 WebControlTM X10RF Control.................................................................. 10
Figure 6.0 WebControlTM Output Control .................................................................. 11
Figure 7.0 WebControlTM email setup ....................................................................... 13
Figure 8.0 Network defaults ...................................................................................... 15
Figure 9.0 WebControlTM J12 Input pins ................................................................... 17
Figure 10.0 WebControlTM Temperature sensor assignments .................................. 18
Figure 11.0 DS2417 layout ....................................................................................... 21

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2011 CAI Networks, Inc. 1
1 Introduction
This document provides an overview of the technical aspects of using WebControlTM
PLC. It describes the inputs and outputs offered by the PLC version of the
WebControlTM hardware and firmware. The WebControl PLC Programming Guide is
found in chapter 6 of this document. Function, usage and syntax as well as many
examples are provided there to help you get started. WebControlTM PLC is different
from the earlier WebControlTM BRE. The PLC version of firmware provides greater
flexibility in I/O control; but in return, expects user to learn programming concepts
and write an assembly like PLC program. A PLC program has the ability to read
write and compare values of the available inputs, outputs, variables and timers. With
a PLC program loaded and running, WebControlTM PLC can operate on its own,
without a network connection. The PLC programming module and programming
guide are provided for a learn-on-your own experience. Assistance in writing or
debugging PLC code is not provided as part of the regular technical support for
WebControlTM PLC configuration.
1.1 Scope
The scope of this document is to be a guide for configuring and using the features
provided by WebControlTM. The reader is expected to be technically competent in all
the technical areas within this document, and is strongly advised to use this
document alongside the other reference material listed in the reference section.
1.2 Table of Definitions
The following table is a list of definitions used though out the document.
Definition Description
HTTP Hypertext transfer protocol
DNS Domain name server
SMTP Simple mail transport protocol
SNTP Simple network time protocol
1-wire Special bidirectional serial data bus from Maxim
RH Relative humidity
NetBios Human readable name used as an alternative to an IP address for
accessing the server on a network. E.g. http://WebControlTM
IP Internet protocol
DHCP Dynamic host configuration protocol
ROM Read only memory
PLC Programmable Logic Controller

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2011 CAI Networks, Inc. 2
2 WebControlTM I/O
The current hardware version of WebControlTM is equipped with a number of inputs
and outputs; these are shown in below in figure 1.0.
Figure 1.0 WebControlTM PCB inputs and outputs diagram
2.1 Power Supply Inputs
The DC power supply input is the electrical supply to the board. The recommended
input voltage is 9V DC. Any voltage greater than 12V applied to this input may
require adding heatsink to regulator, otherwise it may overheat.
2.2 TTL Output Port
The TTL logic level output port has 8 TTL outputs that can each be set or cleared
using web GUI command codes, or by setting up a PLC using the available inputs,
variables, and timers, so that the particular output is set when a particular condition is
met. The maximum current that can be sourced or sinked by one of these outputs at
a time is 20mA or 100mA for the whole board. TTL 0 level defined as 0-2V and TTL
1 level is define 3-5V with TTL 0 almost 0V and TTL 1 almost 5V depending on the

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2011 CAI Networks, Inc. 3
load. TTL output current is capable to drive standard solid state relay, but will not be
able to drive those coil based relays. Be aware of the current requirements of the
circuits/loads attached to these outputs. Damage will occur to the board if too much
current is allowed.
2.3 AUX Input Port
The AUX input connector offers digital and analog inputs that can be monitored or
programmed to set a single TTL output or several TTL outputs. Three analog inputs
are available, each have an input range of 0 to 10Vdc. Eight digital inputs are
available and use TTL input levels (0 and 5Vdc). The AUX Input Port pin out diagram
(labeled as J12AUX in Figure 1) shows the layout of this port in more detail. The
matching connector for this port is TYCO ELECTRONICS - 1658622-3 .
2.4 1-Wire Sensor Input
The 1-wire sensor port allows up to eight Maxim DS1822/DS18B20/DS18S20 1-wire
temperature sensors to be connected. It also allows one Maxim DS2417 real time
clock, and one DS2450 4 channel A/D converter. The temperature and analog input
can be displayed via the HTTP browser and can be used as inputs to the PLC engine
to control the TTL output port. Since hardware revision 2.2.2 uses 5V to power 1-
wire bus, there is no need for any external power to the sensors. Please note if more
than one DS2450 is attached to 1-wire bus, only the first one will be used by the
firmware. If more than 10 1-wire devices attached to the bus, only the first 10 will be
used.
2.5 Humidity Sensor Input
The current WebControlTM hardware has been designed to use the Honeywell 4000
series relative humidity sensor devices. Using any other humidity sensor without
careful consideration may result in malfunction of this feature. The RH sensor can be
used to display relative humidity via HTTP or be used to control the TTL outputs as
an input in the PLC engine.
Figure 2.0 WebControlTM sensor
connections
Please make sure the temp sensor
and humidity sensor connected
similar to this picture. Reverse the
polarity may cause damage to the
board.

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 5
3 WebControlTM PLC Web GUI Configuration
To access WebControlTM PLC, connect WebControlTM to the local network and power
supply. The default IP address will be 192.168.1.15. Be aware that once you enable
DHCP in your WebControl network settings page, you will need to check your DHCP
server log for which IP address DHCP assigned to the board. You need to know and
understand the network you attaching this hardware to in order to know where to look
for DHCP server logs. For home networks, DHCP serving is commonly enabled at
the router. Each WebControlTM PLC board has a unique MAC address. Look in the
DHCP log to find the matching MAC address, then you can find the IP address
DHCP assigned to the hardware. From a computer connected to the same network,
start a web browser, and point to that IP address: for example: http://ww.xx.yy.zz
when the web page loads, you will be prompt for login. The default user ID and
password is: “admin/password”, all in lower case. You will see this page once
logged in:
Figure 3.0 WebControlTM PLC system status
3.1 Network Settings
These are the basic settings that need to be configured in order for WebControlTM to
work successfully on a network. It may be necessary to connect the board directly to
a PC and access it using its default IP address before connecting directly to a live

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 6
network in order to configure it correctly. Figure 4.0 shows the Network settings
WebControlTM has.
Figure 4.0 WebControlTM PLC Network configurable
3.1.1 NTP Server Settings
This version changed from previous versions by reduced Allowed Limits host IP
address from eight to four. In addition, it added NTP Server section to allow user to
enter his local NTP server’s IP address to overwrite the default pool.ntp.org resolved
IP address. By default NTP server field should be 0.0.0.0, so that WebControlTM will
use pool.ntp.org as the Network Time Protocol server.
3.1.2 Access Settings
For security purpose, you can decide your own user name and password. For being
used over Internet, you may also set the access list, so that only host in the list can

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 7
access the WebControlTM board over the network. Please note that if any entry is
0.0.0.0, all IP addresses can access it.

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 8
3.2 I/O Setup
WebControlTM PLC allows users to directly from browser control each output, or
through the PLC logic to control the TTL output. For flexibility, user can decide if the
TTL input or out to be inverted between logic 0 and logic 1. To use PLC logic, first
user must check the “Global PLC enable” to start the PLC engine. Then for each
TTL output, user can decide if the PLC control will be applicable.
Figure 5.0 I/O setup
WebControlTM PLC allows user using browser to directly control the output state. If a
command line utility or third party control software used, you will need to enable the
Browser Control for that TTL output, also may need to go to network configuration to
disable the Web login (see figure 4.0).
The inverted state will be remembered in EEPROM even after power loss. The invert
state will be restored upon power resumed.
X10 Enable will allow user to send X10RF commands through TTL port7 and TTL
port8. Those two ports will not be able to perform any other function, once X10 is
enabled.

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 9
Counter Enable /Frequency Measurement Enable/TTL Input Enable are radio buttons
that you can only select one of them. Those functions sharing the same TTL1 input.
Please note the Counter is triggered at rising edge after the falling edge. If your
counting source TTL level was zero from start with, you may miss count by 1.
Frequency measurement is up to 2MHz.

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 10
3.3 X10 RF Control
Figure 6.0 WebControlTM X10RF Control
WebControl uses TTL7 and TTL8 to control X10RF devices. User must already
enabled X10RF function in the I/O Setup screen. An external RF transmitter must be
attached to the output port TTL7, TTL8, and ground. In the USA, the X10 RF
frequency is 310MHz, and in Europe, the frequency is 433 MHz WebControl can
send all 16 house codes and 16 unit codes, controlling total 256 devices.
X10 RF function is supported in the PLC programming also.
In PLC programming, PLC command is in the format:
X10 H U C
Where H is house code from 0-15, U is unit code, also from 0-15; C is one of
following four commands: 0 – Off, 1 – On, 2 – Bright, 3 – Dim. H,U,C can be
variables so that user can dynamically change the X10 operation in PLC logic.
If the X10 function enabled, TTL7 and TTL8 should not be used for controlling other
devices. Please note PLC logic uses 0-15 or 0-0xF for code, web GUI only use 0-F.

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 11
3.4 Output Control
Figure 6.0 WebControlTM Output Control
When click on each TTL output On or Off, the current state of the TTL output will
change. However, the display may or may not update depending on the “Web
pulling” enabled in the General Setup screen. If you did not enable the “Web Pulling”
to save the bandwidth, you will need to use browser refresh to see the output state
change. Please note “Save States” button will make WebControl store the state in
the EEPROM. When power lost and reapplied, the output will remember the states
being saved.

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 12
3.5 Notification Setup
WebControlTM allows up to 8 different email notifications to be send from the PLC
program. Please note the port can be any number, but WebControl current hardware
cannot support SSL enabled email. Certain email servers like Gmail requires use
SSL enabled email client. WebControl does not support that. However, WebControl
does allow sending email out from port other than 25. Most local ISP provides the
non-SSL email server on port other than 25, for example, Yahoo email using port
587. Please contact your local ISP first to find out how to sending out non-SSL
encrypted email. For example, Yahoo email can be used:
SMTP Host = smtp.mail.yahoo.com Port 587
username = your-Yahoo-email-account,
password = your password used
From field = Your Yahoo mail
From firmware 3.02.16, user can specify different email address for different email
notification. So that different email can be send to different person for a different
event.
WebControl 3.02.16 firmware also allow HTTP GET to be used to set the VAR or
output state to another WebControl board, provided the other board does not enable
logic. If the security is concern, please set up allowed host in Network Setup screen.
This HTTP GET feature can also be used to send notification to the remote HTTP
server, given the remote server does have CGI logic to process the HTTP GET sent
from WebControl. User can specify up to 8 different URLs on each board. There are
three fields in each URL. The first field is IP address and port, in the format of
192.168.2.15:81 . The “:” is to separate the IP address and remote HTTP port. There
is no space. It is followed by virtual host name. The URI portion of the URL is a
string leading all the way to the value being set on the WebControl or remote HTTP
server. The last part of the URL is the Base64 encrypted use name and password.
This will allow one WebControl to set value in another WebControl with password
protected. If the other side does not require login, this field can be left blank.
For example, if you want to set a remote WebControl board VAR1 to value 1234, you
simple in the PLC logic calling:
WEBSET URL1 1234
Or

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 13
WEBSET URL2 VAR1
Please note WEBSET has sending queue of four. If there are WEBSET requests
coming more than the queue can hold, the older requests will get lost. In addition, if
the remote WebControl or server does not respond, the WEBSET will fail.
Figure 7.0 WebControlTM email setup
Starting from the 3.2.15 firmware, we allow user to configure less I/O being report. By
default, all I/O status is reported in the email.
Please note that although there are 8 EMx and 8 URLy, WebControl internally only
has queue for up to five emails and eight URLs queued for sending. If PLC logic
made such a call too fast, the newer email or WEBSET notification will overwrite the
older ones in the queue.

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 14
Most email notification problems are either the configuration problem or the SMTP
host rejected email. In this version PLC firmware, user can send a test email to see if
the email notification working or not. In earlier version user guide, it was not clearly
stated the email message ID is in format of EM1 through EM8. Using number only or
other string may send out wrong email message.
WEBSET feature allows setting VAR value in another WebControl board, or setting
value on your web server, if you have proper CGI code developed to take. For
example, to set a value in ISY from Universal Devices, you can configure the URL1
to:
IP_address:port:virtual_host for example: 192.168.2.222:80:www.mydomain.com
Please note ISY99 using port 80
URI example: /rest/vars/set/1/15/
Base64 encrypted username:password: Example: YWRtaW46cGFzc3dvcmQg
Between username : and password, there is no space. In earlier version, you need to
specify “AUTHBASIC:” from 3.02.17 firmware, the third field is dedicate for the
encrypted user ID and password, so that “AUTHBASIC:” can be omitted.
In your PLC logic, you can put this command:
WEBSET URL1 VAR1
Then it will set ISY variable 15 to the value of VAR1.
To do base64 encryption, you can go to our web site at:
http://www.cainetworks.com/support/base64-encoding.html
From 3.02.17 firmware, server CGI code can return a 32bit signed number to
WebControl during WEBSET call. Please refer to the chapter 6 example 15 for how
to write the CGI code and how to refer to this returned value.
To obtain support for email or WEBSET feature, full TCP capture data is required.
The captured data must be able to fully display in WireShark software.

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 15
3.6 General Setup
When WebControlTM is connected to the network it will obtain NTP time from Internet.
User need to set correct time zone on WebControlTM PLC.
Figure 8.0 Network defaults
If the WebControl cannot reach to pool.ntp.org over Internet, it will use its own built-in
clock with less accuracy. If a DS2417 real time clock chip connected to 1-wire bus,
WebControl will query it for the time. User may change and update the clock from
this screen by typing MM/DD/YY HH:MM:SS format in the Set Date Time input field,
then click “Send” button. If a DS2417 chip is discovered on 1-wire bus, the real time
clock will be set to this time. When synced with NTP server, real time clock chip
DS2417 is also set every 10 minutes.
UROM1…UROM4 are four identifiers can be used in PLC program. They can help
user to fine tune their PLC program for different setup. These four values are stored
in the EEPROM, so that when power lost, its value will be kept by the EEPROM.
When power restored, UROM value will remain whatever they set before. There are
two ways to set UROM value. One is to set it on this web GUI page by save modified

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 16
value. Another way to set their value is to use /api/seturom.cgi call. Please refer to
the FAQ section for that method.
For 1-wire devices on a complex bus configuration, its timing is critical. Time Data
Sample Offset (TDSO) field is for user making his own timing adjustment based on
his setup. Default TDSO is 15uS. For shorter bus, it can be reduced to 14uS or
lower. For longer bus, 16uS or longer may be desirable. 1-wire signals are travelled
in CAT5 cable at speed about 20Meter/uS. However, we recommend to add filter
resistor to reduce bounced signals from stub wire and far end of the bus, instead of
change the timing.
When Web polling enabled, WebControlTM PLC building active Java code will
constantly update the browser display for temperature, humidity, and I/O status.
Please note with such a update, it may take significant amount bandwidth from your
network, as well as WebControl’s processor power.
3.7 Reset Setup
If the configuration was totally mess up, user can reset the board to factory default
configuration by shorting the RESET jumper while powering up the WebControlTM.
Please note reset will wipe out the entire configuration, including the PLC program.
Please make sure backup your PLC program before reset. After reset, the login ID
and password will be restored to “admin/password”. Default IP address is
192.168.1.15 with DHCP disabled.

WebControlTM PLC User Guide Version 3.02.17f
Copyright(c) 2008,-2013 CAI Networks, Inc. 17
4 AUX System Inputs
The system AUX inputs of WebControlTM are used as inputs to the PLC engine (see
section 5.1). This section describes the connector ladled as J12. Digital and analog
inputs come through J12 connector.
Figure 9.0 WebControlTM J12 Input pins
4.1 Digital Inputs
WebControlTM has eight digital TTL inputs, each of which can be configured to be
inverted upon input to the system. The PLC engine will then look for a true of false
case of the input. TTL level 0 is defined 0-1.75V; TTL level 1 is defined as 3-5V.
When TTL1 being used as counter/frequency measurement purpose, its counts
pulses up to 2MHz and max count is 32bit number. Counter starts counts from rising
edge after the falling edge.
Table of contents