Что такое шляпа raspberry pi

Эта шляпа превращает Raspberry Pi 4 в суперкомпьютер

PiKVM — это устройство KVM, которое позволит вам повернуть Raspberry Pi 4 в высокопроизводительный устройство. Так вы можете расширить возможности уже очень способного продукта. Так что, если вы хотите выжать еще больше из своего оборудования, обратите внимание на эту шляпу, разработанную Максимом Деваевым.

PiKVM шляпа

Raspberry Pi 4 сам по себе очень способное устройство. Используя только подходящую операционную систему, вы можете превратить его в ретро-консоль, мультимедийный сервер, систему наблюдения и многое другое, что мы видели здесь на протяжении нескольких месяцев.

Однако его потенциал возрастает, когда вы начинаете комбинировать некоторые аксессуары, разработанные для Raspberry. Среди них HAT (Hardware Attached on Top) — одно из них, и они настолько разнообразны, что в зависимости от того, что вы используете, вы получите те или иные характеристики. Однако таких, разработанных инженером-программистом Максимом Деваевым, не так много.

Игровой автомат Шляпа PiKVM V3 — это устройство, предназначенное для расширения возможностей Raspberry Pi 4. Для этого после подключения вы сможете воспользоваться всем набором опций, которые пользователи с более продвинутым профилем сочтут действительно полезными. Потому что это позволяет избежать зависимости от протоколов, портов или даже конкретных операционных систем.

Конечно, лучше перечислить наиболее важные варианты использования, которые он позволяет:

  • Удаленное управление серверами и рабочими станциями
  • Возможность включать, выключать или перезагружать компьютеры
  • Управление с клавиатуры, мыши и видео по IP (KVM)
  • Конфигурация расширенных аспектов, таких как UEFI или BIOS
  • Установка операционных систем через виртуальный привод компакт-дисков или через флешки

Другими словами, это был бы продукт, разработанный для типа пользователя, который все еще является чем-то особенным, потому что для него требуются вещи, необычные для большинства, но для них это может быть важным преимуществом из-за того, как он был разработан. И идея всего вращается вокруг с открытым исходным кодом . Таким образом, для использования и доступа ко всем его возможностям не требуются такие аспекты, как определенные плагины, также не требуется контролировать конкретную операционную систему на стороне сервера или машины, не нужно платить высокие цены за лицензию и т. Д.

Помимо всего этого, плата PiKVM V3 HAT также даст возможность захват видео через HDMI а затем возможность передавать через веб-браузер с разрешением 1080p и 50 кадрами в секунду. Хотя это будет то, что будет происходить в процессе обновления программного обеспечения. И все это с учетом того, что проект будет реализован, что, скорее всего, произойдет с учетом той цены, по которой они отправят его вам, если они достигнут цели и смогут производить их в большом количестве.

Превратите Raspberry Pi в уникальное устройство

Как вы видели, PiKVM превращает Raspberry Pi 4 в уникальное и, прежде всего, очень эффективное устройство. Настолько, что средний и продвинутый пользователь может предложить бесчисленные преимущества, как только вы начнете исследовать и использовать.

Следовательно, любой пользователь Raspberry Pi должен быть счастлив, если проект увенчается успехом и воплотится в решение, которое можно купить. Потому что возможностей так много, что вы рассердитесь, если останетесь в дороге. Хотя мы не думаем, что это произойдет, потому что они работали над этим годами, и эта V3 — самая надежная версия. Кроме того, у них даже есть конструкция корпуса для изготовления на 3D-принтере.

Источник

Raspberry Pi Documentation

Introducing the Build HAT

The Raspberry Pi Build HAT is an add-on board that connects to the 40-pin GPIO header of your Raspberry Pi, which was designed in collaboration with LEGOВ® Education to make it easy to control LEGOВ® Technicв„ў motors and sensors with Raspberry Pi computers.

A full list of supported devices can be found in the Device Compatibility section.

