Skip to content

Commit 73116e0

Browse files
committed
adding updating FW sections
1 parent eec8078 commit 73116e0

File tree

1 file changed

+115
-63
lines changed
  • content/hardware/08.edu/solution-and-kits/alvik/tutorials/user-manual

1 file changed

+115
-63
lines changed

content/hardware/08.edu/solution-and-kits/alvik/tutorials/user-manual/user-manual.md

+115-63
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ In this tutorial, you will find useful information to get started, test, and mai
2020

2121
Alvik is a robot with two controllers and a wide range of sensors and actuators. The main controller is the Arduino Nano ESP32 attached to the top of the robot while there is an STM32 controller integrated into the robot that takes care of the low-level commands such as reading the sensors and moving the motors. It has been designed for STEAM education, making it an ideal tool for learning programming, Robotics, IoT, Artificial Intelligence...
2222

23+
### Unboxing
24+
25+
![Unboxing Alvik](assets/unboxing.jpg)
26+
27+
Inside the Arduino Alvik package you'll find the following items:
28+
29+
- Alvik robot
30+
- 18650 Li-Ion battery attached to the robot
31+
- USB-C to USB-C cable
32+
2333
### Alvik Overview
2434

2535
![Alvik exploded view](assets/main-components.png)
@@ -219,11 +229,7 @@ With its line follower sensors, Alvik can navigate along predefined paths marked
219229
The goal is to present the sensors and actuators of the Alvik robot, highlighting their key features and uses without delving into programming specifics.
220230

221231

222-
## Alvik First Use
223-
224-
### Unboxing
225-
226-
![Unboxing Alvik](assets/unboxing.jpg)
232+
## Alvik's Firmware
227233

228234
To get started to play with Alvik you will need the following hardware and software:
229235

