#Requires -Version 5.1 <# .SYNOPSIS Configure EL6695 PDOs to 1024 bytes via TcSysManCmdHelper ConsumeXml. .DESCRIPTION Uses TcSysManCmdHelper.exe (Beckhoff CLI tool) to inject the PDO configuration into the .tsproj file, then activate + save. The ConsumeXml payload sets: 0x1608 (IO Outputs) → 0x7000:01 ARRAY[0..1023] OF BYTE (SyncMan 2) 0x1A08 (IO Inputs) → 0x6000:01 ARRAY[0..1023] OF BYTE (SyncMan 3) .PARAMETER ProjectDir Directory containing the .tsproj file. .PARAMETER PayloadBytes PDO payload size in bytes. Default: 1024. .PARAMETER Activate After configuring, also activate + save. Default: $true. .EXAMPLE .\tc-configure-pdo.ps1 .\tc-configure-pdo.ps1 -PayloadBytes 512 .\tc-configure-pdo.ps1 -Activate:$false #> [CmdletBinding()] param( [string]$ProjectDir = $null, [int]$PayloadBytes = 1024, [switch]$Activate = $true ) . "$PSScriptRoot\tc-common.ps1" if (-not $ProjectDir) { $ProjectDir = Split-Path $script:DefaultTsproj -Parent } $tsproj = Join-Path $ProjectDir "TwinCAT_EL6695_Secondary.tsproj" $helper = "C:\Program Files (x86)\Beckhoff\TwinCAT\3.1\Components\Base\TcSysManCmdHelper.exe" New-Log $script:DefaultLogDir $LogFile = Join-Path $script:DefaultLogDir "configure-pdo.log" Write-Log "=== Configure EL6695 PDO ${PayloadBytes}B ===" $LogFile Write-Log "Project: $tsproj" $LogFile if (-not (Test-Path $helper)) { Write-Log "FATAL: TcSysManCmdHelper.exe not found" $LogFile; exit 1 } if (-not (Test-Path $tsproj)) { Write-Log "FATAL: .tsproj not found" $LogFile; exit 1 } # Backup $bak = $tsproj + ".bak_" + (Get-Date -Format 'yyyyMMdd_HHmmss') Copy-Item $tsproj $bak -Force Write-Log "Backup: $bak" $LogFile # ConsumeXml payload $lastSub = "{0:X4}" -f ($PayloadBytes - 1) $xml = @" ARRAY [0..$lastSub] OF BYTE ARRAY [0..$lastSub] OF BYTE "@ # Build argument list $argList = @( "-v", "4026.0", "-o", $tsproj, "-x", $script:El6695Path, $xml ) if ($Activate) { $argList += @("-a", "-s", $tsproj) } Write-Log "Running TcSysManCmdHelper..." $LogFile $proc = Start-Process -FilePath $helper -ArgumentList $argList -Wait -PassThru -NoNewWindow Write-Log "Exit code: $($proc.ExitCode)" $LogFile if ($proc.ExitCode -ne 0) { Write-Log "WARNING: non-zero exit. Check TwinCAT System Manager messages." $LogFile } Write-Log "=== Configure PDO complete ===" $LogFile