This documentation is out of date.

The new version of the documentation is here: https://cannylogic.com/docs

CANNY 7.2 duo, Discrete IO Driver

From CANNY Wiki
Revision as of 15:57, 16 August 2019 by Support (Talk | contribs)


Jump to: navigation, search

Genegal Description

Users CANNY 7.2 duo has nine discrete input-output general purpose channels available. Each channel is physically presented to the appropriate pins of connector X2 (channel 0...7) and X3 (channel 8). Writing and reading data of the respective drivers registers, the functional diagram can manage the electric potential in each of these contacts and get information about current value of potential on each of them.

Channels physical characteristics allows to connect to them a variety of external actuators - electromagnetic relays, small motors, LEDs. As an external digital input signals it is possible to use a mechanical, electromechanical, and electronic buttons and switches, pulse generators, voltage source 0-12V and transistor outputs of various equipment, etc.

Channels operation mode and parameters specified by function diagram. At any given time, the channel can only work in one of the possible modes, but it is possible to dynamic override the channel configuration from the functional diagram during execution.

A number of CANNY 7.2 duo controller drivers, specifically High Resolution PWM, UART / RS232 / Modbus, LIN, in their operation use input-output channels resources and, thus, have a higher priority. Thus, when using these drivers of certain channel controller, IO driver access to these channels is not possible.

Note: The output operating voltage on the controller channels depends on its supply voltage, i.e. matches him. The permissible voltage on the channels operating in the input mode must also not exceed the controller supply voltage.

Diagram of the controller channel

17 6 1 1.png

IO Registers

The parameters defining operation mode and channel current state, are set for each channel independently. Below is acceptable values specifications of registers controlling input-output channels operation in all major modes.

