Programming an AVR PLC board: Setting up PlatformIO IDE on Visual Studio Code

January 23, 2024 by
Programming an AVR PLC board: Setting up PlatformIO IDE on Visual Studio Code
Boot & Work Corp. S.L., Francesc Nosas

In this Blog we'll learn how to use the PlatformIO extension for VSCode in order to write code for an AVR PLC. This add-on offers a comfortable interface in VSCode to manage projects.

Before we start, however, be aware that any board version below 1.1.42 does NOT support PlatformIO.



1. Installing PlatformIO IDE in Visual Studio Code


We first need to have Visual Studio Code installed. If you don't have it, here's where to start: 


https://code.visualstudio.com/download


Once installed, we need to install the PlatformIO extension. Search for "Platformio IDE" on the extensions search tab of VSCode. Click install and wait until it's done. VSCode might ask of you to restart the app in order for the extension to be correctly updated.

 



2. Starting a new project


Follow the steps on the following link:


https://docs.platformio.org/en/latest/integration/ide/vscode.html#quick-start


You can choose any board you want, since we'll be changing it later manually.





3. Project configuration


3.1. Edit platformio.ini


We'll copy the following code onto platformio.ini. This is the bare minimum we need.


[env]
platform_packages=
framework-industrialshields-avr@https://apps.industrialshields.com/main/arduino/boards/industrialshields-boards-avr-1.1.42.tar.bz2

[env:board]
platform = https://github.com/Industrial-Shields/platform-industrialshields-avr.git
board = mduinoplc_21+
framework=arduino


3.1.1. Choose platform packages


We'll have to edit the link on the variable platform_packages with the board version we're using. We can consult all available packages in the following link: 


https://apps.industrialshields.com/main/arduino/boards/


Remember, it has to be 1.1.42 or above.




3.1.2. Choose board


Edit the variable board with the board we're using. We can consult all the compatible boards in the following link:


https://github.com/Industrial-Shields/platform-industrialshields-avr/tree/main/boards




4. Run examples


A set of examples are available in the GitHub Repository: 


https://github.com/Industrial-Shields/platform-industrialshields-avr/tree/main/examples

4.1. Possible issues


99-platformio-udev.rules

If you're using Linux, VSCode might warn that you're missing the udev rules. To download this extension, write the following command on your terminal:

​$ curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/develop/platformio/assets/system/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules


More information on 99-platformio-udev.rules


​Search in our Blog

Programming an AVR PLC board: Setting up PlatformIO IDE on Visual Studio Code
Boot & Work Corp. S.L., Francesc Nosas January 23, 2024
Share this post

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>