Frequently Asked Question

Video: 2.4. Semi-automated testing in HIL SCADA
Last Updated 3 years ago


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

00:00:02

Hello there, now it is time to show you some more advanced features in HIL SCADA.  

00:00:08

These features are related to SCADA API and let you perform semi-automated testing. 

00:00:13

In this session, we will simulate two types of faults: phase loss and IGBT fault. Both  

00:00:19

of these faults will be executed for a predefined period of time. Also,  

00:00:24

let’s capture these transients using SCADA API commands for executing the actions. These actions  

00:00:30

will be executed using Capture handler. We will be continuing with our model from module 2.3. 

00:00:37

First let’s open the Panel Initialization in HIL SCADA and define a global variable.  

00:00:42

This global variable will be callable by all the widgets in the SCADA panel. Let’s  

00:00:47

define the variable global t_fault, which will represent the period of the fault in seconds. 

00:00:58

Also, let’s set the initial for duration of the fault to 0.1 seconds. 

00:01:08

Now let’s insert a textbox widget. With the textbox widget, we can define an arbitrary  

00:01:14

period of time for our fault duration. Let’s open the text box widget properties and rename  

00:01:20

it to “Fault duration [s]”. Also, let’s do a small modification in the macro code.  

00:01:27

Here we want to store the input value to the global t_fault variable. We do that by calling  

00:01:33

the global t_fault variable, and then by setting t_fault to equal inputValue. 

00:02:02

Now let’s add a macro widget. Let’s open the macro widget properties.  

00:02:08

The macro is a special action widget that has four event handlers. The On Start handle is for code  

00:02:14

that will be executed at simulation start, just after the Panel initialization script is executed.  

00:02:21

The On Click handle is for code that will be executed on a button click in  

00:02:24

a similar way to the Button action widget. The On Timer handle is for code that will  

00:02:30

be executed periodically after simulation start based on the defined execution rate.  

00:02:35

The execution rate of this code can be 250, 500, or 1000 mili seconds.  

00:02:42

The On Stop handle is for code that will be executed after the simulation is stopped. 

00:02:47

Checking the Active handlers check box for a specific event handler will allow its  

00:02:51

macro code to be executed. We will use the On Click handler in this example. 

00:02:57

In the On Click dialog let’s write some simple code. First thing that we can do  

00:03:03

is to print the time duration in the message log. First, let’s define the global variable  

00:03:08

t_fault just like we did in the text box. Also, let’s rename this macro to “Fault action”. 

00:03:25

Now let’s do a standard Python print command for t_fault and click OK. 

00:03:35

Let’s set the time duration to another value, 0.2 seconds for example, and confirm it with enter. 

00:03:47

Now, we can run the macro by clicking on the macro button. 

00:03:57

In the message log we can see that we successfully printed the value from fault duration. In this  

00:04:02

way we managed to create an interaction between two widgets in the SCADA panel. This can be very  

00:04:07

helpful for semi-automated tests in HIL SCADA.Now that we can interact between widgets,  

00:04:12

we can go on to the next step. Now let’s automate the operation of the contactor so that it opens  

00:04:18

when there is a fault. Let’s go back to the Fault action macro, and let’s write some code. 

00:04:25

First thing that we need to do is to get the simulation time. Let’s quickly go to the HIL  

00:04:30

API documentation and try to find it. To find the documentation we need to open  

00:04:36

the Documentation Hub in the Typhoon HIL Control Center main menu, and open the HIL API folder. 

00:04:53

Here we can do a quick search and write “time”. 

00:05:01

The first function, get_sim_time, is the one we are looking for. 

00:05:05

Let’s call this function in the macro code and assign it to a new local variable simulationTime.  

00:05:29

The comments provided in the Code Editor show the  

00:05:32

different ways to call various Typhoon HIL API libraries. 

00:05:46

Now that we have the simulation time, we can use it to set the state of the  

00:05:50

contactor at an explicit execution time.Let’s use our API wizard to insert the  

00:05:56

HIL API function for setting the state of the contactor. 

00:06:10

Let’s insert two lines of code. One will define the open state,  

00:06:14

and the second will define the close state of the contactor. 

00:06:18

Next, let’s take a look in the documentation for set contactor function. 

00:06:49

We can see that there is an interesting argument that we haven’t used yet:  

00:06:53

the executeAt argument. This argument executes timed commands on the HIL device with a time  

00:06:59

resolution equal to the simulation step. They are used when very precise timing is needed,  

00:07:05

for example when capturing transients as a contactor opens or closes.  

00:07:10

Let’s add this argument and set the execution time based on the simulation time. 

00:07:31

Let’s set the execute at argument to be the simulation time plus 0.5 seconds.  

00:07:36

This means that when we run this macro, the state of the contactor will change half a second later.  

00:07:43

For the close state, let’s do the same thing but let’s also add the fault duration time. 

00:08:11

