CANNY 5.3 Pico. Discrete IO Driver

General description

CANNY 5.3 Pico gives you access to three discrete general purpose IO channels. Each channel is physically accessed through a corresponding pin of the controller: channel 8 - contact 4; channel 9 - contact 3; channel 10 - contact 5. 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-12V, 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.

A number of CANNY 5.3 Pico controller drivers, specifically High Resolution PWM, UART / RS232 / Modbus, LIN, 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

Structural diagram of the CANNY 5.3 Pico controller channel

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 8
DIO Output Mode Setup Register, IO Channel 9
DIO Output Mode Setup Register, IO Channel 10
≥ 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 constants directory);
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 8
DIO Output Value Register, IO Channel 9
DIO Output Value Register, IO Channel 10
≥ 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 8
DIO Output PWM Period Setup Register, IO Channel 9
DIO Output PWM Period Setup Register, IO Channel 10
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 8
DIO Output PWM Duty Setup Register, IO Channel 9 DIO Output PWM Duty Setup Register, IO Channel 10
1…65535 = set the duty value of pulses generated at the corresponding controller pin, in milliseconds
DIO Input Inversion Register, IO Channel 8
DIO Input Inversion Register, IO Channel 9
DIO Input Inversion Register, IO Channel 10
≥ 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 8 DIO Input Active Wait / Counter Enable Register, IO Channel 9 DIO Input Active Wait Counter Enable Register, IO Channel 10 ≥ 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 8 DIO Input Active Wait / Falling Edges Counter Enable Register, IO Channel 9 DIO Input Active Wait / Falling Edges Counter Enable Register, IO Channel 10 ≥ 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.

Values returned by the I/O driver control registers.
Register Return values
DIO Input Value Register, IO Channel 8
DIO Input Value Register, IO Channel 9
DIO Input Value Register, IO Channel 10
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 8 DIO Input Edges Counter Value, Register, IO Channel 9 DIO Input Edges Counter Value, Register, IO Channel 10 0…65535 = the number of pulses (with given parameters) registered on the corresponding controller pin

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 constants directory.

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 #8 & #9 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 constants directory.

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 + 12V (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 5.3 Pico 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.

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