is a PLAIN-ENGLISH EXPLANATION for you. - Everything inside
 ... 
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 ================================================================================ --> window.huggingface={variables:{"SPACE_CREATOR_USER_ID":"6629298660c08c28bcf66b16"}};d> 01 — Config Variables | Siemens Configurator

① Global Configuration Variables

This is the first section of the script. It runs once when the script starts. Think of it as the "settings file" — 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.

In VBScript, lines beginning with a single quote ' are comments — they are ignored by the computer and only exist to explain the code.

Section 1 — Version & Mode Flags

What this does: Sets the script version number and controls whether the Unwind/Rewind drives use Servo mode or Vector mode. This version code (S53b) also appears in the on-screen title bar.
If True Then   ' This "If True" block is just used to group the variable definitions together.
                 ' It always runs — it's not a real condition.

    ConfigVersion="S53b"  ' Version string shown in the HTML title. Change this if you update the script.
                          ' History: S48=Nov2023, S49=Feb2024, S50=Apr2024, S51-S53=mid-2024

    ' S48 Revision - Part 'a' - Nov 2023 - Revised for vector mode support
    VectorMode=True       ' True = the script includes vector-mode drive support (for winders)

Section 2 — Machine Type & PLC Type

What this does: Selects which type of machine this script is configured for. Machine type affects how the Emergency Stop (E-stop) is handled. PLC type affects the bit-width used for speed feedback signals.
VariableValueMeaning
ConfigMachineType1K5 Standard — instantaneous E-stop
ConfigMachineType2K5 Vision & Expert — timed E-stop
ConfigMachineType3Selectable — engineer picks from UI dropdown
ConfigMachinePlcType1S7 Classic — 16-bit speed feedback
ConfigMachinePlcType2TIA Portal — 32-bit speed feedback
ConfigMachinePlcType3Selectable — engineer picks from UI dropdown
    ConfigMachineType=3        ' ← 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
    ConfigMachinePlcType=3     ' ← CHANGE THIS to 1 or 2 to hard-code PLC type
                                 '   or leave as 3 to let the engineer choose in the UI

Section 3 — Option Flags

What this does: Toggles optional features on or off.
    ConfigOption01_SetupComms=True    ' True = automatically configure communications telegram on the CU320
                                        ' False = skip comms setup (useful if comms is pre-configured)

    TelegramIsConfigured=False          ' 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.

    ConfigOption02_Logfile=True        ' 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.

Section 4 — Winder Drive Type

    ConfigWinderDriveType=3
    ' 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

Section 5 — Logging / Debug Options

    APP.LogActive = True               ' Enable Starter's internal application log
    APP.LogMode="1"                    ' Log mode 1 = errors only
    On Error GoTo 0                    ' If there is a script error, stop and show the error to the user
    Set ThisProject=PROJ               ' PROJ is the current open Starter project. We store a reference to it here.

    ParameterEchoToScreen=False        ' True = print every parameter write to the HTML status bar (very noisy, for debug only)
    CompressedCSVLogfile=False         ' True = remove spacing from log file (compact CSV format)
                                        ' False = padded columns for easy reading
    LogfilePadLength=15                ' If CompressedCSVLogfile=False, each column in the log file is padded to 15 characters wide
    ExtendedDiag = True               ' True = print extra diagnostic messages to the HTML status bar during configuration

Section 6 — Drive Count & Drive List

What this does: 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.
🔑 Key Rule: The DriveList 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.
    NumDrives=13    ' 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.

    NumIdentList=16  ' Maximum rows in the Drive Identification table (allows up to 16 physical drives to appear)

    ' ── 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)
    ' ──────────────────────────────────────────────────────────────────────────────────────────────

    DriveList(1)="Unwind"       : LineDrive(1)=True   : DriveCommSlot(1)=3   'CU1 drive 1 (Unwind = winder, follows line)
    DriveList(2)="Draw"         : LineDrive(2)=True   : DriveCommSlot(2)=7   'CU2 drive 5 (Draw = pulls web)
    DriveList(3)="Drum"         : LineDrive(3)=True   : DriveCommSlot(3)=3   'CU2 drive 1 (Drum = main tension drum)
    DriveList(4)="DTR1wcr"      : LineDrive(4)=True   : DriveCommSlot(4)=8   'CU2 drive 6 (DTR1 = Draw Tension Roller 1)
    DriveList(5)="DTR2cork"     : LineDrive(5)=True   : DriveCommSlot(5)=6   'CU2 drive 4 (DTR2 = Draw Tension Roller 2)
    DriveList(6)="Rewind"       : LineDrive(6)=True   : DriveCommSlot(6)=4   'CU1 drive 2 (Rewind = winder, follows line)
    DriveList(7)="UnwindLayarm" : LineDrive(7)=False  : DriveCommSlot(7)=4   'CU2 drive 2 (Unwind Layarm = arm, NOT a line drive)
    DriveList(8)="RewindLayarm" : LineDrive(8)=False  : DriveCommSlot(8)=5   'CU2 drive 3 (Rewind Layarm = arm, NOT a line drive)
    DriveList(9)="Draw2"        : LineDrive(9)=True   : DriveCommSlot(9)=10  'CU2 drive 8 (added for Atom machine)
    DriveList(10)="Draw3"       : LineDrive(10)=True  : DriveCommSlot(10)=4  'CU3 drive 2
    DriveList(11)="Drum2"       : LineDrive(11)=True  : DriveCommSlot(11)=9  'CU2 drive 7
    DriveList(12)="Drum3"       : LineDrive(12)=True  : DriveCommSlot(12)=3  'CU3 drive 1
    DriveList(13)="Draw4"       : LineDrive(13)=True  : DriveCommSlot(13)=5  'CU3 drive 3 (added for Barbaro machine extra drives)

