CANNY 7.3 Echo. Discrete IO Driver

General Description

The CANNY 7.3 Echo provides access to two discrete low-side IO channels, physically represented by pins #5 (Channel 0) and #3 (Channel 1) of the controller’s X1 connector. By writing to and reading from the corresponding driver registers, the function diagram can both control the electrical potential at each of these pins and retrieve information about their current potential values.

The physical characteristics of these channels allow connection to various external low-current control circuits. They can be used with a wide range of loads, such as electromagnetic relays, small electric motors, LEDs, and other low-current equipment control circuits. As external discrete signal sources capable of controlling the controller, you can use mechanical, electromechanical, and electronic buttons and switches, pulse generators, 0-24V voltage sources, transistor outputs from various equipment, etc.

Note: Avoid directly connecting controller channels to electrical circuits containing high-power loads if these circuits lack protection against voltage exceeding the controller’s supply voltage. When connecting a controller channel to such a circuit whose power exceeds the maximum permissible for the controller channel (full current >100 mA), a resistor must be installed in series with a resistance of at least R = | U | * 10, where U equals the magnitude of the maximum back-EMF voltage impulse occurring in the circuit when the load is disconnected. For example, for U = ±300V, the series resistor R should be 3000Ohm or more.

Channel operation modes and parameters are set via the function diagram. At any given time, a channel can only operate in one of the available modes; however, dynamic reconfiguration of the channel from within the function diagram during execution is allowed.

Several CANNY 7.3 Echo controller drivers, specifically CANNY 7.3 Echo, UART Driver and CANNY 7.3 Echo, LIN Driver, utilize IO channel resources during operation and have higher priority. Consequently, when these drivers are using specific controller channels, the IO driver will not be able to access those channels.

Note: The voltage on channels operating in input mode must not exceed the controller’s supply voltage.

Controller Channel Structural Diagram

Controller channel structural diagram.

Driver Registers

Parameters defining the operation mode and current state of controller channels are set independently for each channel. Below is a description of permissible register values for controlling IO channel operation in all primary modes.

Configuration and IO value registers.
Register Expected Values
DIO Output Mode Setup Register, IO Channel 0
DIO Output Mode Setup Register, IO Channel 1
≥ 1 = set the configuration of the controller channel’s output potentials in the “ON” and “OFF” states (specified by a special constant from the constants reference);
0 = switch the corresponding controller pin to a neutral state and disable the ability to change its state from the function diagram.
DIO Output Value Register, IO Channel 0
DIO Output Value Register, IO Channel 1
≥ 1 = set the electrical potential at the corresponding controller pin as defined by this channel’s configuration for the “ON” state;
0 = set the electrical potential at the corresponding controller pin as defined by this channel’s configuration for the “OFF” state.
DIO Output PWM Period Setup Register, IO Channel 0
DIO Output PWM Period Setup Register, IO Channel 1
1…65535 = activate PWM mode and set the period of pulses generated at the corresponding controller pin, in milliseconds;
0 = disable PWM mode and stop pulse generation. Set the potential at the corresponding controller pin equal to the “OFF” state potential of the current channel configuration.
PWM Duty Cycle Register, Channel 0
PWM Duty Cycle Register, Channel 1
0…65535 = set the duty cycle (fill factor) of pulses generated at the corresponding controller pin, in milliseconds.
Input Value Inversion Register, Channel 0
Input Value Inversion Register, Channel 1
≥ 1 = set an inverted (negative) input signal potential at the corresponding controller pin to be accepted as the “ON” state (logical 1);
0 = set a normal (positive) input signal potential at the corresponding controller pin to be accepted as the “ON” state (logical 1).
DIO Input Active Wait  / Rising Edges Counter Enable Register, IO Channel 0
DIO Input Active Wait  / Rising Edges Counter Enable Register, IO Channel 1
≥ 1 = switch the channel to active mode / activate the rising edge counter (potential switching from “GND” to positive);
0 = switch the channel to passive mode / disable rising edge counter.
DIO Input Active Wait  / Falling Edges Counter Enable Register, IO Channel 0
DIO Input Active Wait  / Falling Edges Counter Enable Register, IO Channel 1
≥ 1 = switch the channel to active mode / activate the falling edge counter (potential switching from positive to “GND”);
0 = switch the channel to passive mode / disable the falling edge counter.
DIO Input Encoder Counter Enable Register, IO Channel 0 paired with IO Channel 1
≥ 1 = activate encoder counter mode, change the channel counter value depending on the state of the auxiliary channel (see “Encoder Counter Mode”);
0 = deactivate encoder counter mode.

