⑥ Machine Data Management

The "Machine Data" is the set of engineering values that describe the physical machine — roller diameters, gear ratios, motor types, encoder types, speed loop gains, etc. It must be entered once per machine by the commissioning engineer and is then stored inside the Starter project for reuse.

Where Machine Data Is Stored

📌 Storage Location:
Machine data is NOT stored as a regular file. It is stored as a VBScript "Script" object inside the Starter project (accessible via Project Navigator → Scripts → "MachineData"). Its .Code property is a multi-line text string formatted as delimiter-separated values.

Machine Data Text Format

The Delimit() function (see below) splits the text by ' characters (row separator) and then by , characters (column separator).

' Row 1: Header comment (script version)
' SINAMICS Script Machine Data S53b
' Row 2: (reserved / not used)
' Row 3: Machine type, PLC type, machine name  (separated by commas)
' 2,2,K5Expert_V24G001
' Row 4: Supply voltage
' 400
' Row 5: Max line speed (m/min)
' 1000
' Row 6: Unwind layarm data (FW speed, FW speed enabled, max tension, max thrust)
' 150,1,250.0,3000
' Row 7: Rewind layarm data (same layout)
' 150,1,250.0,3000
' Rows 8 to 20: Per-drive data (one row per drive, drives 1-13)
' Format: GearRatio, Diameter, Speed, Torque, Direction, MotorType, Encoder, Gain, ResetTime, EnableConfig
' 1.0,165,,, 1, -1, 1, 90, 50, 1     ← Drive 1 (Unwind)
' 1.0,194,,, 1, -1, 0, 27, 40, 1     ← Drive 2 (Draw)
' 2.857,700.0,,, 1, -1, 0, 40, 80, 1 ← Drive 3 (Drum)
...
' Row 21: Winder drive type (0=unset, 1=Servo, 2=Vector)
' 1

Delimit() — CSV Parser

Function Delimit( InputString, MatchNumber, Delimiter )
What it does:
Splits a string by a delimiter character and returns the Nth piece. This is used to parse the machine data text format above.

Example: Delimit("400,1,Test", 2, ",") returns "1"
Example: Delimit("' 400" & Chr(13) & "' 480", 2, "'") returns " 480"
Function Delimit(InputString, MatchNumber, Delimiter)
    DelimitCount=1
    Dim DelimitArray
    DelimitArray = Split(InputString, Delimiter)  ' Split the string into an array using the delimiter
    Delimit = DelimitArray(MatchNumber-1)           ' Return the Nth element (1-based → 0-based)
End Function
' Note: returns empty string if MatchNumber > number of elements

CheckMachineDataExists

Sub CheckMachineDataExists
When called: Once at startup, immediately after the HTML page is built.
What it does:
Tries to load existing machine data. If no machine data exists yet (brand-new project), creates default values and saves them so subsequent loads work correctly.

Default Values Created on First Run

