CANNY 7.2 Duo. Discrete IO Driver

General Description

CANNY 7.2 Duo gives you access to nine discrete general purpose IO channels. Each channel is physically accessed through a corresponding pin of X2(Channels 0..7) and X3(Channel 8) connectors. By writing and reading data of the respective driver registers, the functional diagram can manage the electric potential in each of these contacts, as well as get information about the current potential of each of them.

The physical characteristics of these channels allow them to be connected to a variety of external devices. All channels can be used to work with any type of load, for example: electromagnetic relays, small electric motors, LEDs, low current systems. You can use a variety of input signal sources, such as: mechanical, electromechanical, and electronic buttons and switches, pulse generators, voltage source 0-24V, transistor outputs of various equipment, etc.

Channel operation mode and parameters are set via the function diagram. At any given moment in time, the channels can only work in one of the possible modes, but it is possible to dynamically override the channel configuration from the function diagram.

Several CANNY 7.2 Duo controller drivers, specifically High Resolution PWM, UART / RS232 / Modbus, LIN and Dallas 1-Wire use input-output channels resources while operating and have a higher priority than the Discrete IO driver. This means that when you use these drivers on a certain controller channel, IO driver will not be able to access that channel.

Note: The output operating voltage on controller channels depends matches the supply voltage. The permissible voltage on channels operating in input mode must not exceed the controller supply voltage.

Diagram of the controller channel

Controller channel diagram.

IO Registers

The parameters that define operation mode and current state of the channel are set for each channel independently. Below is a description of expected IO register values.

Configuration and IO value registers.
Register Expected values
DIO Output Mode Setup Register, IO Channel 0

DIO Output Mode Setup Register, IO Channel 8
≥ 1 = set up the configuration of the output level of the controller channel in the “ON” and “OFF” states (given the special constant from the named constants list);
0 = transfer the specified channel’s corresponding controller pin to a neutral state. The channel’s status won’t be changeable from the function diagram.
DIO Output Value Register, IO Channel 0

DIO Output Value Register, IO Channel 8
≥ 1 = set the electric potential specified by this channel’s configuration for status “ON” at the appropriate controller pin;
0 = set the electric potential specified by this channel’s configuration for status “OFF” at the appropriate controller pin.
DIO Output PWM Period Setup Register, IO Channel 0

DIO Output PWM Period Setup Register, IO Channel 8
1…65535 = activate the PWM mode and set the period of pulses generated on the corresponding controller pin, in milliseconds;
0 = disable PWM mode and stop pulse generation. Set the level equal to the “OFF” state level of the current channel configuration on the appropriate controller pin.
DIO Output PWM Duty Setup Register, IO Channel 0

DIO Output PWM Duty Setup Register, IO Channel 8
0…65535 = set the duty value of pulses generated at the corresponding controller pin, in milliseconds
DIO Input Inversion Register, IO Channel 0

DIO Input Inversion Register IO Channel 8
≥ 1 = set on the corresponding controller pin the inverse (negative) value of the input signal potential taken as the state “ON” (logical 1);
0 = set on the corresponding controller pin the normal (positive) value of the input signal potential taken as the state “ON” .
DIO Input Active Wait  / Rising Edges Counter Enable Register, IO Channel 0

DIO Input Active Wait  / Rising Edges Counter Enable Register, IO Channel 8
≥ 1 = set the channel to active mode / activate the rising edge counter (increment counter when level “GND” switches to positive level);
0 = set the channel to passive mode / disable rising edge counter mode.
DIO Input Active Wait  / Falling Edges Counter Enable Register, IO Channel 0

DIO Input Active Wait  / Falling Edges Counter Enable Register, IO Channel 8
≥ 1 = set the channel to active mode / activate the falling edge counter (increment counter when positive level switches to “GND” level);
0 = set the channel to passive mode / disable the falling edge counter mode.

Note: Level monitoring at controller inputs is performed constantly and by default; no additional configuration is required to make a channel work as an input. By default, the inputs are configured as positive, i.e. a logical 1 is a positive potential. Input settings can be changed independently for each channel using the Input Inversion Register of the corresponding channel.

Note: The rising and falling edge counter modes can be activated simultaneously on a single channel. Both rising and falling edges will be taken into account when incrementing the counter, and the value of the total number of registered changes in levels (edges) at the active input will be available in the register counter values register ​​of the corresponding channel. Counting fronts is a cumulative result, with overflow. The counter is reset when the active channel mode is disabled.

IO channel driver control registers are divided into registers containing information about the state of the IO driver altogether and registers containing information about the state of each channel individually. The following table describes driver control register return values in all major operation modes.

IO driver return value control registers.
Register Return Values
DIO Input Value Register, IO Channel 0

DIO Input Value Register, IO Channel 8
1 = an electrical level corresponding to the polarity of the input was set on the channel’s corresponding controller pin (positive - with the normal input setting; “GND” - with input value inversion);
0 = an electric level that does not match the polarity of the input was set on the corresponding contact of the controller (“GND” - with the normal input setting; positive - with input value inversion).
DIO Input Edges Counter Value Register, IO Channel 0

