Circuit measured using a sampling filter

Hi, I am trying to implement a digital filter for measuring (samplling and filtering) the voltage of a circuit. The RLC circuit is defined by an ODE. I’ve come up with a simulation using a callback for sampling, but the filter is continuous (modeled by a ODE again). I am using the ModelingToolkit approach (last version for Julia and the ModelingToolkit itself).

But for a discrete version, I have tried to mix different ideas without result. Is my idea possible? Is any example of something similar?

Thanks

You’re likely to find a broader pool of answers with a minimal working example and reframing the question to be more general, such as “Callback sampling of discrete data possible?” That should draw people who may not be EEs but could have useful ideas.

You mention both measuring the voltage and then filtering it. I have implemented a Julia version of measuring a voltage using the Raspberry PI with the MCC172. This unit allows you to set the sampling rate and it has built-in anti-alias filters typical for instruments made for measuring vibration. This will allow you to set a fast enough sampling rate and use your own digital filter. It works well for what it was designed to do. There is a start in this package for the more cost effective MCC128. This unit does not have the anti-alias filters. This Julia package is available here.

If your question is more related to how to do the filtering, I don’t have experience with that.

Did you try Home · DSP.jl or look at GitHub - OpenSourceAWE/DiscreteFilters.jl: Classical digital filters in Julia · GitHub ?

Thank you, you are rigth, I will try to create an example for the problem. Now, my tests are a mess, and I need some time to reordered and send a more concrete anwer with code.

Thank you. I will analize the code to see if this way is valid for me too.

Thank you. I will analize those examples and see if any of them are valid for me too.

Finally, I think that the reason of my failures is that my idea is not supported. Seems that JuliaSim is needed. This is the error that I have obtained finally.

ERROR: LoadError: HybridSystemNotSupportedException: Hybrid continuous-discrete systems are currently not supported with the standard MTK compiler. This system requires JuliaSimCompiler.jl, see https://help.juliahub.com/juliasimcompiler/stable/

I don’t know what your idea is, but you can model hybrid systems perfectly using standard MTK. You just need to implement the controller in Julia and the continuous model in MTK.

And use the integrator interface.

Nice example: KiteModels.jl

A nice controller is included: KiteModels.jl/examples_3d/parking_controller.jl at main · OpenSourceAWE/KiteModels.jl · GitHub

Thank you very much. I will try this approach. I am quite new in Julia, and I don’t known well the boundaries.

I’ve been looking at similar circuit modeling in Julia and your approach to the measurement logic is much cleaner than what I was trying.