It provides four connectors for LEGOВ® Technicв„ў motors and sensors from the SPIKEв„ў Portfolio. The available sensors include a distance sensor, a colour sensor, and a versatile force sensor. The angular motors come in a range of sizes and include integrated encoders that can be queried to find their position.

The Build HAT fits all Raspberry Pi computers with a 40-pin GPIO header, including — with the addition of a ribbon cable or other extension device — Raspberry Pi 400. Connected LEGO® Technic™ devices can easily be controlled in Python, alongside standard Raspberry Pi accessories such as a camera module.

The Raspberry Pi Build HAT power supply (PSU), which is available separately, is designed to power both the Build HAT and Raspberry Pi computer along with all connected LEGOВ® Technicв„ў devices.

The LEGOВ® Education SPIKEв„ў Prime Set 45678 and SPIKEв„ў Prime Expansion Set 45681, available separately from LEGOВ® Education resellers, include a collection of useful elements supported by the Build HAT.

The HAT works with all 40-pin GPIO Raspberry Pi boards, including Raspberry Pi 4 and Raspberry Pi Zero. With the addition of a ribbon cable or other extension device, it can also be used with Raspberry Pi 400.

Controls up to 4 LEGOВ® Technicв„ў motors and sensors included in the SPIKEв„ў Portfolio

Easy-to-use Python library to control your LEGOВ® Technicв„ў devices

Fits onto any Raspberry Pi computer with a 40-pin GPIO header

Onboard RP2040 microcontroller manages low-level control of LEGOВ® Technicв„ў devices

External 8V PSU available separately to power both Build HAT and Raspberry Pi

The Build HAT can not power the Raspberry Pi 400 as it does not support being powered via the GPIO headers.

Preparing your Build HAT

Before starting to work with your Raspberry Pi Build HAT you should set up your Raspberry Pi, install the latest version of the operating system using Raspberry Pi Imager.

Attach 9mm spacers to the bottom of the board. Seat the Raspberry Pi Build HAT onto your Raspberry Pi. Make sure you put it on the right way up. Unlike other HATs, all the components are on the bottom, leaving room for a breadboard or LEGOВ® elements on top.

Access the GPIO Pins

If you want to access the GPIO pins of the Raspberry Pi, you can add an optional tall header and use 15 mm spacers.

The following pins are used by the Build HAT itself and you should not connect anything to them.

Setting up your Raspberry Pi

Once the Raspberry Pi has booted, open the Raspberry Pi Configuration tool by clicking on the Raspberry Menu button and then selecting “Preferences” and then “Raspberry Pi Configuration”.

Click on the “interfaces” tab and adjust the Serial settings as shown below:

Using your Raspberry Pi Headless

If you are running your Raspberry Pi headless and using raspi-config , select “Interface Options” from the first menu.

Then “P6 Serial Port”.

Disable the serial console:

And enable the serial port hardware.

The final settings should look like this.

You will need to reboot at this point if you have made any changes.

Powering the Build HAT

Connect an external power supply — the official Raspberry Pi Build HAT power supply is recommended — however any reliable +8V±10% power supply capable of supplying 48W via a DC 5521 centre positive barrel connector (5.5mm × 2.1mm × 11mm) will power the Build HAT. You don’t need to connect an additional USB power supply to the Raspberry Pi as well, unless you are using a Raspberry Pi 400.

The Build HAT can not power the Raspberry Pi 400 as it does not support being powered via the GPIO headers.

The LEGO® Technic™ motors are very powerful; so to drive them you’ll need an external 8V power supply. If you want to read from motor encoders and the SPIKE™ force sensor, you can power your Raspberry Pi and Build HAT the usual way, via your Raspberry Pi’s USB power socket. The SPIKE™ colour and distance sensors, like the motors, require an external power supply.

You have the choice to use Build HAT with Python or .NET.

Using the Build HAT from Python

Installing the Python Library

Install the Build HAT Python library. Open a Terminal window and type,

Copy to Clipboard

For more information about the Build HAT Python Library see ReadTheDocs.

Using Motors from Python

There are a number of motors that work with the Build HAT.