DIO Input Edges Counter Value Register, IO Channel 8
0…65535 = the number of pulses (with given parameters) registered on the corresponding controller pin
DIO Input Pulse 1 Width Value, IO channel 0

DIO Input Pulse 1 Width Value, IO channel 8
0…65535 = pulse width value between the previous edge (any last pulse edge previously detected) and the next falling edge, in microseconds (see note)
DIO Input Pulse 2 Width Value, IO channel 0

DIO Input Pulse 2 Width Value, IO channel 8
0…65535 = pulse width value between the previous edge (any last pulse edge previously detected) and the next rising edge, in microseconds (see note)

Note: Due to the specificities of the microsecond timer, the pulse width values in Input Pulse Width Value Registers are in Timer Units. One Timer Unit is equal to 1.066(6) microseconds. To obtain the actual pulse width value in microseconds, multiply the value in the registers by 1.067.

Channel neutral state

The channels are automatically transferred to a neutral state in the following cases:

  • when controller is operating in software download mode;
  • when the controller is in standalone mode if the channel configuration is not set at all or set by the constant “Neutral state” or “0”;
  • at the time of controller software reset or power-on reset, before switching to a stand-alone mode and starting function diagram execution;
  • in the event of controller malfunction or system software failure.

Digital output mode

When the channel is configured to operate as a discrete output, it sets the following electric potentials at its corresponding controller pin:

  • an electric potential corresponding to the “ON” state, when a nonzero value is written to the channel’s output value register;
  • an electric potential corresponding to the “OFF” state when a value of “0” is written to the the channel’s output value register.

Note: The output operating voltage on the controller channels matches the supply voltage.

Channel configuration for operating in this mode is determined by a constant that defines a combination of parameters. These parameters determine the electrical potential and current at the channel’s pin in both the “ON” and “OFF” positions.

Digital output mode configuration parameters.
Parameter Permitted values
Channel type Digital output
“ON” plus (1mA); PLUS (100mA); minus (1mA); MINUS (100mA); Float
“OFF” plus (1mA); PLUS (100mA); minus (1mA); MINUS (100mA); Float

These constants are available in the “DIO Channel Configuration” folder of the CannyLab named constants list.

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

Note: For channels operating in digital output mode, you can also obtain a value that corresponds to the current electrical potential at the channel pin. This allows the use of the channel in feedback mode.

Function diagram that alternately, every second, switches electrical potentials from supply voltage (100mA) to GND (1 mA) at controller pins corresponding to channels #0 & #1 every second.

PWM output mode

When the channel is configured to operate as a PWM output, it generates a pulse-width moudulated signal of a predetermined polarity, frequency, and duty cycle on the corresponding controller pin. In this mode, the channel is asynchronous to functional diagram, which allows for greater stability of the generated timing signal, compared to implementing a PWM generator using the function diagram resources.

PWM mode graph.

Channel configuration for operation in this mode is determined by:

  • a constant, representing a combination of parameters that determine the electrical potential and current to the corresponding controller pin in the active “ON” and passive “OFF” generating phase;
  • a pair of numeric values that define the frequency and filling of the generated pulses in milliseconds.
PWM output mode confguration constant paremeters.
Parameter Permitted values
Channel type PWM output.
“ON” plus (1mA); PLUS (100mA); minus (1mA); MINUS (100mA);Float.
“OFF” plus (1mA); PLUS (100mA); minus (1mA); MINUS (100mA);Float.

These constants are available in the “DIO Channel Configuration” folder of the CannyLab named constants list.

To set the controller channel to PWM output mode, do the following:

  • write the constant value, corresponding to PWM Output mode into the channel’s “DIO Output Mode Setup Register, IO Channel X” register;
  • write a digital value from 0 to 65565, that defines the period of generated pulses in ms, into the channel’s “DIO Output PWM Period Setup Register, IO Channel X” register;
  • write a digital value from 0 to 65565, that defines the duty cycle of generated pulses in ms, into the channel’s “DIO Output PWM Duty Setup Register, IO Channel X” register;

Note: PWM mode has priority over discrete output mode. When the PWM mode is active, the values written to the output value register of this channel are ignored - the channel operates in accordance with the PWM settings.

Function diagram that alternately, every second, switches of electrical potentials from supply voltage (100mA) to GND (1 mA) at the controller pin corresponding to channel #8, implemented using the PWM output mode.

Digital input mode

When a channel is configured to operate as a digital output, it sets the following register values:

  • returns a value of “1” in its input value register, if it detects an electrical potential corresponding to the “Input polarity” state on the appropriate controller pin;
  • returns a value of “0” in its input value register, if it detects an electrical potential not corresponding to the “Input polarity” state on the appropriate controller pin.

This can be inverted using the channel input inversion registers.