Note: Input potential monitoring is performed continuously; no additional configuration is required to operate a channel as an input. By default, inputs are configured as positive, meaning a positive potential is accepted as a logical 1. Input settings can be changed independently for each channel using the corresponding channel’s Input Value Inversion Register.

Note: The rising and falling edge counter modes of the same channel can be activated simultaneously. In this case, both rising and falling edges will be counted, and the total number of registered potential changes (edges) at the active input will be available in the corresponding channel’s counter value register. Edge counting is cumulative with overflow. The counter value is reset when the channel’s active mode is disabled.

I/O channel driver control registers are divided into those containing information about the overall state of the IO driver and those containing information about each channel individually. Below is a description of the return values for the IO driver control registers in all primary operation modes.

Values returned by the I/O driver control registers.
Register Return Values
DIO Output Overload Detect Register 1 = an overload has been detected on any of the controller’s IO channels;
0 = no overload has been detected on any of the controller’s IO channels; channels are operating normally.
DIO Output Overload Register, IO Channel 0
DIO Output Overload Register, IO Channel 1
1 = an overload has been detected at the corresponding controller pin;
0 = no overload has been detected at the corresponding controller pin; the channel is operating normally.
DIO Input Value Register, IO Channel 0
DIO Input Value Register, IO Channel 1
1 = an electrical potential matching the polarity of this input has been established at the corresponding controller pin (positive - with normal input settings; “GND” - with input value inversion enabled);
0 = an electrical potential not matching the polarity of this input has been established at the corresponding controller pin (“GND” - with normal input settings; positive - with input value inversion enabled).
DIO Input Edges Counter Value Register, IO Channel 0
DIO Input Edges Counter Value Register, IO Channel 1
0…65535 = the number of pulses (with specified parameters) registered at the corresponding controller pin.
DIO Input Pulse 1 Width Value, IO Channel 0
DIO Input Pulse 1 Width Value, IO Channel 1
0…65535 = pulse width value between the previous edge (any last detected edge) and the subsequent falling edge, in microseconds (see note).
DIO Input Pulse 2 Width Value, IO Channel 0
DIO Input Pulse 2 Width Value, IO Channel 1
0…65535 = pulse width value between the previous edge (any last detected edge) and the subsequent rising edge, in microseconds (see note).

Channel Neutral State

Channels are automatically switched to a neutral state in the following cases:

  • when the controller is operating in software download mode;
  • when the controller is in standalone mode if the channel configuration is not set, or is set using the “Neutral State” constant or value “0”;
  • during a software reset or power-on reset of the controller, before switching to standalone mode and starting function diagram execution;
  • in case of a controller failure or system software malfunction.

Digital Output Mode

A channel configured for digital output mode sets an electrical potential at the corresponding controller pin corresponding to the “ON” state when a non-zero value is written to the channel’s output value register, and sets a potential corresponding to the “OFF” state when a value of “0” is written to the output value register.

Channel configuration for this mode is determined by a constant that defines the electrical potential at the corresponding controller pin in the “ON” and “OFF” positions.

Channel configuration parameters for digital output mode.
Parameter Permitted Values
Channel Type Digital Output.
“ON” pulled to negative (1mA); MINUS (100mA); neutral (Float).
“OFF” pulled to negative (1mA); MINUS (100mA); neutral (Float).

