The VID (Virtual Instrument Desktop) software allows low cost
industry standard Modbus or NetCommander hardware to be used in distributed control and monitoring
systems. The Software combines a customizable virtual instrument
display with a "behind the scenes" event monitoring,
logging, alerting and control systems, to provide a full and customizable HMI to your application.
The virtual instrument panel can comprise a variety of meters,
dials, digital displays, graph plotters, thermometers, LED
indicators, control knobs, sliders, buttons and switches. These
can be "connected" to a Netcommander monitoring point
anywhere on the local or World Wide network allowing data
sources, temperature, pressure, voltages etc. to be visualised in
seconds.
The instruments are viewed in multiple virtual screens; the
current screen can be selected by using the toolbar forward,
backward, and page cycle buttons or from the drop down list of
configured pages.
The system is equally "at home" with a local LAN or
RS232/RS485 connected system or a globally distributed system
using the Internet or Corporate VPN.
Each NetCommander monitoring unit can provide up to
16 analogue input and outputs, 16 switch (relay) control outputs
and inputs, . The VID software will control up to fifty
monitoring units. Logs can be maintained and analysed for trends
and compared week on week. Control schedules can also be set up.
The events system provides a configurable cause and effect
system, several "causes" can be combined using
AND/OR/NOT logic to produce an event that can have several
"effects". An "effect" can be a control
output, raise an alarm, make a log entry send an e-mail or SMS,
run a control script etc. An almost unlimited number of events
can be processed by the VID software, and a more limited number
can be processed by the NetCommander nodes natively, this will
allow some basic control to be maintained autonomously, in the
event of network or PC failure.
VID has been tested using windows 98/2000/XP and Vista™,
the system will work identically, however, the windows may be
rendered slightly differently to those illustrated below, which
were mostly recorded on Windows XP.
please report any problems
to support@thecodemachine.co.uk.
Alternately the raw web interface to the Netcommander can be investigated here.
The "view only" password is Cuberoot.
Click Setup.exe to download the latest Full VID installer or here for other versions.
Unregistered,
VID is fully functional but will only run for half an hour at a
time before closing down, also the registration dialogue box will
pop-up every five minutes, just to annoy you! There is a publicly
available NetCommander at IP address (81.138.209.253) which is
monitoring the computer room here in Leicester, England, use with
the configuration file "examples.vid" to view this on
the "power monitoring" page. The unregistered software
will allow you to explore all aspects of the system and to design
your own instrument panels, and control regimes and save the
files for future use. The downloaded file is a self extracting
installer, an un installer is also provided.
This publicly
accessible NetCommander module maybe in use by several people
concurrently so the configuration may change unexpectedly and
performance may be lower than would normally be expected.
VID has been tested using windows 98/2000/XP/Vista™*
please report any problems to support@thecodemachine.co.uk.
Alternately the raw web interface can be investigated (http://81.138.209.253). The
"view only" password is cuberoot.
Double click on the file Setup.exe which can be found on
either the Installation CD (this should auto-start) or downloaded
from the Internet from http://thecodemachine.co.uk/VID/Setup/VID_Full/Setup.exe.
You
will almost certainly want all the default settings, keep
clicking "Next" and finally "Install" to
install VID on your computer.
You can follow the same
procedure to upgrade an existing installation, any configuration
files and scripts you have produced will be preserved.
The
latest version is maintained on the web site, this can be
downloaded free of charge, and will not require
re-registration.
VID can be set to periodically check for a
newer version.
The downloaded file is a self extracting
installer, an un installer is also provided.
A Microsoft Installer file "Setup.msi" is also available for remote unattended bulk installations.
Un-Installing VID
VID may be removed from the system by
navigating to "Uninstall VID" from the Start Menu or
using the "Add/Remove Programs" dialogue from the
Control Panel. Any configuration files generated after the
installation will not be deleted, if you want to remove these as
well simply delete the installation directory after the
un-install completes.
The "About" and Program Registration box is
accessed from the [Help][About] menu.
Alternatively this will pop-up by itself every five minutes
until registered.
The Licence Key/Serial number is printed on the VID
installation CD. VID (Lite) only supports one Netcommander and the licence box will be grayed out. In the absence of a
valid license, the system will be fully functional, but will
only operate for 30 minutes at a time, before shutting down,
the run-time remaining is displayed on the caption bar of the
main screen.
To ensure the security of the controlled plant, operators
of the system must login to VID, operators are assigned
various privilege levels
Basic Viewer
Can only view the screen(s).
Advanced Viewer
Can also view messages, logs, raw data etc. and
instrument configurations.
Controller
In addition to the above can operate switches and
control knobs.
Configurer
In addition to the above can make changes to instrument
and event etc. configurations.
Administrator
Can do anything!
The "Lite" version of VID does not
require logins, and the privilege mechanism is not active.
If
there are no operators defined then the system will use the
default operator at Administrator privilege level. Configuring
one or more operators should, therefore be one of your first
actions. All the configured users are presented in a drop-down
list.
Login form
Login & Operator configuration form
The extended Login form left appears when the Modify/Add
button is clicked on the simple form (above). To change the
password of an existing user the new password must be typed
into both the "New Password" and "Repeat
Password" boxes. The logged on operator is timed out
after "Timeout" minutes of operator inactivity.
The "Lite" version of VID does not
require logins, and the privilege mechanism is not active.
The basic system
configuration is achieved using two forms.
One concerns the
local configuration and one for configuring individual NetCommander nodes.
The System
configuration is accessed from the Edit menu, and
allows setting up of the system wide defaults.
If specified, the system log will be used to record all potentially hazardous
operations, stamped by time and user. The log can be cycled
daily, weekly, monthly or continuous. The "Use Standard Time In Logs" checkbox causes Standard Time to be used, i.e. GMT+/- your geographic offset without any reference to daylight saving time, this setting is recommended as the time will then not go forwards and backwards with the seasons. The clocks going backwards would effectively loose an hours' data from the log as the times would be duplicated, and the clocks going forward would cause an hours gap in the data, using Standard Time avoids this and avoids any confusion. Unchecking the box will use local time including any daylight saveing time.
The Server Configuration section controls the built in web server, this allows
remote viewing and control of the VID program from another
remote computer using an ordinary web browser or the VID
Client software. Choose a Port other
than 80 if there is aleready a web server running on this
PC, the same port number must be supplied in the VID
Client configuration or web server URL eg.
http://bigcorporation.com:4321 for port 4321. You may need
to use port forwarding in your router to direct the chosen
port to the VID machine. Choosing a lower Quality setting will result in smaller file transfers, but the
image quality will suffer.
SMTP,User and Pass set up the SMTP mail server, this is the SMTP server for
the VID location, which may or may not be
the same as the SMTP server specified for individual NetCommanders. User and Pass
Word are not usually needed and can be left
blank.
The SMS section is used where
a GSM/GPRS modem (or mobile phone) is connected to the
computer to allow sending of SMS alerts, nb. the phone
number here "SMSC #" is
that of the service provider, Vodafone, Orange etc. Not the telephone to be alerted. The destination 'phone number
is set-up in the events configuration.
Alarm Sound sets the default
for local alarm sounding, for convenience the Browse button bring up a file browse dialogue to locate sound
(.wav) files.
Default background sets the
default background image for all pages, for convenience the Browse button bring up a file
browse dialogue to locate image(.jpg, .gif) files.
Page Cycle Time is the time
(in seconds) between page views when using the cycle pages
feature. Get Config from Netcommander and Send Config to Netcommander downloads or uploads configuration data to the configured
Netcommander. It is recommended however, that the native
Netcommander web based configuration tool is used to
maintain Netcommander configurations, this can be accessed
using the Native Web Manager. button on the Netcommander Configuration dialogue below.
NetCommander Configuration
The Netcommander node configuration accessed
from the Edit Menu,
and is used to set the
communication parameters for individual NetCommander nodes. The "Lite" version of VID only
supports a single Netcommander.
The node IP address is entered
in dotted quad format e.g.."81.138.209.253", to use aTCP port number othe than the default HTTP port 80 specify this after the IP address sepearted by a colon e.g. "81.138.209.253:4562" this allows the use of port
address translation to reach Netcommanders on private
address ranges. Symbolic names can be used, for example,"Netcommander_7.BigBusiness.co.uk". The "Internet"butt
The NetCommander "full access" Password must be specified here.
NetCommander Configurations may be sent/retrieved from the NetCommander using these
buttons. The configuration is stored/retrieved from the
current VID configuration file. The NetCommander Native Web
Interface can also be invoked from here opening in your
default browser.
Miscellaneous Stuff
The SMTP field only needs configuring if the NetCommander is to
autonomously send e-mails, this is the IP address of the
SMTP server which must be accessible from the
NetCommander's location. Time Zone is the number of hours +/- relative to the VID computer's
internal clock to allow local time to be configured on the
NetCommander. The NetCommander time is synchronized with
the VID PC time at startup and subsequently every hour. If
the controlling PC is in England and the NetCommander in,
say, France the Time Zone would be set to 1 to ADD one hour
to the Netcommander time relative to VID. Poll Period specifies how often VID polls this
NetCommander, each Poll retrieves about 100 bytes of data
across the Network. The time is specified in seconds.
Some Internet connected nodes may require a slower poll to allow for
network delays, local and time critical applications can have
shorter poll periods. The shortest practical poll period is 0.3
Seconds. With many connected NetCommanders, consideration should
be given to the available bandwidth.
The Native Web Manager button will launch the default web browser pointing at
the native Web interface of the selected NetCommander.
Port scale conversions
This dialogue allows scaling functions to be assigned to
one or more NetCommander ports. This scaling will be reflected
in the native NetCommander web interface above, and will also
be used as the default scaling function for any Virtual
Instrument that specifies the port. Typically one scaling
factor is used on several ports, the array of check boxes
allows assigning the function to multiple ports. The "inputs"
and "outputs" checkboxes specify whether the
function is applicable to input ports or output ports (or
both).
Modbus nodes can be defined or edited from the
[Edit][Modbus] menu selection. "Modbus Address" is the node address in the range 1...255. "COM" is the PC COM port to use. "Protocol" selects
between RTU (Binary) and ASCII (printable Hexadecimal)
flavours of the Modbus protocol. The "FSD" settings, are used when referring to values by voltage, if the
Modbus device has a 12bit ADC that is 2.4Volts full scale,
then the theoretical FSD of the 16bit Modbus register would be
2.5*16=38.4V. Note that in Modbus speak an analogue output is
termed a "holding register" and a digital output a
"coil". VID tracks which Modbus registers are in use
and only requests data from those registers using the "read
multiple" Modbus commands. A "port" on a
digital VID instrument represents a binary Modbus bit,
therefore the associated Modbus register would be (port/16)
the remainder being the bit number. ie port 35 would be
register 2 bit 3. The "Reset Usage" button can be used to reset the usage map after configuration
changes, to avoid having to restart the config. Modbus is not
supported by VID (Lite).
Modbus modules come in all shapes and
sizes, most are for industrial use and have RS485 interfaces
which will require the use of a RS485 to USB (or RS232)
converter. A convenient small device with a USB interface is
the Novus "myPCLab" device (left) which can be
configured to use two thermocouples, DC voltage or 4-20mA
inputs or a combination thereof. It also has a built in
temperature monitor and a single digital input. A more
extensible DIN rail mounted solution using an RS485 interface
is shown right. Modbus modules can be supplied by Codemachine
Ltd.
RS485 networks only require two wire signaling and can
support up to 128 monitoring nodes. The signaling range is
greater than 1Km. An RS485 converter will be required to
interface with the PC, this will present either a COM port
interface or USB, VID can handle either.
The
completed desktop arrangement can be saved from the [Files][Save] menu or by clicking icon which will become high-lighted if the configuration requires
saving. The [Files][Save as] option
allows the name and location of the saved file to be changed.
Files are saved with a .vid file extension, this is a standard
Windows .ini file format so may be edited directly (e.g. NotePad)
which may be easier in certain circumstances, for example, when
working with multiple similar sites. If you associate .vid files
with the VID program double clicking on a .vid file will open VID
with that data. The default file to load is stored in the vid.ini
file and is initially server.vid, from the program installation
directory and subsequently the last .vid file used. Alternatively
files can be opened using the [File][Open] menu or from the icon, the screen can be blanked to start work on a new display
using [file][close]. [Files][Run
Script] is an advanced option that allows running
of a script file, these files will be familiar to any 'C' or
Pascal programmer, this feature is described here. [Files][ReOpen] re-opens the
current configuration file, this is useful to re-start all
scripts. [Files][Flush Log Files] Flushes all the stored log file data to disk, this is done
automatically every few minutes or if the log files are required
to be viewed, by the charting function for example. This option
is useful to make sure the log files are up to date if you wish
to view them using an external viewer eg. Notepad. Note that some file editors/viewers may block VID from writing to the
log while it is in use.
Options Menu
Various options reside under this menu heading, these are
not saved on a per config basis, but will alter the
functioning of VID for all loaded configs. [Options][Check
Updates] controls whether VID will periodically
check for a newer version on the web, this can then be
downloaded. The [Options][Exit Form] controls whether VID displays a confirmation dialogue on exit "Are You Sure?". The [Options][Spoof Data] will permit
"spoofed" data to be entered on the Instrument
Properties to be displayed, this is useful fir "hacking"
demonstrations, for safety reasons this option is NOT saved,
after a restart VID will always display live data. The [Options][Transparent Forms] will
cause forms to be displayed with some transparency, (see left)
underlying instruments are then not completely obscured by a
form.
The system may have several pages of displayed instruments,
these are selected by the forward, backward and cycle page
buttons on the toolbar or from the drop-down list of
configured pages. The screens can be named and the background
colour and image changed by right clicking on a blank area of
the selected page, the simple dialogue box (left) will appear,
click Apply to transfer the settings to the screen. The
current page can also be deleted or duplicated to another page
for editing. The background image can be stretched by width
and/or height to fit changing screen sizes. VID (Lite)
does not support multiple pages.
Virtual Instrumentation provides a visualization of the
monitored system. A variety of instruments may be included on the
display, a selection of round, horizontal and vertical analogue
meters, thermometers, bar indicators, Oscillograph, digital
displays and LEDs. For analogue control there are rotary mouse
adjustable knobs, and slider controls and for switch outputs
clickable toggle and slide switches and push buttons.
Adding a Virtual Instrument to the display
To
add a new instrument or control to the display left click on a
blank area of the screen, the "instrument chooser"
box (left) appears. Clicking on one of the instrument icons
will place the instrument on the display. The instrument will
appear near to the original cursor position. The instrument
types in the chooser box are ordered top left to bottom right,
by type, starting with analogue displays, through binary
displays, analogue controls, binary controls (switches) and
finally static graphics.
Moving
An instrument may be moved on the screen using the
[Shift][Right Click][Drag] mouse action. Move the instrument
slowly to keep the mouse pointer inside the instrument or it
may "loose focus" and something else might start
moving
Re-Sizing
An instrument may be resized on the screen using the
[CTRL][Right Click][Drag] mouse action.
Properties
Simply Right clicking on the instrument will allow various
properties to be changed, such as instrument type, monitoring
point, scaling factors, caption etc. (see more below).
The available instruments are 270, 180 and
120 degree meters, horizontal and vertical meters, horizontal and
vertical bar indicators, a representation of various tanks with
varying liquid levels, thermometer, a numeric value indicator and
a graph plotter. Top
Graph Plotter
The Graph Plotter is a type of analogue instrument but has a
few more options. The Graph Plotter can display more than one
input value, this is specified by a start port and range. For
example if "port" is set to 3 and "num
ports" to 4 then the values of Netcommander ports
3,4,5 & 6 will be displayed. The same scaling is applied to
all ports. A typical use would be to measure the power
consumption in a three phase supply, and with this in mind the
first three channels are coloured Blue, Yellow and Red (these can
be changed). By specifying a "log file" in the configuration, chart data is logged to a disk file. There
are 60 plotted points to a graph division, so if an hour per
division is specified each point represents one minute and an
entry is logged every minute. The log scale can be specified from
one day per division down to five minutes. Right clicking on a
graph brings up the usual properties selection
panel with the addition of "logger" this produces an historical log analyses tool,
this will open with the log file and scaling associated with the
graph plotter instrument. These values can be subsequently
changed in the analyses tool, and the new settings will be
remembered for the next time.
Binary Instruments
The only Binary "instruments"
are the Light Emitting Diode (LED) representation and Dynamic
Labels, these can be made to change colour and the displayed text
according to input value. There are also options to flash the LED
or Label and to play a sound file when changing state. The
dynamic caption described in Labels below
is useful with LEDs. A typical Caption would be of the form
"Off;On"; The scaling would then be arranged to produce
values in the range 0.0.. 1.9999, anything below 1.0 represents
"off" and 1.0 and upwards represents "on" a
typical mapping for an analogue input would be 0..4095
(raw)0.1.9999
(scaled), this would mean any input value over half scale
deflection (2.5V) would cause the "LED" to be "on".
Labels
Labels can either display a fixed text and a dynamic numeric
value or a dynamic text which changes according to value. The
font size, text and text colour can be changed from the
properties dialogue.
Dynamic Label Value
A dynamic numeric value and fixed text is displayed if units are specified in the properties dialogue.
This example has the units value set to "kW" i.e.
Kilo-Watts.
Dynamic Label Text
If the units field in the properties dialogue
is blank then labels can be considered as a binary (or
multi-state) instruments as the text can change according to the
monitored value.
If a Caption is specified
containing semi-colons, then these will be treated as a list of
captions which will be selected by the integer value of the
scaled result. Up to 16 texts separated by ";" are
allowed giving 16 captions, selected by the scaled values 0.0 to
15.99, for example, a scaled value of 0.35 would select the
first, and say 1.68, the second caption in the list. If the
semi-colon is omitted then the same text will appear for all
values. A '|' (pipe) symbol in the caption dialogue appears as a
new line in the label.
This feature is available on the caption
property of ALL the instrument types but is probably of most use
in switches and LEDs that have only two discrete states i.e. "on"
and "off". Top
Dynamic Graphics
Graphics can be considered as a binary (or
multi-state) instruments as picture can change according to the
monitored value. Up to 100 pictures are allowed are allowed
selected by the scaled values 0.00 through to 99.99. The "base"
picture for the graphic should have a name ending in "00"
e.g."PipeValve00.jpg" that could represent (for
example) a closed valve, "PipeValve01.jpg",
"PipeValve02.jpg" could then represent the same valve
in various degrees of flow. The are some example picture in the
"VID/Media" folder, the user can add some more if
desired. Top
Static Graphics
Static Graphics are primarily for displaying a fixed
background picture, they can be re-sized and the picture file
changed at run-time. Also you can specify a "refresh"
interval from approximately one second upwards, this is useful
for monitory the image file generated by a locally connected "web
cam". For internet connected web Cameras use the "Web
Graphic" option below.
Web Graphics are intended to monitor the output of remote
web cameras, the image file is specified as an Internet URL
e.g."bigfactory.co.uk/web cams/frontgate.jpg" as
long as the URL resolves to an image file it will be displayed
in a captioned box, which may be re-sized and re-positioned.
For locally connected web cams, with an image file located on
the host computer's files system, use the "Static
Graphic" option above.
Analogue Controls
Analogue Controls include two knobs, one
is a single turn with a digital readout, the other is a 10 turn
"pot" called a Gear Dial, horizontal
and vertical sliders are also supplied, also numeric controls in
edit box and spin button styles. Right clicking on the control
will allow various properties to be changed. VID (Lite)
does not support analogue controls.
Switches
There are Toggle and Rocker switches which remember their
state (just like a light switch) and a "momentary action"
switch called a Bit Button. The Bit Button will
only change state whilst the mouse button is held down. Right
clicking on the switch will allow various properties to be
changed, such as control point, caption etc. Rocker and toggle
switch styles are available. The text on the face of the switch
can be made to change according to state using the dynamic
caption described in Labels above The
caption could be of the form "Lights|Off;Lights|On".
The "Bit Button" is a momentary contact push-button, it
is only "On" whilst it is being "pressed".
The Bit Button is unique in that it can also be
associated with a control script which will run when the button
is clicked for more about control scripts see this.
The state of the control will reflect the last update message
received from the Netcommander, if there is more than one
instance of VID controlling the system the switches and controls
may change position by themselves, all VID displays will be kept
consistent. VID (Lite) does not support switches.
Pinger
The Pinger instrument is a departure from the norm, it does
not reflect the state of an I/O port but uses either ICMP Echo
(Ping) or an HTTP request to check that an IP connected host
is contactable. This is useful for monitoring the availability
of a web site or server. The "LED" is green if all
is well, red if contact failed, and black while waiting for e
reply. A failure action can be
specified in the instrument's configuration that will be
actioned in the event of three consecutive contact failures,
the rate of contact requests can be varied between once every
5 seconds to once an hour.
Right
clicking on any instrument will bring up a popup menu with
options to change instrument properties, Nudge (make fine
adjustments to size and position), clone (duplicate), delete, and
change the type of instrument preserving all applicable settings.
The history chart generator and Tariff tool can also be launched
from here, for graph type instruments. Only a subset of the above
options will appear depending on instrument type.
Properties
The Instrument properties form is similar for all instrument
types, some fields will be missing if not applicable. The form on
the left contains all possible fields, they will never all be
present, the fields visible will depend on the type of instrument
being configured. Caption and Units will appear on the face of the instrument, special symbols from
the Extended ASCII character set can be added using the &#nnn; syntax, nnn being
the character code e.g. ° would display °C.
Caption text can change according to the current instrument/ switch value
see Labels above for full explanation. Font sets the font attributes to be used. Colour allows non-standard Font colours to be used. Node/Type/Port dialogue set the monitoring or control point . Value box shows the current scaled value. Dig. min/max and Scaled min/max boxes are used to
define the scaling function. Volts check box determines whether the Digital range boxes contain the
digital value (checked) ie 0..4095 or an analogue value 0..5.0 Volts at the NetCommander input. Sc.
Default button will pre-load the scaling boxes with
the NetCommander port defaults.The raw input value can
be pre-processed by a Script (written in a simplified "c" programming language) to
provide extra data processing, averaging or calibration
etc. Browse button is used to locate
the desired script, more about this below. X
Interval is only applicable to the graphs and
ranges from one minutes per division to one day per
division. GlyphFile and associated
Browse button appears for certain switches and allows an image to
be overlaid on the switch. Inner Colour & Set
Colour set the background and inner colours, these
buttons are renamed "On colour"
and "Off Colour" when
processing binary instruments such as LEDs. Sec
Low & Sec Hi sliders control the size of the
coloured sectors on the instrument face, or in the case of
thermometers the "mercury" colour and in value
indicators the colour of the value text. Only the Mid sector is
controlled, the upper and lower sectors extend to the extremities
of the scale. The instrument values including sector ranges can
be imported into the Events Cause form by
left clicking on an instrument whilst a cause dialogue is
open. Caption tracks LED Colour obviously only appears for LEDs and does what it says! Page allows the instrument to be "sent to" another page,
this can be used in conjunction with cloning (below) to duplicate
an instrument onto another page with identical settings. Beveled controls whether the instrument bezel is displayed.
Change Face
This option brings up the Change Face Dialogue, the instrument face type can be change (within
reason!). It is not possible to change a switch to an analogue
meter for example, but all analogue instruments are
interchangeable, likewise binary displays, and switch types.
Refresh
This option retrieves a web based image from a server and
refreshes the instrument on the display.
This option only appears on controls (sliders, knobs,
switches etc.). It allows configuration of timed and calendar
control schedules. Shown is the analogue version, the binary
(switch) version has an on/off checkbox instead of a control
knob. Control actions can be done weekly on preset days of the
week at certain times or on a Calendar date at a certain time
for a "one off" action. The example left is a church
heating control, showing an entry for the heaters to be
switched on and set to 16°C on all days (bar Sunday) from
5:30pm until 6:45 for Evensong.
Clone
This option creates an identical instrument on the display,
useful when there a lot of only slightly differently configured
instruments.
Delete Instrument
The Instrument will removed from the display and from the
active configuration.
Logger
This option opens the instrument logging and charting
tool.
Delete Instrument
The Instrument will removed from the
display and the active configuration. Top
Toolbar
Page Selection
The drop-down menu selects the page of
instruments to be displayed.
Web Server activity LED
Is to the right of the page selection box, and indicates
activity on the internal web server (or Web Client for Client
versions of VID)
Monitoring node Status Bar
The row of bars to the right of the Web server activity LED
indicate the status of the monitoring nodes.
Hovering the
mouse over an individual indicator opens a hint box indicating
the monitoring node number.
Left clicking on a bar brings up
the raw data viewer for that node, right
clicking displays the message viewer.
The
colours are as follows:
Blue VID
Transmitting to Node
Green VID
Receiving from Node
Red Node/response
in Fault
Gray Node
Configured but idle
Black Node not configured
ToolBar Icons
Most of functions available from
the toolbar icons are available from the menus (above). The page
control Icons will not be present in VID (Lite).
Open File Dialogue (same as [File][Open])
Save File (same as [File][Save]) (high-lighted when save
reqd.)
Take a snapshot of the VID screen, and open in default
browser
Expand to full screen (ESC cancels)
Display the Help file in web browser (same as [Help][Help])
Display the VID Web site (same as [Help][Web site])
Open Login/Logoff Dialogue
Move one page to the left (lower page index number)
Move one page to the right (higher page index number)
Continuously cycle through the pages (configurable delay)
All the above Icons are self explanatory or have functions
described in the relevant menu section. With the exception
of:-
Full Screen, this button hides the menu and tool bars and
expands the main form to fill the screen, pressing the Escape
(ESC) key cancels this.
Log Annotation (see below). Top
Chart Log Annotation
Log Annotation allows comments to be inserted into the
chart data. By right clicking on a chart (graph) instrument,
the form on the left can be accessed, this will annotate the
data for that chart only.
Accessing
the same dialogue from the tool icon (above) will annotate ALL charts simultaneously (the "Log File" field will be
empty). VID will remember the fields from the last use, so
only those changed need filling in, Shift and Product fields are optional and intended for
industrial users. The Annotations will subsequently be
displayed in the chart plot information box
(see below). Annotations within +/-1 time division, the number
of arrows e.g. ">>>>>" indicate the
closeness of the annotation to the current cursor position.
Log Analyses Tool
This form allows the configuration and display of a
historical chart of instrument data over time. The start time
of the chart can be adjusted with the slider. The graph window
is re-sizeable, and multiple graphs can be on-screen at once.
An instrument chart can be accessed from the right click
instrument properties menu. Two log files can be compared, for
example two logs from different weeks, only one channel of the
(up to eight channels) in the log files can be compared at
once, selected by "Cmp Ch.", "Fill
Ch." specifies which channel is made into a
solid colour (channel 2, yellow, is selected above), you can
also use the "fill Ch." to remind
yourself which channel colour is associated with which
channel. The dates on the X axis represent the dates for "Log
File", the comparison log file data will be synchronized
to the same time, but typically a different date. When
comparing Weekly logs as above the comparison data will be
aligned to the same day of the week, and in the case of
Monthly logs, the same day of the Month. Comparing files with
no log cycling is fairly meaningless, but will be aligned by
time of day. information about a particular plot can be had by
left clicking on the chart and a hint box will pop-up as shown
above. The X-Axis time resolution can be changed, if the time
period is longer than the recorder time period data will be
averaged between plots, where the specified time resolution is
shorter, the data will be interpolated between plots. the
chart can be dragged to the left or right to change the time
period (sufficient data permitting) use the down arrows to
access the ca lender for dates, highlight the hours/minutes
and use the up and down arrows or directly edit the time. "Excel Chart" and "Excel
Log" allow the export of .csv Microsoft Excel
spreadsheet data for the chart or the entire log respectively.
Note the Chart Plot Information box, this
pops up when clicking on any chart whether live or recorded
and displays the values and any annotations at the cursor
position (highlighted vertical yellow line). The log files
must be of .clg file extension or a zipped log file in which
case the ".clg" is replaced by ".zip", by
their nature log files contain many repeated elements and are
so eminently compressible! The "Zip?" buttons allow a outdated log to be converted to compressed zip
format, you cannot zip an "in date"active log
file.
The "Histogram" checkbox,
when checked, causes the chart to be displayed as a histogram,
averaging the values over each division as in the clip
(right), (hint) set 1 hour per div, then the Histogram bar heights will be "units"/Hour. The chart total "units"/Hour is also displayed top left, this only has a meaning for charts showing consumption rates ir power, gas flow etc. The "Tariffs" button,
invokes the Tariff Tool.
This tool is for comparing actual utility usage,
electricity, water, gas, or any other metered resource,
against different suppliers' tariff structures, you can save
files describing your own, and alternative suppliers, tariffs.
All the data entered into the "Tariff Bands" panel
will be saved on clicking "Save Tariff" allowing you
to create new tariff files or modify existing ones. The tool
will calculate the cost for the selected Tariff structure or
can search through all tariffs (.trf files) in the folder
specified to find the cheapest supplier for your particular
usage pattern. The span of the data to process is initially
taken from the underlying chart, you can select different
start/end times by clicking on the chart at the appropriate
position. The Start/End time selection boxes will be loaded
from the chart cursor position with alternate clicks or use
the "set start time" check box to specify which to
update, alternatively. Remember you can get more data on the
chart by reducing the X-Axis resolution. Some tariff files are
provided, but these may well be out of date or not appropriate
for your application, you should maintain your tariff files
from the information on your utility bills.
Standing Charges
If a standing charge is specified then a proportion of that
will be added to the calculated total depending on the data
span. Similarly if the standing charge is "hidden"
in a "primary unit rate" with a premium for first
500 units (or similar) consumed per quarter year. Enter the
units for a MONTH so if the standing charge is for three
months divide by three, similarly for the number of primary
units charged.
The Instrument Scale factors require a little more
explanation. Analogue input and outputs have raw digital values
expressed as a scaler number between 0 and 4095 (for A 12bit
resolution A/D). Scaling functions are required to convert this
range to a floating point representation of a "real world"
value e.g. degrees Centigrade or Volts.
The standard NetCommander monitoring board provides 16 analogue
inputs and 8 outputs, and monitors/controls voltages in the range
0.0 to 5.0 Volts. This scaling is performed by a simple raw to
scaled value mapping by specify the upper and lower limits of
both the raw input range in use and the required floating point
"real world" value.
The basic scale function is
defined by the raw min & max values and scaled min & max
values in the instrument properties dialogue. This can be preset
to the NetCommander port default. Additional
scaling and data processing can be provided by a script which is
written in a simplified "C" language. The simplest
scripts is below :-
result=input_rel(0);
This will be familiar to any 'C' programmer. The above script
does nothing, the input value is simply conveyed un-altered to
the auto-defined double precision variable "result".
The
script below takes a running average of the last ten readings.
The script is applied to the raw A/D value BEFORE the scaling
function.
double Av[size];
int c,count=0,size=10;
Av[count%size]=input_rel(0);
result=0;
count++;
if (count>=size) {
c=0;
while (c<size) {
result+=Av[c];
c++;
}
result = result/size;
} else {
c=0;
while (c<count) {
result+=Av[c];
c++;
}
result = result/count;
}
The important thing to note here is that variables are "static",
each time the script is called the values are remembered from the
last run, "count" is incremented from one call to the
next, the variables assigned a value in declaration statements
"int" or "double" are set to that value on
the first run only, and then may subsequently be updated (or left
the same). Each instruments' scaling function has its own set of
variable values, even though the same script may be in use by
several different instruments.
More about Scaling Algorithms
and Control Scripts in the Scripts section. You can create your own scripts using "NotePad"
or similar editor and place them in the scripts folder. Scripts
may be tested using the Scriptor utility.
The Virtual Instrument Desktop (VID) plant monitoring and
control system can execute script files to perform sophisticated
control and monitoring tasks. The scripts are used to perform
sequenced actions for example to shut down a system in an orderly
fashion. The script language has built in functions to monitor
and control NetCommander I/O ports.
Delays and "time of day" functions can also be
programmed. Emails and alerts can be generated in a similar way
to the VID events system.
The language itself is a subset of
'C' so will be familiar to any 'C' programmer.
Only the for,
while, switch and if flow control
constructs are implemented, there are no do .. while loops. All variables, constants and functions are integers (int)
or double precision floating point. Strings can also be defined
using char[];
VID can invoke a script from either a push
button on the virtual display panel, or as an "effect"
from the event handler, or can be run from the [File][Run Script]
Menu.
The script will open in a window as above, but can be
subsequently hidden and revealed under control of the script
itself.
several scripts can run concurrently, and may run
continuously in a loop, waiting for various conditions to occur
in the monitored system.
On a Pentium class 1Ghz PC the script
interpreter should exceed one million lines of code per
second.
The scripts are interpreted rather than compiled, this
means that the system only "sees" the code as it is
executed, any areas of your script that only execute under
exceptional conditions e.g. alarm handling may contain errors
that will only become evident when the alarm condition occurs, be
careful coding these areas and test thoroughly before putting on
a live system.
Script Types
There are two types of scripts, their syntax is identical, but
they are used for different purposes within the system, these are
"Scaling Algorithms" and "Control Scripts".
Scaling Algorithms
Scaling Algorithms are used to process the raw values into a
suitable range for display by an instrument see Virtual
Instruments or Scaling inputs into the Events system. In addition to simple scaling they may calculate, for
example, averaging functions, and non-linear conversions for
instruments like thermo-couples etc. These scripts have the
".vsa" (VID Scaling Algorithm) file extension. These
scripts should be kept as simple as possible to reduce execution
time and CPU overhead to a minimum, as they may be being called
hundreds of times a second. Scaling algorithms are run "blind"
they do not run in a Scriptor Window
Control Scripts
Control Scripts can use the full
functionality of the scripting engine including writing
information to a Console Window these
scripts run asynchronously to the main code, in a separate
thread, and so can run for a long time without disturbing the
main functionality of the program. In fact, a control script may
run continuously in a loop monitoring inputs etc. Control Scripts
have the ".vcs" (VID Control Script) filename
extension. The system can run eight scripts concurrently. The
scripts may be launched from the [File][Run Script] menu or from
a virtual on-screen Button, or as an event action. If invoked from the [File][Run Script] menu the Console
Window will be visible otherwise it is minimized, the running
script may force a minimized window open by a call to the
visible() function, the window opens automatically in the event
of an error.
Control
Scripts are usually run minimized (left), however the Scriptor
Window, as above, is available, and can be used to
start,stop,resume and edit the scripts. The File button opens the file dialogue to select a control script file,
this will run automatically. Start is used to
re-load from disk and run the previously selected file name, this
is useful for reloading the script if it has been edited, Halt will halt the running script, Continue will
cause the script to resume at the same point. This will
otherwise, generally, not effect the operation of the script,
however, events in the monitored plant may be missed or functions
that rely on time differences (as read by the get_time()
function) may malfunction. Exit will exit from
the running script. Edit will open the "NotePad" editor
(on a Microsoft Windows system) and open the current script for
editing. This is a convenient way to achieve a fast
edit/run/debug cycle for scripts. Close will
exit from the current script and close the scriptor window. Any
outputs made from the running script (using the print(...)
command) will appear in the main window. The eight boxes at the
bottom of the window, give a display of what the Script Engines
are doing, the first box is reserved for Scaling Algorithms, as
these always run in the same thread there can only be one of
them! The other seven are the general control scripts, the number
following the file name is the "program counter", the
current position in the script file. The file associated with the
current window is coloured red. The screen shot above is showing
the execution of the test.vcs syntax and performance test script.
Instrument Scaling
The Instrument Scale factors were introduced in the Virtual
Instruments topic. These have the same syntax as control
scripts but have the specific function of processing raw input
values to engineering units, Volts, Liters etc. for display on
virtual instruments or for processing in the event handler. The
basic anatomy of a VID Scaling Algorithm (.vsa) file is:-
This will be familiar to any 'C' programmer, the two double
precision variables "scale_min" and "scale_max"
set the upper and lower bounds of the instrument scale, "result"
will represent the value to be sent to the instrument in the
scaled units. The raw value is retrieved by a call to the
"input_rel(0)" function, which returns
the raw value from the port specified in the Instrument or event
Cause, this is a value in the range 0 .. 4095 for an analogue
signal. The calculation in the script coverts this to a value in
the range (in this case) 0.0..5.0 for display this value must be
stored in a variable called "result" which is
pre-declared by the system. The same script can be used for many
instruments, each instrument will maintain its own copies of all
variable values. The scripts should be designed to drop "straight
through" without excessive looping, these scripts may be
called hundreds of times a second, so keep them simple! The above
script is stored in the scripts folder as "electrical5V.vsa"
a slightly more complex script "average10.vsa" used for
calculating the average of the last 10 values is reproduced
below.
double Av=0,scale_max=5;
Av *= 0.9;
Av += (input_rel(0)*scale_max*0.1)/4095;
result = Av;
Building on this is a script to calculate domestic power
consumption, it uses averaging as above and also time functions.
//==================================================================================
// KWH.vsa : script to tot up power consumption in KW/hours
// The input value is 0..2400 Watts @ FSD
//==================================================================================
double power;
double background=150; // make an initial guess at background consumption (watts)
int iv, Watt_secs;
iv = input_rel(0);
if (iv==4095) {
// FSD on current transformer, make a guess at what is happening!
double tod = get_time();
if (tod<50) {
Watt_secs=0; // reset total at midnight
}
if (tod<730000) {
// before 7:30
if (tod>100000) {
// Time between 1am, and 7:30am
power=2700+background; // assume this is the immersion heater 2.7kW + background
}
} else {
// after 7:30 am
if (tod<905000) {
// Time between 7:30am, and 9:05am
power=7000+background; // assume this is the shower 7kW + background
}
}
} else {
power = iv*2400/4095; // 2400 Watts FSD
background*= 0.9;
background+= (power/10);
}
Watt_secs += (power/10); // come here every 100mS hence /10
result = Watt_secs; // Watt/Seconds
result = result/3600; // Watt/Hours
result = result/1000; // KWH
The important thing to note here is that variables are "static",
each time the script is called the values are remembered from the
last run, the variables assigned a value in declaration
statements "int" or "double" are set to that
value on the first run only, and then may subsequently be updated
(or left the same) and their current value remembered from one
call to the next see "background" above. More about
Scaling Algorithms and Control Scripts in the Scripts section. If the same script is running on several instruments
each will have its own set of variables. You can create your own
scripts using "NotePad" or similar editor and place
them in the scripts folder. The Scripts may be indented and
commented freely, this will make them easier to maintain and be
understood by others, this will not effect the speed of execution
as all "white space" and comments will be discarded
when the file is first loaded. Scaling Algorithms are only loaded
from disk once (or when the instrument properties are changed) so
changing the files will not effect the running system until
restarted. Scripts can be tested and debugged using the
[File][Run Script] launching the Scriptor mechanism.
Variables must be declared before first use, this is usual in
most programming languages, this allows memory to be allocated
for storage and allows the type of variable to be defined so the
appropriateness of subsequent assignment statements can be
assessed.
The variables can be assigned an initial value in
the declaration statement, In the case of scaling algorithms,
this value is set on the first pass only, and the current value
remembered from one run to the next for that instrument, in that
way counters (for example) can be initialized and subsequently
incremented. The following variable types and associated
declaration syntax are available.
Type
Range
Syntax
Example
double
2.23 10^-308 < X < 1.79 10^308
double <name[=expression]>;
double fred=1.234;
int
-2,147,483,648 <= X <= 2,147,483,647
int <name[=expression]>;
int count=0,output;
char
-127 <= X <= 127
char <name[=expression]>;
char ch='X';
More than one variable can be declared per statement by
separating with a comma. All variable types can be declared as
arrays by adding an array dimension in square brackets to the end
of the name e.g.
int results[40];
Constants
All variable types can be declared "constant" by
prefixing with the keyword "const" the run time system
will then check that the variable has not been modified. this is
useful in making code more readable e.g.
const int server_room_netcommander=1;
const int boiler_room_netcommander=2;
if (get_input(server_room_netcommander,rack3_temp)>45) {
// Server cabinet 3 is overheating
....
}
Non Volatiles
All outer block variables can be prefixed "nonvolatile"
the system will then remember the variables value, if VID is
restarted, the PC crashes etc. this is useful foe scripts that
keep running totals eg kWh counters. The keyword "volatile"
can also be used for clarity but this is the default.
Note:
the data is stored keyed on Node,Port,Port Type and Script Name.
If the same script is running on the identical port configuration
on a second instrument there will be a clash in the variable
store, resulting in unpredictable behavior!
volatile int RunTimeHourCounter,TickCount;
if (++TickCount==36000) {
// The 0.1S counter has reached one hour, reset it and increment hour counter
TickCount=0;
RunTimeHourCounter++;
}
Character arrays can be assigned strings, and subsequently used
in place of quoted strings, the blank dimension "[]"
will allocate just sufficient space for the assigned string. eg.
All the usual arithmetic and comparison
operators are provided. Processing of an expression is from left
to right. Multiplication and division are processed before
addition and subtraction. bracketed expressions are resolved
first, brackets can be used to prevent any ambiguity.
The following functions are available for monitoring and
control of the NetCommander inputs and
outputs. All variables are double precision types, most of these
functions return and integer or boolean (1 or 0) value as a
double precision quantity.
input_rel(offset)
This
function is used to get raw input values into a scaling algorithm
script 0.0 .. 4095. The node, port number and port type are
specified by the configuration of the instrument that invoked the
script the parameter "offset" specifies an offset from
the configured port number, useful for processing (for example)
three phase power calculations. e.g.
iv = input_rel(0); // Red Phase current
iv += input_rel(1); // + Yellow phase
iv += input_rel(2); // + Blue phase
input_abs(port)
As above; the node and port
type are specified by the instrument configuration, "port"
specifies the port number. input_scaled()
Returns
the scaled result from the attached instrument, there are no
parameters. sync(node)
This function waits
until the next NetCommander Poll response has been
received. event_set(node, id)
Check to see
if a VID event has been triggered, returns 1 if triggered
otherwise 0. get_input(node, port)
Get the
value from an A/D converter input 0 .. FSD. get_switch(node,
port)
Get the value from a switch (binary) input
returns 0 or 1. get_output(node, port)
Get
the value from an D/A converter output 0 .. FSD. get_state(node,
port)
Get the value from a NetCommander state
variable. get_node_vidvar(node, port)
Get
the value from a VID node variable 0..65535 associated with node
"node". get_vidvar(port)
Get the
value from a VID variable 0..4294967295. set_output(node,
port, value)
Set the value of a D/A converter output
0 .. FSD. set_switch(node, port, value)
Set
the value of a boolean switch output (1 or 0). set_state(node,
port, value)
Set the value of a NetCommander state
variable. set_node_vidvar(node, port, value)
Set
the value of a VID node variable 0..65535 associated with node
"node". set_vidvar(port)
Set the
value of a VID variable 0..4294967295.
In all the
functions above, "node" refers to a monitoring unit,
this can either be the index number from the VID node
configuration dialogue or more usefully (from the point of view
of portability of the script between VID files) either an IP
address or node name e.g.
value =
get_input(3,4); value = get_input("Turbo
Generator 3",4); value =
get_input("192.168.33.74",4);
These
examples all equally validly access port 4 of the node at IP
address 192.168.33.74
the "node", "port"
and "value" parameters can be any constant, variable or
expression that resolves to a valid number.
"node"
(if numeric) and "port" are both based from 1.
e.g. set_output("Turbo Generator 3",
exciter_drive, 200);
Date and Time Functions
The time functions (below) use a floating point number to
express date and time. The integer part of the value is the
number of days that have passed since 30/12/1899. The fractional
part of a time value is the time of day in fractions of a day
(from midnight), negative dates are before 30/12/1899 but are
unlikely to be of any concern to us!
Following are some
example values and their corresponding dates and times:
0.00000 30/12/1899 12:00 am (mid-night)
2.75000 1/1/1900 6:00 pm
-1.25 29/12/1899 6:00 am
35065.50 1/1/1996 12:00 pm (mid-day)
The time has a resolution of about 10mS
get_date()
Gets
the current date and time as a double precision floating point
number in days elapsed since 00:00:00 UTC, January 1st. 1970.
The
fractional part represents the time of day. This is a useful
format as for instance adding 1.0 to the date is the same time
tomorrow, or adding say, (1.0/24.0), is the time in an hour
hence. get_ms()
Gets the current time of
day expressed as the number of mS after midnight. get_day()
Gets
the current day Sunday is 0, Monday is 1 .. Saturday is
6. get_month_day()
Gets the current day of
the month 1..31. get_time()
Gets the
current time of day in a decimal representation.
i.e. 0 ..
2359599 i.e. 13210437 represents 1:21:04.7 pm. with one tenth of
a second resolution.
Hours, minutes, seconds can easily be
extracted using div and mod operators.
eg.
int hour = int(get_time()/10000);
eg.
if (get_time()==1200000) {
// reset total at mid-day
total=0;
}
All instrument scaling scripts are called 10 times per second, so
get_time() will return a unique incrementing value on every call
in a particular script, so lines like "if
(get_time()==1200000)" will be safe, the value eg. 1200000
will never be skipped.
date(date)
Returns
a string representation of the date, omitting the the argument
i.e. data() returns the current date.
print(date()); // print the current time and date
convert_date("DD/MM/YY HH:MM:SS")
converts
a date/time string to the internal date format
The following
Snippet of code illustrates the operation of the time functions
double switch_off_time = convert_time("3/7/2004 17:30:00"); // switch off at this time
while(1) { // loop "forever"
while (get_date()<=switch_off_time) {
sleep(60000); // sleep for a minute
}
print("Plant Shutdown initiated at ");
print_time(switch_off_time);
switch_off_time += 1.0; // add one to do the same thing at this time TOMORROW!
plant_shutdown(); // call the plant shutdown procedure
}
or ...
while(1) { // loop "forever"
int t = get_time();
while (t<=1730) { // switch off at 5:30pm
sleep(60000); // sleep for a minute
}
print("Plant Shutdown initiated at ", t/100, ":", t%100 );
plant_shutdown(); // call the plant shutdown procedure
}
Arithmetic Functions
All the arithmetic functions use double precision arithmetic
and have 15 digit resolution.
abs(expression)
Returns
the absolute value of a floating point
expression
int(expression)
Returns the
integer part of a floating point
expression
fraction(expression)
Returns
the fractional part of a floating point
expression
exp(expression)
Returns the
exponential e to the power <expression>, used in infinite
series averaging etc.
logn(expression)
Returns
the natural logarithm of <expression>, ie. the inverse of
exp(x) above.
System Functions
Sleep(duration)
Sleep for "duration"
milliSeconds, this should be used in loops whilst waiting for a
condition to occur, to avoid excessive CPU utilisation. e.g.
// wait for steam pressure to reach 6 Bar before opening turbine valve
mins=0;
while (get_input("Boiler Room", steam_pressure)<600) {
if (++mins>60) {
generate_alarm("Failed to raise steam after one hour!");
exit; // run-up sequence failed exit script
}
Sleep(60000); // wait for 60 Seconds (60,000 mS)
}
set_switch("Boiler Room",tubine_valve,1); // Open the turbine steam valve
print(format_string, ....)
Prints uses a
format string and expressions to print to the output window e.g.
print("Flour Silo %d is %d%%", silo_num, level);
This could possibly print:- "Flour Silo 3 is 27% full"
The
format string syntax is described here for those not familiar with the 'C' standard library
functions.
syslog(format_string, ....)
Prints
to the system log (if specified), the parameters are the same as
for print() above,
eg.
if (get_time()==0) {
// Log Kwh at midnight
syslog("Yesterdays total power consumption: %f Kwh", Kwatt_hours);
}
will create a log entry similar to:
22/06/2006 00:00:00:0 user: Mike > Yesterdays total power consumption: 145.47 Kwh
syscommand(file[, arguments])
Invokes, a
system command, most usefully a DOS batch (.bat) file with
optional arguments. The file path can be relative to the VID
installation folder or absolute ie. proceeded by the drive
letter.
Where (in this case) "delete_logs.bat" could be a batch
file to delete the VID log files in folder "site3logs",
however, a batch file or other DOS command could be invoked to
achieve just about anything.
com(port, format_string, ....)
Prints to
the specified serial (COM) port, the parameters following the
port number are the same as for print() above,
visible()
This function forces the script
window open, this is useful to bring to an operator attention
some text in the console window, which is of insufficient urgency
to warrant an alarm condition (below). Scripts invoked from a
button or event action usually run minimized. If an error occurs
in the script, parameter out-of-range or syntax, error for
example, the window will automatically open and the script
halted.
alarm( format_string, ....) This function
will display a warning box on the screen. The box is non-modal,
i.e. processing of the script will continue, the cancel button on
the box merely dismisses the form. The function takes a single
string parameters "alarm text" which will be displayed
along with the time in a similar fashion to VID event alarms.
eg. using a string array to reference an alarm text by number
...
alarm_popup(alarm_texts[alarm_no]);
send_email(to,from,subject,body)
This
function will send an email via the SMTP server configured by the
current .vid file. The function takes four string parameters "to"
and "from" addresses followed by "subject"
and "body" texts.
set_page(page)
Programmatically set the
current on-screen page (1..10).
hold()
This
function is typically placed at the end of the script, it will
wait with the screen visible, until it is manually closed. This
allows printouts to be read before the window is closed. Normally
the window is automatically closed on reaching the end of the
script or an explicit exit(); function call.
exit()
Exit
the script and close the script window.
Libraries
Libraries of useful functions can be built up over time, this
can be included into your script using the directive
#include
"file.inc"
The file name extension is is up to you,
I have made it .inc here to indicate an include file, the file by
itself may not be executable as it may lack some vital variable
declarations etc. to function, so it is a good idea not to give
the code fragments and libraries .vcs or .vsa extensions. See the
PID (Proportional, Integral, Derivative) controller example below
// pid_test.vcs PID Controller
// All values used by the PID refer to 0..5V at the A/D inputs
double Proportional_Gain=1.3;
double Integral_Gain=1.2;
double Derivative_Gain=0.025;
double Acceleration_Feed_Forward=0.0;
double Friction_Feed_Forward=0.0;
double Velocity_Feed_Forward=0.0;
double Bias=0.0;
double Acceleration_Rate=3.0;
double Set_Point=3.5; // Volts at A/D
double Min_Output=0.0; // minimum output value allowed
double Max_Output=5.0; // maximum output value allowed
double Slew=0.0; // maximum output slew rate V/Cycle
int Output_Hold=0; // in Cycles
int Cycles=0; // terminate script after this no. of cycles (or never)
char NC_Input_Node[] = "Temp controller 2";
int NC_Input_Port = 3;
char NC_Output_Node[] = "Temp controller 2";
int NC_Output_Port = 3;
#include "scripts\pid.inc"; // include the standard PID algorithm
The control script above just declares and initializes variables
for the PID controller, and then includes the main body of the
PID logic from the file "pid.inc". In this way if the
PID control algorithm is modified the modifications are
automatically inherited by all the scripts that use it.
Lines may be drawn on the screen to
join or box instruments into logical groups. Lines are drawn
using <ALT><Right Click> ... Drag mouse movements. Lines that are very nearly vertical or
horizontal will snap to the relevant axis to avoid "jaggies".
Lines ending very close to another line end will be automatically
joined up. An existing line can be moved by dragging in the usual
way, only one end can be dragged at once, the end nearest to the
mouse on left-clicking will be selected. If the a moved line is
joined to another line both lines will move together. This allows
the easy drawing of boxes around instrument groups.
<ALT><Right Click> on
a line brings up a properties box allowing change of width and
colour as well as deletion. Lines that are very nearly
vertical or horizontal will be automatically aligned with the
axis. Lines starting very close to the end of another line
will be automatically joined up. The Snap button will attempt to tidy the lines on the screen.
There are essentially two events system, one handled locally
in the VID software and one remotely in the NetCommander nodes.
The remote event system is more limited in
scope, one advantage is the remote system will operate
autonomously of the VID software in the event of a communication
failure, and will respond better to transitory events that may
fall between VID poll periods. We shall describe the local system
first as it is more comprehensive, the remote system has a subset
of the functionality.
Local Events system
The system combines several "causes" to produce one
or more "effects". In this example the event indicates
that a server room door is open AND an intruder
is present. This is further qualified by time to only occur
outside office hours. In the example an Email is sent, an alarm
will display and an output is made which could for example switch
on an alarm bell.
The Events Dialogue, left, provides an overview of the
event being configured, the event is selected by the select
event drop down . Delete deletes the
event. Un-checking Enable will allow
the event to be saved but prevents it from being used, this
can be used to disable an event if, for example, some
maintenance operation is in progress.
The "LEDs" to left of the cause names indicate if
the cause is currently on or triggered these LEDs will be
refreshed every second whilst the form is on the screen. The
"LED" by the Event ID box
indicates if the event as a whole has been triggered and the
"effects" actioned.
The Check Boxes labeled Sunday, MondaySaturday
select which day(s) of the week the event is active, by default
the event is active every day but typically may be disabled at
weekends. The day selection is disabled if the "on date"
timer is selected.
Causes
The
Cause dialogue is invoked by the Edit/View button to the right of the cause name boxes.The best way to
configure a cause is to click on the virtual instrument
monitoring the desired property, at least it will give you a
starting point and the value can be changed to suite, the set
points can be changed on the VI using the VI [Right
Click][Properties]
dialogue and adjusting the sector colour ranges with the
sliders, the new values will be imported into the cause form
on exiting the properties dialogue.
In this example the cause is set to trigger within a
monitored range of 3185 to 5000 (Gallons). The Re-trigger
values define a slightly larger range and the cause will not
be re-activated until the monitored value leaves both the
trigger range AND the re-trigger range, this provides some
hysteresis, preventing floods of alarms when a cause condition
is bouncing around the trigger value. The re trigger values
can be set using the hysteresis buttons or directly edited. The event can combine cause inputs
from different NetCommander nodes. The Scaler box and
associated Browse button is used to select a Scaling Algorithm
see Instrument Scaling.The Type will usually be an analogue input, however outputs and switch
(boolean) inputs and outputs can also be monitored as well as
Internal and NetCommander State values which can be used to
link events together. One of Effects of an event can be to
modify the value of a state variable. A remote event running
on the Netcommander node could increments a state
variable, say monitoring the pulsed output of a turn-stile.
This variable could be monitored by a local event to raise an
alarm after a certain number of people had been counted.
Causes are AND ed together by default but can be OR ed and
also negated to produce NOR and NOT logical combinations, also
precedence is from top to bottom so combination like "(Cause1 AND Cause2) OR (Cause3 AND Cause4) AND NOT Cause5" can be built up.
The Log check box will cause a time stamped
entry in the system log to be made on each event state
transition.
The Timer buttons allow a timer
to be added as an extra "And ed" condition to the
event. Using the dialogue box (right), the timer can be either
a "one shot" at a certain date and time or at a
certain time of day, every day or periodically down to every
second. The TOn "LED"
illuminates whilst the timer is "On". If an an "Off"
timer is specified, this starts running when the "On"
timer condition is met, this allows operations like, "enable
the event at 8:30 am and disable at 17:30", or "enable
the event every hour for ten minutes". The box between
the two timer config buttons shows which timer is running and
the remaining time to change state. The date box can be edited
directly or using the drop down arrow a subsidiary calendar
dialogue is opened.
Times are stored as an absolute value
not a "delay to next event" form so any change to
the PC clock setting e.g. for DayLight Saving Time will not
generally effect the operation of the timer.
Effects
The effects are actioned when the logical combination of the
event causes becomes true.
There may be up to four effects for
each event.
This is the basic action for drawing a local operators'
attention to an event, a red pop-up box will appear on screen,
with the requested message, and (optionally) a sound file will
play, a browse button is provided to locate suitable files, the
Windows Media directory is a good source of bells and whistles! A
count is incremented on the pop-up display if the same alarm
condition occurs more than once to avoid duplication and clutter
of pop-up boxes. The pop-up boxes will cascade across the screen
from top-left. Operator acknowledgement of the alarm will be
recorded in the system log. Alarms will be cleared from the
screen after an hour.
The Email option can be used to call out a
service engineer, for example. The SMTP server is specified in
the Basic Configuration section.
SMS (Mobile Phone Text) messages can be
made by sending an e-mail to a suitably configured SMS
gateway. There are numerous such services on the Internet,
typically the To address will
contain an account ID for the SMS gateway account and the SMS
Phone number to contact, the body of the message will be sent
as the SMS Text.
This
option allows a control output to be made in response to the
event, for example turn on a cooling fan in the case of an
over temperature condition.
The three buttons control
whether the output is incremented or decremented by, or set
to, the specified value. In the case of a switch (that has
only on and off, 1or 0 values) if either Inc or Dec is set the switch will be
toggled. Inc and Dec are usually used to count events, with type set to a state variable. The output
effect can (optionally) change the output value when the event
transitions from on to off, the Off value is then used. If inc or dec is set the the opposite action occurs on the "to off"
transition, in this way the event can be used to hunt for a
set point. The On and Off Values are in units of Volts at the D/A outputs of the
Netcommander.
This
option allows a control script to be run in response to the
event. The script files will be familiar to the 'C' or Pascal
programmer, these are interpreted by VID to perform sequenced
tasks. This is an advanced topic and is explained here.
This
option causes another event to be enabled or disabled. For
example if one event causes a fire alarm to sound, this could
simultaneously disable another event that monitors the
unauthorized opening of emergency fire doors, thus preventing
intruder alarms on top of the fire alarm!
The
serial option allows a message to be sent out of the specified
serial COM port. This can be used to control any serially
connected device, an X.10 controller, for example, or could be
used for logging purposes to a serial printer. The message can
be provided in plain text or ASCII Hex for binary outputs.
Both views are always displayed. Only NetCommander text strings have names, and only VID effects require a COM
port to be configured.
The
SMS option allows a message to be sent on SMS. The SMS service
provider needs selecting, VodaFone, Orange etc. and the
destination phone number as well as the text to send, as
above, this can be specified in ASCII Hex. Only NetCommander SMS messages have names.
The Remote Events system (accessed from the [Edit][Remote
Events] Menu) has a more limited functionality
than the local system, but as the events are processed on the
NetCommander node, they can react to more transitory signals
that may otherwise fall between the VID software polls which
are typically once a second. The effects are limited to
"output", "email", "EvDis" and
"Serial", these have already been described above in
the Local Events Section. Again the
causes are very similar to those described Local
Events but are limited to four causes per event.
The System log records all actions and conditions that effect
the monitored system, All the operator's actions are logged,
switch settings, control knob movements, configuration changes
etc. System events (are optionally) logged. All log entries are
time stamped and in chronological order.
The log file name is
selected from the Basic Configuration form. A
log cycling scheme can also be selected, the following assumes a
selected log file name of "sys.log".
Log Cycling
None
file sys.log, the file may be deleted or
moved while VID is running.
Daily
files of the form sys_<year>_M<month>_D<day>.log
eg. sys_2004_M05_D17.log 17th May log
Weekly
files of the form sys_<year>_W<week number>.log
eg. sys_2004_W13.log ie. Week 13 log
Monthly
files of the form sys_<year>_M<month>.log eg. sys_2004_M07.log ie September's log
With the log folder's contents
listed in MicroSoft Explorer, clicking the "Name" tab
will sort the files in alphabetic (and as the name structures are
chosen to do so) Chronological order.
VID also maintains
chart data logs with a similar naming convention for time-cycled
logs. Top
VID Data Views
Raw Data View
This
option (available from the [View][Raw Data] menu) gives an overview of the data output from any one
NetCommander. Input data, output data, switch settings and
State variables may be viewed by checking the appropriate
radio button. Several views can be on-screen at once and all
are updated at the polling frequency (typically every second).
Switch values are reported as "On" (contact closed)
or "Off". Analogue values are scaled to 0.0 to 5.0
Volts, State variables are integers in the range 0 to 1023.
This is useful for debugging in determining which probes are
connected to which inputs. Checking the "Names" box
will display the Names associated with the Netcommander ports.
Message Data View
This option available from the [View]
[Messages] menu, gives a view of the messages
between VID and the selected node, The Console checkbox alters the display to handle Wireless UMON console
messages. Checking "All Nodes" will
show All messages into and out of VID, the Stop button will freeze the display, but data will be lost while
the screen is frozen. The TXQLen box shows
the number of message pending on the transmit queue for to the
node, it will generally be zero.
Configuration Summary Viewer
The Summary is an HTML document generated from the running
configuration when [view][summary] is executed.
The Summary lists the main points of the
configuration and is useful as an overview of the system or
printed record for study, the file is generated with the same
name and in the same directory as the VID files (/configs in
the installation directory, by default) but will have the
.html filename extension [view][summary] also launches the Web browser to enable viewing/printing the
file.
An example summary file can be seen here,
this is the summary for the example VID file examples.vid.
The client version of VID is a remote or slave viewer for a
VID master installation. The client will display the same
configuration file as the master, but not necessarily the same
page. The config form (left) is used to specify the IP
parameters to contact the master. The master is effectively a
web server, which servers all the images and logs to the
client and periodically the monitoring data. The IP port
specified must not clash with any existing server on the
master machine. The Client version is predominantly "read
only" and is meant for viewing rather than control.
Instrument logs are maintained locally by the client once
downloaded from the master but may not be as accurate as the
master copy due to a (potentially) lower data polling rate.
The Master is used as a proxy server to the Netcommanders
which may or may not be visible from the client location. The
client is designed to run without any installation, and does
not modify the windows registry, the executable may be run
from a memory stick for example in an internet cafe or guest
PC.