ethercat-linux/scripts/tc-ads-quick.ps1
Tony Cao aabfe31526 Enable EL6695 DC-Synchron mode (AssignActivate 0x320)
- DC selection must use the structured <Dc><Data AssignActivate/> XSD
  element; legacy DcData hex writes get normalized to zeros by TwinCAT
- TwinCAT converts it to DcData '2003...' (0x0320) on save: SYNC0/SYNC1
  cyclic + SYNC0 activate for the bridge
- Verified: clean activation, ticker OP, bSync=True, 90k cycles 0 errors,
  timing unchanged (jitter 7.3us mean)
- docs: pitfall #10 (DC selection method)
2026-08-09 15:32:56 +08:00

14 lines
565 B
PowerShell

$ErrorActionPreference = 'Continue'
Add-Type -Path 'C:\Program Files (x86)\Beckhoff\TwinCAT\3.1\Components\Base\v170\TwinCAT.Ads.dll'
$c = New-Object TwinCAT.Ads.TcAdsClient
$c.Connect('169.254.176.217.1.1', 851)
$h = $c.CreateVariableHandle('GVL_Sync.nCycles')
$n1 = $c.ReadAny($h, [uint64])
Start-Sleep -Milliseconds 5000
$n2 = $c.ReadAny($h, [uint64])
$c.DeleteVariableHandle($h)
Write-Host ("nCycles rate = {0} Hz" -f [math]::Round(($n2 - $n1) / 5.0, 1))
$bs = $c.ReadAny($c.CreateVariableHandle('GVL_Sync.bSync'), [bool])
Write-Host "bSync = $bs"
$c.Dispose()