Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Current »

(available in Software Version 4.10 and newer)

Introduction

The Quadrature Decoder provides an interface between an external Incremental Encoder (Linear or Rotary) and the Sensor Trigger Control Block. The actual Incremental Encoder is connected to the Quadrature Decoder via the External Input.

Incremental Encoders provide motion information of a mechanical device in the form of 1 to 3 analogue or digital signals. These signals, once converted into digital format, are connected to the GPIO input pins of the iam. The motion information is conveyed via 1 or 2 signals (referred to as “Signal-A” and “Signal-B”) by providing a pulse each time the Encoder has travelled a particular distance. There is also an optional Reference signal (also called “Index” or “Home”) which is activated each time the Encoder reaches a certain starting position. The Decoder analyses these signals to determine what exact physical position the Encoder is currently at and generates a trigger signal to the sensor based on the Encoder position.

Physical Connection

The following pins are used as input for the quadrature decoder block.

Decoder Input

Hardware Pin

A

IN_ENC1

B

IN_ENC2

Reset Source ("Reference signal")

IN_ENC3

Sensor Trigger Usage

To use the quadrature decoder trigger output as sensor trigger, set TriggerSelector remote device feature to FrameStart, set TriggerMode to On and set TriggerSource to Quadrature Encoder ("Encoder0").

(De)activating the Decoder

To activate the decoder, set SvEncoderMode ("Encoder Mode") to the desired operation mode (SinglePhase, DualPhase or Quadrature). To disable the decoder, set the feature to Off.

Also set the appropriate "Encoder Value Max".

Encoder Modes

The Encoder signals can be decoded using one of three different modes:

SinglePhase