Connecting a Motor

Connect a motor to port A on the Build HAT. The LPF2 connectors need to be inserted the correct way up. If the connector doesn’t slide in easily, rotate by 180 degrees and try again.

Working with Motors

Start the Thonny IDE. Add the program code below:

Copy to Clipboard

Run the program by clicking the play/run button. If this is the first time you’re running a Build HAT program since the Raspberry Pi has booted, there will be a few seconds pause while the firmware is copied across to the board. You should see the red LED extinguish and the green LED illuminate. Subsequent executions of a Python program will not require this pause.

Your motor should turn clockwise for 5 seconds.

Change the final line of your program and re-run.

Copy to Clipboard

The motor should now turn faster. Make another change:

Copy to Clipboard

The motor should turn in the opposite (anti-clockwise) direction

Create a new program by clicking on the plus button in Thonny. Add the code below:

Copy to Clipboard

Run the program. Grab the motor and turn the shaft. You should see the numbers printed in the Thonny REPL changing.

Using Sensors from Python

There is a large range of sensors that work with the Build HAT.

Working with Sensors

Connect a Colour sensor to port B on the Build HAT, and a Force sensor to port C.

If you’re not intending to drive a motor, then you don’t need an external power supply and you can use a standard USB power supply for your Raspberry Pi.

Create another new program:

Copy to Clipboard

Run it and hold a coloured object (LEGO® elements are ideal) in front of the colour sensor and press the Force sensor plunger. The sensor’s LED should switch on and the name of the closest colour should be displayed in the thonny REPL.

Using the Build HAT from .NET

Installing the .NET Framework

The .NET framework from Microsoft is not available via apt on Raspberry Pi. However, you can follow the official instructions from Microsoft to install the .NET framework. Alternatively, there is a simplified third party route to get the .NET toolchain on to your Raspberry Pi.

The installation script is run as root . You should read it first and make sure you understand what it is doing. If you are at all unsure you should follow the official instructions manually.

After installing the .NET framework you can create your project:

This creates a default program in the buildhat subdirectory, and we need to be in that directory in order to continue:

You will now need to install the following nuget packages:

Running C# Code

You can run the program with the dotnet run command. Let’s try it now to make sure everything works. It should print «Hello World!»

(When instructed to «run the program» in the instructions that follow, you will simply rerun dotnet run )

Editing C# Code

In the instructions below, you will be editing the file buildhat/Program.cs , the C# program which was generated when you ran the above commands.

Any text editor will work to edit C# code, including Geany, the IDE/Text Editor that comes pre-installed. Visual Studio Code (often called «VS Code») is also a popular alternative.

Using the Build HAT from .NET

The Raspberry Pi Built HAT is referred to «Brick» in LEGOВ® parlance and you can talk directly to it from .NET using the Build HAT Serial Protocol.

You can create a brick object as below,

Copy to Clipboard

but you need to remember to dispose of the brick at the end of your code.

Copy to Clipboard

If you do not call brick.Dispose() your program will not terminate.

If you want to avoid calling brick.Dispose at the end, then create your brick with the using statement:

Copy to Clipboard

In this case, when reaching the end of the program, your brick will be automatically disposed.

Displaying the information

You can gather the various software versions, the signature, and the input voltage:

Copy to Clipboard

The input voltage is read only once at boot time and is not read again afterwards.

Getting sensors and motors details

The functions GetSensorType , GetSensor will allow you to retrieve any information on connected sensor.

Copy to Clipboard

In this example, you can as well use the IsMotor static function to check if the connected element is a sensor or a motor.

Copy to Clipboard

ActiveSensor have a collection of advanced properties and functions allowing to understand every element of the sensor. It is also possible to call the primitive functions from the brick from them. This will allow you to select specific modes and do advance scenarios. While this is possible, motor and sensor classes have been created to make your life easier.

Events

Most sensors implements events on their special properties. You can simply subscribe to PropertyChanged and PropertyUpdated . The changed one will be fired when the value is changing while the updated one when there is a success update to the property. Depending on the modes used, some properties may be updated in the background all the time while some others occasionally.

