KRAKsat nanosatellite documentation
  • KRAKsat nanosatellite documentation
  • Introduction
    • KRAKsat mission
    • KRAKsat team
    • Partners
    • Glossary
  • SR-NANO-BUS platform
    • SR-NANO-BUS platform
  • Payload
    • Ferrofluid Reaction Wheel
    • Payload electronics
  • Software
    • Satellite state machine
    • Communication with OBC
    • Sensors
  • Communication
    • Communication specification
    • Infrastructure & Software
Powered by GitBook
On this page
  • Mode structure definition
  • Diagnostic algorithm
  • F.R.W. control algorithms
  • Detumbling algorithm
  • Detumbling modes high level logic
  • Detumbling algorithm

Was this helpful?

  1. Software

Satellite state machine

Nine modes can be distinguished in the logic of the satellite’s payload operation. Five of them, that is the default logic, are shown in the diagram below.

PreviousPayload electronicsNextCommunication with OBC

Last updated 5 years ago

Was this helpful?

Mode name

Mode ID

IDLE

0

DETUMBLING

1

DETUMBLING_F

2

EXPERIMENT

3

EXPERIMENT_F

4

MANUAL

5

DIAGNOSTIC

6

DIAGNOSTIC_F

7

IDLE_FOR_TIME

8

CURRENT_MODE

9

DETUMBLING_SR_MODE

10

Mode structure definition

Property

Description

mode_id

The id of the mode.

init_function

The function that is executed within initialization of the mode.

exit_function

The function that is executed immediately on the exit of the mode.

condition_exit

The function that returns state enum when at least one of stop conditions of the mode is fulfilled.

condition_entry

The function that returns state enum when all of begin conditions of the mode are fulfilled.

do_custom_function

The function that contains logic that is executed not in 1min/1s/200ms timer exception.

do_1min_cycle

The function that contains logic that is executed in 1min timer exception.

do_1000ms_cycle

The function that contains logic that is executed not in 1s timer exception.

do_200ms_cycle

The function that contains logic that is executed not in 200ms timer exception.

timer_1s

The default value that determines the maximum time of the mode duration [s].

timer_prescaler

The value that is prescaler for property timer_1s.

is_timer_active

The property that determines if timer timer_1s is active.

next_mode

The mode that will be set as a following mode if condition_entry equals SUCCESS.

failure_mode

The mode that will be set as a following mode if condition_entry equals FAIL.

IDLE mode is a low power consumption mode that is set as a middle mode in which the state machine waits for the fulfilment of the next mode’s begin conditions.

Property

Description

mode_id

0

init_function

None

exit_function

None

condition_exit

The stop condition is equal to the begin condition of the next mode

condition_entry

None

do_custom_function

None

do_1min_cycle

IMU magnetometer sensor refresh

do_1000ms_cycle

None

do_200ms_cycle

None

timer_1s

n/a

timer_prescaler

1

is_timer_active

False

next_mode

Diagnostic

failure_mode

Diagnostic

Diagnostic mode’s goal is to make measurements and control the actuator in such order in time to allow an observer to determine if all sensors and actuators are working correctly. The table bellow shows how measurement and actuator control is performed in time.

Property

Description

mode_id

6

init_function

Initialization of all actuators.

exit_function

Stop of all actuators.

condition_exit

If power voltage < 9.5 then WAIT IN IDLE; If temp F.R.W. temperature > 90 then FAIL; If timer_1s <= 0 then SUCCESS;

condition_entry

If power voltage > 10 then SUCCESS.

do_custom_function

None

do_1min_cycle

None

do_1000ms_cycle

The function is described in section "Diagnostic algorithm"

do_200ms_cycle

None

timer_1s

100

timer_prescaler

1

is_timer_active

True

next_mode

Detumbling

failure_mode

Detumbling

Diagnostic force mode has the same function as Diagnostic mode. Only the entry and exit conditions differ.

Property

Description

mode_id

7

init_function

Initialization of all actuators.

exit_function

Stop of all actuators.

condition_exit

If power voltage < 9 then WAIT IN IDLE; If timer_1s <= 0 then SUCCESS;

condition_entry

If power voltage > 10 then SUCCESS.

do_custom_function

None

do_1min_cycle

None

do_1000ms_cycle

The function is described in section "Diagnostic algorithm"

do_200ms_cycle

None

timer_1s

100

timer_prescaler

1

is_timer_active

True

next_mode

Detumbling

failure_mode

Detumbling

