LEGO MINDSTORMS EV3¶
Input / Output Ports¶
By default, a sysfs device is created for each input and output port on the
EV3. See the input ports and output ports driver descriptions for more
information on how these work. There is a single module for input and output
ports named legoev3_ports
. This module has some module parameters.
Name | Description |
---|---|
disable_in_port |
Used to prevent the input port device from being loaded. This is useful if you want to use input port 1 for printing kernel messages this if you want while you are debugging the Linux kernel. You may also want to do to control the input port gpios directly. |
disable_out_port |
Used to prevent the output port from being loaded. This leaves the pwm device and gpios used by the port free to be controlled directly or used by other drivers. |
Input Ports¶
LEGO MINDSTORMS EV3 has four input ports labeled 1, 2, 3 and 4. These ports are used with LEGO MINDSTORMS EV3 and NXT compatible sensors and other devices. Most sensors can be automatically detected when plugged in.
General Info¶
Module | legoev3_ports |
Driver name | legoev3-input-port |
Connection types | NXT/Analog, NXT/I2C, Other/I2C, EV3/Analog, EV3/UART, Other/UART |
Connection prefix | in |
Number of modes | 9 |
Modes¶
Name | Description |
---|---|
auto [1] |
Automatically detect sensors. |
nxt-analog [2] |
Configure the port for NXT/Analog sensors |
nxt-color [3] |
Configure the port for the LEGO NXT Color sensor |
nxt-i2c |
Configure for I2C communications and load the nxt-i2c-host device. |
other-i2c |
Configure for I2C communications but do not probe for NXT sensors. |
ev3-analog |
Configure the port for EV3/Analog sensors |
ev3-uart |
Configure for UART communications and load the ev3-uart-host device. |
other-uart |
Configure for UART communications but do not load any device. |
raw [4] |
Provide access to low level drivers. |
Notes¶
[1] | In auto mode, the port will attempt to automatically detect the type of sensor that was connected and load the appropriate driver. See the list of Supported Sensors to determine if a sensor can be automatically detected. |
[2] | This loads the generic
NXT/Analog Sensors driver by default. Use
set_device to load the appropriate device/driver. |
[3] | NXT Color sensor driver has not been implemented yet, so right now, this mode does nothing. |
[4] | Exports gpios and analog/digital converter values to sysfs so that they can be controlled directly. |
Output Ports¶
LEGO MINDSTORMS EV3 has four output ports labeled A, B, C and D. These ports are used with LEGO MINDSTORMS EV3, NXT and RCX compatible motors and other devices. EV3 motors can be automatically detected when plugged in. Other motors with position feedback (such as the NXT motor) are usually detected as an EV3 Large Motor. RCX motors and LEDs cannot be automatically detected and the mode of the output port must be manually set to use these types of devices.
General Info¶
Module | legoev3_ports |
Driver name | legoev3-output-port |
Connection types | tacho-motor, dc-motor, led |
Connection prefix | out |
Number of modes | 5 |
Modes¶
Name | Description |
---|---|
auto [5] |
Automatically detect motors when they are connected. |
tacho-motor [6] |
Load the [tacho-motor] device. |
dc-motor [7] |
Load the dc-motor Subsystem device. |
led [8] |
Load the LEDs device. |
raw [9] |
Provide access to low level drivers. |
Notes¶
[5] | Only the EV3/NXT large motors and the EV3 medium motor can be automatically detected. All other devices must be manually configured. |
[6] | Configures the port to use
the tacho-motor Subsystem driver module. The default
driver is the EV3 Large Motor (lego-ev3-l-motor ). You
can change the driver using the set_device attribute. |
[7] | This can be use with MINDSTORMS RCX motors, Power Functions motors and any other “plain” DC motor. By “plain”, we mean the motor is just a motor without any feedback. |
[8] | This can be used with MINDSTORMS RCX LEDs, Power Functions LEDs or any other LED connected to pins 1 and 2 of the output port. |
[9] | Exports gpios, pwm and analog/digital converter values to sysfs so that they can be controlled directly. |
Buttons¶
The EV3 buttons use the standard Linux input subsystem. You can find the event
device node at /dev/input/by-path/platform-gpio-keys.0-event
. The buttons
are mapped to Linux key codes as shown in the table below.
Button | Linux key code (value) |
---|---|
Back | KEY_BACKSPACE (14) |
Center | KEY_ENTER (28) |
Up | KEY_UP (103) |
Left | KEY_LEFT (105) |
Right | KEY_RIGHT (106) |
Down | KEY_DOWN (108) |
LEDs¶
The EV3 brick status LEDs used the standard Linux LEDs subsystem. You can
find the LED devices at /sys/class/leds/
. There are two bi-color LEDs.
The color for each LED is controlled separately, so there is a green
and
red
device node for each LED. Turning both of these on at the same time
will make the LED appear orange(ish).
The LEDs are controlled by a PWM signal, so you can vary the brightness between
0 and max_brightness
.
Display¶
The EV3 display uses the standard Linux frame buffer subsystem (fbdev). The
display memory can be directly accessed by reading and writing or memory mapping
/dev/fb0
. Display attributes such as width, height and row stride can be
read using FBIOGET_VSCREENINFO
and FBIOGET_FSCREENINFO
ioctls.
Note
You must make sure that you control the active virtual console before drawing on the display, otherwise other programs could be writing to the display at the same time, causing unexpected results.
Sound¶
The snd-legoev3
module provedes an ALSA driver for PCM playback and a
Linux input device with sound capabilities (EV_SND
) for producing tones.
The ALSA driver can be used with standard tools such as alsamixer
and
aplay
. Tones can be produced by using the beep
command, ioctls such
as KDMKTONE
(must run on local console or as root for ioctls) or by
writing SND_*
events to the event device (must be member of input
group for this).
Battery¶
- This driver is used to get information about the EV3 battery.
- It uses the power_supply subsystem.
- It registers a sysfs device node at
/sys/class/power_supply/legoev3-battery/
.
current_now |
Returns the battery current in microamps. |
scope |
Always returns System . |
technology |
Returns Unknown or Li-ion depending on if the rechargeable
battery is present. |
type |
Always returns Battery . |
voltage_max_design |
Returns the nominal “full” battery voltage. The value returned
depends on technology . |
voltage_min_design |
Returns the nominal “empty” battery voltage. The value returned
depends on technology . |
voltage_now |
Returns the battery voltage in microvolts. |