+2 votes
247 views
in Modeling by Eberhard Kromer (17 points)
- frequency given by signal in Schematic Editor, not in SCADA

- constant amplitude and offset

- only signal processing blocs, use of electrical circuit should be avoided

Thank you for your help.

2 Answers

+1 vote
by Dusan Kostic (211 points)
selected by Dimitrije Jelić
 
Best answer

Hi Eberhard,


I suppose that you are aware that there is a mechanism of Tunable components in Typhoon HIL toolchain. If you enable that option in the Square Wave Source component you can change all the component parameters in runtime using HIL API function model_write().

However, since you have expressed the intention to vary the parameters of this component through signal processing, a different approach must be taken. In the attached example model you can see the custom-made C function component representing square wave source, but with the dedicated inputs that are allowing runtime change through signal processing. 

In the attachment you can also find a SCADA panel, so you can test how this component works. Note that, unlike the library component, this custom-made component allows you to change phase during runtime (not just before simulation start).

Attachments:
model.tse
panel.cus

by Eberhard Kromer (17 points)
+2
Excellent service. Thank you so much.
+1 vote
by Ricardo Morim (150 points)
Hello Eberhard,

You can do it by using C function in the Schematic Editor.

In C function you get the signal processing sampling time by using the variable "execution_rate".

Then you can do something like,

counter++;

t_set = 1/freq/execution_rate;

if(counter < t_set/2)

{

    out = amp + offset;

}else

{

    out = 0 + offset;

    if(counter >= t_set)

    {

        counter = 0;

    }

}

Where counter can be an int var, freq, amp and offset are inputs of the C function.
by Eberhard Kromer (17 points)
+1
Thank you for the great hint.
...