F.R.W. experiment mode’s goal is to control electromagnets in order to conduct acceleration of the ferrofluid. Its custom function is turned on by interrupts from timer 5.

Property

Description

mode_id

3

init_function

Initialization of PWM timers for F.R.W. magnetorquers.

exit_function

Stop of PWM timers for F.R.W. magnetorquers.

condition_exit

If power voltage < 9.5 then WAIT IN IDLE; if temp F.R.W. temperature > 90 then FAIL; if timer_1s <= 0 then SUCCESS;

condition_entry

If power voltage > 10 and temp F.R.W. temperature > 0 and temp F.R.W. temperature < 50 then SUCCESS;

do_custom_function

The function logic is described in section "F.R.W. control algorithm".

do_1min_cycle

None

do_1000ms_cycle

None

do_200ms_cycle

None

timer_1s

180

timer_prescaler

1

is_timer_active

True

next_mode

IDLE time

failure_mode

IDLE time

F.R.W. experiment force mode has the same function as F.R.W. experiment mode. Only the entry and exit conditions differ.

Property

Description

mode_id

3

init_function

Initialization of PWM timers for F.R.W. magnetorquers.

exit_function

Stop of PWM timers for F.R.W. magnetorquers.

condition_exit

If power voltage < 9 then WAIT IN IDLE; if timer_1s <= 0 then SUCCESS.

condition_entry

If power voltage > 10 then SUCCESS.

do_custom_function

The function logic is described in section "F.R.W. control algorithm".

do_1min_cycle

None

do_1000ms_cycle

None

do_200ms_cycle

None

timer_1s

180

timer_prescaler

1

is_timer_active

True

next_mode

IDLE time

failure_mode

IDLE time

Detumbling mode’s goal is to reduce the angular velocity of the satellite. The implemented algorithm calculates and adjusts a control on 3 magnetorquers based on IMU sensor data. If detumbling doesn't succeed, the payload will go to Detumbling SR mode and trigger the algorithm embedded in the ADCS module.

Property

Description

mode_id

1

init_function

Initialization of PWM timer for ADCS magnetorquers.

exit_function

Stop of PWM timer for ADCS magnetorquers.

condition_exit

If power voltage < 9.5 or temp F.R.W. temperature > 80 then WAIT IN IDLE; If timer_1s <= 0 then FAIL;

If average angular speed in all axes < 5°/s then SUCCESS;

condition_entry

If power voltage > 10 and temp F.R.W. temperature < 60 then SUCCESS.

do_custom_function

None

do_1min_cycle

None

do_1000ms_cycle

None

do_200ms_cycle

The function logic is described in section "Detumbling algorithm".

timer_1s

10800

timer_prescaler

1

is_timer_active

True

next_mode

F.R.W. experiment

failure_mode

Detumbling SR

Detumbling force mode has the same function as Detumbling mode. Only the entry and exit conditions differ.

Property

Description

mode_id

2

init_function

Initialization of PWM timer for ADCS magnetorquers.

exit_function

Stop of PWM timer for ADCS magnetorquers.

condition_exit

If power voltage < 9 then WAIT IN IDLE; If timer_1s <= 0 then FAIL;

If average angular speed in all axes < 5°/s then SUCCESS.

condition_entry

If power voltage > 10 then SUCCESS.

do_custom_function

None

do_1min_cycle

None

do_1000ms_cycle

None

do_200ms_cycle

The function logic is described in section "Detumbling algorithm".

timer_1s

10800

timer_prescaler

1

is_timer_active

True

next_mode

F.R.W. experiment

failure_mode

F.R.W. experiment

Detumbling SR mode triggers detumbling algorithm embedded in the OBC board. No action is performed by the microcontroller in the Payload module.

Property

Description

mode_id

10

init_function

Initialization of detumbling algorithm embedded in the OBC board.

exit_function

Stop of detumbling algorithm embedded in the OBC board.

condition_exit

If OBC transmit SUCCESS then SUCCESS; If timer_1s <= 0 then FAIL.

condition_entry

None

do_custom_function

None

do_1min_cycle

Check register table if OBC transmit SUCCESS.

do_1000ms_cycle

None

do_200ms_cycle

None

timer_1s

2700

timer_prescaler

1

is_timer_active

True

next_mode

F.R.W. experiment

failure_mode

F.R.W. experiment

Manual mode is a mode that controls ADCS magnetorquers based on commands from the ground station.

Property

Description

mode_id

5

