How to program the "ticks" for the module in c

I need to add a clock to my module
is there a example of how the “ticks” are programmed in C?

thank you

You can use a timer interrupt or sleep functions in C for basic ticking. For QSPICE, check if it supports timed events or a clock function in the simulation. Here’s a quick example using sleep in C:

#include <unistd.h>

while(1) {
    
    sleep(1);  // Ticks every second
}

This is what spawns that basic tick every second. The should have some options in QSPICE for exact simulation timing!

Hi, Fausto. Welcome to the forum.

If I understand your request, you want to implement a clock signal for a C-Block component. There are two approaches:

  1. Use a pulse voltage source on the schematic and tie that to a component input. I found that a bit unreliable; QSpice would drop pulses. Per Mike Engelhardt (QSpice author), adding a capacitor across the voltage source should prevent dropped pulses. I’ve not tested that.
  2. Implement the clock inside of the component. The C-Block Basics #5 paper on my GitHub QSpice repository demonstrates how to do this reliably and efficiently.

Hope that helps.

–robert