README.md 6.97 KB
Newer Older
David Gauchard's avatar
David Gauchard committed
1
Pousse Seringue / Arduino / ESP8266 / LAAS-HW
Maximilien Naveau's avatar
Maximilien Naveau committed
2
=============================================
David Gauchard's avatar
David Gauchard committed
3

Maximilien Naveau's avatar
Maximilien Naveau committed
4
## Données préliminaires
David Gauchard's avatar
David Gauchard committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18

- Hardware
  - [A4988 breakout](https://www.pololu.com/file/0J450/a4988_DMOS_microstepping_driver_with_translator.pdf)
  - [A4988 wiring](https://tasmota.github.io/docs/A4988-Stepper-Motor-Controller/#wiring-diagrams)
  - Stepper: 17HS19-2004S1
    - 200steps 1.8°/step 2A/φ 1.4Ω/φ
    - WIRING: 1A/A-/grn 1B/A+/blk 2A/B-/blu 2B/B+/red
    - [Wiring ref1](https://www.omc-stepperonline.com/download/17HS19-2004S1.pdf)
    - [Wiring ref2](https://1000diy.com/p3140/kak-podklyuchit-shagovyy-motor-k-drayveru-cvetovaya-markirovka-provodov)

- Arduino libraries (git-clone dans le répertoires des librairies Arduino)
  - [Web UI](https://github.com/s00500/ESPUI.git)
  - [Stepper Driver](https://github.com/laurb9/StepperDriver)
  - [OLED](https://github.com/greiman/SSD1306Ascii)
Maximilien Naveau's avatar
Maximilien Naveau committed
19
20
21
22
23
24
25
26
27
28
29

## Installation des drivers et outils de compilation

### Installer toutes les dépendences:

Créer un espace de travail: `mkdir -p ~/devel/workspace/src`

Cloner les paquets suivant dans le dossier `~/devel/workspace/src`.
- [Compiler and driver pour le esp8266 arduino (coeur arduino).](https://github.com/esp8266/Arduino/)
- [Fournisseur d'interface web pour arduino.](https://github.com/s00500/ESPUI)
  On l'utilise pour l'interface graphique
30
31
32
33
34
35
36
37
38
- [Parseur de fichier Json pour arduino.](https://github.com/bblanchon/ArduinoJson)

Pour compiler sur la cible :
- [Pile TCP asynchrone.](https://github.com/me-no-dev/ESPAsyncWebServer)
- [Serveur web asynchrone.](https://github.com/me-no-dev/ESPAsyncTCP)

Pour compiler sur le PC (pour test) :
- [Remplacement du serveur web asynchrone.](https://github.com/d-a-v/emuAsync)
  (les librariries Async* ne sont pas compilables sur PC)
Maximilien Naveau's avatar
Maximilien Naveau committed
39
40
41
42
43
44
- [WebSocket driver pour arduino.](https://github.com/Links2004/arduinoWebSockets)
  Utilisé pour la compilation locale de l'interface graphique web.

```
mkdir -p ~/devel/workspace/src
cd ~/devel/workspace/src
45

Maximilien Naveau's avatar
Maximilien Naveau committed
46
47
git clone --recursive git@github.com:esp8266/Arduino.git arduino_esp8266
git clone --recursive git@github.com:s00500/ESPUI.git
48
49
50
51
52
git clone --recursive https://github.com/bblanchon/ArduinoJson.git
# pour l'esp8266 seulement
git clone --recursive https://github.com/me-no-dev/ESPAsyncWebServer
git clone --recursive https://github.com/me-no-dev/ESPAsyncTCP
# pour emulation sur PC seulement
Maximilien Naveau's avatar
Maximilien Naveau committed
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
git clone --recursive git@github.com:d-a-v/emuAsync.git
git clone --recursive https://github.com/Links2004/arduinoWebSockets.git
```

On récupère la chaine d'outil pour compiler sur arduino
```
cd ~/devel/workspace/src/arduino_esp8266/tools/
./get.py
```

Pensez à verifier l'installation en suivant les instruction du paragraph suivant.

### Vérification de l'installation:

#### Emulation de l'interface graphique

Pour verifier sir l'émulateur fonction on fait tourner un test unitaire d'ESPUI.
```
export ESP8266ARDUINO=~/devel/workspace/src/arduino_esp8266
export ARDUINOLIB=~/devel/workspace/src/
cd ~/devel/workspace/src/
./emuAsync/tests/ESPUI-gui
```
Cela devrait compiler le test et creer un executable `gui`.
Celui ci se trouve afficher dans le terminal entre deux flèches:
```
----> ~/devel/workspace/src/arduino_esp8266/tests/host/bin/gui/gui <----
```
Vous l'éxecuter:
```
~/devel/workspace/src/arduino_esp8266/tests/host/bin/gui/gui
```
Et vous ouvrez firefox sur localhost:9080:
```
firefox localhost:9080
```

## Compiler et flasher la carte:

### IDE Arduino

@todo

### PlaterformIO

98
99
100
101
102

1. Visual Studio Code: Download Visual Studio Code, either from <https://code.visualstudio.com/> or from the repository manager of your OS. Install it.

![Getting started step1 - Download VSCode](docs/figures/image.png)

103
2. PlatformIO: Launch Visual Studio Code. On the left side menu, click on the extension icon ![extension_icon](docs/figures/image2.png). 
104

105
106
107
In the search engine, type "PlatformIO IDE", and click install. Finally, restart Visual Studio Code when you are prompted to do so.

![Getting started step 2 - PlatformIO installation](docs/figures/image3.png)
108
109
110

Now we will download the code from Git to Visual Studio, and compile it.

111
3. In Visual Studio code, on the left side menu, click on PlatformIO icon ![platformio_icon](docs/figures/image4.png)! Pro tip: if the alien icon does not show up spontaneously, wait for a few more seconds, then press F1 key and type platformio home.
112
113
4. In Platform.io, select "Clone Git Project ". PlatformIO will automatically open a field in which you can type `https://gitlab.laas.fr/fablaas/pousseseringue/pousseseringue-arduino` and press enter. PlatformIO will ask you in which folder to clone the project. Choose the folder you have created previously. A pop up will appear asking if you trust the authors. You can trust us. :smile:

114
![Getting started step4 - clone the git repository](docs/figures/image5.png)
115
116
117
118
119

:warning: Make sure that the name of the cloned project has no space in its path as it would create issues.

5. Make sure you are on the main branch of the Git project. You should see the following file tree.

120
![Getting started step 5 - File tree and main branch](docs/figures/image6.png)
121
122
123
124
125
126
127
128
129

## Step-by-step implementation

6. Connect hardware

Now we will connect the serynge to the PC with a micro USB cable.

7. Build and Upload

130
131
* In the bottom menu, click on the Build icon ![build_icon](docs/figures/image7.png). This will launch the compilation of the code. If this is the first time that you compile, Visual Studio Code will download several extensions that are required to write the code onto the serynge microcontroller. When the compilation is completed, you should see \[SUCCESS\] in the terminal.
* In the bottom menu, click on the Upload icon ![flash_icon](docs/figures/image8.png). This will flash the compiled code on the microcontroller of serynge. When the process is completed, you should see \[SUCCESS\] in the terminal.
132
133
134

:warning: For Linux users, you may have the LIBUSB_ERROR_ACCESS error when uploading to the board, check your udev permissions: <https://community.platformio.org/t/stm32-vs-code-mbed-upload-issue-error-libusb-open-failed-with-libusb-error-access-error-open-failed/10650>

135
8. In the bottom toolbar, click on the Serial Monitor icon ![serial_icon](docs/figures/image9.png). You will be able to see the messages from the serynge in the terminal.
136
137

That’s it!
Maximilien Naveau's avatar
Maximilien Naveau committed
138
139
140

### ESP

141
142
@todo

Maximilien Naveau's avatar
Maximilien Naveau committed
143
144
## Visualization locale de l'interface utilisateur sans l'arduino.

145
Compiler l'application localement:
Maximilien Naveau's avatar
Maximilien Naveau committed
146
```
147
# se positionner dans pousseseringue-arduino/
Maximilien Naveau's avatar
Maximilien Naveau committed
148
149
export ESP8266ARDUINO=~/devel/workspace/src/arduino_esp8266
export ARDUINOLIB=~/devel/workspace/src/
150
151
cd host_gui
./make.sh
Maximilien Naveau's avatar
Maximilien Naveau committed
152
153
154
```
lancer le server:
```
155
${ESP8266ARDUINO}/tests/host/bin/pousseseringue-arduino/pousseseringue-arduino
Maximilien Naveau's avatar
Maximilien Naveau committed
156
157
```

158
159
160
161
162
163
164
165
166
167
168
169
170
## Some code details explanation

### CORE_MOCK

Ce `CORE_MOCK` permet d'ignorer les ligne qui sont spécifique au micro-controller
afin de compiler le driver sur le PC local. Cela permet notamment de visualiser
le gui sans avoir la carte éléctronique physiquement et de la flasher.
```
#if !CORE_MOCK
  // on the target
#else // !CORE_MOCK
  // on host
#endif // !CORE_MOCK
171
```