init_function

Initialization of PWM timer for ADCS magnetorquers.

exit_function

Stop of PWM timer for ADCS magnetorquers.

condition_exit

If timer_1s <= 0 then SUCCESS;

If battery_volt<9 then FAILURE.

condition_entry

If battery_volt>10 then SUCCESS.

do_custom_function

None

do_1min_cycle

None

do_1000ms_cycle

ADCS magnetorquers control and IMU magnetometer sensor refresh.

do_200ms_cycle

None

timer_1s

10800* timer_prescaler

timer_prescaler

1

is_timer_active

True

next_mode

IDLE

failure_mode

IDLE

IDLE TIME mode is a low power consumption mode that is set to wait for a long period of time for recharging batteries and cooling coils. IDLE TIME mode lasts for 48h or while special log buffer is not full and the battery is charged above 10V.

Property

Description

mode_id

8

init_function

None

exit_function

None

condition_exit

If timer_1s <= 0 or (battery_volt>10 and special log buffer is not full) then SUCCESS;

condition_entry

None

do_custom_function

None

do_1min_cycle

IMU magnetometer sensor refresh

do_1000ms_cycle

None

do_200ms_cycle

None

timer_1s

2880 * timer_prescaler

timer_prescaler

60

is_timer_active

True

next_mode

Diagnostic mode

failure_mode

Diagnostic mode

Diagnostic algorithm

The diagnostic algorithm is used to validate proper functioning of satellite's hardware. This procedure toggles certain actuators in predefined intervals. Simultaneously, measurements from the IMU and the temperature sensor that is attached to the payload container are taken.

Timeline

Step

15 s

Only measurements

10 s

ADCS magnetorquer X

10 s

ADCS magnetorquer Y

10 s

ADCS magnetorquer Z

15 s

Only measurements

10 s

F.R.W. electromagnets phase 0

10 s

F.R.W. electromagnets phase 1

10 s

F.R.W. electromagnets phase 2

10 s

F.R.W. electromagnets phase 3

F.R.W. control algorithms

F.R.W. control algorithms are designed to control electromagnets in order to accelerate the ferrofluid. Its custom function is turned on by interruption from timer 5. F.R.W. can work in 9 different modes which are listed in the table below. More information about control system of the Ferrofluid Reactio Wheel can be found in: Jan Życzkowski, "Ferrofluid reaction wheel for nanosatellites orientation control", Master Thesis, AGH University of Science and Technology, Cracow 2019, supervisor: Adam Piłat.

Control mode

mode ID

FRW_BAISIC_CLOCKWISE

0

FRW_BAISIC_ANTICLOCKWISE

1

FRW_ACC_CLOCKWISE

2

FRW_ACC_ANTICLOCKWISE

3

FRW_STEP_CLOCKWISE

4

FRW_STEP_ANTICLOCKWISE

5

FRW_PID_DUTY

6

FRW_PID_FREQ

7

FRW_LIST_MODE

8

FRW_ControlBasicClockwise works as a universal control. It is possible to change its parameters:

Parameter

Details

pwm_duty

duty of coils PWM

period

period with which 4 coils are working, in ms. Period of the is F.R.W. two times larger

pwm_direct

direction of the current going through coils (it is not the direction for F.R.W.)

control duty

percentage of time every phase is tuned on during cycle (e.g. 25 - one-step, 37 - one and half-step, 50 - two-step)

To control F.R.W. in opposite direction use function: FRW_ControlBasicAntiClockwiseFunction.

FRW_ControlAcceleratingClockwise works like the basic mode, with changing frequency over time. It has some additional parameters:

Parameter

Details

start_period

Starting period for 4 coils

stop_period

ending period for 4 coils

acceleration_time

Time of acceleration in seconds. After this time, F.R.W.will work with period: stop_period

To control F.R.W. in opposite direction use function: FRW_ControlAcceleratingAntiClockwise.

FRW_ControlStepAntiClockwise is an experimental asymetric control with the following parameters:

Parameter

Details

period

period with which 4 coils are working, in ms

coils_on_time

Time of one phase turned on, in ms

phase_delay

delay in turning on phases, in ms

pwm_direct

direction of the current going through coils (it is not the direction for F.R.W.)

pwm_duty

duty of coils PWM

The function works when:

  • period>3∗phase_delay+coils_on_time

  • coils_on_time>2∗phase_delay

To control F.R.W. in the opposite direction use function: Algorithm FRW_ControlStepAntiClockwise.