VariableDefault ValueMeaning
MachineData_Type2Machine uses timed E-stop (K5 Vision/Expert)
MachineData_PlcType2TIA Portal PLC
MachineData_Name"None"Machine name not set yet
MachineData_SupplyVoltage0Not set — must be entered by engineer
MachineData_LineSpeed1000.0Default 1000 m/min web speed
MachineData_GearRatio(1-13)VariesDefault gear ratios (1:1 for most, 2.857 for drums, blank for layarms)
MachineData_Gain(1) (Unwind)90 (Servo) or 5 (Vector)Speed loop proportional gain Kp
MachineData_ResetTime(1)50Speed loop integral time Ti in ms
MachineData_WinderDriveType0Not set — must be selected by engineer
Sub CheckMachineDataExists
    GetMachineData     ' Try to load existing data. Sets MachineDataExists=True or False.
    If Not MachineDataExists Then   ' No saved data found — set sensible defaults

        MachineData_Type=2          ' Default: timed E-stop
        MachineData_PlcType=2       ' Default: TIA Portal
        MachineData_Name="None"     ' No name yet
        MachineData_SupplyVoltage=0 ' Not set
        MachineData_Linespeed=1000.0

        ' ── Line drives: Unwind(1), Draw(2), DTR2(5), Rewind(6), Draw2(9), Draw3(10), Draw4(13)
        If (index=1) Or (Index=2) Or (Index=5) ... Then
            MachineData_GearRatio(Index)="1.0"    ' 1:1 gear ratio
            MachineData_RollDiameter(Index)=""   ' Blank — must be filled by engineer
            MachineData_Direction(Index)=0        ' Not yet set
        End If

        ' ── Drums: Drum(3), Drum2(11), Drum3(12)
        If (Index=3) Or (Index=11) Or (Index=12) Then
            MachineData_GearRatio(Index)="2.857"  ' Drums always use 2.857:1 ratio
        End If

        ' ── Layarms / DTR1: DTR1(4), UnwindLayarm(7), RewindLayarm(8)
        If (Index=4) Or (Index=7) Or (Index=8) Then
            MachineData_GearRatio(Index)=""    ' Will be read from drive schematic
        End If

        ' ── Default PID gains (changed based on drive type)
        MachineData_Gain(1)=90  : MachineData_ResetTime(1)=50  'Unwind Servo default
        MachineData_Gain(2)=27  : MachineData_ResetTime(2)=40  'Draw
        MachineData_Gain(3)=40  : MachineData_ResetTime(3)=80  'Drum
        MachineData_Gain(4)=15  : MachineData_ResetTime(4)=200 'DTR1
        MachineData_Gain(5)=20  : MachineData_ResetTime(5)=200 'DTR2
        MachineData_Gain(7)=0.8 : MachineData_ResetTime(7)=15  'Unwind Layarm
        MachineData_Gain(8)=0.8 : MachineData_ResetTime(8)=15  'Rewind Layarm

        SaveMachineData    ' Write the defaults to the Starter script so they persist
    End If
End Sub

LoadMachineData