Note: Special contact pads are located on the back of the controller board. By shorting them (installing a jumper), you can organize a constant pull-up of the channel to the positive potential - the controller’s supply voltage (individually for each channel). By default, the controller’s channel pull-up resistors are installed but not connected.

Named constants representing available user combinations of channel configuration parameters are located in the “DIO Output Stage Modes” section of the CannyLab constants reference, accessible via the context menu of the function block entry of type “Constant”.

To set a controller channel to digital output mode, place the value of the constant corresponding to the selected operation mode into the channel’s “DIO Output Mode Setup Register, IO Channel X”.

Note: When using a channel as an output, the user can monitor the actual current electrical potential at the channel pin via the corresponding channel’s input value register. This allows for implementing feedback if necessary.

Example of a function diagram performing a cyclic alternating switching of electrical potentials from a neutral state (Float) to “GND” (100mA) and back every second, on controller pins corresponding to Channels 0 and 1.

PWM Output Mode

A channel configured for PWM output mode generates a pulse-width modulated signal of specified polarity, frequency, and duty cycle at the corresponding controller pin. In this mode, the channel operates asynchronously to the function diagram, which allows achieving greater stability in the timing parameters of the generated signal compared to organizing a PWM generator using function diagram resources, especially at small period values.

PWM mode graph.

Channel configuration for this mode is determined by a constant representing a combination of parameters that define the electrical potential and current at the pin during the active “ON” and passive “OFF” generation phases, and a pair of numeric values defining the frequency and duty cycle of the generated pulses.

Channel configuration parameters for PWM output mode.
Parameter Permitted Values
Channel Type PWM Output.
“ON” pulled to negative (1mA); MINUS (100mA); neutral (Float).
“OFF” pulled to negative (1mA); MINUS (100mA); neutral (Float).

Named constants representing available user combinations of channel configuration parameters are located in the “DIO Output Stage Modes” section of the CannyLab constants reference, accessible via the context menu of the diagram element “Constant”.

To switch a controller channel to PWM output mode, you must:

  • pass the value of the constant corresponding to the selected operation mode to the channel’s “DIO Output Mode Setup Register, IO Channel X”;
  • pass a numeric value from 1 to 65535 to the channel’s “DIO Output PWM Period Setup Register, Channel X”, setting the period of generated pulses;
  • pass a numeric value from 0 to 65535 to the channel’s “DIO Output PWM Duty Setup Register, Channel X”, setting the duty cycle of generated pulses.

Note: PWM mode has priority over digital output mode. When PWM mode is active, values written to the Channel X output value register are ignored - the channel operates according to PWM settings.

Function diagram constantly performing a cyclic switching of electrical potential from a neutral state (Float) to “GND” (100 mA) every second on the controller pin corresponding to Channel 0.

Digital Input Mode

During the execution of a user diagram, the current potential value at the controller pins can be determined using the input value registers of the corresponding channel. By default, it returns a value of “1” if a positive electrical potential is established at the corresponding controller pin, and returns a value of “0” when a “GND” electrical potential is established at the corresponding controller pin. The controlled potential settings at the controller pins can be changed using the channel’s input value inversion register.

The controller’s digital input mode is always on, allowing it to be used for feedback.

Channel configuration parameters for digital input mode.
Parameter Permissible Values
Channel Type Digital Input.
Input Polarity PLUS (default); MINUS (in inverted input potential state).
Standby Mode active / input rising edge counter; active / input falling edge counter; passive.

A change in potential at the pin of a channel in active standby mode will immediately trigger an automatic exit from the controller’s low-power consumption mode. A change in potential at the pin of a channel in passive standby mode will not affect the controller’s power consumption mode.

Controller input channels operate with maximum sensitivity, meaning “debounce protection” is not provided and must be implemented in the function diagram if necessary.

Example of a function diagram that turns on the controller’s built-in green LED upon receiving and holding a positive potential for at least 200ms at the controller pin corresponding to Channel 0.

Counter Mode

