Frequently Asked Question

Video: 6.4.3 Additional signal analysis
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! And welcome to our third lesson on Typhoon Test.  

00:00:05

In this lesson, we will be using our model from the previous lesson and  

00:00:09

continue improving our test to include additional analysis functions and more. 

00:00:13

To run this example, we will have to modify our model. Let s add a probe with the name ref  

00:00:24

from the speed reference n_ref and save the model.  

00:00:28

You don t need to compile it, we will be adding this functionality in the test itself. 

00:00:33

Let s start by changing the code to compile the model. Import the Schematic API library as model  

00:00:40

and add the load and compile functions. Since we want to do this just once, add the  

00:00:45

commands inside the load_model fixture, above where we load the compiled model to the HIL. 

00:01:01

Now, let s add the ref variable to our capture. We will be using the capture  

00:01:05

rate later in our analysis functions, so let s move its value to the variable fs . 

00:01:18

Let s find events during the capture; for instance, we would like to measure the exact  

00:01:23

moment where the speed reference changes. In order to do so, we will use one of the find  

00:01:28

functions from the signal library.We have find , find all , and find  

00:01:34

edges . The first returns only the first time where the condition matches the criteria, the  

00:01:39

second function will return all of them, and the third one is used to find rising and falling edges  

00:01:44

of a signal. Let s see how to use each one of them to find the instant where the reference changes. 

00:01:49

Let s store the returned value from the find function into t1 right after we get  

00:01:53

the capture results. Set the signal as the speed reference from the capture variable,  

00:01:58

df['ref'] , the region as outside , and the value as (495, 505) . This function will return  

00:02:06

the first instant where the reference is outside of the values 495 to 505. 

00:02:18

Let s now save the first value of find_all to the variable t2 . The function parameters are  

00:02:24

the same previous one. Since we want to find the first condition that meets this criterion,  

00:02:30

select the first item from the list.Now, let s store the first find_edges  

00:02:38

value into t3 . Before doing that, let s calculate the average value of the reference and use it as  

00:02:44

the threshold to find the step. We can use the mean function from pandas and store it into the  

00:02:48

variable ref_mean . You can easily find all the available functions for pandas online. 

00:02:57

Set the signal as speed reference, the value as the average speed reference, and the rising and  

00:03:02

falling parameters as True. Since we want just the first condition that meets this criterion, we will  

00:03:08

also select only the first item from the list.In order to visualize these results,  

00:03:13

we can use some reporting functions. They are not listed in the Typhoon Test API,  

00:03:18

but you can easily find them in the documentation. So, let's open the Typhoon HIL Control Center,  

00:03:25

open the Documentation Hub, select Typhoon Test API, and search for the report_message function. 

00:03:40

To import packages that are not present in the module list,  

00:03:43

we can select Import other module, provide the fully qualified name,  

00:03:53

click on import and create the alias msg . 

00:04:02

Under the function menu, select report_message and write the desired message. 

00:04:16

Let s do the same for t2 and t3 . 

00:04:32

After that, overwrite the fixed value for the variable time_before_step by any of these acquired  

00:04:37

values, because as it will be shown, they are the same. To maintain the same variable type,  

00:04:43

let s convert from time delta to seconds, using the total_seconds() function. 

00:04:51

Let s run the test and see how it looks like in the report. On the console, we can follow in  

00:04:56

real time what the test is doing. We can see that model is being compiled as part of the test run,  

00:05:02

thanks to the model.compile() function we added earlier. 

00:05:09

Once one of the tests is done, you can open the report with the already executed tests.  

00:05:14

To do that, go to the working directory folder and double click on the open_report.cmd file. 

00:05:20

Let s check how the three find functions,  

00:05:22

find , find_all , and find_edges , look like and the custom report message we added. 

00:05:29

As expected, the values are the same. This is very important for precise reaction time measurements.  

00:05:35

Before we were using a wait command to estimate the reference step occurrence.  

00:05:40

However, all the commands have a delay that shifts the step occurrence a little,  

00:05:44

so with the find function it is possible to measure the precise moment the step happened. 

00:05:49

Going back to the test. The next signal analysis we would like to present is to  

00:05:53

measure the converter frequency. In order to do so, we will use the filtered current measurement.  

00:05:59

Let s search the documentation and add the low pass filter function manually. 

00:06:18

Further, we can create an additional signal in the  

00:06:20

