Configuring RevPi Virtual Device

The RevPi Virtual Device can be used to exchange data between CODESYS and other external applications such as Node-RED. The space provided for this purpose in the RevPi process image is used for this via a virtual interface.

Here we show you how to configure a RevPi Virtual Device in CODESYS.

Prerequisites

A project with a RevPi device is created.

  • Right-click on the device interface piBridgeVirtual in the project tree.
  • Click on Add Device.
  • Select RevPi_Virtual.
  • Click on Add Device.

This device provides 32 bytes each of input and output memory in the RevPi process image for virtual access.

  • Double-click on RevPi_Virtual to open the tab for the mapping.
  • Enter a variable name for the 32-byte array of input and output.

  • Write the code for your desired CODESYS project using the virtual device variables created in the previous step.
  • Download the program.

RevPi Virtual is now in operation.

  • Open PiCtory.

In the following example, a RevPi Connect and a RevPi Virtual Device are displayed. This PiCtory configuration is created automatically each time CODESYS is started. It is only used as Read Only in PiCtory, as the config.rsc file is executed again after each restart of CODESYS. The variables of the virtual device can be seen in the figure below as Input_11_1 etc.

  • Activate the Export fields for the variables that are used in the RevPi Virtual Device.
  • Click on File/Export.
  • Select Offset list, Show Only and confirm with Ok.

The offsets that refer to the RevPi Virtual Device in the process image are now listed.

These variables can be accessed with external applications with the corresponding name or offset in the RevPi process image.

Example: With piTest you can read the 32 bytes of the virtual inputs (Input_11_1 to Input_11_32) from base offset 11 using the command piTest -r 11,32 .

Note: The outputs of the RevPi Virtual Device in CODESYS are written to the virtual inputs (Input_11_1 to Input_11_32) of the RevPi process image. External applications can write to virtual outputs (Output_1 to Output_32). These are then available as inputs of the RevPi Virtual Device in CODESYS.