ethercat-linux/scripts/tc-task-rate.ps1

13 lines
505 B
PowerShell
Raw Normal View History

#Requires -RunAsAdministrator
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)
$rate = ($n2 - $n1) / 5.0
Write-Host ("nCycles rate = {0} Hz (n1={1} n2={2})" -f [math]::Round($rate,1), $n1, $n2)
$c.Dispose()