Generating triggers with a very precise timing
Posted: Thu Mar 30, 2023 12:30 am
Hello everyone,
for a project i need to generate triggers at a precise period.
It seems the triggers are drifiting from a reference (a few ms after several minutes which is not ok for my application).
In order to have the more precise period possible, i worked with a timer interupt (at 10kHz / 10 useconds rate). In this interrupt i increment a counter in order to fire the trigger (when the counter reach a certain value). I also worked with the micros() function - in both cases the same problem occurs : the period is a bit longer. I use a custom board with a stm32f103c8t6 and a 8MHz crystal coming from mouser, with the right capacitors values. Only doubt i could have it the crystal is not completely close the CPU (i had to put this crystal at 2 cm from the CPU, the capacitors are at 1 cm from the crystal).
Also i can accept a slight period error between each pulses - the more important is to not have a drift that accumulates with time.
Any idea on what can go wrong ?
for a project i need to generate triggers at a precise period.
It seems the triggers are drifiting from a reference (a few ms after several minutes which is not ok for my application).
In order to have the more precise period possible, i worked with a timer interupt (at 10kHz / 10 useconds rate). In this interrupt i increment a counter in order to fire the trigger (when the counter reach a certain value). I also worked with the micros() function - in both cases the same problem occurs : the period is a bit longer. I use a custom board with a stm32f103c8t6 and a 8MHz crystal coming from mouser, with the right capacitors values. Only doubt i could have it the crystal is not completely close the CPU (i had to put this crystal at 2 cm from the CPU, the capacitors are at 1 cm from the crystal).
Also i can accept a slight period error between each pulses - the more important is to not have a drift that accumulates with time.
Any idea on what can go wrong ?