CANNY 5.3 MD1A. Discrete IO Driver
- General Description
- Diagram of the controller channel
- IO Registers
- Channel neutral state
- Digital output mode
- PWM output mode
- Digital input mode
- Counter mode
- Determining pulse width (duration)
- Counter-encoder mode
- Electrical protection
General Description
CANNY 5.3 MD1A gives you access to three discrete general purpose IO channels. Each channel is physically accessed through a corresponding pin of X3 (Channels #8, #9, #10) 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 from 0 to controller supply voltage, transistor outputs of various equipment, etc.
Note: Avoid directly connecting controller channels to electrical circuits that contain high-power loads. When connecting to circuits whose power exceeds the maximum permissible for the controller channel (total current more than 100 mA), it is necessary to install a resistor with a resistance of more than 2000 Ohms in series.
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 5.3 MD1A controller drivers, specifically High Resolution PWM, UART / 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
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.
Register | Expected values |
---|---|
DIO Output Mode Setup Register, IO Channel 8 … 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 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 8 … 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 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 10 |
0…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 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 / Rising Edges 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 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. |
DIO Single Wair Hall Effect Sensor Power Output Enable Register, IO Channel 8 | ≥ 1 = activate the mode of operation with a single-wire Hall sensor; 0 = switch the channel to normal discrete operating mode / disable operating mode with a single-wire Hall sensor. |
DIO 5VDC High Side Mode Enable Register, IO Channel 8 | ≥ 1 = activate the 5 volt high side mode, switch the output to operating mode in the voltage range 0…5V; 0 = switch the channel to normal discrete operating mode / disable the 5 volt high side 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.
Note: Channel 8, in 5 volt high side mode, can be used to power external sensors that require a 5V supply voltage.
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.
Register | Return Values |
---|---|
DIO Output Overload Detect Register | ≥ 1 = a short circuit is detected on one or more controller channels included as a power output and the channel is switched to protection mode; 0 = no short circuit was detected on any of the controller channels. |
DIO Input Value Register, IO Channel 8 … 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 10 |
0…65535 = the number of pulses (with given parameters) registered on the corresponding controller pin |
DIO Input Pulse 1 Width Value, IO channel 8 … DIO Input Pulse 1 Width Value, IO channel 10 |
0…32767 = 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 8 … DIO Input Pulse 2 Width Value, IO channel 10 |
0…32767 = 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.
Parameter | Permitted values |
---|---|
Channel type | Digital output |
“ON” | Weak VDD (1mA); Strong VDD (100mA); Weak GND (1mA); Strong GND (100mA); Float. |
“OFF” | Weak VDD (1mA); Strong VDD (100mA); Weak GND (1mA); Strong GND (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.
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.
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.
Parameter | Permitted values |
---|---|
Channel type | PWM output. |
“ON” | Weak VDD (1mA); Strong VDD (100mA); Weak GND (1mA); Strong GND (100mA); Float. |
“OFF” | Weak VDD (1mA); Strong VDD (100mA); Weak GND (1mA); Strong GND (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.
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.
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.
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 MD1A 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 >= 3.2 volt, 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 >= 3.2 volt, 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.
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.
Parameter | Return values |
---|---|
DIO Input Pulse 1 Width Value, Channel X | 0 |
DIO Input Pulse 2 Width Value, Channel X | Т2 |
Parameter | Return values |
---|---|
DIO Input Pulse 1 Width Value, Channel X | Т1 |
DIO Input Pulse 2 Width Value, Channel X | 0 |
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.
Counter-encoder mode
Working together with channel 10, channel 9 of the controller can act as an encoder, increasing or decreasing the value of its counter depending on the state of channel 10: if, when the front was fixed by the encoder channel, a positive potential was set on the auxiliary channel, then the value will increase counter, if the “GND” potential was set on the auxiliary channel, the counter value will be reduced.
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.