How to Set Up Your Raspberry Pi Industrial Controller

The Raspberry Pi is an embedded microcomputer based on the ARM system. It is just a circuit board the size of a credit card, with interfaces reserved for GPIO, USB, Bluetooth, Wi-Fi, RJ45, etc. Users can connect a mouse, keyboard, monitor, and speakers to create a complete office computer. However, many people use it not for office work but to do interesting projects or research. For example, using the Raspberry Pi for an autonomous patrol car, a vacuum cleaner robot, a home control system, etc. The operating system of the Raspberry Pi is based on Linux, and many people use it to learn Linux programming. With the development of artificial intelligence, many people use it to learn and research AI.

My main purpose for using the Raspberry Pi is for industrial automation control. I had been using the Raspberry Pi 1 B+ model, which felt quite outdated. Recently, I bought a Raspberry Pi 4 B model to use with CODESYS to create an industrial controller. Since CODESYS has launched a runtime based on the Raspberry Pi, it can turn the Raspberry Pi into a PLC, achieving various industrial communication and control. The CODESYS development environment supports five programming languages defined by IEC 61131-3, making it an excellent environment for learning PLC standard programming. In this article, we will first introduce how to install the system on the newly purchased Raspberry Pi and power it on.

How to Set Up Your Raspberry Pi Industrial Controller

The appearance of the Raspberry Pi 4 B model is shown in the figure below:

How to Set Up Your Raspberry Pi Industrial Controller

Generally, the new Raspberry Pi does not come with a pre-installed operating system. To install the system, you first need the following hardware:

  1. Raspberry Pi motherboard;

  2. Micro SD card (capacity greater than 8GB);

  3. Micro SD card reader;

After preparing the above materials, follow the steps below:

Step 1: Download the Operating System

Go to the official Raspberry Pi website (https://www.raspberrypi.org) to download the latest operating system. Three types of operating systems are provided:

  • With desktop and recommended software (Raspberry Pi OS with desktop and recommended software);

  • With desktop (Raspberry Pi OS with desktop);

  • Lightweight system without desktop (Raspberry Pi OS Lite);

The desktop system has a graphical interface similar to Windows, making operations intuitive and convenient, but the installation package will be larger. The lightweight system does not have a graphical interface and can be operated using the command terminal, which is not very intuitive but saves space, especially suitable for controller products. Here I choose the lightweight system without desktop.

Step 2: Write the Operating System

Insert the prepared micro SD card into the card reader and connect it to the computer’s USB port. Use a writing software, such as Win32 Disk Imager, to write the downloaded Raspberry Pi operating system to the micro SD card.

The official website of Win32 Disk Imager is: https://win32diskimager.org/, and its interface is as follows:

How to Set Up Your Raspberry Pi Industrial Controller

This software is relatively simple to use. First, browse to locate the downloaded operating system file, select the micro SD card drive letter under Device, click Write, and wait for it to complete.

If your micro SD card has been used before, it is best to format it first using the SDFormatter software.

After writing is completed, you will see that the micro SD card has become two partitions, one is the boot partition, and the other is an unrecognized partition. Windows may prompt you to format it; at this point, be careful not to format it, as this is a Linux system partition that Windows cannot recognize.

Since the operating system installed on the Raspberry Pi currently does not have a desktop, and I have not prepared a screen, I need to use SSH to connect to it remotely. This requires enabling the SSH function. The method is to create a file named “ssh” (in lowercase, without a suffix) under the boot partition, as shown in the figure below:

How to Set Up Your Raspberry Pi Industrial Controller

With this operation, the operating system is complete. The micro SD card is actually equivalent to the hard disk of the Raspberry Pi. Insert it into the slot of the Raspberry Pi and power it on.

Step 3: Connect to the Raspberry Pi Remotely

Use remote tools that support SSH, such as Putty or MobaXterm, to connect to the Raspberry Pi. During the first startup, we do not know its IP address, so we can use the default user “pi” and the default address “raspberrypi.local”, with the code as follows:

ssh [email protected]

After successfully connecting, enter the default password: raspberry to log in. Once logged in successfully, you can add a new user, change the password, etc.

Step 4: Change the Static IP Address

In subsequent communications, the Raspberry Pi needs a fixed IP address, so you need to modify the file:

/etc/dhcpcd.conf

I generally prefer to use the Vim command to modify it, with the code as follows:

sudo vim /etc/dhcpcd.conf

If Vim is not installed on the system, you can use the following command to install Vim:

sudo apt-get install vim

After opening the dhcpcd.conf file, modify the static IP address for eth0, as shown in the figure below:

How to Set Up Your Raspberry Pi Industrial Controller

After completing the modifications, save and restart the Raspberry Pi, and you will be able to access it via the fixed IP address.

That’s it for the introduction on powering on the Raspberry Pi.

I share some industrial control knowledge on my WeChat video account, welcome to watch:

Leave a Comment

×