When the active mode / rising (forward) or/and falling (reverse) edge counter is enabled for any controller channel, CANNY 7.3 Echo allows automatic counting of input signal potential changes of the corresponding direction, asynchronously to the function diagram.

Note: The controller considers a rising edge as a change in potential at a given pin from negative (“GND”) to positive (controller supply voltage), and a falling edge as a change from positive (controller supply voltage) to negative (“GND”).

Note: Channel configuration in input-counter mode is determined by the output potential configuration of that channel.

Note: Rising and falling edge counters are enabled using two separate independent registers, allowing simultaneous activation of both counters and, accordingly, counting any potential changes (rising and falling edges) at a given controller pin.

Asynchronous counting mode allows achieving higher accuracy in counting received pulses and registering signals with higher frequencies than when organizing a pulse counter using function diagram resources.

In counter mode, the channel is always in active standby with maximum sensitivity.

To switch a controller channel to input-counter mode, you must:

  • pass the value of the constant corresponding to the required channel setting to the channel’s “DIO Output Mode Setup Register, IO Channel X”;
  • write the value “1” to the channel’s “DIO Input Active Wait / Rising Edges Counter Enable Register, IO Channel X” and/or “DIO Input Active Wait / Falling Edges Counter Enable Register, IO Channel X”;

Edge counting is cumulative with overflow. This means that upon reaching a value of 65535 and subsequently increasing by one, the counter value is set to zero, but each subsequent pulse again increments the counter by one. The counter value is reset when the channel’s active mode is disabled.

Example of a tachometer function diagram with a resolution of 100 RPM, counting the number of pulses at the controller pin corresponding to Channel 0.

Determining Pulse Width (Duration)

When operating in counter mode, the controller channels allow determining pulse duration in microseconds asynchronously to the function diagram. Information about pulse durations is available in special registers of the specified input channels.

If only the rising or falling edge counter is activated, the time between the arrivals of the corresponding edges will be determined, i.e., the actual period of pulse reception. If both rising and falling edge counters are activated simultaneously, the time elapsed between two adjacent edges will be determined. That is, one register will display the time between a rising edge and the subsequent falling edge, while the other will show the time between the last falling edge and the next rising edge. The sum of these values will yield the total pulse period.

Scenario 1. Only the rising edge counter is enabled.
Register values for Scenario 1.
Parameter Return Values
DIO Input Pulse 1 Width Value Register, Channel X 0
DIO Input Pulse 2 Width Value Register, Channel X T2
Scenario 2. Only the falling edge counter is enabled.
Register values for Scenario 2.
Parameter Return Values
DIO Input Pulse 1 Width Value Register, Channel X T1
DIO Input Pulse 2 Width Value Register, Channel X 0
Scenario 3. Both rising and falling edge counters are enabled.
Register values for Scenario 3.
Parameter Return Values
DIO Input Pulse 1 Width Value Register, Channel X T1
DIO Input Pulse 2 Width Value Register, Channel X T2

The asynchronous counting mode allows for high precision in determining pulse width.

Example function diagram for determining pulse duration on Channel 0 of the CANNY 7.3 Echo controller.

Encoder Counter Mode

When operating in counter mode, Channel 0 of the controller can function as an encoder, increasing or decreasing its count value depending on the state of Channel 1: if a positive potential is present on the auxiliary channel when the encoder channel detects an edge, the counter value will increase; otherwise, it will decrease.

Example function diagram using Channel 0 counter of the CANNY 7.3 Echo controller in encoder mode.

While executing the diagram, the controller sends a message to CAN0 containing the current encoder counter value each time it changes.

Note: External pull-up of the channels to a positive potential may be required for correct diagram operation.

Electrical Protection

For channels operating in digital output and PWM output configurations, if the current in the “ON” or “OFF” state significantly exceeds 100mA, the controller’s system software implements automatic short-circuit protection. This protection works by switching the shorted channel to a neutral state, followed by periodic pulsed test activations, and automatically returning to the user-defined configuration once the short circuit is cleared. This protection operates fully automatically and requires no user configuration.

SEE ALSO