03 Lesson. Getting to know the reaction wheel
RW module (control motor-reaction wheel)

Picture 1. RW module
When orbiting, many satellites require precise orientation with certain faces in the right direction - relative to the Earth, the Sun, the stars, or otherwise. For example, to aim a remote sensing camera at the Earth or solar panels at the Sun. On small devices, reaction wheel engines are most often used to ensure a given orientation of the satellite in space relative to the center of mass.
reaction wheel motor is an electromechanical device, which is an electric motor with a wheel mounted on its axis of rotation. The engine rotates, sometimes accelerating, then slowing down, and according to the law of conservation of kinetic momentum, the spacecraft itself rotates faster or slower. Since there are no external forces in space and the amount of motion cannot change, rotating the reaction wheel clockwise causes the entire spacecraft to rotate counterclockwise. Thus, by controlling the engine and the rotation of the reaction wheel engine, we can control the movement around the center of mass (in fact, the rotation) of the entire apparatus.
In our model, the free rotation of the OrbiCraft 3D constructor, and, consequently, the reaction wheel, is possible only around one axis - vertical. Therefore, only one orientation reaction wheel is installed on a uniaxial Orbicraft 3D.
The following functions are used to work with the reaction wheel motor (in C):
Set the rotation speed of the reaction wheel. As arguments, the function takes the serial number of the reaction wheel and the speed in rpm.
motor_set_speed ( uint16_t num, float RPM)Arguments:
- [in] num - device number according to UniCAN, for the reaction wheel with address 0xA, the value of num=0, for 0xB num=1, for 0xC num=2;
- [in] RPM - angular rotation speed, rpm.
The following function allows you to request the current reaction wheel speed:
motor_request_speed ( uint16_t num, float *pRPM)The value is written to the pRPM variable. Units of measurement: rpm.
Arguments:
- [in] num - device ID;
- [out] pRPM - angular rotation speed, rpm.
Sample code for checking a reaction wheel engine in C:
#include <stdio.h>
#include <stdint.h>
#include "libschsat.h"
void control(void){
const int num = 1; /* motor number #1(B) */
float rpm = -2000; /* -2000 ... +2000 */
printf("Enable motor #%d\n", num);
printf("Manage speed motor #%d\n", num);
while (rpm <= 2000) {
printf("<<< Set speed to %f\n", rpm);
motor_set_speed(num, rpm);
Sleep(1);
rpm += 200;
}
printf("<<< Set speed to 0\n");
motor_set_speed(num, 0);
Sleep(1);
printf("Disable motor #%d\n", num);
}
This program has already been uploaded to the BVM. Open the WEB interface, find it and run it (Picture 2):

Picture 2. The reaction wheel engine test program on the Web interface
Run the program and test the operation of the reaction wheel. When the program starts, it will accelerate to -2000 rpm, then once a second it will reduce the rotation speed by 200 rpm until it reaches zero, and then it will rotate in the opposite direction, increasing the rotation speed by 200 rpm. once a second.

Picture 3. Example of the received data
In case of an emergency stop of the reaction wheel, it is useful to have the following program loaded into Orbicraft 3D:
#include <stdio.h>
#include <stdint.h>
void control(void){
motor_set_speed(0, 0);
}
View the reaction wheel rotation speed graph
Launch the Houston App and connect to it via Wi-Fi as described on this page.
In this mode, on the Wheel tab, you can view a graph of the change in the rotation speed of the reaction wheel (Picture 4):

Picture 4. Graph of the change in the rotation speed of the reaction wheel
User API
The User API reference with all the functions of working with OrbiCraft 3D can be found on the pages: User API in C++ and User API in Python.