Sub LoadMachineData
What it does:
Reads the "MachineData" script from the Starter project and parses the CSV-like text using the Delimit() function to fill all the MachineData_* array variables.
▼ Step 1: Try to access the "MachineData" script object in Starter ▼ Step 2: If the script doesn't exist, set MachineDataExists = False and return ▼ Step 3: If it does exist, read its .Code text and parse each row
Sub LoadMachineData
    Dim MachineDataScript   ' Will hold the Starter script object named "MachineData"
    Dim MDText               ' Will hold the text content of that script
    On Error Resume Next
    Set MachineDataScript = PROJ.Scripts.Item(MachineDataScriptName)

    If Err.Number<>0 Then
        MachineDataExists=False   ' Script doesn't exist = no data saved yet
    Else
        MachineDataExists=True
    End If

    If MachineDataExists Then
        MDText=MachineDataScript.Code   ' Read the entire text of the data script

        ' ── Parse Row 3: Machine type, PLC type, name
        MachineData_Type        = Delimit(Delimit(MDText,3,"'"),1,",")   ' Row 3, Column 1
        MachineData_PlcType     = Delimit(Delimit(MDText,3,"'"),2,",")   ' Row 3, Column 2
        MachineData_Name        = Delimit(Delimit(MDText,3,"'"),3,",")   ' Row 3, Column 3

        ' ── Parse Row 4: Supply voltage
        MachineData_SupplyVoltage = Int(Delimit(Delimit(MDText,4,"'"),1,","))

        ' ── Parse Row 5: Max line speed
        MachineData_LineSpeed = Int(Delimit("0"&Delimit(MDText,5,"'"),1,","))
        ' ↑ Note the "0" prepended — this prevents a crash if the row is blank (returns 0 instead of error)

        ' ── Parse Rows 8 to 20: Per-drive data
        For index=1 To NumDrives    ' Loop through all 13 drives
            ' Row number = index + 7 (drives start at row 8, which is index 1 → row 1+7=8)
            MachineData_GearRatio(Index)     = Delimit(Delimit(MDText,Index+7,"'"),1,",")
            MachineData_RollDiameter(Index)  = Delimit(Delimit(MDText,Index+7,"'"),2,",")
            MachineData_Speed(Index)         = Delimit(Delimit(MDText,Index+7,"'"),3,",")
            MachineData_Torque(Index)        = Delimit(Delimit(MDText,Index+7,"'"),4,",")
            MachineData_Direction(Index)     = Int("0"&Delimit(Delimit(MDText,Index+7,"'"),5,","))
            MachineData_MotorType(Index)     = Int(Delimit(Delimit(MDText,Index+7,"'"),6,","))
            MachineData_Encoder(Index)       = Int("0"&Delimit(Delimit(MDText,Index+7,"'"),7,","))
            MachineData_Gain(Index)          = Delimit(Delimit(MDText,Index+7,"'"),8,",")
            MachineData_ResetTime(Index)     = Delimit(Delimit(MDText,Index+7,"'"),9,",")
            MachineData_EnableConfig(Index)  = Delimit(Delimit(MDText,Index+7,"'"),10,",")
        Next

        ' ── Parse Row 6: Unwind layarm data
        MachineData_UnwindFWSpeed   = Delimit(Delimit(MDText,6,"'"),1,",")
        MachineData_UnwindFWSEnabled= Delimit(Delimit(MDText,6,"'"),2,",")
        MachineData_ULayarmMaxTension= Delimit(Delimit(MDText,6,"'"),3,",")
        MachineData_ULayarmMaxThrust = Delimit(Delimit(MDText,6,"'"),4,",")

        ' ── Parse Row 7: Rewind layarm data
        MachineData_RewindFWSpeed    = Delimit(Delimit(MDText,7,"'"),1,",")
        MachineData_RewindFWSEnabled = Delimit(Delimit(MDText,7,"'"),2,",")
        MachineData_RLayarmMaxTension= Delimit(Delimit(MDText,7,"'"),3,",")
        MachineData_RLayarmMaxThrust = Delimit(Delimit(MDText,7,"'"),4,",")

        ' ── Parse Row 21: Winder drive type (added in S52a)
        MachineData_WinderDriveType  = Delimit(Delimit(MDText,21,"'"),1,",")
    End If
    On Error GoTo 0
End Sub

DisplayMachineData

