Documentation

Contec CNT32-8M(PCI) Incremental Encoder

Contec CNT32-8M(PCI) Incremental Encoder block

Library

Simulink® Real-Time™ Library for Contec

Note

Each channel of this block has an external input and output signal. You can configure these channels to trigger events (such as starting the encoder on the rising or falling edge of an input signal). You can also configure them for general purpose I/O, where the signals behave like digital I/O signals. The block can have the following ports:

  • Output port labeled with the channel number

  • Output port labeled din , if you configure the block for digital input

  • Input port labeled dout , if you configure the block for digital output

Scaling

Encoder (Input to Output)

I/O Module Input

Block Input Data Type

Scaling

TTL or differential (pulse input)

Double

Counts

Digital Input (Input to Output)

I/O Module Input

Block Input Data Type

Scaling

TTL

Double

TTL low = 0.0

TTL high = 1.0

Digital Output (Output to Input)

I/O Module Output

Block Output Data Type

Scaling

TTL

Double

TTL low = < 0.5

TTL high = > 0.5

Block Parameters: Main Tab

The Main tab contains parameters that define the operation of the board.

Channel

From the list, select 1 through 8. This parameter specifies the board channel to which the subsequent parameters refer. Number the channels beginning with 1 even if this board manufacturer numbers them beginning with 0. The other parameters in this block apply to this channel. The channel you select becomes the label for the output port of the block.

Operation mode

From the list, select one of the following operation modes:

  • 2-phase Input Synchronous Clear Multiply by 1

  • 2-phase Input Synchronous Clear Multiply by 2

  • 2-phase Input Synchronous Clear Multiply by 4

  • 2-phase Input Asynchronous Clear Multiply by 1

  • 2-phase Input Asynchronous Clear Multiply by 2

  • 2-phase Input Asynchronous Clear Multiply by 4

  • Single-phase Input Asynchronous Clear Multiply by 1

  • Single-phase Input with Gate Control Attached Asynchronous Clear Multiply 1

  • Single-phase Input with Gate Control Attached Asynchronous Clear Multiply 2

    See the Contec CNT32-8M(PCI) 8-Ch 32-Bit Up/Down High-Speed Counter Board for PCI documentation for definitions of these modes.

Digital filter

From the list, select the desired digital filter time, in microseconds. To disable digital filtering, select No filtering.

Pulse input

From the list, select one of the following pulse inputs:

  • Differential line receiver input

  • TTL Level input

    You can connect the CNT32-8M(PCI) board to either differential or TTL input signals. See the Contec CNT32-8M(PCI) 8-Ch 32-Bit Up/Down High-Speed Counter Board for PCI documentation for connection details.

Direction

From the list, select one of the following count directions:

  • Up in the clockwise direction/Down in the counterclockwise direction

  • Down in the clockwise direction/Up in the counterclockwise direction

    The board can count either up or down in the clockwise direction.

Initial value

Enter a number from 0 to the largest 32-bit number. This parameter specifies the initial value of the counter before the model begins.

Load initial value

Select this check box to load the value from Initial value into the counter, overwriting the previous count value. If you do not select this check box, the driver does not load the initial value, preserving the previous count value.

Sample time

Enter the base sample time or a multiple of the base sample time (-1 means sample time is inherited).

PCI slot (-1:autosearch)

If only one board of this type is in the target computer, enter -1 to locate the board.

If two or more boards of this type are in the target computer, enter the bus number and the PCI slot number of the board associated with this driver block. Use the format [BusNumber,SlotNumber].

To determine the bus number and the PCI slot number, type:

tg = slrt;
getPCIInfo(tg, 'installed')

Block Parameters: Counter Control Tab

The Counter Control tab contains parameters that define

  • How to start and stop counting

  • How to use the external input signal

  • Under what circumstances to reset the counter

Start method

Directs counter to begin counting under one of the following conditions:

  • Model Start — Begin counting when model starts.

  • External Input Rising — Begin counting when external TTL input rises.

  • External Input Falling — Begin counting when external TTL input falls.

  • Disable — Do not begin counting.

Stop method

Directs counter to stop counting under one of the following conditions:

  • Model Terminate — Stop counting when model stops.

  • External Input Rising — Stop counting when external TTL input rises.

  • External Input Falling — Stop counting when external TTL input falls.

  • Free Running — Do not stop counting.

Zero-clear external input rising

Select this check box to clear the counter upon a rising edge on the external input signal.

Zero-clear external input falling

Select this check box to clear the counter upon a falling edge on the external input signal.

Zero-clear match 0

Select this check box to clear the counter when the counter has the same value as that contained in the Match 0 value parameter.

Zero-clear match 1

Select this check box to clear the counter when the counter has the same value as that contained in the Match 1 value parameter.

Preset external input rising

Select this check box to preset the counter to the value contained in the Preset value parameter upon a rising edge on the external input signal.

Preset external input falling

Select this check box to preset the counter to the value contained in the Preset value parameter upon a falling edge on the external input signal.

Preset match 0

Select this check box to preset the counter to the value contained in the Preset value parameter when the counter value has the same value as that contained in the Match 0 value parameter.

Preset match 1

Select this check box to preset the counter to the value contained in the Preset value parameter when the counter value has the same value as that contained in the Match 1 value parameter.

Preset value

Enter the value that you want the counter to reset when a preset condition occurs.

Match 0 value

Enter the value that you want the counter value to be compared to for the Zero-clear match 0 or Preset match 0 conditions.

Match 1 value

Enter the value that you want the counter value to be compared to for the Zero-clear match 1 or Preset match 1 conditions.

Block Parameters: Signals Tab

The Signals tab contains parameters that

  • Control the optional use of the external output signal

  • Control the encoder index signal

  • Enable the external signals for general purpose

Output signal match 0

Select this check box to strobe the output signal when the counter value has the same value as the Match 0 parameter.

Output signal match 1

Select this check box to strobe the output signal when the counter value has the same value as the Match 1 parameter.

Output signal abnormal input error

Select this check box to strobe the output signal when the phase-A and phase-B signals change at the same time.

Output signal digital filter error

Select this check box to strobe the output signal when a pulse is faster than the digital filter time setting.

Output signal disconnection alarm error

Select this check box to strobe the output signal when both the positive and negative differential inputs are high.

One-shot duration

From the list, select the pulse width of the output signal for the one-shot duration, in microseconds or milliseconds.

Index enable

From the list, select the following to enable or disable the phase-Z/CLR input signal:

  • Disable — Disables phase-Z input (select this option if phase-Z does not exist).

  • Enable Once — Enables only the next phase-Z input.

  • Enable All — Enables all of the phase-Z inputs.

Index logic

From the list, select one of the following to set the logic of the phase-Z input signal. Setting Index enable to Enable Once or Enable All activates this parameter.

  • Positive (Active High)

  • Negative (Active Low)

Enable digital input

Select this check box to enable the external input signal to be used as a general purpose digital input. Even if you select an external input signal other than general-purpose input, the block can still read the input level.

Enable digital output

Select this check box to enable the external output signal to be used as a general-purpose digital output. If you select an external output signal other than general purpose, the block cannot write the output level. Selecting this check box enables the Digital output initial value and Digital output final value parameters.

Digital output initial value

From the list, select how you want to set the initial value of the digital output when the model starts:

  • None — Do not modify the output value.

  • Set — Set the bit.

  • Clear — Clear the bit.

Digital output final value

From the list, select how you want to set the final value of the digital output when the model terminates:

  • None — Do not modify the output value.

  • Set — Set the bit.

  • Clear — Clear the bit.

Was this topic helpful?