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?
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.
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.
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.