Skip to content

Commit 24d3adb

Browse files
authored
Merge pull request #2 from runger1101001/master
added platformio setup instructions
2 parents 2db2029 + fdef992 commit 24d3adb

File tree

8 files changed

+113
-1
lines changed

8 files changed

+113
-1
lines changed

docs/simplefoc_library/installation/library_platformio.md

Lines changed: 113 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,119 @@ grand_parent: Arduino <span class="simple">Simple<span class="foc">FOC</span>lib
1010

1111
# Installing <span class="simple">Simple<span class="foc">FOC</span>library</span> with PlatformIO
1212

13-
<blockquote class="info"> In depth docs coming soon!</blockquote>
13+
Using SimpleFOC from PlatformIO is not hard at all! The following instructions should get you set up and compiling your code in a matter of minutes.
14+
15+
## Prerequisites
16+
17+
- You need an active internet connection throughout this process, until your project is set up.
18+
- First, install [Visual Studio Code](https://code.visualstudio.com/download)
19+
- Run Visual Studio Code, and install PlatformIO using the Extensions Manager:
20+
21+
<img src="extras/Images/platformio_screenshot1.png">
22+
1. Select extension manager
23+
2. Enter "PlatformIO" in the search
24+
3. Choose PlatformIO extension from the list (should be the first result)
25+
4. Click install - after a few moments PlatformIO will be installed, you will be prompted to reload Visual Studio Code
26+
27+
Congratulations, you're ready to start your first project!
28+
29+
## Creating a project
30+
31+
To create a new project that uses SimpleFOC, use the following steps:
32+
33+
<img src="extras/Images/platformio_screenshot2.png">
34+
1. Select the PlatformIO Menu on the left sidebar
35+
2. Choose Open to open the platformIO home screen
36+
3. Click "New Project"
37+
38+
You will be taken to the new project wizard:
39+
40+
<img src="extras/Images/platformio_screenshot3.png" class="width50">
41+
1. Give your project a name, e.g. simplefoc_test_project
42+
2. Choose your board. SimpleFOC supports many MCU architectures, see [hardware/mcus]
43+
3. Once you have chosen your board, make sure the Framework "Arduino" is selected. PlatformIO supports other Frameworks, but SimpleFOC is an Arduino Library and must be run in Arduino framework.
44+
4. Click finish
45+
46+
At this point, if it is the first project you are creating for this board, PlatformIO will download all the required compilers, tools and core library files. Depending on your internet speed, this can take quite a few minutes, so please be patient!
47+
48+
## Add <span class="simple">Simple<span class="foc">FOC</span>library</span> to your project
49+
50+
When everything is finished installing, you should be presented with a view like this:
51+
52+
<img src="extras/Images/platformio_screenshot4.png">
53+
54+
You can now add the SimpleFOC library to the project:
55+
56+
<img src="extras/Images/platformio_screenshot5.png">
57+
1. Click on the PlatformIO icon, and choose "Libraries" from the Menu
58+
2. Enter "Simple FOC" in the search
59+
3. Click on the library
60+
61+
<img src="extras/Images/platformio_screenshot6.png">
62+
1. Click on "Add Library" to display the "Add Library" wizard
63+
64+
<img src="extras/Images/platformio_screenshot7.png" class="width50">
65+
1. Choose your project from the drop-down
66+
2. Click "Add" to add the library
67+
68+
Cool! The SimpleFOC library is now associated with your project.
69+
70+
## Configure your project
71+
72+
Open the platformio.ini file in the root directory of your project. It should look something like this, depending on the board you chose:
73+
74+
```
75+
; PlatformIO Project Configuration File
76+
;
77+
; Build options: build flags, source filter
78+
; Upload options: custom upload port, speed and extra flags
79+
; Library options: dependencies, extra library storages
80+
; Advanced options: extra scripting
81+
;
82+
; Please visit documentation for the other options and examples
83+
; https://docs.platformio.org/page/projectconf.html
84+
85+
[env:mkrwifi1010]
86+
platform = atmelsam
87+
board = mkrwifi1010
88+
framework = arduino
89+
lib_deps = askuric/Simple FOC@^2.2
90+
```
91+
92+
Important!
93+
You have to add the line *lib_archive = false* to make SimpleFOC compile correctly with PlatformIO.
94+
95+
You may also want to add some other options, like *monitor_speed* to set the serial port speed for debug output.
96+
97+
```
98+
lib_archive = false
99+
monitor_speed = 115200
100+
```
101+
102+
The available options depend on your board, and we cannot cover them all here, but they are documented in PlatformIO's documentation.
103+
104+
## Code away!
105+
106+
You can begin to write your code in the *src/main.cpp* file.
14107

15108
## Youtube tutorial by [@owennewo](https://github.com/owennewo)
109+
16110
<iframe class="youtube" src="https://www.youtube.com/embed/3B88qCny7Kg" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
111+
112+
113+
## Advanced Usage
114+
115+
PlatformIO makes it easy for you to use the source version of the SimpleFOC library. This lets you modify the code, or use the most recent "dev" branch version of the library to try out new features before they are officially released.
116+
117+
To use the source code version of the library, try the following steps:
118+
119+
1. Using your favourite git client, clone the simplefoc library from https://github.com/simplefoc/Arduino-FOC.git
120+
2. This will create a folder "Arduino-FOC" on your file-system, containing the library source code
121+
3. Go to your PlatformIO project, and inside the project go to the lib folder. You can use your operating system's shell, or the built-in shell in Visual Studio Code.
122+
4. Inside the lib folder of your project, create a symlink to your Arduino-FOC folder<br/>
123+
Mac/Linux:<br/>
124+
`% ln -s /path/to/Arduino-FOC`<br/>
125+
Windows:<br/>
126+
`% mklink /J Arduino-FOC C:\path\to\Arduino-FOC`
127+
128+
Note: If you had previously added the release version of the library to the project using PlatformIO's library management, you will have to remove this reference from the platformio.ini file
409 KB
Loading
522 KB
Loading
146 KB
Loading
235 KB
Loading
464 KB
Loading
325 KB
Loading
100 KB
Loading

0 commit comments

Comments
 (0)