Engee documentation
Notebook

Voltage failure generation

This demonstration is devoted to a tool for forming the logic of finite automata using the Chart block. This block has its own special library of elements containing states, nodes, and transitions. It is shown in the picture below.

image.png

To demonstrate the capabilities of the tool, we will consider a voltage fault generation system.
In this example, we compare the voltage across the sensor windings (U+, U-) with a THRESHOLD value. When the voltage is lower, we form a failure. The upper level of the system is shown in the figure below.

image.png

If we consider the logic of the state machine itself, then note that there are two winding voltages. When a certain voltage becomes less than the THRESHOLD value, the fault confirmation process is started (CNTR_START, CNTR_STOP states). This process lasts 1 sec (1 sec – 0.01 sec is the calculation step). If, at the end of the fault detection process, the fault condition persists, then we confirm the failure and switch to the FAULT state. The figure below shows the logic implemented in Chart.

image.png

Now let's run the model itself and analyze the results of its execution.

In [ ]:
# Enabling the auxiliary model launch function.
function run_model( name_model, path_to_folder )
    
    Path = path_to_folder * "/" * name_model * ".engee"
    
    if name_model in [m.name for m in engee.get_all_models()] # Checking the condition for loading a model into the kernel
        model = engee.open( name_model ) # Open the model
        model_output = engee.run( model, verbose=true ); # Launch the model
    else
        model = engee.load( Path, force=true ) # Upload a model
        model_output = engee.run( model, verbose=true ); # Launch the model
        engee.close( name_model, force=true ); # Close the model
    end

    return model_output
end
Out[0]:
run_model (generic function with 1 method)
In [ ]:
run_model("Voltage_failure_generation",@__DIR__) # Launching the model.
Building...
Progress 0%
Progress 100%
Progress 100%
Out[0]:
SimulationResult(
    run_id => 4,
    "v" => WorkspaceArray{Float64}("Voltage_failure_generation/v")
,
    "Chart.check_flag" => WorkspaceArray{Float64}("Voltage_failure_generation/Chart.check_flag")
,
    "res" => WorkspaceArray{Bool}("Voltage_failure_generation/res")

)

As we can see from the simulation result, three signals were saved:

  • v = validity – a sign of the validity of the signals,
  • cf = check_flag – internal counter variable,
  • res – indicates that one of the voltages has become less than the threshold.

Let's plot these signals.

In [ ]:
# Reading signals from simout
v = simout["Voltage_failure_generation/v"];
v = collect(v);

check_flag = simout["Voltage_failure_generation/Chart.check_flag"];
check_flag = collect(check_flag);

res = simout["Voltage_failure_generation/res"];
res = collect(res);
In [ ]:
plot(v.time, [v.value, check_flag.value, res.value], layout = (3,1), title=["v" "check_flag" "res"])
Out[0]:

As we can see from the graph, our system worked correctly when an error condition appeared.

Conclusion

In this example, we have analyzed the possibilities of using Chart in Engee using the example of a voltage fault generation system.