I am pretty new to the forum and wanted to ask for a practicle solution on how to switch an IGBT inside an Interrupt Function.
I want to use the IGBT to switch capacitors and make it close for a certain amount of time (about a few milliseconds; probably under 4ms).
Normally I would say that I would switch the IGBT on when the interrupt is triggered then make a delay of about 2ms and then switch it off again.
But I am aware that every form of delay (only delayMicroseconds(<500?)) would not work.
I did this with an SCR which I turned on for a few 100 microseconds via the delayMicroseconds function which worked fine because the SCR only needs a very short impulse and then shuts itself up again when the capacitors are fully discharged.
But now I have IGBTs which are way more suitable for my application but they need to be set to high for the duration where they should be closed.
I also have another program (voltage meter via voltage divider to measure the voltage of the capacitors and print that on an LCD screen) so I can‘t simply put a if() with the signal which should trigger the ISR in the loop because when that signal comes in, it should immediatelly switch the IGBT on for a few ms!
I hope you know what I mean and thanks for the answers in advance
You can use internal timer of the atmega328p and make 1ms timer interrupts. Whenever you press the button you can record the timer value and then you can compare the old recorded value and the real timer value. This will give you 2ms delay without delayMicroseconds.
The AVR timers can do that very precisely. The TimerOne library may shed some light on the special timer functions. Up to 3 pulse outputs are supported, but only one at a time. More or independent outputs require more timers (Arduino Mega?) or a detached Arduino that does not have to do anything but produce the pulses.