Frequently Asked Question
Press "Ctrl + F" to find the keyword of your interest.
If you wish to have a direct link access to the video timestamps, please follow these instructions.
Found this video helpful? Why not take the whole HIL Specialist course? A Certificate is waiting for you for free at HIL Academy.
Would you or your organization benefit from having these videos narrated in your native language? Contact us and let us know if you wish to contribute.
TRANSCRIPT
Hello there, now it is time to show you some more advanced features in HIL SCADA.
These features are related to SCADA API and let you perform semi-automated testing.
In this session, we will simulate two types of faults: phase loss and IGBT fault. Both
of these faults will be executed for a predefined period of time. Also,
let’s capture these transients using SCADA API commands for executing the actions. These actions
will be executed using Capture handler. We will be continuing with our model from module 2.3.
First let’s open the Panel Initialization in HIL SCADA and define a global variable.
This global variable will be callable by all the widgets in the SCADA panel. Let’s
define the variable global t_fault, which will represent the period of the fault in seconds.
Also, let’s set the initial for duration of the fault to 0.1 seconds.
Now let’s insert a textbox widget. With the textbox widget, we can define an arbitrary
period of time for our fault duration. Let’s open the text box widget properties and rename
it to “Fault duration [s]”. Also, let’s do a small modification in the macro code.
Here we want to store the input value to the global t_fault variable. We do that by calling
the global t_fault variable, and then by setting t_fault to equal inputValue.
Now let’s add a macro widget. Let’s open the macro widget properties.
The macro is a special action widget that has four event handlers. The On Start handle is for code
that will be executed at simulation start, just after the Panel initialization script is executed.
The On Click handle is for code that will be executed on a button click in
a similar way to the Button action widget. The On Timer handle is for code that will
be executed periodically after simulation start based on the defined execution rate.
The execution rate of this code can be 250, 500, or 1000 mili seconds.
The On Stop handle is for code that will be executed after the simulation is stopped.
Checking the Active handlers check box for a specific event handler will allow its
macro code to be executed. We will use the On Click handler in this example.
In the On Click dialog let’s write some simple code. First thing that we can do
is to print the time duration in the message log. First, let’s define the global variable
t_fault just like we did in the text box. Also, let’s rename this macro to “Fault action”.
Now let’s do a standard Python print command for t_fault and click OK.
Let’s set the time duration to another value, 0.2 seconds for example, and confirm it with enter.
Now, we can run the macro by clicking on the macro button.
In the message log we can see that we successfully printed the value from fault duration. In this
way we managed to create an interaction between two widgets in the SCADA panel. This can be very
helpful for semi-automated tests in HIL SCADA.Now that we can interact between widgets,
we can go on to the next step. Now let’s automate the operation of the contactor so that it opens
when there is a fault. Let’s go back to the Fault action macro, and let’s write some code.
First thing that we need to do is to get the simulation time. Let’s quickly go to the HIL
API documentation and try to find it. To find the documentation we need to open
the Documentation Hub in the Typhoon HIL Control Center main menu, and open the HIL API folder.
Here we can do a quick search and write “time”.
The first function, get_sim_time, is the one we are looking for.
Let’s call this function in the macro code and assign it to a new local variable simulationTime.
The comments provided in the Code Editor show the
different ways to call various Typhoon HIL API libraries.
Now that we have the simulation time, we can use it to set the state of the
contactor at an explicit execution time.Let’s use our API wizard to insert the
HIL API function for setting the state of the contactor.
Let’s insert two lines of code. One will define the open state,
and the second will define the close state of the contactor.
Next, let’s take a look in the documentation for set contactor function.
We can see that there is an interesting argument that we haven’t used yet:
the executeAt argument. This argument executes timed commands on the HIL device with a time
resolution equal to the simulation step. They are used when very precise timing is needed,
for example when capturing transients as a contactor opens or closes.
Let’s add this argument and set the execution time based on the simulation time.
Let’s set the execute at argument to be the simulation time plus 0.5 seconds.
This means that when we run this macro, the state of the contactor will change half a second later.
For the close state, let’s do the same thing but let’s also add the fault duration time.
Now we can test it and see what we did. We should define the fault duration first,
let’s put it to one second.
Let’s observe the machine speed. We can see that we have a drop in the speed of the machine,
followed by a return to full speed after the fault duration completes.
Now it is a perfect time to include the SCADA API for doing a force trigger from
the fault action macro.Firstly, let’s open SCADA
API documentation and let’s see how to execute actions using Capture / Scope.
All widgets in the panel have their own ID and fully qualified name or FQN. Let’s
find the Get widget by fully qualified name function in the documentation.
The name of the function is get widget by fqn.
To get the fqn from Capture / Scope,
you need to right click on the capture widget and click Copy fully qualified name.
Let’s paste it as the value of a new fqn widget variable in the Fault action macro.
Let’s use this fqn variable and add it as an argument in the get widget by fqn function,
and assign this to a new variable called cs.
Now it is time to see how to force the trigger in the capture.
We will use the execute action function from the SCADA API.
As we can see in the documentation, we have to add the widget handle and
action name. For widget handle we will call the cs variable we made a few seconds ago,
and for action we will use force_trigger.
Now let’s save the code and open the Capture Scope window.
When we click the Fault Action button, we should now see a capture appear showing the fault.
Now let’s include the IGBT fault as an option.
Firstly, let’s open documentation of the Three phase inverter.
To open the documentation let’s click on the help button.
Here we can find important information on the functionality,
control, and topology of the Three phase inverter. If we want to create an IGBT fault,
we have to control one of the six IGBTs in the converter. In order to simulate fault
of one of IGBTs in the converter let’s close the Sa_top IGBT switch in the converter.
Let’s add another global variable type_fault that
will tell us know which type of fault we want to simulate.
Also, for this part of semi-automated test let’s use the combo box.
Let’s drag and drop it in the panel.
Let’s open the combo box widget properties. First let’s rename it to Fault type.
Here we have additional dialog, that dialog is Available values, by the default we have
case 1 and case 2. Let’s rename these two cases as Phase loss and IGBT fault.
In the macro code we can see that we already have autogenerated if statement which we can
use to define actions for each case. Since we wish to make the same action regardless of the case,
we can remove this.
Now we can define global variable type_fault to
take the value of the input value from the combo box.
As in the previous example, we need to define the global variable type_fault in
the macro code so this combo box and the fault action macro can interact.
Confirm the changes. Now let’s go to fault action and do some small modifications.
Let’s create here a new if statement where we are going to ask what fault we want to perform.
If the type fault is Phase loss then we will do the existing test.
Else, we are dealing with an IGBT fault. In this case, we will need to set the power electronics
switching mode and value. To do that let’s use help of API wizard. Let’s open the code editor.
Let’s open the switching blocks settings dialog and set software control to
True and value to 1 for the Sa_top contactor. It is worth mentioning when software control is True,
model control is overridden. This means that when there is an IGBT fault, the current in the S1_top
contactor will be fault current. Let’s do the insert. Then let’s insert the code for returning
software control to false in order to reenable model control of the IGBT after the fault.
Now let’s add executeAt arguments to all four lines of code. We will again use 0.5 seconds
after the simulation time, and additionally adding t_fault for the last two lines.
We can save it and close the code editor.
Let’s set the combo box to IGBT fault. This will simulate when the IGBT is at fault,
which in SCADA means that the Sa_top IGBT is closed for a defined period of time.
We can see the waveform in the capture.We can see that we have a DTV flag raised.
This is what we expected; since both contactors in phase A are closed,
the software raised the flag. We can easily reset this flag by right-clicking on it.
To summarize, in this session we showed you how to use HIL SCADA in a more advanced way.
Also, we’ve found out more about using HIL API and SCADA API,
as well as how to perform semi-automated tests in HIL SCADA.