A8 - Embedded Programming

Group Assignment:

I propose myself to learn how it works the Platform. IO for the Group Assignment

PlatformIO

PlatformIO is a IDE (Integrated development environment) extension, it´s a user friendly and extensible integrated development environment that simplifies the creation and delivery of embedded products.

Features:

  • Cross-platform tools for embedded C++ development
  • Run as a plug-in in visual Studio Code and other IDEs
  • Also available as a command-line utility
  • IDE has advanced features and includes debugger
  • More capable than Arduino IDE

Platform IO advantages:

  1. Code editor
  2. Syntax highlighter
  3. Autocomplete
  4. Debugger
  5. Compiler
  6. Library manager
  7. Version control
  8. Serial monitor

Install Platform IO

You have to have Visual Studio Code or other Text editor and Python version 3.5 minimum

You can find it as an extension for all of this Text Editors.

https://platformio.org/install/integration

emmbeded_Platformio_00

Install Python or check you Python version, it´s important to check Add Python 3.9 to PATH

image-20210322142547588

To check your Python version

python3 -- version

I had some installation problems, and I find the solution on https://github.com/platformio/platformio-core-installer/issues/221

image-20210322153703722

I had to access to a Windows utility - App Execution Aliases turn off Python and Phyton3 and restart Visual Studio Code.

After I restart VS Code, the extension download some stuff, and the user interface appears

image-20210322154134725

If you click on the new project a wizard appears

image-20210322155719670

You can choose more than 400 boards and different Frameworks, after choosing your setting the wizard downloads the necessary libraries and generates a folder structure for the project.

image-20210322155948924

The wizard creates all the files necessary for the project, in the src folder it creates file called main.cpp (a C++)

I pasted the Blink code from the Arduino examples, check the code in the "check icon" and sent to Arduino to test the communications.

All codes must include <Arduino.h> to work, and you have to include all the functions before the code use it.

Pio_Send

After checking the connections and sketch I insert a serial monitor line to check the serial communications, and use Serial.println("High") or ("Low") to print the status of the LED in the serial monitor

#include <Arduino.h>

// the setup function runs once when you press reset or power the board

*void* setup() {

 // initialize digital pin LED_BUILTIN as an output.

 pinMode(LED_BUILTIN, OUTPUT);

 Serial.begin(9600);

}

// the loop function runs over and over again forever

*void* loop() {

 digitalWrite(LED_BUILTIN, HIGH); 

 Serial.println("HIGH"); // turn the LED on (HIGH is the voltage level)

 delay(1000);            // wait for a second

 digitalWrite(LED_BUILTIN, LOW); 

 Serial.println("LOW");  // turn the LED off by making the voltage LOW

 delay(1000);            // wait for a second

}

Libraries

Different from the Arduino IDE, that each sketch use it´s own libraries, in PlatformIO you can assign a library and a version of that library to a different project, so you can work with different versions libraries for each project.

  • PlatformIO registry has over 10,000 libraries
  • Includes libraries from Git, Hg and SVN
  • Advanced Library Search Feature
  • Very well documented and included examples
  • Arduino framework includes built-in libraries.

The parameters for your PlatformIO project including the libraries are stored on a settings file called platformio.ini

PlatformIO is a best alternative to develop code because it´s more flexible, robust and have more tools than the Arduino IDE.

http://archive.fabacademy.org/fabacademy2017/fablabtrivandrum/students/280/week10.html

Neil Board

http://fabacademy.org/2020/labs/techworks/students/hani-alawamleh/assignments/week07/#the-components-needed

Stepper Board

http://archive.fabacademy.org/2016/fablabsingapore/students/156/project04.html

Read microcontroller data Sheet?

Checklist

  • [x] Linked to the group assignment page
  • [ ] Documented what you learned from reading a microcontroller datasheet.
  • [ ] Programmed your board
  • [ ] Described the programming process/es you used
  • [ ] Included your source code
  • [ ] Included a short 'hero video' of your board