R5 state machine#

The state of the UltraZohm is controlled by a state machine in the R5 (uz_platform_state_machine.c). The initialization of the system is not part of the state machine and is done in main.c of the R5.

        stateDiagram-v2
    [*] --> Idle
    Idle --> Running: Enable System
    Running --> Control: Enable Control
    Control --> Error: Error
    Running --> Error: Error
    Idle --> Error: Error
    Error --> Idle: Stop
    Running --> Idle: Stop
    Control --> Idle: Stop
    state "Idle" as Idle: Slowly blink ready LED
    state "Running" as Running: Blink ready LED <br> Enable FPGA outputs
    state "Control" as Control: Blink ready LED <br> Turn on running LED <br> Enable control algorithm
    state "Error" as Error: Disable FPGA outputs <br> Turn on error LED
    

The figure above shows the four state of the UltraZohm:

  • Idle

  • Running

  • Control

  • Error

The implicit state assertion is not shown (see Assertions). If in any state an execution is triggered, the error state is executed once, the system is hold and can only be used after a restart (power cycle). The state machine has the following input variables:

  • Enable system

  • Enable control

  • Stop

  • Error

The inputs are set using the set functions (e.g., ultrazohm_state_machine_set_enable_system). For all UltraZohm versions >2, enable system, enable control, and stop are available as buttons on the frontpanel. Additionally, the signals can be set using the JavaScope. The input Error is only set from software functions.

The different states are indicated by the status of the LEDs on the front panel. The main difference between the states is that no output signals are routed through the CPLD (gate signals are off) if the system is not in the state Running or Control. Likewise, the control algorithm in the ISR is not executed, if the system is not in the state Control.

The following table shows the complete state table.

Table 7 State table with inputs and outputs of the UltraZohm#

Output

Output

Output

Output

Output

Output

Input

Input

Input

Input

Next state

LED

LED

LED

LED

Software

FPGA

State

Ready

Running

Error

User

Controller

Outputs

Enable System

Enable Control

Stop button

Error

Next state

Idle

Blink slow

Off

Off

Off

Off

Off

==1

x

!=1

!=1

Running

Idle

Blink slow

Off

Off

Off

Off

Off

x

x

x

==1

Error

Running

Blink fast

Off

Off

Off

Off

On

x

==1

!=1

!=1

Control

Running

Blink fast

Off

Off

Off

Off

On

x

x

x

==1

Error

Running

Blink fast

Off

Off

Off

Off

On

x

x

==1

!=1

Idle

Control

Blink fast

On

Off

Off

On

On

x

x

==1

!=1

Idle

Control

Blink fast

On

Off

Off

On

On

x

x

x

==1

Error

Error

Off

Off

On

Off

Off

Off

x

x

==1

!=1

Idle

Software reference#

enum platform_state_t#

Enum for the available states of the UltraZohm.

Values:

enumerator idle_state#
enumerator running_state#
enumerator control_state#
enumerator error_state#
platform_state_t ultrazohm_state_machine_get_state(void)#

Returns the current state of the ultrazohm.

Returns:

platform_state_t

void ultrazohm_state_machine_step(void)#

Exectures the central state machine of the UltraZohm once.

void ultrazohm_state_machine_set_enable_system(bool enable_system)#

Sets the input signal enable system of the state machine.

Parameters:
  • enable_system

void ultrazohm_state_machine_set_enable_control(bool enable_control)#

Sets the input signal enable control of the state machine.

Parameters:
  • enable_control

void ultrazohm_state_machine_set_stop(bool stop)#

Sets the input signal stop of the state machine.

Parameters:
  • stop

void ultrazohm_state_machine_set_error(bool error)#

Sets the input signal error of the state machine.

Parameters:
  • error

bool ultrazohm_state_machine_get_enable_system(void)#

Get state of the input signal enable system.

Returns:

true

Returns:

false

bool ultrazohm_state_machine_get_enable_control(void)#

Get state of the input signal enable control.

Returns:

true

Returns:

false

bool ultrazohm_state_machine_is_control_state(void)#

Special function to check if the state machine is in the state “control” - should only be used in the ISR!

Returns:

true

Returns:

false

bool ultrazohm_state_get_led_running(void)#

Returns the current state of the running led.

Returns:

true

Returns:

false

bool ultrazohm_state_get_led_ready(void)#

Returns the current state of the ready led.

Returns:

true

Returns:

false

bool ultrazohm_state_get_led_error(void)#

Returns the current state of the error led.

Returns:

true

Returns:

false