You may be interested only when a color is changing or the position of the motor is changing, using it as a tachometer. In this case, the PropertyChanged is what you need!

Copy to Clipboard

Waiting for initialization

The brick can take a long time before it initializes. A wait for a sensor to be connected has been implemented.

Copy to Clipboard

It does as well take a CancellationToken if you want to implement advance features like warning the user after some time and retrying.

Using Motors from .NET

There are two types of motors, the passive ones and the active ones. Active motors will provide detailed position, absolute position and speed while passive motors can only be controlled with speed.

A common set of functions to control the speed of the motors are available. There are 2 important ones: SetPowerLimit and SetBias :

Copy to Clipboard

The accepted values are only from 0.0 to 1.0. The power limit is a convenient ay to reduce in proportion the maximum power.

The bias value sets for the current port which is added to positive motor drive values and subtracted from negative motor drive values. This can be used to compensate for the fact that most DC motors require a certain amount of drive before they will turn at all.

The default values when a motor is created is 0.7 for the power limit and 0.3 for the bias.

Passive Motors

The typical passive motor is a train and older Powered Up motors. The Speed property can be set and read. It is the target and the measured speed at the same time as those sensors do not have a way to measure them. The value is from -100 to +100.

Functions to control Start , Stop and SetSpeed are also available. Here is an example of how to use it:

Copy to Clipboard

Once the train is started, you can adjust the speed and the motor will adjust accordingly.

Active Motors

Active motors have Speed , AbsolutePosition , Position and TargetSpeed as special properties. They are read continuously even when the motor is stopped.

The code snippet shows how to get the motors, start them and read the properties:

Copy to Clipboard

You should not forget to start and stop your motors when needed.

Advance features are available for active motors. You can request to move for seconds, to a specific position, a specific absolute position. Here are couple of examples:

Copy to Clipboard

Each function allow you to block or not the thread for the time the operation will be performed. Note that for absolute and relative position moves, there is a tolerance of few degrees.

Copy to Clipboard

You can place the motor in a float position, meaning, there are no more constrains on it. This is a mode that you can use when using the motor as a tachometer, moving it and reading the position. If you still have constrains on the motors, you may not be able to move it.

Using Sensors from .NET

Like for motors, you have active and passive sensors. Most recent sensors are active. The passive one are lights and simple buttons. Active ones are distance or color sensors, as well as small 3×3 pixel displays.

Button/Touch Passive Sensor

The button/touch passive sensor have one specific property IsPressed . The property is set to true when the button is pressed. Here is a complete example with events:

Copy to Clipboard

Passive Light

The passive light are the train lights. They can be switched on and you can controlled their brightness.

Copy to Clipboard

Active Sensor

The active sensor class is a generic one that all the active sensor heritate including active motors. They contains a set of properties regarding how they are connected to the Build HAT, the modes, the detailed combi modes, the hardware, software versions and a specific property called ValueAsString . The value as string contains the last measurement as a collection of strings. A measurement arrives like P0C0: +23 -42 0 , the enumeration will contains P0C0: , +23 , -42 and 0 . This is made so if you are using advance modes and managing yourself the combi modes and commands, you’ll be able to get the measurements.

All active sensor can run a specific measurement mode or a combi mode. You can setup one through the advance mode using the SelectModeAndRead and SelectCombiModesAndRead functions with the specific mode(s) you’d like to continuously have. It is important to understand that changing the mode or setting up a new mode will stop the previous mode.

The modes that can be combined in the Combi mode are listed in the CombiModes property. Al the properties of the sensors will be updated automatically when you’ll setup one of those modes.

WeDo Tilt Sensor

WeDo Tilt Sensor has a special Tilt property. The type is a point with X is the X tilt and Y is the Y tilt. The values goes from -45 to + 45, they are caped to those values and represent degrees.

You can set a continuous measurement for this sensor using the ContinuousMeasurement property.

Источник