How to set up a user defined, periodic square wave in AWB

« Go Back

Information

 
ProblemHow do I create a periodic square wave in AWB?
Solution
NOTE: The output of this function in Analysis Workbench is to create an interval list component or interval list file and not to bring in a square wave to be used as an input in STK.

A periodic square wave can be useful when doing design and or analysis. You can use a function like this to set up an imaging pattern for a sensor (e.g. on for 5 minutes, off for 10 minutes). You can also use it in conjunction with a scheduled vector to point a vector in one location for a period of time and then point it to another location for a period of time and repeat. This can be used for any application where you have a repeating on-off construct in which you want to define the duration of the on time and off time.

1. Create sine wave based on your on-off time

We are going to use the Function(x) scalar calc component as our base for the square wave. Select new scalar component for the object you want to create the square wave on and then change the Function value to a*Sin(bx+c)+d
 
User-added image
 
Leaving the coefficients as the default we see the sine wave looks like this:
 
User-added image
where amplitude = 1 and period = 2π

Now we need to modify the sine wave to reflect the on time and off time we desire. We do this by adjusting the period. Instead of the period being 2π seconds, we want it to be our 'on time' added to our 'off time' in seconds. The b coefficient is calculated by dividing the default period by our desired period. So b=2π/(on time + off time), where the times are in seconds. Let's look at an example of a 1 minute on, 5 minutes off wave. 
 
User-added image          User-added image
                                                                                                                            amplitude = 1, period = 6

2. Shift sine wave to account for on time versus off time

We will need to shift the overall wave so that only the 1 minute on time is above 0. This will allow us later to set up a conditional calc object to actually create the square wave. We do this shift by modifying the d coefficient. Since the amplitude is 1, we need to find the percentage of our on time versus off time. This will be the decimal value we need to shift down. So d=-(1 - (on time)/(period)). Which gives us the following:
 
User-added image          User-added image
              amplitude = 1, period = 6, notice the entire wave is shifted down

3. Turn your sine wave into a square wave

We now have everything set up so that we can create the square wave. Create a Scalar Bounds Condition calc object. Set the Scalar value to the previously created sine wave, and keep the Operation at Above Minimum and the Minimum equal to 0.
 
User-added image

This gives us the final square wave that looks like this:
 
User-added image          

Square wave showing 1 minute on, 5 minutes off; showing 1 period

User-added image
     Square wave showing 1 minute on, 5 minutes off; showing 4 periods


You can then use this with a satisfaction time interval to create time intervals you can use as sensor constraints or to point vectors. You can also merge this time interval with other square wave intervals to create complex repeating patterns such as 30 seconds on, 2 minutes off for 1 hour; then 5 minutes on, 2 minutes off for 3 hours; then back to 30 seconds on, 2 minutes off for 1 hour; repeat.

The attached file is an html utility that will take your input of On-time duration and Off-time duration and create the square wave calc object as well as the associated interval file.
ProductSTK
Version(s)
Resource File 1 
Resource File 2