vab / 01_config_variables.html
bardd's picture
Upload 8 files
f6f4993 verified
<!DOCTYPE html>
<!--
================================================================================
FILE: 01_config_variables.html
PURPOSE: This file documents the FIRST section of the VBScript script:
the global variable definitions and configuration settings.
HOW TO READ THIS FILE:
- Everything inside <!-- ... --> is a PLAIN-ENGLISH EXPLANATION for you.
- Everything inside <pre class="code"> ... </pre> is the ACTUAL CODE.
- The yellow boxes are IMPORTANT NOTES.
- The green boxes are "what this does in plain English".
WHERE THIS CODE LIVES IN THE ORIGINAL FILE:
Original file: notes.txt
Lines: 1 — 186
================================================================================
-->
<html>
<head>
<meta charset="UTF-8">
<title>01 — Config Variables | Siemens Configurator</title>
<style>
body { font-family: Arial, sans-serif; background: #f5f5f5; color: #222; margin: 20px; }
h1 { color: #003366; border-bottom: 3px solid #003366; padding-bottom: 6px; }
h2 { color: #005599; margin-top: 30px; }
h3 { color: #007733; }
pre.code { background: #1e1e1e; color: #d4d4d4; padding: 16px; border-radius: 6px;
font-family: Consolas, monospace; font-size: 13px; overflow-x: auto;
border-left: 4px solid #569cd6; white-space: pre-wrap; }
.comment { color: #6a9955; } /* green - VBScript comment colour (same as ' comment) */
.keyword { color: #569cd6; } /* blue - VBScript keywords */
.string { color: #ce9178; } /* orange - string values */
.number { color: #b5cea8; } /* light green - numeric values */
.note { background: #fff8dc; border: 2px solid #f0c040; border-radius: 6px;
padding: 12px; margin: 10px 0; }
.explain { background: #e8f5e9; border: 2px solid #4caf50; border-radius: 6px;
padding: 12px; margin: 10px 0; }
.warn { background: #fff3e0; border: 2px solid #ff9800; border-radius: 6px;
padding: 12px; margin: 10px 0; }
nav { background: #003366; padding: 10px; border-radius: 6px; }
nav a { color: #fff; text-decoration: none; margin-right: 18px; font-size: 14px; }
nav a:hover { text-decoration: underline; }
table { border-collapse: collapse; width: 100%; margin: 10px 0; }
th { background: #003366; color: white; padding: 8px; }
td { border: 1px solid #ccc; padding: 7px; vertical-align: top; }
tr:nth-child(even) td { background: #f0f0f0; }
</style>
</head>
<body>
<nav>
<a href="index.html">📋 README</a>
<a href="01_config_variables.html">① Config</a>
<a href="02_utility_functions.html">② Utilities</a>
<a href="03_drive_configuration.html">③ Drive Config</a>
<a href="04_ui_html_builder.html">④ HTML Builder</a>
<a href="05_event_handlers.html">⑤ Event Handlers</a>
<a href="06_machine_data.html">⑥ Machine Data</a>
</nav>
<h1>① Global Configuration Variables</h1>
<p>
This is the <strong>first section</strong> of the script. It runs once when the script starts.
Think of it as the <em>"settings file"</em> — everything that controls how the script behaves
is set here. A commissioning engineer or developer would change values here to adapt the
script to a different machine.
</p>
<p>
In VBScript, lines beginning with a single quote <code>'</code> are <em>comments</em> — they
are ignored by the computer and only exist to explain the code.
</p>
<!-- ===========================================================================================
SECTION 1: VERSION AND MODE FLAGS
These tell the script which "flavour" it is running in.
=========================================================================================== -->
<h2>Section 1 — Version &amp; Mode Flags</h2>
<div class="explain">
<strong>What this does:</strong> Sets the script version number and controls
whether the Unwind/Rewind drives use <em>Servo mode</em> or <em>Vector mode</em>.
This version code (<code>S53b</code>) also appears in the on-screen title bar.
</div>
<pre class="code"><span class="keyword">If True Then</span> <span class="comment">' This "If True" block is just used to group the variable definitions together.
' It always runs — it's not a real condition.</span>
ConfigVersion=<span class="string">"S53b"</span> <span class="comment">' Version string shown in the HTML title. Change this if you update the script.</span>
<span class="comment">' History: S48=Nov2023, S49=Feb2024, S50=Apr2024, S51-S53=mid-2024</span>
<span class="comment">' S48 Revision - Part 'a' - Nov 2023 - Revised for vector mode support</span>
VectorMode=<span class="keyword">True</span> <span class="comment">' True = the script includes vector-mode drive support (for winders)</span>
</pre>
<!-- ===========================================================================================
SECTION 2: MACHINE TYPE SELECTION
=========================================================================================== -->
<h2>Section 2 — Machine Type &amp; PLC Type</h2>
<div class="explain">
<strong>What this does:</strong> Selects which type of machine this script is configured for.
Machine type affects how the <strong>Emergency Stop (E-stop)</strong> is handled.
PLC type affects the bit-width used for speed feedback signals.
</div>
<table>
<tr><th>Variable</th><th>Value</th><th>Meaning</th></tr>
<tr><td><code>ConfigMachineType</code></td><td>1</td><td>K5 Standard — instantaneous E-stop</td></tr>
<tr><td><code>ConfigMachineType</code></td><td>2</td><td>K5 Vision &amp; Expert — timed E-stop</td></tr>
<tr><td><code>ConfigMachineType</code></td><td>3</td><td>Selectable — engineer picks from UI dropdown</td></tr>
<tr><td><code>ConfigMachinePlcType</code></td><td>1</td><td>S7 Classic — 16-bit speed feedback</td></tr>
<tr><td><code>ConfigMachinePlcType</code></td><td>2</td><td>TIA Portal — 32-bit speed feedback</td></tr>
<tr><td><code>ConfigMachinePlcType</code></td><td>3</td><td>Selectable — engineer picks from UI dropdown</td></tr>
</table>
<pre class="code"> ConfigMachineType=<span class="number">3</span> <span class="comment">' ← CHANGE THIS to 1, 2, or 3 to hard-code the machine type
' or leave as 3 to let the engineer choose in the UI</span>
ConfigMachinePlcType=<span class="number">3</span> <span class="comment">' ← CHANGE THIS to 1 or 2 to hard-code PLC type
' or leave as 3 to let the engineer choose in the UI</span>
</pre>
<!-- ===========================================================================================
SECTION 3: OPTION FLAGS
=========================================================================================== -->
<h2>Section 3 — Option Flags</h2>
<div class="explain">
<strong>What this does:</strong> Toggles optional features on or off.
</div>
<pre class="code"> ConfigOption01_SetupComms=<span class="keyword">True</span> <span class="comment">' True = automatically configure communications telegram on the CU320
' False = skip comms setup (useful if comms is pre-configured)</span>
TelegramIsConfigured=<span class="keyword">False</span> <span class="comment">' Internal tracking flag. Set to False at start.
' Set to True by SetupComms() after it runs.
' Used in UpdateStatusDisplay to show "Complete" on step 3.</span>
ConfigOption02_Logfile=<span class="keyword">True</span> <span class="comment">' True = write a log script in Starter showing every parameter changed
' The log is stored as a script called "LogFile" in the Starter project.
' Very useful for auditing what the script changed.</span>
</pre>
<!-- ===========================================================================================
SECTION 4: WINDER DRIVE TYPE
=========================================================================================== -->
<h2>Section 4 — Winder Drive Type</h2>
<pre class="code"> ConfigWinderDriveType=<span class="number">3</span>
<span class="comment">' 1 = Servo mode — high-precision position/speed control (default for winders)
' 2 = Vector mode — torque-focused control (used for larger winder motors)
' 3 = Selectable — engineer picks in the UI at commissioning time
'
' NOTE: Changing winder type requires a factory reset of the Unwind and Rewind drives.
' The gains also change: Vector = Kp 5 / Ti 200ms, Servo = Kp 90 / Ti 50ms</span>
</pre>
<!-- ===========================================================================================
SECTION 5: LOGGING OPTIONS
=========================================================================================== -->
<h2>Section 5 — Logging / Debug Options</h2>
<pre class="code"> APP.LogActive = <span class="keyword">True</span> <span class="comment">' Enable Starter's internal application log</span>
APP.LogMode=<span class="string">"1"</span> <span class="comment">' Log mode 1 = errors only</span>
On Error GoTo 0 <span class="comment">' If there is a script error, stop and show the error to the user</span>
Set ThisProject=PROJ <span class="comment">' PROJ is the current open Starter project. We store a reference to it here.</span>
ParameterEchoToScreen=<span class="keyword">False</span> <span class="comment">' True = print every parameter write to the HTML status bar (very noisy, for debug only)</span>
CompressedCSVLogfile=<span class="keyword">False</span> <span class="comment">' True = remove spacing from log file (compact CSV format)
' False = padded columns for easy reading</span>
LogfilePadLength=<span class="number">15</span> <span class="comment">' If CompressedCSVLogfile=False, each column in the log file is padded to 15 characters wide</span>
ExtendedDiag = <span class="keyword">True</span> <span class="comment">' True = print extra diagnostic messages to the HTML status bar during configuration</span>
</pre>
<!-- ===========================================================================================
SECTION 6: NUM DRIVES AND DRIVE LIST
=========================================================================================== -->
<h2>Section 6 — Drive Count &amp; Drive List</h2>
<div class="explain">
<strong>What this does:</strong> Defines how many drives the script knows about
and assigns each one a name, a flag for whether it is a "line drive" (follows web speed),
and a communications slot number on the CU320.
</div>
<div class="note">
<strong>🔑 Key Rule:</strong> The <code>DriveList</code> names MUST exactly match
the Technology Object (TO) names inside the Starter project after the Identify Drives step.
If they don't match, the script cannot configure that drive.
</div>
<pre class="code"> NumDrives=<span class="number">13</span> <span class="comment">' Total number of drives in this project (changed from 8 → 12 → 13 over revisions)
' If you add a new drive, increment this and add a DriveList entry below.</span>
NumIdentList=<span class="number">16</span> <span class="comment">' Maximum rows in the Drive Identification table (allows up to 16 physical drives to appear)</span>
<span class="comment">' ── Drive List Definition ──────────────────────────────────────────────────────────────────────
' Each drive gets 3 things assigned:
' DriveList(n) = The name the drive must have in Starter (must match TO name)
' LineDrive(n) = True → drive speed is proportional to line (web) speed
' False → drive is a layarm (position-controlled, independent of line speed)
' DriveCommSlot(n) = Which slot on the CU320 this drive uses for communications
' (slots 1-10 are used; 0 = no comms needed)
' ──────────────────────────────────────────────────────────────────────────────────────────────</span>
DriveList(<span class="number">1</span>)=<span class="string">"Unwind"</span> : LineDrive(<span class="number">1</span>)=<span class="keyword">True</span> : DriveCommSlot(<span class="number">1</span>)=<span class="number">3</span> <span class="comment">'CU1 drive 1 (Unwind = winder, follows line)</span>
DriveList(<span class="number">2</span>)=<span class="string">"Draw"</span> : LineDrive(<span class="number">2</span>)=<span class="keyword">True</span> : DriveCommSlot(<span class="number">2</span>)=<span class="number">7</span> <span class="comment">'CU2 drive 5 (Draw = pulls web)</span>
DriveList(<span class="number">3</span>)=<span class="string">"Drum"</span> : LineDrive(<span class="number">3</span>)=<span class="keyword">True</span> : DriveCommSlot(<span class="number">3</span>)=<span class="number">3</span> <span class="comment">'CU2 drive 1 (Drum = main tension drum)</span>
DriveList(<span class="number">4</span>)=<span class="string">"DTR1wcr"</span> : LineDrive(<span class="number">4</span>)=<span class="keyword">True</span> : DriveCommSlot(<span class="number">4</span>)=<span class="number">8</span> <span class="comment">'CU2 drive 6 (DTR1 = Draw Tension Roller 1)</span>
DriveList(<span class="number">5</span>)=<span class="string">"DTR2cork"</span> : LineDrive(<span class="number">5</span>)=<span class="keyword">True</span> : DriveCommSlot(<span class="number">5</span>)=<span class="number">6</span> <span class="comment">'CU2 drive 4 (DTR2 = Draw Tension Roller 2)</span>
DriveList(<span class="number">6</span>)=<span class="string">"Rewind"</span> : LineDrive(<span class="number">6</span>)=<span class="keyword">True</span> : DriveCommSlot(<span class="number">6</span>)=<span class="number">4</span> <span class="comment">'CU1 drive 2 (Rewind = winder, follows line)</span>
DriveList(<span class="number">7</span>)=<span class="string">"UnwindLayarm"</span> : LineDrive(<span class="number">7</span>)=<span class="keyword">False</span> : DriveCommSlot(<span class="number">7</span>)=<span class="number">4</span> <span class="comment">'CU2 drive 2 (Unwind Layarm = arm, NOT a line drive)</span>
DriveList(<span class="number">8</span>)=<span class="string">"RewindLayarm"</span> : LineDrive(<span class="number">8</span>)=<span class="keyword">False</span> : DriveCommSlot(<span class="number">8</span>)=<span class="number">5</span> <span class="comment">'CU2 drive 3 (Rewind Layarm = arm, NOT a line drive)</span>
DriveList(<span class="number">9</span>)=<span class="string">"Draw2"</span> : LineDrive(<span class="number">9</span>)=<span class="keyword">True</span> : DriveCommSlot(<span class="number">9</span>)=<span class="number">10</span> <span class="comment">'CU2 drive 8 (added for Atom machine)</span>
DriveList(<span class="number">10</span>)=<span class="string">"Draw3"</span> : LineDrive(<span class="number">10</span>)=<span class="keyword">True</span> : DriveCommSlot(<span class="number">10</span>)=<span class="number">4</span> <span class="comment">'CU3 drive 2</span>
DriveList(<span class="number">11</span>)=<span class="string">"Drum2"</span> : LineDrive(<span class="number">11</span>)=<span class="keyword">True</span> : DriveCommSlot(<span class="number">11</span>)=<span class="number">9</span> <span class="comment">'CU2 drive 7</span>
DriveList(<span class="number">12</span>)=<span class="string">"Drum3"</span> : LineDrive(<span class="number">12</span>)=<span class="keyword">True</span> : DriveCommSlot(<span class="number">12</span>)=<span class="number">3</span> <span class="comment">'CU3 drive 1</span>
DriveList(<span class="number">13</span>)=<span class="string">"Draw4"</span> : LineDrive(<span class="number">13</span>)=<span class="keyword">True</span> : DriveCommSlot(<span class="number">13</span>)=<span class="number">5</span> <span class="comment">'CU3 drive 3 (added for Barbaro machine extra drives)</span>
</pre>
<!-- ===========================================================================================
SECTION 7: SETUP STEPS LIST
=========================================================================================== -->
<h2>Section 7 — Setup Step List</h2>
<div class="explain">
<strong>What this does:</strong> Defines the names of the 11 buttons shown
in the main HTML UI, in order from Step 0 to Step 10.
Each button triggers a specific action.
</div>
<pre class="code"> NumSteps=<span class="number">10</span> <span class="comment">' Number of steps (0 through 10) — changed from fewer steps in earlier revisions</span>
StepList(<span class="number">0</span>)=<span class="string">"Automatic Controller Reset"</span> <span class="comment">' Not a script step — reminder to run Starter's auto-reset</span>
StepList(<span class="number">1</span>)=<span class="string">"Identify Drives"</span> <span class="comment">' Shows drive table, lets engineer assign function names to drives</span>
StepList(<span class="number">2</span>)=<span class="string">"Edit Machine Data"</span> <span class="comment">' Shows machine data form (gear ratios, diameters etc.)</span>
StepList(<span class="number">3</span>)=<span class="string">"Config Infeed and CUs"</span> <span class="comment">' Runs ConfigureAllCUs() — sets up CU320 and infeed parameters</span>
StepList(<span class="number">4</span>)=<span class="string">"Config Drives"</span> <span class="comment">' Runs ConfigureAllDrives() — sets drive-specific parameters</span>
StepList(<span class="number">5</span>)=<span class="string">"Download"</span> <span class="comment">' Goes online and downloads all parameters to physical drives</span>
StepList(<span class="number">6</span>)=<span class="string">"Safety Integrated Setup"</span> <span class="comment">' Reminder step — engineer must do this manually in Starter</span>
StepList(<span class="number">7</span>)=<span class="string">"Motor Identification"</span> <span class="comment">' Reminder step — engineer must run motor ID routine manually</span>
StepList(<span class="number">8</span>)=<span class="string">"Post ID Drive Config"</span> <span class="comment">' Fixes parameters that motor ID overwrites (speed loop gains etc.)</span>
StepList(<span class="number">9</span>)=<span class="string">"Ram to Rom, Upload &amp; Save"</span> <span class="comment">' Copies drive RAM → ROM, then uploads from drives back to Starter project</span>
StepList(<span class="number">10</span>)=<span class="string">"Export File to HMI"</span> <span class="comment">' (Added in S53) Saves machine data to a file for the HMI panel</span>
</pre>
<!-- ===========================================================================================
SECTION 8: MOTOR TYPES LIST
=========================================================================================== -->
<h2>Section 8 — Non Drive-Cliq Motor List</h2>
<div class="explain">
<strong>What this does:</strong> Registers known motor types that don't have
DriveCliq (Siemens' plug-and-play motor interface). The script cannot auto-detect these,
so they must be listed here. Add new motors here if needed.
</div>
<pre class="code"> NumSiemensMotorList=<span class="number">2</span> <span class="comment">' How many non-cliq motors are listed below (change if you add more)</span>
<span class="comment">' Format: Code = Siemens motor order code. Description = model number string.</span>
<span class="comment">' Ratings are shown in the comment for reference only — not used by the script.</span>
SiemensMotorList_Code(<span class="number">1</span>)=<span class="number">28643</span> : SiemensMotorList_Description(<span class="number">1</span>)=<span class="string">"1FW6150-0xx05-4Fxx"</span> <span class="comment">'Ratings: 360 Nm, 20.3 kW</span>
SiemensMotorList_Code(<span class="number">2</span>)=<span class="number">28661</span> : SiemensMotorList_Description(<span class="number">2</span>)=<span class="string">"1FW6160-xxx10-2Pxx"</span> <span class="comment">'Ratings: 933 Nm, 38.9 kW</span>
</pre>
<!-- ===========================================================================================
SECTION 9: MACHINE MODEL / DEFAULT DATA TABLES
=========================================================================================== -->
<h2>Section 9 — Machine Default Data Tables</h2>
<div class="explain">
<strong>What this does:</strong> Stores pre-defined gear ratio and roller diameter values
for known machine types (K5 Expert, K5 Vision, Barbaro, Master).
If <code>DefaultingMode=1</code>, these values are loaded automatically when the script runs
for the first time on a fresh project — saving the engineer from typing everything manually.
</div>
<div class="warn">
<strong>⚠️ Note:</strong> <code>DefaultingMode</code> is currently set to <code>0</code>
(blank on first startup). Set it to <code>1</code> to use the tables below as defaults.
Change <code>MachineModel</code> to select which machine's data to use (0=Custom, 1=K5 Expert,
2=K5 Vision, 3=Barbaro, 4=Master).
</div>
<pre class="code"> MachineModel = <span class="number">1</span> <span class="comment">' 0=Custom, 1=K5 Expert, 2=K5 Vision, 3=Barbaro, 4=Master</span>
DefaultingMode = <span class="number">0</span> <span class="comment">' 0=Blank on first startup, 1=Use table below on first startup</span>
<span class="comment">' Columns below correspond to drives:
' UNW DRAW DRUM DTR1 DTR2 REW ULAY RLAY DRAW2 DRAW3 DRUM2 DRUM3 DRAW4
' [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]</span>
MachineK5EGearData = Array( <span class="number">1.0</span>, <span class="number">1.0</span>, <span class="number">2.857</span>, <span class="number">1.1</span>, <span class="number">1.0</span>, <span class="number">1.0</span>, <span class="number">89.2</span>, <span class="number">41.43</span>, <span class="number">1.0</span>, <span class="number">1.0</span>, <span class="number">2.857</span>, <span class="number">2.857</span>, <span class="number">1.0</span>)
MachineK5EDiamData = Array( <span class="number">165</span>, <span class="number">194</span>, <span class="number">700.0</span>, <span class="number">250</span>, <span class="number">326.2</span>, <span class="number">165</span>, <span class="number">81.49</span>, <span class="number">101.86</span>, <span class="number">197.4</span>, <span class="number">197.4</span>, <span class="number">900.0</span>, <span class="number">900.0</span>, <span class="number">197.4</span>)
<span class="comment">' ↑ K5 Expert defaults: Drum gear=2.857x, Layarms have high ratios (89x / 41x), etc.</span>
MachineK5vGearData = Array( <span class="number">1.0</span>, <span class="number">1.0</span>, <span class="number">2.857</span>, <span class="number">1.1</span>, <span class="number">1.0</span>, <span class="number">1.0</span>, <span class="number">89.2</span>, <span class="number">160.0</span>, <span class="number">1.0</span>, <span class="number">1.0</span>, <span class="number">2.857</span>, <span class="number">2.857</span>, <span class="number">1.0</span>)
MachineK5vDiamData = Array( <span class="number">165</span>, <span class="number">193.2</span>, <span class="number">700.0</span>, <span class="number">251.2</span>, <span class="number">184.2</span>, <span class="number">165</span>, <span class="number">81.49</span>, <span class="number">101.86</span>, <span class="number">197.4</span>, <span class="number">197.4</span>, <span class="number">900.0</span>, <span class="number">900.0</span>, <span class="number">197.4</span>)
<span class="comment">' ↑ K5 Vision: Rewind layarm gear ratio is 160 (different from Expert's 41.43)</span>
<span class="keyword">End If</span> <span class="comment">' End of the "If True" grouping block</span>
</pre>
<!-- ===========================================================================================
SECTION 10: MAIN SCRIPT STARTUP SEQUENCE
=========================================================================================== -->
<h2>Section 10 — Main Script Startup Sequence</h2>
<div class="explain">
<strong>What this does:</strong> After all variable definitions, these lines actually
<em>run the script</em> in order. Think of them as the "main function" of the program.
</div>
<pre class="code"><span class="comment">' ─────────────── START OF MAIN SCRIPT ───────────────</span>
CreateMainPage <span class="comment">' Opens an Internet Explorer (MSIE) window to host the HTML UI</span>
CreateMainPageDocument <span class="comment">' Writes all the HTML (buttons, tables, forms) into that window</span>
CheckMachineDataExists <span class="comment">' Checks if machine data was saved from a previous session and loads it</span>
CreateLogFile <span class="comment">' Creates a VBScript log file called "LogFile" inside Starter</span>
PrintToLogFile(<span class="string">"* Test log file ---- Date: "</span>&amp;Date) <span class="comment">' Writes today's date as the first log entry</span>
UpdateStatusDisplay <span class="comment">' Refreshes which buttons are greyed out / active based on current state</span>
EventHandler(MainPage) <span class="comment">' Enters the event loop — waits indefinitely for the user to click buttons</span>
<span class="comment">' ─────────────── END OF MAIN SCRIPT ─────────────────
' After EventHandler() returns (user closed the window), the script ends.</span>
</pre>
<hr>
<p style="color:#888; font-size:12px;">
← This file only covers lines 1–201 of the original notes.txt.
Continue to <a href="02_utility_functions.html">② Utility Functions</a>.
</p>
</body>
</html>