32 lines
1.6 KiB
PowerShell
32 lines
1.6 KiB
PowerShell
|
|
#Requires -RunAsAdministrator
|
||
|
|
#Requires -Version 5.1
|
||
|
|
$ErrorActionPreference = 'Continue'
|
||
|
|
$adsDll = 'C:\Program Files (x86)\Beckhoff\TwinCAT\3.1\Components\Base\v170\TwinCAT.Ads.dll'
|
||
|
|
Add-Type -Path $adsDll -ErrorAction Stop
|
||
|
|
$c = New-Object TwinCAT.Ads.TcAdsClient
|
||
|
|
$c.Connect('169.254.176.217.1.1', 851)
|
||
|
|
function ReadSym($name, $type) {
|
||
|
|
try {
|
||
|
|
$h = $c.CreateVariableHandle($name)
|
||
|
|
$v = $c.ReadAny($h, $type)
|
||
|
|
$c.DeleteVariableHandle($h)
|
||
|
|
return $v
|
||
|
|
} catch { return "ERR" }
|
||
|
|
}
|
||
|
|
Write-Host "nCycles = $(ReadSym 'GVL_Sync.nCycles' ([uint64]))"
|
||
|
|
Write-Host "bSync = $(ReadSym 'GVL_Sync.bSync' ([bool]))"
|
||
|
|
Write-Host "nMatchLag = $(ReadSym 'GVL_Sync.nMatchLag' ([int])) (bridge round-trip, PLC cycles)"
|
||
|
|
Write-Host "nMismatch = $(ReadSym 'GVL_Sync.nMismatch' ([int]))"
|
||
|
|
Write-Host "--- RTT (PLC cycles, 1 cycle = 1 ms) ---"
|
||
|
|
Write-Host "nRttCycles = $(ReadSym 'GVL_Sync.nRttCycles' ([int]))"
|
||
|
|
Write-Host "nRttMin = $(ReadSym 'GVL_Sync.nRttMin' ([int]))"
|
||
|
|
Write-Host "nRttMax = $(ReadSym 'GVL_Sync.nRttMax' ([int]))"
|
||
|
|
Write-Host "nRttSum = $(ReadSym 'GVL_Sync.nRttSum' ([int64]))"
|
||
|
|
Write-Host "nRttCount = $(ReadSym 'GVL_Sync.nRttCount' ([uint64]))"
|
||
|
|
Write-Host "--- EL1252 DC latch path delay ---"
|
||
|
|
Write-Host "nLatchCount = $(ReadSym 'GVL_Sync.nLatchCount' ([uint64]))"
|
||
|
|
Write-Host "nLatchDelayMin = $(ReadSym 'GVL_Sync.nLatchDelayMin' ([int])) us"
|
||
|
|
Write-Host "nLatchDelayMax = $(ReadSym 'GVL_Sync.nLatchDelayMax' ([int])) us"
|
||
|
|
Write-Host "nLatchDelaySum = $(ReadSym 'GVL_Sync.nLatchDelaySum' ([int64])) ns"
|
||
|
|
$c.Dispose()
|