Configuring Analog Outputs with CODESYS

CODESYS helps you to configure your RevPi AIO.

  • In the Codesys tree double-click on the RevPi AIO.
  • Navigate to the first tab “Module Parameters”.

Your AIO has two analog outputs. The outputs can emit either voltage or current. You can connect up actuators like for example frequency converters for speed control.

For your configuration to work it is important that your devices are connected to the correct output pins.

Output 1

Pin

Application

1

V+  positive output for voltage ranges channel 1

3

I+  positive output for current ranges channel 1

5

common ground for both output channels 1 and 2 (current and voltage)

7

common ground for both output channels 1 and 2 (current and voltage)

Output 2

Pin

Application

2

V+  positive output for voltage ranges channel 2

4

I+  positive output for current ranges channel 2

6

common ground for both output channels 1 and 2 (current and voltage)

8

common ground for both output channels 1 and 2 (current and voltage)

Please note that you can only output either current or voltage on one channel, although there are two separate connections. Detailed settings can be found in the following table: In the CODESYS AIO Module Parameters you need to click on the respective value tab to populate the drop-down list.

PiCtory setting

Value

Function

Output1 Range,
Output2Range

Off (output inactive)
0 – 5 V
0 – 10 V
-5 – 5 V
-10 – 10 V
0 – 5,5 V
0 – 11 V
-5.5 – 5.5 V
-11 – 11 V
4 – 20 mA
0 – 20 mA
0 – 24 mA

Set here the value ranges for the current or voltage that the outputs should emit.

Output1EnableSlew,
Output2EnableSlew

On = use slew rate
Off= don’t use slew rate

Here you can specify whether you want to use a slew rate for the respective output.
The slew rate controls the rate at which the output voltage or current changes when you set a new value for an output in the process image.

Output1SlewStepSize,
Output1SlewStepSize

1
2
4
8
16
32
64
128

Here you can select the slew rate step size for the respective function. Step size 1 corresponds to the smallest bit value (LSB) from the converter. Together with the clock frequency, the step size determines the slew rate between two analog values.

Output1SlewUpdateFreq,
Output1SlewUpdateFreq

258 kHz
200 kHz
154 kHz
131 kHz
116 kHz
70 kHz
38 kHz
26 kHz
20 kHz
16 kHz
10 kHz
8,3 kHz
6,9 kHz
5,5 kHz
4,2 kHz
3,3 kHz

Here you can select the step clock frequency for the slew rate of the respective output. Together with the clock frequency, the step size determines the slew rate between two analog values.

Scaling output 1:
Output1Multiplier
Output1Divisor
Output1Offset
Scaling output 2:
Output2Multiplier
Output2Divisor
Output2Offset

16 Bit signed Multiplier
16 Bit unsigned Divisor
16 Bit signed Offset

Here you can set a scaling for every output channel. It is determined by the three configuration values and calculated according to the following formula from the original value: (available in mV or µA respectively):
Y = X*Multiplier/Divisor + OffsetX is the value for the output,
Y stands for the voltage supply used in millivolts

Please note that you can only output either current or voltage on one channel, although there are two separate connections.

The scaling can be used for the conversion into other units or for a subsequent calibration of an actuator. A 32-bit integer arithmetic is used for calculations in the AIO module. The results are then sent again as 16-bit values to DAC. Should the result Y exceed the limits of a 16-bit signed value, then the error is recognized and the value limited. The output values for scaling factor 1 always have to be stored in the process image in the unit mV or µA respectively.

Example:

A frequency converter triggers an electric motor. It has an analog input of 0 to 10 V, whereby 0 V corresponds to a speed of 200 rpm and 10 V a speed of 3000 rpm. To store the speed in rpm in the process image, you have to select the parameters for the output range 0-10 V as follows:

Multiplier = 100, Divisor = 28, Offset = -714

Image

The slew rate settings have the following meaning:

Let”s assume you have selected an output range from 0 to 10 V. In the process image there is an output value of 3 V for channel 1. This value is now to change to 8 V. Therefore you write the number 8000 instead of the 3000 mV to the corresponding offset in the process image. In the next PiBridge cycle, the figure is then consigned to the DAC (Digital to Analog Converter) which then generates the analogue voltage for the output. This takes place with a certain delay time of 10-40 ms depending on the load on the PiBridge (which depends on the configuration). After this delay, the output voltage would jump from 3 V to 8 V very quickly. The slew rate of the voltage is only dependent on the total capacity at the output (which amongst other things is dependent on the connected devices). As a rule, it should amount to a few µs. The slew rate is often not desired because it has an extremely high frequency ratio that can lead to interference radiation and other problems. You can therefore artificially reduce the slew rate. To do so, click on “Output?EnableSlew”. Now the DAC will, as soon as it has received the new data (8000), increase the output voltage in small steps until 8 V is reached. You should set the amplitude by yourself by going to “Output?SlewStepSize”. This step size will be shown as a “LSB” (Last Significant Bit). As our converter works with a 16-bit resolution in every output range, the step size of the lowest-valued bit (LSB) measures, in the 0-10V range, 10V/2^16 = 0.15 mV (or respectively 0.30 µA in the 4-20 mA range). The number of minute steps that the DAC needs depends therefore only on the voltage jump: In our example, it is, for a step size of 1, therefore 5000 mV / 0.15 mV = 33,333 steps. The time in which these steps are performed is determined by the clock speed by which the steps are integrated into the signal. They can be set by yourselves by means of the “Output?SlewClock” parameter. When the clock speed is set at 3.3 kHz, the edge needs from 5 V, therefore 33,333* 1/3300 s = 10 s. When set at 258 kHz, it is therefore 130 ms. The slew rate is, for a 3.3 kHz clock speed, therefore 0.5 V/s or 38 V/s respectively when the clock speed is 258 kHz. You can obviously significantly increase the slew rate with larger step sizes but the signal will also “skip” so that it will receive significantly greater share of high frequency signals.

  • Click on “File>Save”. This saves your file.
  • Click on “Tools>Reset Driver”. This activates the changes for the adapter.

Should an error occur, you will receive error messages in the input values of channel names AO_Status_Ch1 and AO_Status_Ch2 located in tab AIO Module I/O Mapping. The respective bits in the status bytes have the following meaning:

Bit Position

Status Message

0 (LSB)

Temperature error of the output chip. The output chip is overheated as a result of overloading (short circuit).

1

Open Load Error of the current output. In the “Current Output” operating mode, the connected circuit is highly resistive because, for example, the supply has been interrupted.

2

Internal CRC error of the output chip. The error points to a hardware defect or serious external interference signals.

3

Range Error: The output value in the process image is below the configured output range.

4

Reserved for internal purposes

5

The supply voltage for the module is less than 10.2 V.
The outputs have been shut down.

6

The supply voltage for the module is more than 28.8 V.
The outputs have been shut down.

7 (MSB)

Timeout in the connection to RevPi Connect (e.g. due to a disturbance to the PiBridge or if the PiControl drive program no longer runs properly on the RevPi Connect). The outputs have been shut down.