Idle Scanning¶
A new feature in version 16.3 of the Pinchot API is Idle Scanning.
Definition
Idle Scanning will turn off scanning, or reduce scanning frequency, if the encoder has not moved for a specific time (1 second), i.e. when the line is not moving. The ScanHeads enter an "Idle" state and will produce profiles only in intervals specified by IdlePeriod, or not produce profiles at all when the IdlePeriod is set to zero. The ScanHeads will resume scanning at the regular intervals immediately after detecting encoder movement.
With Idle Scanning, you can reduce network load and save laser life, while not missing profiles once the chain has started moving again.
Idle Scanning will reduce the amount of profiles sent to your optimizer software. In previous versions of the API, your software was responsible for determining the position of a profile, and discarding it if the encoder had not moved since the last profile.
Important Notes on Idle Scanning¶
When reading out profiles in a scan loop, using either one of the TryTakeNextProfile()
overloads in C# or jsScanHeadWaitUntilProfilesAvailable()
in C/C++, you normally specify a timeout as an argument. When Idle Scanning is enabled, and the chain is stopped, you will likely hit the timeout, as no new profiles are arriving. Your code should be prepared for that situation, and not treat it as an error condition. There are two ways to deal with this situation:
-
In response to a timeout, you can check the status of the ScanHead via
RequestStatus()
in C# orGetStatusMessage()
in C/C++. In the resulting status, the fieldLaserDisabled
is set to true during the time the ScanHead is in Idle Mode. This check should only be performed when a timeout occurs and not as part of the normal scan loop, as it adds additional network rountrips. If you discover that the ScanHead is indeed in Idle Mode, you can re-enter the profile readout via the above functions, and continue to do so until you receive profiles again. -
You can instruct the ScanHeads to send profiles at a reduced rate while in Idle Mode. If your timeout value is larger than the time period set for Idle Scanning, you will not hit the timeout, however, the profiles received will all be at the same encoder value and you have to discard them yourself, as before.
The same considerations apply to scanning in Frame Mode. You will need to handle timeouts in a similar manner.
Using Idle Scanning¶
To enable Idle Scanning with a reduced rate of profiles:
using var scanSystem = new ScanSystem(ScanSystemUnits.Inches);
var options = new StartScanningOptions(){
... // dataformat, min scan period, etc
IdlePeriodUs = 1000 // enable idle scanning and send a profile every millisecond while in Idle Mode
}
scanSystem.StartScanning(options);
To enable Idle Scanning with completely stopped profiles:
using var scanSystem = new ScanSystem(ScanSystemUnits.Inches);
var options = new StartScanningOptions(){
... // dataformat, min scan period, etc
IdlePeriodUs = 0 // enable idle scanning and don't send any profiles while in Idle mode
}
scanSystem.StartScanning(options);
using var scanSystem = new ScanSystem(ScanSystemUnits.Inches);
var options = new StartScanningOptions(){
... // dataformat, min scan period, etc
IdlePeriodUs = null // disable idle scanning completely, you will receive profiles
// at the normal rate even while the encoder is stopped.
}
scanSystem.StartScanning(options);
To enable Idle Scanning with a reduced rate of profiles:
jsScanSystem scan_system = jsScanSystemCreate(JS_UNITS_INCHES);
jsScanSystemSetIdleScanPeriod(scan_system, 1000);
// enable idle scanning and send a profile every millisecond while in Idle Mode
jsScanSystem scan_system = jsScanSystemCreate(JS_UNITS_INCHES);
// enable idle scanning and don't send any profiles while in Idle mode
jsScanSystemSetIdleScanPeriod(scan_system, 0);
To disable Idle Scanning:
jsScanSystem scan_system = jsScanSystemCreate(JS_UNITS_INCHES);
// by default, idle scanning disabled on a new ScanSystem, so the following call is redundant
jsScanSystemDisableIdleScanning(scan_system);
// disable idle scanning completely, you will receive profiles
// at the normal rate even while the encoder is stopped.
Note
The actual IdlePeriod will be padded to be a multiple of the scan system's scan period. This means that it may slightly differ from the requested IdlePeriod, but never by more than a scan period.
How does a ScanHead determine Idle state?¶
- The ScanHeads continuously evaluate the value of the main encoder, and if Idle Scanning is enabled, will enter the Idle state when the value has not changed in one second.
- A ScanHead will exit the Idle state and resume sending profiles when more than 3 encoder ticks (in either direction) occurred within one millisecond.
- Encoder jitter (randomly changing encoder values of +/- 1 tick, due to e.g. vibration) will not cause the ScanHead to leave Idle mode.