The discrete input mode of the controller is always on, which allows it to be used for feedback.

Channel configuration for operation in this mode is determined by a constant that represents a combination of parameters.

Channel configuration parameters for digital input operation.
Parameter Permitted values
Channel type Digital Input
Input polarity PLUS (default); MINUS (in inverted state).
Standby mode active, input rising edges counter; active, input falling edges counter; passive.

Note: The pull-up and polarity on the channel is determined by the output mode setup of this channel.

Change of potential on the channel pin is in the active standby mode will result in the controller exiting the hibernation state immediately. Change of potential on the channel pin is in the passive standby mode won’t result in the controller changing its power consumption state.

The input channels of the controller always operate at maximum sensitivity, that is, “Bounce protection” is not provided and should be implemented separately, if necessary, in the function diagram.

Function diagram that turns on the built-in green LED when a positive level is detected at the channel #8 pin and held for at least 200ms.

Counter mode

When the active mode / counter of the rising and/or and falling edges is turned on on any controller channel, CANNY 7.2 Duo can automatically count input signal level changes on the appropriate channel in the corresponding direction. This is done asynchronously to the function diagram.

Note: The controller detects a rising edge when it detects a in level on a given pin from negative (GND) to positive (voltage of the controller), and the falling edge when it detects a change of level from positive (voltage of the controller) to negative (GND).

Note: Channel configuration in counter mode is determined by the output mode setup of this channel.

Note: Turning on the counters of the rising and falling edges is done in two separate independent registers, which allows you to simultaneously activate both counters and, accordingly, keep track of all level changes (both edges) on this controller pin.

In this mode, the channel is asynchronous to the function diagram, which allows for greater accuracy when determining the time parameters of the signal and measuring a higher frequency signal than possible with a pulse counter implemented solely through the function diagram.

In counter mode, the channel is always in active standby with maximum sensitivity. Counting the number of state changes of this channel is carried out asynchronously.

When configured for operation in the input-counter mode, the channel counts the number of pulses corresponding to: the total number of times the electrical level switched on the corresponding controller pin from the GND state to >= 4.5…13 volts, depending on the controller supply voltage, when the rising edge counter register is on; the total number of times the electrical level switched on the corresponding controller pin from the state >= 4.5…13 volts, depending on the controller supply voltage, to the GND state, when the falling edge counter register on. This value is available in the channel’s input edge counter register.

To set controller channel to the input-counter mode:

  • write a constant value, corresponding to the selected mode into the channel “DIO Output Mode Setup Register, IO Channel X” register;
  • write 1 into this 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” registers to activate rising and falling edge counters respectively.

Pulses are counted with overflow. This means that when a value of 65565 is reached and is subsequently increased by one, the counter value is set to zero and each subsequent pulse again increments the counter by one again. The counter is reset when the channel active mode is turned off.

Function diagram of a tachometer with a resolution of 100 RPM, counting the number of pulses on the controller pin corresponding to channel №8.

Determining pulse width (duration)

Working in input-counter mode, the controller channels can determine pulse width/duration in microseconds, asynchronously to the function diagram. Pulse width will be available in special registers of these channels.

If only the rising or falling edge counter mode is active, the actual period between the wave edges will be determined by the controller. If both rising and falling edge counter modes are active, the registers will contain values between the last two pulse edges. One register will contain the time between the last rising and the following falling edge, the other will contain the time between the last falling and the following risign edge. The sum of these values is the actual period.

Scenario 1. Only the rising edge counter is enabled.
Scenario 1 register values.
Parameter Return values
DIO Input Pulse 1 Width Value, Channel X 0
DIO Input Pulse 2 Width Value, Channel X Т2


Scenario 2. Only the falling edge counter is enabled.
Scenario 2 register values.
Parameter Return values
DIO Input Pulse 1 Width Value, Channel X Т1
DIO Input Pulse 2 Width Value, Channel X 0


Scenario 3. Rising and falling edge counters are both enabled.
Scenario 3 register values.
Parameter Return values
DIO Input Pulse 1 Width Value, Channel X Т1
DIO Input Pulse 2 Width Value, Channel Х Т2


Asynchronous counting mode means that the pulse length values are determined very precisely.

Note: Due to the specificities of the microsecond timer, the pulse width values in Input Pulse Width Value Registers are in Timer Units. One Timer Unit is equal to 1.066(6) microseconds. To obtain the actual pulse width value in microseconds, multiply the value in the registers by 1.067.

Function diagram for determining pulse length on channel 0 of CANNY 7.2 Duo controller.

Electrical protection

Controller system software performs automatic short circuit protection for channels that operate in digital output and PWM output modes, whose current in the “ON” or “OFF” states significantly exceeds 100 mA. Protection works in the following way:

  • the shorted channel is switched into the neutral mode;
  • the channel is periodically pulsed as test;
  • the channel is returned to the user-defined configuration when the short-circuit is no longer detected.

This protection is fully automatic and requires no user configuration.

SEE ALSO