Now that we have a timing "scheme" and a proper schedule of when what works; nothing easier than writing mcu code that will do it without problems.
But that's not the point. The point is to go slower (and the harder way); in order to fully understand the entire process that takes place in such a detector.
Only when we have a full understanding of the processes taking place there; then we can play around and convert the hardware piece by piece into code.
Unfortunately my favorite Atmega328P doesn't have enough resources to generate 4 pulses on 4 separate pins and do it all flawlessly accurately.
By the most stupid method "digitalWrite pin..." and so one after another all 4 pins... is a child's toy, which will not work well.
Because the final goal here is the shortest possible sample delay and the most precise timing.
A single C function can take too much time for such tasks.
Direct port/pin manipulation with (or without) interrupts can be up to 12 times faster.
But still not enough for such a delicate task.
Ok, that's all great when we make a detector that is a child's toy with a delay greater than 50uS and timings that will have a smaller or larger jitter at each clock.
The internet is full of such attempts. And on this forum you have "a dozen" attempts in that style.
It's all child's play, good for educational purposes, elementary education and entry into the world of programming.
But if I want a PI detector with maximum 10uS sample delay and very precise timing; it takes much more than that.
Perhaps something more could be extracted from Atmega at the lowest level, using pure assembler. But even then it wouldn't be good.
Ok, STM32, ARM... that's a better story.
And that can be done.
But we are far from that, this detector has not yet shone with its full glory. There are still a lot of tweaks to come until then.
I will always have a good laugh at one of Carl's "free thoughts" that he unwittingly and unintentionally wrote... and it has something to do with this!
When he was explaining on another topic how easy it is to solve this kind of task; he said (I'll paraphrase, it's not verbatim): "I'll choose a mcu that has at least 8 to 16 timers and that's it..."



Carl the GENIUS!
Leave a comment: