This driver supports an A/D converter from Microchip technology inc. It is an SPI device, which features 4 or 8 analog channels, which are autonomously sampling the signals at a pretty high rate:
This is far beyond what we are able to read via Linux over SPI.
You need to have the device description and driver library installed from the "MCP3008" project.
This driver can be used in a similar way as most other CODESYS devices. Except, that the outputs are not mapped through the I/O mapping, but they are privided as an output of the FB from the device tree.
The chip has to be connected to a free SPI port. We assume, that you connect the chip with a chip select that coresponds to your SPI port. ATM we don't supporr to use general GPIOs for chip selects. Also no daisy chaining is supported, as the device doesn't support that.
This examle shows the wirering of an MCP3008 with a Raspberry Pi on SPI port 0 and chip select 0. This corresponds to "spidev0.0".
...
The device is named MCP3008 and has to be inserted below an SPI Master of your CODESYS project.
The SPI port and chip select have to be set to the Pins, where you connected the MCP3008.
The first number specifies the SPI bus. The second number specifies the chip select.
After the configuration is done, the input of the MCP3008 can be used directly from the output of the function block.
ch1 := MCP3008. ...