Help with a variation of the electrical components' example

In your first example, there is no need to register the driving function, remove this line:

@register sine(t,f::Number)

Registering a function indicates that the function should not be traced, so it is treated as opaque by all symbolic operations. When the derivative of this function is needed, it cannot be computed.

I’m not sure why adding the resistor fixes the second example, but I think the problem is that the never hits a change in the PWM voltage and steps right past all the edges. Try setting dtmax or tsteps Common Solver Options · DifferentialEquations.jl