Sub DisplayMachineData
What it does:
Takes the values in the MachineData_* variables (filled by LoadMachineData) and pushes them into the HTML form fields so the engineer can see/edit them. Also:
Sub DisplayMachineData
    If MachineDataExists And ShowMachineData Then

        ' ── Apply forced machine settings ────────────────────────────────────────────
        '   If the config hard-codes the machine type, lock the dropdown
        If ConfigMachineType=1 Or ConfigMachineType=2 Then
            MachineData_Type=ConfigMachineType
            MainPage.Document.GetElementbyid("MachineType").Disabled=True   ' Grey out the dropdown
        End If

        ' ── Fill in header fields ────────────────────────────────────────────────────
        MainPage.Document.GetElementbyid("MachineName").Value        = MachineData_Name
        MainPage.Document.GetElementbyid("MachineType").Value        = MachineData_Type
        MainPage.Document.GetElementbyid("MachinePlcType").Value     = MachineData_PlcType
        MainPage.Document.GetElementbyid("SupplyVoltage").Value      = MachineData_SupplyVoltage
        MainPage.Document.GetElementbyid("WinderDriveType").Value    = MachineData_WinderDriveType
        MainPage.Document.GetElementbyid("LineSpeed").Value          = MachineData_LineSpeed

        ' ── Fill in per-drive table ──────────────────────────────────────────────────
        For index=1 To NumDrives
            MainPage.Document.GetElementbyid("GearRatio_"&Index).Value  = MachineData_GearRatio(Index)
            MainPage.Document.GetElementbyid("Diameter_"&Index).Value   = MachineData_RollDiameter(Index)
            MainPage.Document.GetElementbyid("Speed_"&Index).Value      = MachineData_Speed(Index)
            MainPage.Document.GetElementbyid("Direction_"&Index).Value  = MachineData_Direction(Index)
            MainPage.Document.GetElementbyid("MotorType_"&Index).Value  = MachineData_MotorType(Index)
            MainPage.Document.GetElementbyid("Torque_"&Index).Value     = MachineData_Torque(Index)
            MainPage.Document.GetElementbyid("Encoder_"&Index).Value    = MachineData_Encoder(Index)
            MainPage.Document.GetElementbyid("Gain_"&Index).Value       = MachineData_Gain(Index)
            MainPage.Document.GetElementbyid("ResetTime_"&Index).Value  = MachineData_ResetTime(Index)
            MainPage.Document.GetElementbyid("Enable_"&Index).Checked   = Not (MachineData_EnableConfig(Index)=0)

            ' ── Override motor type / torque from DriveCliq data if drive is in project ──
            If DrivePresent Then
                If DriveTo.Parameters(302,0)>0 Then    ' p302 > 0 = DriveCliq motor data identified
                    MachineData_MotorType(Index)=-1      ' -1 = DriveCliq motor (auto-detected)
                    MainPage.Document.GetElementbyid("MotorType_"&Index).Value=-1
                    MainPage.Document.GetElementbyid("Torque_"&Index).Value=DriveTo.Parameters(333,0)  ' p333 = rated torque from nameplate
                    MainPage.Document.GetElementbyid("MotorType_"&Index).Disabled=True               ' Lock it
                ElseIf DriveTo.Parameters(302,0)=0 And DriveTo.Parameters(304,0)>0 Then
                    MachineData_MotorType(Index)=-2      ' -2 = pre-configured (wizard), non-cliq
                End If
            End If
        Next

        ' ── Fill in layarm fields ────────────────────────────────────────────────────
        MainPage.Document.GetElementbyid("MaxSpeed_1").Value              = MachineData_UnwindFWSpeed
        MainPage.Document.GetElementbyid("MaxSpeedEnable_1").Checked       = (MachineData_UnwindFWSEnabled=1)
        MainPage.Document.GetElementbyid("UnwLayarmMaxTensSetpoint").Value  = MachineData_ULayarmMaxTension
        MainPage.Document.GetElementbyid("UnwLayarmMaxThrust").Value        = MachineData_ULayarmMaxThrust
        MainPage.Document.GetElementbyid("MaxSpeed_6").Value              = MachineData_RewindFWSpeed
        MainPage.Document.GetElementbyid("MaxSpeedEnable_6").Checked       = (MachineData_RewindFWSEnabled=1)
        MainPage.Document.GetElementbyid("RewLayarmMaxTensSetpoint").Value  = MachineData_RLayarmMaxTension
        MainPage.Document.GetElementbyid("RewLayarmMaxThrust").Value        = MachineData_RLayarmMaxThrust

        Call MainPage.Document.GetElementbyid("RewLayarmMaxThrust").onblur   ' Trigger the onblur event to fire the JS update() function
    End If
End Sub

SaveMachineData

