en:wheel_subsys

# Reaction Wheel

Virtual power draw: 2000 mA

As they travel along the orbit, many satellites need precise positioning whereby specific edges would be aligned with particular directions relative to Earth, Sun, fixed stars or some other reference. A particular application would require the satellite to have its observation camera face Earth or solar cells face Sun. In smaller-scale orbiters the required spatial orientation of the satellite relative to the mass center is achieved most often using reaction wheels.

A reaction wheel is a mechanical device comprising an electric motor with a wheel fixed on its spindle. The engine spins by accelerating and decelerating alternately, and the angular momentum conservation law will make the orbiter itself spin faster or slower. Considering that there are no external forces in the space and the amount of motion cannot change, clockwise rotation of the wheel would make the entire orbiter rotate counterclockwise. So, by controlling the motor and the reaction wheel we can control motion around the mass center (in essence, rotation) of the entire orbiter.

In our model free rotation of the Orbicraft Construction Set and hence the reaction wheel is only possible around a single axis – the vertical axis. For that reason the “satellite” only has a single positioning reaction wheel.

The following functions (in C) are used for interacting with the reaction wheel motor:

int32_t motor_set_speed(uint16_t num,int16_t RPM,int16_t *confirm);

Commands a speed setpoint to the wheel, returning the LSS_OK code upon success and the requested RPM in the confirm variable. However it could take quite some time for the wheel to actually reach the requested speed.

The following function queries the current wheel rotation speed:

int32_t motor_request_speed(uint16_t num,int16_t *pRPM);

### Sample C Test Code for the Reaction Wheel

Wheel_test.c
	#include "libschsat.h"
/*
** Lab 5: manage motor speed
*/
void control(void)
{
const int num = 1;	/* motor number #1 */
int16_t temp;
int16_t rpm = -3000;	/* -3000 ... +3000 */
printf("Enable motor #%d\n", num);
motor_turn_on(num);
printf("Manage speed motor #%d\n", num);
while (rpm <= 3000) {
printf("<<< Set speed to %d\n", rpm);
if (LSS_OK == motor_set_speed(num, rpm, &temp)) {
if (temp == rpm)
printf("\t%d confirmed\n", rpm);
}
Sleep(1);
if (LSS_OK == motor_request_speed(num, &temp)) {
printf("Got speed %d >>>\n", temp);
} else {
puts("Fail! >>>");
}
rpm += 500;
}
printf("<<< Set speed to 0\n");
if (LSS_OK == motor_set_speed(num, 0, &temp)) {
if (temp == 0)
printf("\t%d confirmed\n", 0);
}
Sleep(1);
if (LSS_OK == motor_request_speed(num, &temp)) {
printf("Got speed %d >>>\n", temp);
} else {
puts("Fail! >>>");
}
Sleep(1);
motor_set_speed(num, 0, &temp);
Sleep(1);
printf("Disable motor #%d\n", num);
motor_turn_off(num);
}