- 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)
16 lines
602 B
PowerShell
16 lines
602 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', 10000)
|
|
Write-Host "before: $($c.ReadState().AdsState)"
|
|
try {
|
|
$c.WriteControl((New-Object TwinCAT.Ads.StateInfo([TwinCAT.Ads.AdsState]::Run, 0)))
|
|
Write-Host "WriteControl Run sent"
|
|
} catch { Write-Host "err: $_" }
|
|
$c.Dispose()
|
|
Start-Sleep 10
|
|
$c2 = New-Object TwinCAT.Ads.TcAdsClient
|
|
$c2.Connect('169.254.176.217.1.1', 10000)
|
|
Write-Host "after: $($c2.ReadState().AdsState)"
|
|
$c2.Dispose()
|