Section 7 — Setup Step List

What this does: 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.
    NumSteps=10    ' Number of steps (0 through 10) — changed from fewer steps in earlier revisions

    StepList(0)="Automatic Controller Reset"  ' Not a script step — reminder to run Starter's auto-reset
    StepList(1)="Identify Drives"             ' Shows drive table, lets engineer assign function names to drives
    StepList(2)="Edit Machine Data"           ' Shows machine data form (gear ratios, diameters etc.)
    StepList(3)="Config Infeed and CUs"        ' Runs ConfigureAllCUs() — sets up CU320 and infeed parameters
    StepList(4)="Config Drives"               ' Runs ConfigureAllDrives() — sets drive-specific parameters
    StepList(5)="Download"                    ' Goes online and downloads all parameters to physical drives
    StepList(6)="Safety Integrated Setup"     ' Reminder step — engineer must do this manually in Starter
    StepList(7)="Motor Identification"        ' Reminder step — engineer must run motor ID routine manually
    StepList(8)="Post ID Drive Config"        ' Fixes parameters that motor ID overwrites (speed loop gains etc.)
    StepList(9)="Ram to Rom, Upload & Save"   ' Copies drive RAM → ROM, then uploads from drives back to Starter project
    StepList(10)="Export File to HMI"         ' (Added in S53) Saves machine data to a file for the HMI panel

Section 8 — Non Drive-Cliq Motor List

What this does: 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.
    NumSiemensMotorList=2    ' How many non-cliq motors are listed below (change if you add more)

    ' Format: Code = Siemens motor order code. Description = model number string.
    ' Ratings are shown in the comment for reference only — not used by the script.
    SiemensMotorList_Code(1)=28643 : SiemensMotorList_Description(1)="1FW6150-0xx05-4Fxx"  'Ratings: 360 Nm, 20.3 kW
    SiemensMotorList_Code(2)=28661 : SiemensMotorList_Description(2)="1FW6160-xxx10-2Pxx"  'Ratings: 933 Nm, 38.9 kW

Section 9 — Machine Default Data Tables

What this does: Stores pre-defined gear ratio and roller diameter values for known machine types (K5 Expert, K5 Vision, Barbaro, Master). If DefaultingMode=1, these values are loaded automatically when the script runs for the first time on a fresh project — saving the engineer from typing everything manually.
⚠️ Note: DefaultingMode is currently set to 0 (blank on first startup). Set it to 1 to use the tables below as defaults. Change MachineModel to select which machine's data to use (0=Custom, 1=K5 Expert, 2=K5 Vision, 3=Barbaro, 4=Master).
    MachineModel = 1      ' 0=Custom, 1=K5 Expert, 2=K5 Vision, 3=Barbaro, 4=Master
    DefaultingMode = 0   ' 0=Blank on first startup, 1=Use table below on first startup

    ' 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]

    MachineK5EGearData = Array( 1.0, 1.0, 2.857, 1.1, 1.0,  1.0, 89.2, 41.43, 1.0, 1.0, 2.857, 2.857, 1.0)
    MachineK5EDiamData = Array( 165, 194, 700.0, 250, 326.2, 165, 81.49, 101.86, 197.4, 197.4, 900.0, 900.0, 197.4)
    ' ↑ K5 Expert defaults: Drum gear=2.857x, Layarms have high ratios (89x / 41x), etc.

    MachineK5vGearData = Array( 1.0, 1.0, 2.857, 1.1, 1.0, 1.0, 89.2, 160.0, 1.0, 1.0, 2.857, 2.857, 1.0)
    MachineK5vDiamData = Array( 165, 193.2, 700.0, 251.2, 184.2, 165, 81.49, 101.86, 197.4, 197.4, 900.0, 900.0, 197.4)
    ' ↑ K5 Vision: Rewind layarm gear ratio is 160 (different from Expert's 41.43)
End If  ' End of the "If True" grouping block

Section 10 — Main Script Startup Sequence

What this does: After all variable definitions, these lines actually run the script in order. Think of them as the "main function" of the program.
' ─────────────── START OF MAIN SCRIPT ───────────────

CreateMainPage           ' Opens an Internet Explorer (MSIE) window to host the HTML UI
CreateMainPageDocument   ' Writes all the HTML (buttons, tables, forms) into that window
CheckMachineDataExists   ' Checks if machine data was saved from a previous session and loads it
CreateLogFile            ' Creates a VBScript log file called "LogFile" inside Starter
PrintToLogFile("* Test log file ---- Date: "&Date)  ' Writes today's date as the first log entry
UpdateStatusDisplay      ' Refreshes which buttons are greyed out / active based on current state
EventHandler(MainPage)   ' Enters the event loop — waits indefinitely for the user to click buttons

' ─────────────── END OF MAIN SCRIPT ─────────────────
' After EventHandler() returns (user closed the window), the script ends.

← This file only covers lines 1–201 of the original notes.txt. Continue to ② Utility Functions.