Register Expected values
DIO Output Mode Setup Register, IO Channel 0
DIO Output Mode Setup Register, IO Channel 1
...
DIO Output Mode Setup Register, IO Channel 8
≥ 1 = set 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 to a neutral state, controller terminal corresponding to an output channel, and eliminate the possibility of its status changing from a functional diagram.
DIO Output Value Register, IO Channel 0
DIO Output Value Register, IO Channel 1
...
DIO Output Value Register, IO Channel 8
≥ 1 = set at the appropriate controller pin, the electric potential specified by this channel configuration for status "ON";
0 = set at the appropriate controller pin, the electric potential specified by this channel configuration for status «OFF».
DIO Output PWM Period Setup Register, IO Channel 0
DIO Output PWM Period Setup Register, IO Channel 1
...
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 contact of the controller, 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 corresponding contact of the controller.
DIO Output PWM Duty Setup Register, IO Channel 0
DIO Output PWM Duty Setup Register, IO Channel 1
...
DIO Output PWM Duty Setup Register, IO Channel 8
0...65535 = set the duty value of the pulses generated at the corresponding controller contact, in milliseconds;
DIO Input Inversion Register, IO Channel 0
DIO Input Inversion Register, IO Channel 1
...
DIO Input Inversion Register, IO Channel 8
≥ 1 = set on the corresponding contact of the controller inverse (negative) value of the potential of the input signal, taken as the state "ON" (logical 1);
0 = set on the corresponding contact of the controller the usual (positive) value of the potential of the input signal, taken as the state "ON" (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
...
DIO Input Active Wait / Rising Edges Counter Enable Register, IO Channel 8
≥ 1 = set the channel to active mode / activate the rising edges counter (switching level "GND" to positive level);
0 = set the channel to passive mode / disable the counter mode of rising edges.
DIO Input Active Wait / Falling Edges Counter Enable Register, IO Channel 0
DIO Input Active Wait / Falling Edges Counter Enable Register, IO Channel 1
...
DIO Input Active Wait / Falling Edges Counter Enable Register, IO Channel 8
≥ 1 = set the channel to active mode / activate the falling edges counter (switching level positive to "GND" level);
0 = set the channel to passive mode / disable the counter mode of falling edges.
Note: Level monitoring at the controller inputs is carried out continuously; additional configuration of the channel for operation as an input is not required. By default, the inputs are configured as positive, i.e. a logical unit is a positive potential. Changing the settings of the inputs can be performed independently for each channel using the inversion register of the input value of the corresponding channel.
Note: The counter modes of rising and falling edges of the same channel can be activated simultaneously, both edges will be taken into account, and the value of the total number of registered changes in levels (edges) at the active input will be available in the register of counter values ​​of the corresponding channel. Counting fronts is a cumulative result, with overflow. The counter is reset when the active channel mode is disabled.

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

Register Return values
DIO Input Value Register, IO Channel 0
DIO Input Value Register, IO Channel 1
...
DIO Input Value Register, IO Channel 8
1 = an electrical level corresponding to the polarity of the input was established on the corresponding contact of the controller (positive - with the usual input setting; "GND" - with the inversion of the input value);
0 = an electric level that does not match the polarity of the input has been established on the corresponding contact of the controller ("GND" - with the usual input setting; positive - with the inversion of the input value).
DIO Input Edges Counter Value Register, IO Channel 0
DIO Input Edges Counter Value Register, IO Channel 1
...
DIO Input Edges Counter Value Register, IO Channel 8
0...65535 = the number of pulses (with given parameters) registered on the corresponding contact of the controller.

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, given 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 start functional diagram execution;
  • in the event of controller malfunction or system software failure.

Digital output mode

The channel configured to operate as a discrete output, sets at the appropriate controller pin, an electric potential, corresponding to the "ON" state, when writing a nonzero value to the address of channel output value register, and sets at the appropriate controller pin,an electric potential corresponding to the "OFF" state when recording the value of "0 " to the address of channel output value register.

Note: The output operating voltage on the controller channels depends on its supply voltage, i.e. matches him.

Channel configuration for operation in this mode is determined by a constant, defining combination of parameters, that determine the electrical potential and current at the terminal of the corresponding controller channel in the "ON" and "OFF" position

Parameter Acceptable 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.

Named constants that represent channels configuration parameters combination available to the user, contains in the "DIO Output Stage Modes" CannyLab constants directory, which can be accessed via function block entry context menu having a type of "constant".

To transfer controller channel in to digital output mode, it's necessary to copy the constant value corresponding to the selected mode in to corresponding channel address "DIO Output Mode Setup Register, IO Channel X"

Note: For channels operating in the digital output configuration, it is also possible to obtain a value, corresponding to the actual current electrical potential at the channel terminal, which allows the use of channel feedback mode

An example of a functional diagram performing every second, alternate switching from supply voltage (100mA) to GND level (1 mA) at controller pins, corresponding to channels #0 and #1.

17 6 4 1.PNG

PWM output mode

The channel configured for operation in PWM output, generates on the corresponding controller pin a pulse width signal of a predetermined polarity, frequency, and duty cycle. In this mode, the channel is asynchronous to functional diagram, which allows for greater stability of generated timing signal, than in the organization of PWM generator by functional diagram resources.

17 6 5 1.png

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 terminal in the active "ON" and passive "OFF" generating phase, corresponding channel of the controller, and a pair of numeric values defining the frequency and filling generating pulses in milliseconds.

Parameter Acceptable 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.

Named constants that represent channels configuration parameters combination available to the user, contains in the "DIO Output Stage Modes" CannyLab constants directory, which can be accessed via function block entry context menu having a type of "constant".

To transfer controller channel in to PWM output mode it is necessary:

  • to copy value constant, corresponding to the selected mode into selected channel address "DIO Output Mode Setup Register, IO Channel X";
  • to copy digital value 0 to 65565, setting generated pulses period in ms into selected channel address "DIO Output PWM Period Setup Register, IO Channel X" ;
  • to copy digital value 0 to 65565, setting generated pulses duty cycle in ms into selected channel address "DIO Output PWM Duty Setup Register, IO Channel X" ;

An example of a functional diagram performing every second, alternate switching from supply voltage (100mA) to GND level (1 mA) at controller pin, corresponding to channel #0.

17 6 5 2.PNG

Digital input mode

The channel, configured to operate as a digital input, returns a value of "1" in its input value register, if on the appropriate controller pin establishes an electrical potential corresponding to the "Input polarity" state; and returns the value "0" to input value register, if on the appropriate controller pin establishes an electrical potential not corresponding to the "Input polarity" state.

Channel configuration for operation in this mode is determined by a constant, representing a combination of parameters that determine the electrical potential at the terminal accepted for the state of "1" of corresponding controller channel, the existence and potential of internal controller pin "pull-up", sensitivity and channel activity in a low power mode of the controller.

Parameter Acceptable values
Channel type Digital Input.
Input polarity PLUS; MINUS.
Pull-up plus; minus; air.
Standby mode active; passive.
Sensitivity max (0 ms); high (20 ms); norm (200 ms); low (700 ms).

Change potential on the channel pin is in the active standby mode, will result in immediate automatic exip controller from hibernation. Change potential on the channel pin is in the passive standby mode, does not affect controller power consumption.

Channel sensitivity determines its "bounce protection", ie the time interval during which the electrical potential on the corresponding channel pin should remain unchanged, in order to be considered a set and change channel input value.

Named constants that represent channels configuration parameters combination available to the user, contains in the "DIO Channel Configuration" CannyLab constants directory, which can be accessed via function block entry context menu having a type of "constant".

To transfer controller channel into Digital Input mode it is necessary to copy value constant, corresponding to the selected mode into channel address "DIO Mode IO Channel ##".

An example of a functional diagram, switching-on a built-in green LED with the flow and hold for at least 200ms at the appropriate pin of channel №0, the potential GND:

6 6 6 1.png

Counter mode

The channel configured for operation of a counter, returns a number to its output value register, corresponding to the number of electric potential switching on the corresponding controller pin from the state opposite of the parameter "Input Polarity" into the state of the parameter "Input Polarity" for the last time a given duration. Thus, the channel in this mode functions as a counter of the signal rising edges or frequency meter.

In this mode, the channel is asynchronous to functional diagram, which allows for greater accuracy in determining the time parameters of the signal and measure higher frequency signal than in the organization of pulse counter by functional diagram resources.

Channel configuration for operation in this mode is determined by a constant, is parameters combination that determine the electrical potential when it appears at the controller channel corresponding pin registers the rising edge of a signal, presence and potential of internal "pull-up".

Channel Configuration for operation in this mode is given by the combination of the following parameters:

Parameter Acceptable values
Channel type Input-Counter.
Input polarity PLUS; MINUS.
Pull-up plus; minus; air.

In the 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.

Named constants that represent channels configuration parameters combination available to the user, contains in the "DIO Channel Configuration" CannyLab constants directory, which can be accessed via function block entry context menu having a type of "constant".

To transfer controller channel into Counter mode it is necessary:

  • to copy value constant, corresponding to the selected mode into selected channel address "DIO Mode IO Channel ##";
  • to copy digital value 0 to 65565, setting pulses counting period in ms into selected channel address "DIO Period IO Channel ##";

With a value of none-zero in the period register, the value in the input value register of a channel is updated once a period and contains the number of pulses registered by the counter in the intervening period.

Counting the pulse by the counter is conducted with overflow. This means that when the value of 65565 reached and subsequent increases by one, the counter value is set to zero, but each subsequent pulse again increments the counter by one.

An example of a functional diagram of a tachometer with a resolution of 100 RPM, count the number of pulses on the controller pin corresponding to channel №0:

6 6 7 1.png
Note: If the period is set to zero, the counter continuously counts pulses with result accumulation in the register of the channel output value. In this mode, the value of this register is reset only by register overflow .

Equivalent circuit diagrams

Equivalent circuit diagrams for each possible state of the input-output channel shown in the table below:

Channel state Equivalent circuit diagram
«air»
6 6 9 1.png
«plus (1mA)»
6 6 9 2.png
«PLUS (100mA)»
6 6 9 3.png
«minus (1mA)»
6 6 9 4.png
«MINUS (100mA)»
6 6 9 5.png
«pull up air»
6 6 9 6.png
«pull up plus»
6 6 9 7.png
«pull up minus»
6 6 9 8.png


Electrical protection

For channels operated in a digital output and PWM output modes, whose current in "ON" or "OFF" state significantly exceeds 100 mA, controller system software performs automatic short circuit protection. Protection implemented as the form of switching of a shorted channel into the neutral mode, the subsequent periodic pulse of start test and reset to a user-defined configuration upon detection elimination of short circuit. This protection is fully automatic and requires no user configuration.

See also

CANNY 7.2 duo

CANNY 7.2 duo, HR PWM Driver