CANNY 5.3 pico, Discrete IO Driver

From CANNY Wiki
Jump to: navigation, search

Genegal Description[edit]

Users CANNY 5.3 pico has three discrete input-output general purpose channels available. Each channel is physically presented to the appropriate pins of controller: channel 8 - contact 4; channel 9 - contact 3; channel 10 - contact 5. 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 5.3 pico 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[edit]

16 6 1 1.png

IO Registers[edit]

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 8
DIO Output Mode Setup Register, IO Channel 9
DIO Output Mode Setup Register, IO Channel 10
≥ 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 8
DIO Output Value Register, IO Channel 9
DIO Output Value Register, IO Channel 10
≥ 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 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 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 8
DIO Output PWM Duty Setup Register, IO Channel 9
DIO Output PWM Duty Setup Register, IO Channel 10
0...65535 = set the duty value of the pulses generated at the corresponding controller contact, 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 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 8
DIO Input Active Wait / Rising Edges Counter Enable Register, IO Channel 9
DIO Input Active Wait / Rising Edges Counter Enable Register, IO Channel 10
≥ 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 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 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 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 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 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 contact of the controller.

Channel neutral state[edit]

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[edit]

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 #8 and #9.

16 6 4 1.PNG

PWM output mode[edit]

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.

16 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 #8.

16 6 5 2.PNG

Digital input mode[edit]

In the process of executing a user diagram, the current level value on the controller contacts can be determined using the input value registers of the corresponding channel, in which, by default, the value "1" is returned if a positive electric level is established on the corresponding contact of the controller and the value "0" is returned when an electric level "GND" is established on the corresponding contact of the controller. The setting of the controlled level on the controller contacts can be changed using the channel input inversion register.

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

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

The input channels of the controller operate with maximum sensitivity, that is, "Protection against surges" is not provided and should be implemented, if necessary, in the users functional diagram.

An example of a functional diagram, switching-on a built-in green LED and hold for at least 200ms at the appropriate pin of channel #8, the positive level:

16 6 6 1.PNG

Counter mode[edit]

When the active mode / counter of the rising or / and falling edges of any of the controller channels is turned on, CANNY 5.3 pico allows, asynchronously to a functional diagram, to automatically count the changes in the level of the input signal corresponding direction.

Note: The rising edge of the controller refers to the change in level on a given contact from negative (GND) to positive (voltage of the controller), and the falling edge - the change of level from positive (voltage of the controller) to negative (GND).
Note: Channel configuration is determined by the output mode setup of this channel.
Note: Turning on the counters of the rising and falling edges is carried out using two separate independent registers, which allows you to simultaneously activate both counters and, accordingly, keep track of any level changes (both edges) on this contact of the controller.

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.

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

Configured for operation in the input-counter mode, the channel returns in the register of its input edges counter value the number of pulses corresponding to: the total number of switching of the electric level on the corresponding contact of the controller 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 switching of the electric level at the corresponding controller contact from the state >= 4.5...13 volts, depending on the controller supply voltage, to the GND state, with the falling edge counter register on.

To transfer controller channel into Counter 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 value 1 into selected channel address "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";

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. The counter is reset when the channel active mode is turned off.

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 №8:

16 6 7 1.PNG

Electrical protection[edit]

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[edit]

CANNY 5.3 pico

CANNY 5.3 pico, HR PWM Driver