A
Arduino2mo ago
Waðe

I need help verifying code

A friend of mine works with a lot of different devices and stuff, but he is not a programmer, he asked me this: "create arduino code for 3 thyristor regulators (each in a different phase) that need to be controlled with one common control signal? I have a link where there is code for one phase but I need 3 phases at the same time. I drew a circuit - it should work. Control could be either from an analog input with a potentiometer, or from a digital one with an encoder. " I'm a programmer, but I know nothing about electronics, circuits or anything of that sort, and I know very little C++, never worked with arduino before either. I read a bit on this topic but I am unsure about how much I picked up as it's a quite difficult and vast topic it seems like. Using AI I managed to get this, the code is pretty much all AI written, the question is, does this seem right? I have no real way of verifying this quickly either, as we are in different countries at the moment, so it would take a lot of time to know what results this gives. I'm not even entirely sure that this is a fully functioning code. I have also added the circuit schematic
2 Replies
Waðe
WaðeOP2mo ago
pseud0
pseud02mo ago
all variables shared between interrupt functions and the regular functions (like setup()) must be declared volatile, the fired bool array misses that. The ISRs should be as fast as possible, and digitalRead() is very slow. The digitalWriteFast library contains an extremely fast digitalReadFast() macro that can help speed things up.
GitHub
GitHub - ArminJo/digitalWriteFast: Arduino library for faster and s...
Arduino library for faster and smaller digitalWrite(), digitalRead() and pinMode() functions using direct port manipulation for constant pin numbers. - GitHub - ArminJo/digitalWriteFast: Arduino l...

Did you find this page helpful?