Sub SaveMachineData
What it does:
The reverse of LoadMachineData. Reads the current HTML form values (if the Machine Data form is visible) into the MachineData_* arrays, then rebuilds the CSV text and writes it back to the "MachineData" script object in Starter.
Sub SaveMachineData
    Dim MachineDataScript
    On Error Resume Next
    Set MachineDataScript = PROJ.Scripts.Item(MachineDataScriptName)

    If Err.Number<>0 Then   ' Script doesn't exist yet — create it
        PROJ.Scripts.Add(MachineDataScriptName)
        Set MachineDataScript = PROJ.Scripts.Item(MachineDataScriptName)
    End If

    If ShowMachineData Then   ' Only read from the screen if the form is currently visible
        MachineData_Name         = MainPage.Document.GetElementbyid("MachineName").Value
        MachineData_Type         = MainPage.Document.GetElementbyid("MachineType").Value
        MachineData_PlcType      = MainPage.Document.GetElementbyid("MachinePlcType").Value
        MachineData_SupplyVoltage= MainPage.Document.GetElementbyid("SupplyVoltage").Value
        MachineData_LineSpeed    = MainPage.Document.GetElementbyid("LineSpeed").Value
        '... (read all 10 fields for each of the 13 drives)
    End If

    ' ── Build the CSV text and write it ──────────────────────────────────────────
    '   Each .Code = ... line appends another row to the script text'
    MachineDataScript.Code  = "' SINAMICS Script Machine Data " & ConfigVersion & vbCrLf
    MachineDataScript.Code = MachineDataScript.Code & "' " & vbCrLf                          ' Row 2 (blank)
    MachineDataScript.Code = MachineDataScript.Code & "' " & MachineData_Type & "," & MachineData_PlcType & "," & MachineData_Name & vbCrLf  ' Row 3
    MachineDataScript.Code = MachineDataScript.Code & "' " & MachineData_SupplyVoltage & vbCrLf  ' Row 4
    MachineDataScript.Code = MachineDataScript.Code & "' " & MachineData_LineSpeed & vbCrLf       ' Row 5
    ' Row 6: Unwind layarm
    MachineDataScript.Code = MachineDataScript.Code & "' " & MachineData_UnwindFWSpeed & "," & MachineData_UnwindFWSEnabled & "," & MachineData_ULayarmMaxTension & "," & MachineData_ULayarmMaxThrust & vbCrLf
    ' Row 7: Rewind layarm
    MachineDataScript.Code = MachineDataScript.Code & "' " & MachineData_RewindFWSpeed & "," & MachineData_RewindFWSEnabled & "," & MachineData_RLayarmMaxTension & "," & MachineData_RLayarmMaxThrust & vbCrLf
    ' Rows 8-20: Per-drive data
    For index=1 To NumDrives
        MachineDataScript.Code = MachineDataScript.Code & "' " & _
            MachineData_GearRatio(index) & "," & MachineData_RollDiameter(index) & "," & _
            MachineData_Speed(index) & "," & MachineData_Torque(index) & "," & _
            MachineData_Direction(index) & "," & MachineData_MotorType(index) & "," & _
            MachineData_Encoder(index) & "," & MachineData_Gain(index) & "," & _
            MachineData_ResetTime(index) & "," & MachineData_EnableConfig(index) & vbCrLf
    Next
    ' ... (winder type goes to row 21)
End Sub

Complete Machine Data Variable Reference

Variable NameHTML Form IDSiemens Parameter Written
MachineData_NameMachineNameNot written to drives (display only)
MachineData_TypeMachineTypep2126[2] on CU (machine E-stop type)
MachineData_PlcTypeMachinePlcTypep2126[3] on CU (PLC speed word width)
MachineData_SupplyVoltageSupplyVoltagep210 on each infeed and drive
MachineData_LineSpeedLineSpeedUsed to calculate p2000 (reference speed) for each drive
MachineData_GearRatio(n)GearRatio_nUsed to calculate p2000 and p1082
MachineData_RollDiameter(n)Diameter_nUsed to calculate p2000 and p1082 (mm)
MachineData_Speed(n)Speed_n (read-only, calculated)p2000[0] = reference speed AND p1082 = max speed
MachineData_Direction(n)Direction_np1821 (CW=0, CCW=1)
MachineData_MotorType(n)MotorType_nDetermines which parameters to write for motor characterization
MachineData_Encoder(n)Encoder_nDetermines encoder type settings (p400 series)
MachineData_Torque(n)Torque_np2003 (reference torque in Nm)
MachineData_Gain(n)Gain_np1460[0] (speed loop proportional gain Kp)
MachineData_ResetTime(n)ResetTime_np1462[0] (speed loop integral time Ti in ms)
MachineData_EnableConfig(n)Enable_n (checkbox)If 0, skip configuring this drive entirely
MachineData_WinderDriveTypeWinderDriveType1=Servo → Kp=90, Ti=50ms; 2=Vector → Kp=5, Ti=50ms
MachineData_ULayarmMaxThrustUnwLayarmMaxThrustp2126[14] on CU (max layarm force in Newtons)

← You have reached the end of the documentation. Return to README.