The simplest mode of Encoder operation is to generate a single (on/off) pulse for each step taken by the Encoder. Encoders which operate in this mode usually derive the motion pulse from a simple, equidistance hole mask (or equivalent) and provide the lowest positional resolution of all three modes, 1 Encoder Cycle = 1 Decoder Count. The Decoder only needs to interpret a single signal (Signal-A) and increments an internal Position Counter when the signal is turned on, i.e. on the rising-edge of Signal-A. The EncoderDirectionDetectionEnable feature can be set to determine the direction of the movement based on the B signal, potentially decreasing the position (see https://net-iam.atlassian.net/wiki/spaces/iam/pages/edit-v2/1294303234?draftShareId=823a6c5f-4070-4a58-bb9a-a62e502850ae#Direction-Analyzer).

DualPhase

Dual-Phase Encoders typically derive the motion pulse from a slot mask (or equivalent) where the length of the slot is a measure of the distance travelled. This mode is similar to Single-Phase Mode in that only a single signal (Signal-A) is used, but this time the Decoder must interpret when the signal is turned on and when it is turned off. The resolution in Dual-Phase Mode is twice that of Single-Phase Mode, i.e. 1 Encoder Cycle = 2 Decoder Counts. The Position Counter is therefore incremented on the rising and falling edges of Signal-A. The EncoderDirectionDetectionEnable feature can be set to determine the direction of the movement based on the B signal, potentially decreasing the position (see https://net-iam.atlassian.net/wiki/spaces/iam/pages/edit-v2/1294303234?draftShareId=823a6c5f-4070-4a58-bb9a-a62e502850ae#Direction-Analyzer ).

Quadrature

Encoders operating in Quadrature Mode provide 2 motion signals where the phase information between these signals is used to determine distance as well as direction. The 2 signals are typically generated by 2 slot masks (or equivalent) which are offset from each other by 90°. Depending on the current position of the Encoder, Signal-A and Signal-B are always in a particular phase relative to each other. When the Encoder travels in the forward direction, the phase change will be different to when it travels in backward direction. The Decoder can therefore determine the direction of the Encoder movement by analyzing the phase sequences of Signal-A and Signal-B (see https://net-iam.atlassian.net/wiki/spaces/iam/pages/edit-v2/1294303234?draftShareId=823a6c5f-4070-4a58-bb9a-a62e502850ae#Direction-Analyzer ). Quadrature Mode provides the highest resolution of the three modes: 1 Encoder Cycle = 4 Decoder Counts.

In addition to the motion signals, a third optional Encoder signal (Reference Signal) can be used to provide absolute position information of the Encoder. When a Signal-A/B change is detected the Reference Signal indicates that the Encoder has reached a defined position, i.e. top or left- or rightmost, or similar. This event can be used in the Decoder to re-align the internal Position-Counter and/or to detect if any errors may have occurred during the last Encoder rotation.

In the Decoder the reference signal will be updated, if Signal-A changes - in Quadrature Mode, if A/B-Signals changes. Therefore the length and position of the reference signal have to meet the requirement, that it can be sampled internaly. If the reference signal does happen close after a change of A/B-Signals, a timing window for determining the direction can be set via the SvEncoderSamplingDelay ("Encoder Sampling Delay") feature. Please note that the "Encoder Sampling Delay" contributes to the latency between the Decoder’s Signal-A/B inputs and the Sensor Trigger output.

Position and Rotation

The Position-Counter (EncoderValue) indicates the current position of the Encoder within a rotation (Rotary Encoders) or track (Linear Encoders). When the Direction Analyzer indicates that the Encoder has taken a step forward, the Position-Counter is incremented by ‘1’. Similarly, if the Encoder travels backward the Position-Counter is decremented by ‘1’. If the Reference signal is detected and the Encoder is travelling in forward direction, the Position-Counter is set to ‘0’. In backward direction the Counter is set to a value of (Counts-per-Rev – 1), which is stored in SvEncoderValueMax.

The Decoder uses either the rising or falling edge of the Reference signal as the synchronization point at which an encoder rotation is considered to be complete and a new cycle is started. The edge of the Reference signal can be selected with EncoderResetActivation. With EncoderResetSource the Reference signal can be enabled. The EncoderResetSource can be inverted with EncoderInvertResertSource.

The SvEncoderValueMax register is also used to detect “Position Errors” (SvEncoderPositionError) in the Decoder at the time the Reference signal is received. If the Encoder travels forward at the time the Reference signal is received, the Position-Counter is compared with SvEncoderValueMax. If the two values do not match, the Decoder may have lost synchronization with the Encoder at some point during the rotation. This condition is most likely due to phase error sequences received from the Encoder. The same error also occurs when the Encoder travels backwards through the Reference point, except in this case the expected Position-Counter value is ‘0’.

The Quadrature Decoder can also operate without the use of a Reference pin from the Incremental Encoder. In this mode (EncoderResetSource = Off) the Decoder relies on the Position-Counter to determine when a full rotation has been completed. All functions carried out by the Decoder are identical, except that (due to the missing Reference point) absolute Encoder position information is lost. Also, Position-Error checking is not possible.

The rotation refers to the number of reference signals received. When a reference signal is received, the SvEncoderRotationCount ("Encoder Rotation Count") value is incremented or decremented depending on the direction of movement. Since the Encoder can travel in either forward or backward direction, the Revolution-Counter is a signed (2’s compliment) register to indicate the total number of revolutions. The register can represent the number of revolutions within a range of -128 to +127. If the counter overflows (or underflows) an interrupt is generated to inform the Host of the limit condition. In either case, the Revolution-Counter is reset to ‘0’ when the over/underflow occurs.

Direction Analyzer

In Single or Dual Mode the Direction Analyzer receives Signal-A as indicator that another step has been taken by the Encoder. As an option Signal-B can be used as a directional input to allow the Decoder to operate in the same way as Quadrature Mode, albeit with a lower resolution. The table below shows how Signal-B is interpreted to determine direction:

Single Mode

Dual Mode

Signal-A

Signal-B

Direction

Signal-A

Signal-B

Direction

Rising

0

Forward

Rising

0

Forward

--

--

--

Falling

1

Forward

Rising

1

Backward

Rising

1

Backward

--

--

--

Falling

0

Backward

In Quadrature Mode the Direction Analyzer receives both Encoder signals Signal-A and Signal-B and determines at what time a step is made by the Encoder and also in which direction it is travelling. The two Encoder signals are combined into a 2-bit Current-Phase (bit 0 = Signal-A, bit 1 = Signal-B) variable. When a phase change is detected, the Analyzer compares the previous phase value with the current (i.e. next) phase value and determines the direction as shown in the table below:

Quadrature Mode

Forward

Backward

Previous Phase

Next Phase

Previous Phase

Next Phase

00

01

00

10

01

11

01

00

10

00

10

11

11

10

11

01

It is also possible that the Decoder receives erroneous phase sequences. For example, if the Encoder is travelling at excessively high speeds the Encoder output signals may get distorted, resulting in phases being skipped. Alternatively, electrical noise may interfere with the Encoder signals. Whatever the reason for the error, a wrong phase sequence is likely to result in the Decoder temporarily (or permanently) loosing track of the Encoder position. These error conditions are reported to the Host via a Decoder-Error-Interrupt-Request.

Decoder Start-up Behaviour

Decoder Activation

It is possible to activate the decoder to a specific position. If SvEncoderAwaitReferenceSignal is set, the position and rotation counters wait for the first occurance of the reference signal before starting the counters.

First Trigger Event

The offset of the (first) decoder trigger in the rotation can be set with SvEncoderTriggerOffset.

Trigger Mode

The SvEncoderTriggerMode feature allows to specify different ways of determining when triggers are generated based on position and rotation.

FixedTriggerMode

In this mode only a single trigger is generated per rotation, this is useful in area-scan (or similar) applications. The position generating the trigger is specified via the SvEncoderTriggerOffset("Encoder Trigger Offset") feature.

The SvEncoderRotationDivider("Encoder Rotation Divider") feature allows you to specify a number of rotations that should not generate a trigger: If a trigger was generated in rotation N, the next rotation generating a trigger is (N+SvEncoderRotationDivider), i.e. for SvEncoderRotationDivider=1 all rotations generate a trigger, for SvEncoderRotationDivider=5 every fifth rotation generates a trigger.

ConstantTriggerMode

In this mode multiple triggers can be generated per rotation (useful in line-scan (or similar) applications). The EncoderDivider feature can be used to specify the difference in position of encoder positions generating a trigger signal: For EncoderDivider=1 triggers are generated for every position. For EncoderDivider=2 every other position generates a trigger.

MultiTriggerMode

This mode is similar to Constant-Trigger-Mode but has the added advantage of being able to blend-out portions of an Encoder rotation were no triggers are generated, followed by evenly spaced trigger pulses within a single Encoder rotation. SvEncoderTriggerOffset provides an offset from the Reference Point in which triggers are suppressed. After that point triggers are generated every EncoderDivider Encoder positions, just like in Constant-Trigger-Mode.

RangeTriggerMode

This mode is the most flexible trigger method of all and allows the user to specify up to 8 intervals ("segments") within an Encoder rotation where triggers are generated with differing delays.

The SvEncoderSegmentCount feature is used to specify the number of intervals. SvEncoderSegment is used to chose the segment to configure.

SvEncoderSegmentStart specifies the first position within the segment where a trigger is generated. After this position triggers are generated at every position P where (P-SvEncoderSegmentEnd) is divisible by SvEncoderSegmentDivider up to SvEncoderSegmentEnd(inclusive).

Segments must not overlap and must be specified in ascending position; if a SvEncoderSegmentStart or SvEncoderSegmentEnd value is set that conflicts with segments with smaller SvEncoderSegment, the smallest valid value is chosen instead. If the value conflicts with segments with higher SvEncoderSegment, these segments adjusted to accomodate for the value written by the user. The SvEncoderSegmentEnd value of the same segment may be adjusted to keep it larger than SvEncoderSegmentStart.

For this reason it is recommended to fill the SvEncoderSegmentStart and SvEncoderSegmentEnd values in order of increasing SvEncoderSegment

The limits of the feature do not represent this limitation properly. Since the SvEncoderSegmentStart and SvEncoderSegmentEnd values may be adjusted automatically, you may want to read back the values after writing them, unless you're sure you've written correct values in the correct order.

Trigger-Pulse-Counter

The Quadrature Decoder features a Trigger-Pulse-Counter which can be used to automatically stop image acquisition after a programmable number of Encoder pulses or Frame-Triggers have been detected.

The Trigger-Pulse-Counter (SvEncoderCurrentTriggerCounter) can be configured via the SvEncoderMaxTriggerCountMode and SvEncoderTriggerDeactivationCounterPosition.

When enabled (SvEncoderMaxTriggerCountMode unequal Off) the Trigger-Pulse-Counter is incremented or decremented each time a defined event is detected. When the Trigger-Pulse-Counter reaches a value equal to SvEncoderTriggerDeactivationCounterPosition all further Frame-Triggers to the Sensor are suppressed by setting a Trigger-Block, regardless of any external trigger events which may occur.

The table lists how the Trigger-Pulse-Counter can be configured:

SvEncoderMaxTriggerCountMode

Function

Off

Trigger-Pulse-Counter is disabled

Encoder Forward Only

Encoder Forward Direction only are counted

Encoder Backward Only

Encoder Backward Direction only are counted

Encoder Forward and Backward

Encoder Both Directions are counted

Output

Frame Triggers to the Sensor are counted

The Trigger-Pulse-Counter is incremented in Modes “Encoder Forward Only” and “Output” but can be decremented in Mode “Encoder Backward Only”. It can be incremented and decremented in Mode “Encoder Forward and Backward”. In the last case a wrap-around of the counter value from the minimum value (-16777215) to the maximum value (16777215) may occur.  This needs to be considered when initializing SvEncoderMaxTriggerCount with an appropriate value. Regardless of the direction the Counter is counting, the Trigger-Block is always set when the Trigger-Pulse-Counter reaches the value equal to SvEncoderTriggerDeactivationCounterPosition.

The Trigger-Pulse-Counter can be enabled or disabled regardless of the operating mode of the Quadrature Decoder. When the Trigger-Pulse-Counter is disabled  (SvEncoderMaxTriggerCountMode equal Off) the Trigger-Block is inactive.


🔍 References

🔗 related content

👥 contact NET

📲 +49 8806 / 9234 0
📧 info@net-gmbh.com

👩‍💼 Contact our Sales Team.

  • No labels