FRW_ControlPID_duty aim is to stabilize satellite rotation according to Z axis to value given in INIT_FRW_MODE_DUTY (degrees/s). It uses mesurements done by gyroscope. There are 3 constants: Ki_duty, Kp_duty and Kd_duty - which can be changed from Earth using IMU paramconfig.

The purpose of FRW_ControlPID_frequency is to stabilize satellite rotation according to Z axis to value given in INIT_FRW_MODE_FREQ (degrees/s). It uses mesurements done by gyroscope. There are 3 constants: Ki_freq, Kp_freq and Kd_freq - which can be changed from the Earth using IMU paramconfig.

FRW_Control_list enables the user to create their own control. It is done by performing all instructions from the control list. To add an instruction to the list, use command 240 which consists of:

Parameter

Details

coil

phase which should be changed

time

time till next action [ms]

dir

direction of current in phase - 0 for clockwise, 1 for anticlockwise

duty

duty for changed phase

reset

1- for cleaning all data on the list, 0 - to add instruction

Detumbling algorithm

Detumbling modes high level logic

Detumbling algorithm

The payload detumbling algorithm uses magnetorquers in all three satellite axes. A magnetorquer is an electromagnet which due to current flow creates a magnetic moment which interfaces with the Earth'a magnetic field. This creates a torque acting on the satellite. Thus, being able to control the current flowing through the coil (the words coil and electromagnet will be used interchangeably) enables controling the angular velocity of the satellite. The equation used to calculate the torque created by the electromagnet is shown below:

M⃗=μ⃗×B⃗\vec{M}=\vec{\mu} \times \vec{B}M=μ​×B

Where M⃗\vec{M}Mis the created torque, μ⃗\vec{\mu}μ​is the magnetic moment and B⃗\vec{B}B is the Earth's magnetic field's induction.

The algorithm is based on the so-called Angular Rate Feedback algorithm. The equation used to calculate the needed current in each of the coils is shown below (the current in each coil is one of the components of the current vector):

​

B⃗˙=B⃗×ω\dot{\vec{B}} = \vec{B}\times\omegaB˙=B×ω
i⃗=−kB⃗˙∥B∥2\vec{i} = -k \frac{\dot{\vec{B}}}{ \left\lVert B \right\rVert ^2}i=−k∥B∥2B˙​

The optimal value of k was chosen after conducting simulations on a model of the satellite. An appropriate PWM signal is passed on the inputs of H-bridges, which control the current of the magnetorquers.

One cycle of the algorithm consists of five steps; the time interval between those steps is 200 ms (so the whole algorithm cycle is 1s).

  • Step 1: At the beginning of this step, the current in all coils is always zero. The magnetic field induction (B) is measured (because no current flows through the magnetorquers, their magnetic field has no influence on the measurement). Also the angular velocity of the satellite is acquired. The output current of the coils is calculated using the above equation and the current of the coils is changed.

  • Step 2, 3, 4: In each of these steps the magnetic field induction in the satellite-oriented reference frame is estimated and the angular velocity is measured. Apart from that, the operations are the same as in step 1

  • Step 5: The current of the coils is set to 0, so that the magnetic field induction can be measured in step 1. Return to step 1.

The estimation of the magnetic field induction in the satellite-oriented reference frame is conducted as follows: it is assumed that it is constant in the Earth-oriented frame and it changes because of the non-zero angular velocity of the satellite (which is measured). So, the magnetic field induction can be estimated as:

B⃗(t+Δt)≈B⃗(t)+B⃗˙Δt,\vec{B}(t+\Delta t) \approx \vec{B}(t) + \dot{\vec{B}}\Delta t,B(t+Δt)≈B(t)+B˙Δt,

where:

Δt=200ms.\Delta t = 200 ms.Δt=200ms.

More information about detumbling system can be found in: Artur Hadasz, "Simulation of stabilization algorithms and building a prototype of a stabilization system for picosatellites using magnetorquers", BSc Thesis, AGH University of Science and Technology, Cracow 2018, supervisor: Paweł Zagórski and in the work: Piotr Mikołajek, "Design and simulation of a picosatellite low Earth orbit magnetic field based attitude determination system", BSc Thesis, AGH University of Science and Technology, Cracow 2018, supervisor: Paweł Zagórski.

KRAKsat state machine
FRW Baisic control diagram
FRW acceleration control diagram
FRW Step control diagram
Detumbling high level logic
The operation of a magnetorquer