@@ -241,103 +247,149 @@ To get started to play with Alvik you will need the following hardware and softw
241247
- Operating Systems: All the major Operating Systems are supported
242248
- [Arduino Lab for Micropython](https://labs.arduino.cc/en/labs/micropython)
243249

244-
### ESP32 MicroPython Firmware
250+
### Updating Alvik's Brain (Nano ESP32)
245251

246-
Download and install the [Arduino Lab for MicroPython](https://labs.arduino.cc/en/labs/micropython), if you are able to connect the Arduino Nano ESP32 it means that your board is ready. You have to see the **CONNECTED** yellow label at the bottom.
252+
It may happen that you used your Nano ESP32 for other projects than Alvik, or you need to replace it. In order to make your Nano ESP32 work with Alvik, there are few steps needed:
247253

248-
![Connection Succeeded](assets/connection_succeeded.png)
254+
1. Install the micropython bootloader on it following [this guide](https://docs.arduino.cc/micropython/basics/board-installation/).
249255

250-
If something goes wrong it means you need to upload the MicroPython firmware on the Nano ESP32.
256+
2. Download the Alvik micropyton libraries
251257

252-
Follow [this guide](https://docs.arduino.cc/micropython/basics/board-installation/).
258+
1. Alvik micropython libraries from the [Alvik repository](https://github.com/arduino/arduino-alvik-mpy/tree/main)
259+
2. ucPack libraries from the [ucPack repository](https://github.com/arduino/ucPack-mpy/tree/main)
253260

254-
### How to Upload Libraries
261+
3. Unzip both of the downloaded libraries in a single "Alvik" folder, open the Arduino Lab for MicroPython, go to the "files" tab and set the path to the unzipped folder on the Arduino Lab for Micropython
255262

256-
You will find the latest instructions directly in the [repository](https://github.com/arduino/arduino-alvik-mpy/releases). Here are the main steps:
263+
![Setting the FW path on the Labs for micropython](assets/fw_path.png)
257264

258-
1. Prepare file
265+
4. Make sure your Alvik is OFF, connect it to your computer and then, turn it ON
259266

260-
Download the repository and extract all the files in a specific folder that will become the main Alvik folder.
267+
![Alvik USB Connection](assets/connecting-final.gif)
261268

262-
2. Remove old files
269+
5. Connect your Alvik to the Arduino Labs for micropython and open the "lib"
270+
![Setting the FW path on the Labs for micropython](assets/lib_folder.png)
263271

264-
Open **Arduino Lab for MicroPython** and **connect** Alvik. Then:
272+
6. Select the "Arduino-alvik" and move it inside the "lib" folder in your Alvik.
273+
![Setting the FW path on the Labs for micropython](assets/moving_alvik_folder.png)
265274

266-
Click on the `files` icon
275+
7. Go back to the main folder and select the "ucPack-mpy-main" folder and move it next to the arduino_alvik inside the "lib" folder in your Nano ESP32.
276+
![Setting the FW path on the Labs for micropython](assets/moving_ucPack.png)
267277

268-
Click on a `files name` in the bottom left explorer windows.
278+
8. Now go back to the main root of the files system on the Nano ESP32. Then in your local folder navigate to the examples folder once there, select the following files and move them to the main folder of the ESP32.
269279

270-
Click on the `bin` icon to delete it
280+
1. demo.py
281+
2. hand_follower.py
282+
3. line_follower.py
283+
4. main.py
284+
5. touch_move.py
271285

272-
Repeat for all the files, from all folders
286+
![Setting the FW path on the Labs for micropython](assets/moving_examples.png)
273287

274-
![Delete all files](assets/delete_files.png)
288+
With this last step, your Nano ESP32 has been set up with the Alvik out of the box experience and is ready to be used.
275289

276-
3. Install mpremote
290+
### Updating Alvik's Body (STM32)
277291

278-
[mpremote](https://docs.micropython.org/en/latest/reference/mpremote.html) is a Python module needed to upload files on the Nano ESP32. The minimum suggested mpremote release is 1.22.0. Be sure to have Python installed before proceeding!
292+
1. Download the [pre-compiled firmware](https://github.com/arduino-libraries/Arduino_AlvikCarrier/releases/latest) from the [Alvik Carrier GitHub reposiitory](https://github.com/arduino-libraries/Arduino_AlvikCarrier)
279293

280-
`(venv)$ pip install mpremote` or `(venv)$ python3 -m pip install mpremote`
294+
This step will download a "firmware_x_x_x.bin" file, save it in your Alvik folder
281295

282-
Depending on how you configure Python on your machine.
296+
2. Connect your Alvik to the Computer and to the Arduino Labs for Micropython. Then, go to the files tab and navigate to the folder where you stored the "firmware_x_x_x.bin"
297+
![Setting the FW path on the Labs for micropython](assets/firmware.png)
283298

284-
4. Install library
285-
Run the following line to upload all files and download the dependencies needed to run the Arduino Alvik MicroPython library.
299+
3. Let's move now the "firmware_x_x_x.bin" to the main root.
300+
![Setting the FW path on the Labs for micropython](assets/moving_fw_bin.png)
286301

287-
Linux
288-
`$ ./install.sh -p <device port>`
302+
4. Turn ON your alvik, go to the Editor tab and tun the following commands by typing them and clicking on the "Play" button
289303

290-
Windows
291-
`install.bat -p <device port>`
304+
```
305+
from arduino_alvik import update_firmware
306+
307+
update_firmware('./firmware_1_0_0.bin')
308+
```
292309

310+
![Setting the FW path on the Labs for micropython](assets/flashing_fw.png)
293311

294-
The `install.*` script will copy all the needed files into your Alvik.
295-
The `<device port>` is the name of the USB port that your computer assigned to the Nano ESP32.
312+
After executing these commands, there will be updates of the process on the prompt, once the process finishes, the firmware of your alvik will be updated.
296313

297-
There are several ways to find it, depending on your OS, for example:
298-
- You can use the Arduino IDE to discover the port, [follow this guide to know more](https://support.arduino.cc/hc/en-us/articles/4406856349970-Select-board-and-port-in-Arduino-IDE).
299-
- You can check it by using the Arduino Lab for MicroPython by clicking `Connect` after connecting Alvik with the USB cable.
300-
- You can check the list of the USB devices attached to your PC.
314+
### Hello Alvik! Your first program!
301315

302-
### How to Upload Firmware
316+
Alvik is intended to be programmed with MicroPyton. We recommend you to install the [Arduino Lab for MicroPython](https://labs.arduino.cc/en/labs/micropython) editor.
303317

304-
1. Download the latest [pre-compiled firmware](https://github.com/arduino-libraries/Arduino_AlvikCarrier/releases/latest) and place it inside Alvik's project folder.
318+
Now that all the previous steps have been set, let's see how to create custom programs for Alvik to move forward until detecting an object in front of it, Alvik will detect it, dodge it and continue on its way.
305319

306-
2. Go into `utilities` folder and run the `flash_firmware` script:
307320

308-
Linux
309-
`$ ./flash_firmware.sh -p <device port> <path-to-your-firmware>`
321+
**1. **Create an Alvik folder in your computer and set it as the path of the Arduino Lab for MicroPython IDE
310322

323+
![Adding Alvik folder path to the IDE](/Users/josegardel/Documents/arduino_GH/docs-content-private/content/hardware/08.edu/solution-and-kits/alvik/tutorials/getting-started/assets/alvik_folder_path.png)
311324

312-
Windows
313-
`flash_firmware.bat -p <device port> <path-to-your-firmware>`
325+
**2. **Create a new file "obstacle_avoider.py" in your local folder
314326

327+
![Creating obstacle_avoider.py file](/Users/josegardel/Documents/arduino_GH/docs-content-private/content/hardware/08.edu/solution-and-kits/alvik/tutorials/getting-started/assets/creating_file.png)
315328

316-
Answer `y` to flash firmware.
329+
**3. **Double click on the file to open it. Once it is opened, erase the text on it and add the following code.
317330

331+
![Adding custom code](/Users/josegardel/Documents/arduino_GH/docs-content-private/content/hardware/08.edu/solution-and-kits/alvik/tutorials/getting-started/assets/adding_custom_code.gif)
318332

319-
There are also several examples to test all the features of your Alvik placed inside the `examples` folder.
320-
Open **Arduino Lab for MicroPython** and **connect** Alvik. Then:
333+
``` python
334+
from arduino_alvik import ArduinoAlvik
335+
from time import sleep_ms
336+
import sys
337+
338+
alvik = ArduinoAlvik()
339+
alvik.begin()
340+
sleep_ms(5000) #waiting for the robot to setup
341+
#robot.set_illuminator(0)
342+
distance = 10
343+
speed = 40 #rpm
344+
345+
def turning():
346+
alvik.set_wheels_speed(0,0)
347+
sleep_ms(250)
348+
alvik.set_wheels_speed(-35,-35)
349+
sleep_ms(1500)
350+
alvik.set_wheels_speed(35,-35)
351+
sleep_ms(1000)
352+
353+
while (True):
354+
355+
distance_l, distance_cl, distance_c, distance_r, distance_cr = alvik.get_distance()
356+
sleep_ms(50)
357+
print(distance_c)
358+
359+
if distance_c < distance:
360+
turning()
361+
elif distance_cl < distance:
362+
turning()
363+
elif distance_cr < distance:
364+
turning()
365+
elif distance_l < distance:
366+
turning()
367+
elif distance_r < distance:
368+
turning()
369+
else:
370+
alvik.set_wheels_speed(speed, speed)
371+
372+
```
321373

322-
1. Click on the `files` icon
323-
2. Click on the `path string` in the bottom right explorer windows.
324-
3. Click on the `file name` of the example you choose
325-
4. Click on the `play button`
374+
**4. **Connect Alvik to your PC using the cable included in the box, under the tray.
326375

327-
![Test examples files](assets/test_files.png)
376+
![Connecting Alvik to the PC](/Users/josegardel/Documents/arduino_GH/docs-content-private/content/hardware/08.edu/solution-and-kits/alvik/tutorials/getting-started/assets/connecting_alvik.gif)
328377

378+
***Make sure that Alvik is OFF before connecting it to your computer.***
329379

330-
## Program Alvik!
380+
**5. **Once Alvik is connected to the PC, connect it to the Arduino Lab for MicroPython and open the _main.py_ file in the Alvik folder. Once the file is opened let's replace the `import demo` statement by `import obstacle_avoider`.
331381

332-
![Alvik USB Connection](assets/connecting-final.gif)
382+
![Connecting Alvik to the IDE](/Users/josegardel/Documents/arduino_GH/docs-content-private/content/hardware/08.edu/solution-and-kits/alvik/tutorials/getting-started/assets/connecting_alvik_ide.gif)
333383

334-
In order for Alvik to work properly three things have to be set correctly:
384+
***If you want to go back to the out of the box experience where you could select between reg, green and blue programs, you only need to modify the _main.py_ again replacing the `import obstacle_avoider` statement by `import demo`***
335385

336-
1. The Nano ESP32 needs the [MicroPython firmware](https://labs.arduino.cc/en/labs/micropython) on it.
337-
2. The [latest libraries](https://github.com/arduino/arduino-alvik-mpy/releases) have to be placed in the Nano ESP32.
338-
3. The [latest firmware](https://github.com/arduino-libraries/Arduino_AlvikCarrier/releases) has to be uploaded to the STM32 microcontroller.
386+
**6. **The last step is to move the _obstacle_avoider.py_ file from the local repository to Alvik's memory.
339387

340-
Alvik comes with a preinstalled version of libraries and firmware, but in case you want to upgrade it or if something happens and you mess things up, here is the guide to reinstall both libraries and firmware.
388+
![Moving file from local to Alvik's memory](assets/local2memory.gif)
389+
390+
You are now all set, disconnect Alvik from the computer, put some obstacles around Alvik, turn it ON and see how Alvik detects them and turns to avoid them.
391+
392+
## Deep dive programming Alvik
341393

342394
### Controlling the Motors
343395

@@ -761,18 +813,18 @@ In this example, the robot uses its line follower sensor array to navigate along
761813
from arduino_alvik import ArduinoAlvik
762814
import time
763815
from time import sleep
764-
816+
765817
# Initialization
766818
alvik = ArduinoAlvik()
767819
alvik.begin()
768820
sleep(5) # Waiting for the robot to setup
769-
821+
770822
# Calibrate color sensor for white
771823
alvik.color_calibration('white')
772-
824+
773825
# Main logic
774826
detected_colors = set()
775-
827+
776828
print("Starting to move and detect colors...")
777829

778830
try:

0 commit comments

Comments
 (0)