Now we can test it and see what we did. We should define the fault duration first,  

00:08:16

let’s put it to one second. 

00:08:23

Let’s observe the machine speed. We can see that we have a drop in the speed of the machine,  

00:08:28

followed by a return to full speed after the fault duration completes. 

00:08:38

Now it is a perfect time to include the SCADA API for doing a force trigger from  

00:08:42

the fault action macro.Firstly, let’s open SCADA  

00:08:47

API documentation and let’s see how to execute actions using Capture / Scope. 

00:09:02

All widgets in the panel have their own ID and fully qualified name or FQN. Let’s  

00:09:07

find the Get widget by fully qualified name function in the documentation. 

00:09:30

The name of the function is get widget by fqn. 

00:09:39

To get the fqn from Capture / Scope,  

00:09:41

you need to right click on the capture widget and click Copy fully qualified name. 

00:10:10

Let’s paste it as the value of a new fqn widget variable in the Fault action macro. 

00:10:21

Let’s use this fqn variable and add it as an argument in the get widget by fqn function,  

00:10:26

and assign this to a new variable called cs. 

00:10:40

Now it is time to see how to force the trigger in the capture.  

00:10:43

We will use the execute action function from the SCADA API.  

00:11:06

As we can see in the documentation, we have to add the widget handle and  

00:11:09

action name. For widget handle we will call the cs variable we made a few seconds ago,  

00:11:14

and for action we will use force_trigger. 

00:11:41

Now let’s save the code and open the Capture Scope window.  

00:11:45

When we click the Fault Action button, we should now see a capture appear showing the fault. 

00:11:55

Now let’s include the IGBT fault as an option.  

00:11:59

Firstly, let’s open documentation of the Three phase inverter.  

00:12:13

To open the documentation let’s click on the help button. 

00:12:22

Here we can find important information on the functionality,  

00:12:25

control, and topology of the Three phase inverter. If we want to create an IGBT fault,  

00:12:31

we have to control one of the six IGBTs in the converter. In order to simulate fault  

00:12:37

of one of IGBTs in the converter let’s close the Sa_top IGBT switch in the converter. 

00:12:48

Let’s add another global variable type_fault that  

00:12:50

will tell us know which type of fault we want to simulate.  

00:13:10

Also, for this part of semi-automated test let’s use the combo box.  

00:13:15

Let’s drag and drop it in the panel. 

00:13:22

Let’s open the combo box widget properties. First let’s rename it to Fault type. 

00:13:34

Here we have additional dialog, that dialog is Available values, by the default we have  

00:13:39

case 1 and case 2. Let’s rename these two cases as Phase loss and IGBT fault. 

00:13:56

In the macro code we can see that we already have autogenerated if statement which we can  

00:14:01

use to define actions for each case. Since we wish to make the same action regardless of the case,  

00:14:08

we can remove this. 

00:14:15

Now we can define global variable type_fault to  

00:14:17

take the value of the input value from the combo box. 

00:14:20

As in the previous example, we need to define the global variable type_fault in  

00:14:24

the macro code so this combo box and the fault action macro can interact. 

00:14:29

Confirm the changes. Now let’s go to fault action and do some small modifications.  

00:14:35

Let’s create here a new if statement where we are going to ask what fault we want to perform.  

00:14:41

If the type fault is Phase loss then we will do the existing test. 

00:15:07

Else, we are dealing with an IGBT fault. In this case, we will need to set the power electronics  

00:15:13

switching mode and value. To do that let’s use help of API wizard. Let’s open the code editor. 

00:15:31

Let’s open the switching blocks settings dialog and set software control to  

00:15:35

True and value to 1 for the Sa_top contactor. It is worth mentioning when software control is True,  

00:15:41

model control is overridden. This means that when there is an IGBT fault, the current in the S1_top  

00:15:47

contactor will be fault current. Let’s do the insert. Then let’s insert the code for returning  

00:15:54

software control to false in order to reenable model control of the IGBT after the fault. 

00:16:05

Now let’s add executeAt arguments to all four lines of code. We will again use 0.5 seconds  

00:16:11

after the simulation time, and additionally adding t_fault for the last two lines. 

00:16:47

We can save it and close the code editor. 

00:16:51

Let’s set the combo box to IGBT fault. This will simulate when the IGBT is at fault,  

00:16:55

which in SCADA means that the Sa_top IGBT is closed for a defined period of time. 

00:16:57

We can see the waveform in the capture.We can see that we have a DTV flag raised.  

00:17:27

This is what we expected; since both contactors in phase A are closed,  

00:17:31

the software raised the flag. We can easily reset this flag by right-clicking on it. 

00:17:38

To summarize, in this session we showed you how to use HIL SCADA in a more advanced way.  

00:17:44

Also, we’ve found out more about using HIL API and SCADA API,  

00:17:48

as well as how to perform semi-automated tests in HIL SCADA.

Please Wait!

Please wait... it will take a second!