data frame with the low pass filtered current from phase A.  

00:06:32

From the documentation, we can see that this function needs the signal,  

00:06:36

the filter order, the frequency, and the sampling frequency. 

00:06:49

Now, let s use the signal_frequency_zc function, under the harmonic module,  

00:06:54

to compute the frequency from the filtered current measurement. Save the result as w_hz . 

00:07:12

Right now, w_hz is a pandas series with frequency values for the whole capture. Let s make some  

00:07:18

changes to get the average frequency for the last 100 milliseconds. In order to do it, we have to  

00:07:23

slice the data frame from 900 milliseconds to 1 second using Timedelta type variables.  

00:07:29

To convert the time from seconds to Timedelta we can use the following TyphoonTest function. 

00:07:45

Now we can slice the signal from 900 milliseconds until the end of the  

00:07:48

capture and compute its average value.Let s also calculate the period of the  

00:08:02

signal as one over frequency and add this information to the report. 

00:08:32

Let s create additional auxiliary variables to store the time to start the steady state analysis.  

00:08:38

It is important to use an integer number of periods to calculate some functions,  

00:08:42

like THD. So, let s use a window of 10 periods. 

00:09:04

The next signal analysis we would like to present is the rms calculation.  

00:09:08

So, let s open the module list once more and import Typhoon Test Rms as rms . 

00:09:19

Let s compute the rms value of Ia , using the window_rms function and add it to the data frame  

00:09:25

under the name Ia_rms . Set the signal as Ia from the data frame and the window length as period .  

00:09:31

This function computes the rms of a signal using a moving window with a parameterizable size. 

00:09:44

Just like we did before, let s add the average steady state rms  

00:09:48

value over the evaluation period to the report. 

00:10:07

The next signal analysis we would like to show is the converter harmonic content. The value will be  

00:10:12

stored in the variable fft_result and calculated with the function frequency_content , also under  

00:10:18

the harmonic module. Let s set the signal as Ia from the data frame,  

00:10:22

during our 10 fundamental cycles window at the end of the capture, and the max frequency as 500. 

00:10:36

The returned value is a FFTResult type. You can check the documentation for more  

00:10:41

information about it. Let s also include in the report a message to display the harmonic  

00:10:46

amplitude at the fundamental frequency. 

00:11:08

Similarly, we can calculate the total harmonic distortion and add it to the report. 

00:11:51

Since now we are capturing the reference signal,  

00:11:53

we can compare the speed response with its actual reference. For that,  

00:11:58

we will use the assert_follows_reference function inside a pytest assume statement.  

00:12:15

We can set the signal as the measured speed, the reference signal as the speed reference,  

00:12:22

tolerance as 15, strictness as 0.8, and time tolerance as 50 milliseconds. 

00:12:30

In order to analyze all the functions outside of the test environment,  

00:12:34

you need to save the data frame and run it in another Python environment. So, right  

00:12:38

after capturing the data, you can use a pandas function to store the information in a file. 

00:12:54

Now, let s run the complete test. 

00:13:12

After the simulation is completed, let s see how to open the files we acquired.  

00:13:16

Here we will be using the command prompt to plot all the captured signals. 

00:13:45

Let s now open the report and check the tests.Here, one test passed and the others failed.  

00:13:51

Let s navigate to the test list and take a closer look at the third one. 

00:13:57

We can see that the measured fundamental frequency was 36.5 Hz with a period of 27 milliseconds, and  

00:14:04

an rms value of around 18 Amperes. There is also the frequency content plot with a magnitude of  

00:14:10

26.1 Volts at the fundamental frequency of 36 Hz, which are the same as the numerical values. Also,  

00:14:17

the THD value is smaller than 1% which is expected due to the low harmonics observed in the plot. 

00:14:24

Finally, we can check the assert follows reference, where we configured the allowed  

00:14:29

region around the step in the amplitude axis as well as in the time axis. This  

00:14:33

is a very flexible function that can be applied to sinusoidal, triangular, or any type of waveforms. 

00:14:40

In this lesson we learned some additional Typhoon Test Functions, such as different find functions,  

00:14:45

the use of messages in the report, assert follows reference, and the RMS, FFT, and THD functions. We  

00:14:54

also learned how to save data for future offline usage. In the next lesson we will learn how to  

00:14:59

enhance and customize the report.

00:15:02

Thank you for watching!

Please Wait!

Please wait... it will take a second!