Ideal Diode and Ideal Switch instability problem

You can find one (complex) example how to use callbacks in my tutorial: Examples · Tethers.jl

In priciple you just have to define:
@named sys = ODESystem(eqs, t; continuous_events = cb)

and cb must be an array of equations that passes zero when your switches switch…

What I am doing in my code is to create an array of equations, because I have segment elements that can “switch”.

Did you read the documentation: Event Handling and Callback Functions · ModelingToolkit.jl ?