You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/04.pro/boards/portenta-h7/tutorials/usb-host/content.md
+21-21Lines changed: 21 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ software:
22
22
---
23
23
24
24
## Overview
25
-
It is possible to configure the Portenta H7 to act as a USB host in a way that allows to connect peripherals such as a keyboard or mouse to interact with the board. This way you could connect a keyboard to your Portenta and type numbers or characters to trigger actions from your sketch.
25
+
It is possible to configure the Portenta H7 to act as a USB host in a way that allows to connect peripherals such as a keyboard or mouse to interact with the board. This way, you could connect a keyboard to your Portenta and type numbers or characters to trigger actions from your sketch.
26
26
27
27
## Goals
28
28
@@ -48,13 +48,13 @@ It is possible to configure the Portenta H7 to act as a USB host in a way that a
48
48
49
49
## USB Host and Client Mode
50
50
51
-
When using the Portenta H7 as a USB host it can receive and manage the information provided by other USB peripherals connected to it through a hub. In this scenario, the Portenta H7 is referred to as "USB host" or "controller" device, and the peripheral is called the "client" device, ( usually a mouse or a keyboard).
51
+
When using the Portenta H7 as a USB host, it can receive and manage the information provided by other USB peripherals connected to it through a hub. In this scenario, the Portenta H7 is referred to as "USB host" or "controller" device, and the peripheral is called the "client" device (usually a mouse or a keyboard).
52
52
53
-
Computers are by default USB hosts too as they receive the information the USB peripherals provide. PCs follow a “plug and play” mechanism, this means that whenever a USB device is connected, the host detects the device and loads the appropriate drivers for the device to establish a communication channel over the serial bus.
53
+
Computers are by default USB hosts too, as they receive the information the USB peripherals provide. PCs follow a “plug and play” mechanism, this means that, whenever a USB device is connected, the host detects the device and loads the appropriate drivers for the device to establish a communication channel over the serial bus.
54
54
55
-
In contrast to being the host point for peripherals, the Portenta H7 can also be connected to the computer as the "client". In this case, the PC is the USB host and the Portenta H7 the peripheral. We see this scenario whenever we upload sketches to the board or when we monitor data through the serial monitor.
55
+
In contrast of being the host point for peripherals, the Portenta H7 can also be connected to the computer as the "client". In this case, the PC is the USB host and the Portenta H7 the peripheral. You can see this scenario whenever you upload sketches to the board or when you monitor data through the Serial Monitor.
56
56
57
-
Furthermore, the Portenta H7 can also be set to be a mouse or keyboard itself. With the corresponding sketch, circuitry and components, we could send keyboard or mouse data to a PC (not covered in this tutorial).
57
+
Furthermore, the Portenta H7 can also be set to be a mouse or keyboard itself. With the corresponding sketch, circuitry and components, you could send keyboard or mouse data to a PC (not covered in this tutorial).
58
58
59
59
## Instructions
60
60
@@ -64,7 +64,7 @@ In this tutorial you are going to configure your Portenta H7 as a USB Host. This
64
64
65
65
Throughout the tutorial, you will learn how to establish a serial communication between the board and the keyboard and also, how to program the board so it acts as a USB Host device.
66
66
67
-
To achieve this you will use the [USBHOST](https://os.mbed.com/handbook/USBHost) library which is part of the Portenta H7 core. This library facilitates the USB connections between USB devices and and the Portenta board.
67
+
To achieve this, you will use the [USBHOST](https://os.mbed.com/handbook/USBHost) library which is part of the Portenta H7 core. This library facilitates the USB connections between USB devices and and the Portenta board.
68
68
69
69
Thanks to USB OTG (On The Go) specification the Portenta H7 can switch between host and client modes automatically. The code that enables USB OTG in Portenta H7 is included in the **mbed** core and it is ready to function without additional configurations. Some related classes to make use of the USB port for different use cases are:
70
70
@@ -75,15 +75,15 @@ Thanks to USB OTG (On The Go) specification the Portenta H7 can switch between h
75
75
76
76
### 1. The Basic Setup
77
77
78
-
Begin by plugging in your Portenta board to the computer using a USB-C cable and open the Arduino IDE or the Arduino Pro IDE. If this is your first time running Arduino sketch files on the board, we suggest you check out how to [set up the Portenta H7 for Arduino](setting-up-portenta) before you proceed.
78
+
Begin by plugging in your Portenta board to the computer using a USB-C cable and open the Arduino IDE. If this is your first time running Arduino sketch files on the board, we suggest you to check out how to [set up the Portenta H7 for Arduino](https://docs.arduino.cc/tutorials/portenta-h7/setting-up-portenta) before you proceed.
79
79
80
80

81
81
82
82
### 2. Creating the Keyboard Controller
83
83
84
-
Let's create a sketch that handles the USB connections and modifies the state of the LEDs with each press on the R, G or B keys. When you press the key first time the LEDs will switch on and to turn them off, you will need to press the corresponding key again.
84
+
Let's create a sketch that handles the USB connections and modifies the state of the LEDs with each press on the R, G or B keys. When you press the key first time, the LEDs will switch on and, to turn them off, you will need to press the corresponding key again.
85
85
86
-
As programming the USB protocol that allows the board to handle USB devices is an arduous task, you will use a pre-built example called **KeyboardController**. To find it make sure you have the board description for the Arduino Portenta H7 installed using the Boards Manager.
86
+
Since programming the USB protocol that allows the board to handle USB devices is an arduous task, you will use a pre-built example called **KeyboardController**. To find it, make sure you have the board description for the Arduino Portenta H7 installed using the Boards Manager.
87
87
88
88

89
89
@@ -97,7 +97,7 @@ The **USBHost** library that is used in this example is a revamp of the classic
97
97
98
98
### 3. Detecting the Keys From the Keyboard
99
99
100
-
The example you opened describes how the board will handle the connection with a keyboard, addressing the functionality of each one of the keys of it. In order to detect which one of the keys from the keyboard is pressed, you will need to modify and add some lines of code to the example.
100
+
The example you opened describes how the board will handle the connection with a keyboard, addressing the functionality of each one of its keys. In order to detect which one of the keys from the keyboard is pressed, you will need to modify and add some lines of code to the example.
101
101
102
102
Let's start by removing the comment line ( `//` ) of the following line `.on_key = process_key` at the beginning of the code. By doing this, each time you press a key, the program calls the function that converts the data received from the keyboard from `HEX` to a `char` type.
103
103
@@ -164,15 +164,15 @@ bool ledBstate = false;
164
164
165
165
### 5. Upload the Code
166
166
167
-
Before uploading the sketch to the board, save it you sketchbook and name it **leds_keyController.ino**. Then select the **Arduino Portenta H7 (M7 core)** from the **Board** menu and the port the Portenta is connected to. Upload the **leds_keyController.ino** sketch. Doing so will automatically compile the sketch beforehand.
167
+
Before uploading the sketch to the board, save it in your sketchbook and name it **leds_keyController.ino**. Then select the **Arduino Portenta H7 (M7 core)** from the **Board** menu and the port the Portenta is connected to. Upload the **leds_keyController.ino** sketch. Doing so will automatically compile the sketch beforehand.
168
168
169
-
***Turning the Portenta into a USB host will stop it from advertising it's serial port. To get it back, simply do a double press on the reset button to turn it into bootloader mode.***
169
+
***Turning the Portenta into a USB host will stop it from advertising it is a serial port. To get it back, simply do a double press on the reset button to turn it into bootloader mode.***
170
170
171
171

172
172
173
173
### 6. Connecting a Keyboard to Portenta
174
174
175
-
When you connect the Portenta board to the computer to program it, the computer is the USB host and the Portenta board is the USB client. The same happens when you connect an external keyboard to your PC. For this tutorial the Portenta board will be the host. It won't be connected to the PC after programming it! Let's see how to make the connections.
175
+
When you connect the Portenta board to the computer to program it, the computer is the USB host and the Portenta board is the USB client. The same happens when you connect an external keyboard to your PC. For this tutorial the Portenta board will be the host. It will not be connected to the PC after programming it! Let's see how to make the connections.
@@ -184,7 +184,7 @@ In the image above you can see that:
184
184
185
185
### Alternative Configuration (No USB Hub Required)
186
186
187
-
If you don't have a USB-C type hub you may complete this tutorial with a USB-C type keyboard or with a USB A type keyboard and a USB A to C adapter. To do so proceed as follows:
187
+
If you do not have a USB-C type hub, you may complete this tutorial with a USB-C type keyboard or with a USB A type keyboard and a USB A to C adapter. To do so, proceed as follows:
188
188
189
189
- Power the Portenta H7 through the VIN pin with 5V. (Check [pinout diagram](https://content.arduino.cc/assets/Pinout-PortentaH7_latest.pdf))
190
190
- Connect the keyboard directly to the Portenta's USB-C connector (use a USB-A to USB-C adapter if your keyboard's connector is USB type A)
@@ -196,7 +196,7 @@ Once you have connected your portenta board, you should be able to toggle the LE
196
196
197
197

198
198
199
-
If it doesn't work as it should try the following:
199
+
If it does not work as it should, try the following:
200
200
201
201
1. Reset the portenta by pressing the Reset button. 
202
202
2. Disconnect the Portenta board from the USB Hub (USB C adapter), disconnect the power from the USB Hub, connect the Portenta to the USB Hub and then connect the power to the USB Hub.
@@ -207,23 +207,23 @@ This tutorial shows how to connect and control a keyboard by configuring Portent
207
207
208
208
### Next Steps
209
209
210
-
Now that you've learnt how to set up the board as a USB Host and understood how the example works, start experimenting with the **KeyboardController.ino** sketch. This sketch can be tweaked in a variety of ways based on your needs. For example, you could add a mouse to the USB Hub and increase the brightness of the built-in LEDs when pressing the left button and decrease it when pressing the right button.
210
+
Now that you have learnt how to set up the board as a USB Host and understood how the example works, start experimenting with the **KeyboardController.ino** sketch. This sketch can be tweaked in a variety of ways based on your needs. For example, you could add a mouse to the USB Hub and increase the brightness of the built-in LEDs when pressing the left button and decrease it when pressing the right button.
211
211
212
212
## Troubleshooting
213
213
214
214
### The LEDs Are Not Toggling
215
215
216
-
This troubleshooting guide will help you to find out why the LEDs of your Portenta don't toggle when you press the keys on the keyboard. To do so, you will need some extra components:
216
+
This troubleshooting guide will help you to find out why the LEDs of your Portenta do not toggle when you press the keys on the keyboard. To do so, you will need some extra components:
217
217
218
218
* Arduino Arduino MKR WiFi 1010 board (or another Arduino board with at least two serial ports)
219
219
* USB cable to connect the extra board to the PC
220
220
* 3 jumper wires
221
221
222
-
To detect what the problem is, we are going to send all the information about the USB peripheral (in this case the keyboard) through serial communication from Portenta to the Arduino MKR WiFi 1010 board. Once this info arrives to the Arduino MKR WiFi 1010 board, we will print it out through the Serial Monitor, which will allow us to debug what can be happening.
222
+
To detect what the problem is, you are going to send all the information about the USB peripheral (in this case the keyboard) through serial communication from Portenta to the Arduino MKR WiFi 1010 board. Once this info arrives to the Arduino MKR WiFi 1010 board, you can print it out through the Serial Monitor, which will allow you to debug what can be happening.
223
223
224
224
### 1. Connect the Portenta to the Arduino MKR WiFi 1010
225
225
226
-
To connect thePortenta to the Arduino MKR WiFi 1010 board you will need connect the pins with Serial1 functionality (13RX and 14TX on both boards) between them as shown in the image below. Don't forget to connect as well the ground pins (GND) of the boards.
226
+
To connect the Portenta to the Arduino MKR WiFi 1010 board, you will need connect the pins with Serial1 functionality (13RX and 14TX on both boards) between them as shown in the image below. Do not forget to connect as well the ground pins (GND) of the boards.
@@ -267,9 +267,9 @@ Once you have everything connected, open the Serial Monitor and reset the Porten
267
267
268
268
In the data received on the MKR WiFi 1010 board you should see some "Enabled" messages. It means that the Portenta detected the different ports of your USB Hub. If you can see them, whenever you press a key on the keyboard, it should get printed to the Serial Monitor.
269
269
270
-
If in the messages received on the MKR WiFi 1010 board you see any "Disabled" message, it means that something went wrong with the communication of the USB Hub and the Portenta board. If this happens try:
270
+
If in the messages received on the MKR WiFi 1010 board you see any "Disabled" message, it means that something went wrong with the communication of the USB Hub and the Portenta board. If this happens, try:
271
271
272
272
1. Reset the Portenta by pressing the reset button.
273
273
2. Disconnect the Portenta board from the USB Hub (USB C adapter), disconnect the power from the USB Hub, connect the Portenta to the USB Hub and connect the power to the USB Hub.
274
274
275
-
If, after repeating this process several times, the connection still isn't working, the USB Hub you are using may not be compatible with the Portenta board and you will need a different USB Hub to complete this tutorial.
275
+
If, after repeating this process several times, the connection still is not working, the USB Hub you are using may not be compatible with the Portenta board and you will need a different USB Hub to complete this tutorial.
0 commit comments