Is there a way to create a fixed delay inside the C++ block? With the same style of delay that exist in MCU/Arduino? for example wait 20 nano? Thank you.
Hi, Daniel.
To clarify, are you simply wanting to have an output state change reflect an input state change delayed by a fixed time?
If so, it shouldn’t be difficult using some combination of Trunc() and/or MaxExtStepSize(). There’s lot’s of information about using C-Blocks on my QSpice GitHub repository.
On the other hand, if all you want is to add a delay to some circuit signal and don’t need it to be in a C-Block, I think that I’ve seen it done without using C-Blocks, perhaps with a lossless transmission line. If that would solve your problem, I’d refer you to @KSKelvin. (He’s way better at the Spice side of QSpice side that I am.)
–robert
I need clarification on the type of delay you are referring to. You mentioned the delay that exists in Arduino; the delay()
function in Arduino programming has a minimum delay of 1ms (delay() | Arduino Documentation), which actually creates a pause. However, you mentioned waiting for 20 nano (ns?); this seems to refer to the propagation delay of a logic gate… Or does delay refer to discrete control with actions taken at consistent intervals?
As @RDunn mentioned, analog and digital delays can be handled differently in Qspice. Therefore, we need to understand your specific purpose before suggesting a direction for you. Could you please explain what you are trying to achieve and why you think a delay is required?
Sorry for the lack of clarify. I want to emulate a delay line. Specifically for dead time. I usually use external logic gates, as shown in the snapshot I added:
This gate perform 20nsec delay. I wonder I there is a way to implement it inside the block. Thank you.
The logic you showed above is generally used to generate dead time. We had a discussion and code sample for delay implementation in the C-block. @RDunn and I both have code posted there. If you run the delay in ns, you have to change “ttol” in “Trunc()” in ps to ensure the transient timestep is relatively small compared to the delay to reform a sharp transition.
https://forum.qorvo.com/t/creating-delay-loop-in-c/16970/3