Custom Sample Hold component goes wrong

Hello Qspice community.

I made a C++ Sample Hold component. It works well if I instantiate once in my simulation sheet but it is not the case anymore if I instantiate more than once .

First Simulation:



IN1 and IN2 generate the same signal and OUT1 and OUT2 show the same result → OK

If I change one source , IN2 is 2 V peak now I get
Second Simulation:


Please can someone explain that ?

Here included all files.

Thank you

Best regards,
Davide
question2.qsch (3.9 KB)
sh.qsch (1.6 KB)
sh.qsym (374 Bytes)
sh_x1.cpp (1.3 KB)

Hi, Davide.

Use per-instance data instead of global variables. See CBlockBasics tutorials here.

–robert

3 Likes

I always have a thought if simulation will run more efficiently if you use minimum number of Cblock if possible

Hello RDunn,

Thank you . Your doc is perfect.
Best regards,
Davide