Raspberry Pi Serial

From Axel Public Wiki
Jump to navigation Jump to search

_TOC_

Introduction

The Axel PLC runtime for Raspberry PI offers some possibilities if you have an 'external' USB serial device, for example an RS232 or RS485 USB interface.
First of all, from a command line, you have to identify what device file represents that serial line under Linux, usually once you have inserted a new serial interface on an usb port, the file /dev/ttyUSB0 will appear.
One you have identified the file, suppose /dev/ttyUSB0, you have three ways to use it under PLC runtime:

  • Use directly the serial line in IEC code, by using the I/O interface offered by the library Serial.
  • You can configure yor Raspberry PI as a Modbus RTU Slave.
  • You can drive some Modbus IO module, by using your Raspberry PI as a Modbus RTU Master
  • You can configure the Raspberry PI as a gateway from Modbus TCP to a Modbus RTU: this means that the Raspberry PI act as Modbus TCP Slave, but forward the commands on the serial line to some Modbus RTU slave.

Please follow the following instructions for an introduction.

Serial Library

Modbus RTU Slave

Modbus RTU Master

Modbus RTU Gateway