# Circuit measured using a sampling filter

**URL:** https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687
**Category:** Modelling & Simulations
**Tags:** question
**Created:** [April 11, 2026, 11:09pm UTC](https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687 "2026-04-11T23:09:09Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![josujugo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josujugo/32/216643_2.png) [@josujugo](https://discourse.julialang.org/u/josujugo)
#### Post date: [April 11, 2026, 11:09pm UTC](https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687/1 "2026-04-11T23:09:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![technocrat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/technocrat/32/220947_2.png) [@technocrat](https://discourse.julialang.org/u/technocrat)
#### Post date: [April 11, 2026, 11:52pm UTC](https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687/2 "2026-04-11T23:52:48Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)
#### Post date: [April 12, 2026, 12:43am UTC](https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687/3 "2026-04-12T00:43:41Z")

</div>

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](https://digilent.com/shop/mcc-172-iepe-measurement-daq-hat-for-raspberry-pi/). 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](https://digilent.com/shop/products/data-acquisition-daq/). This unit does not have the anti-alias filters. This Julia package is available [here](https://github.com/Spectrum-Tec/MccDaqHats.jl).

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

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [April 12, 2026, 3:08am UTC](https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687/4 "2026-04-12T03:08:06Z")

</div>

> [@josujugo](#):
>
> But for a discrete version, I have tried to mix different ideas without result. Is my idea possible? Is any example of something similar?

Did you try [Home · DSP.jl](https://docs.juliadsp.org/dev/) or look at [GitHub - OpenSourceAWE/DiscreteFilters.jl: Classical digital filters in Julia · GitHub](https://github.com/OpenSourceAWE/DiscreteFilters.jl) ?

---

<div class="post-metadata">

### Author: ![josujugo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josujugo/32/216643_2.png) [@josujugo](https://discourse.julialang.org/u/josujugo)
#### Post date: [April 12, 2026, 9:19am UTC](https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687/5 "2026-04-12T09:19:25Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![josujugo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josujugo/32/216643_2.png) [@josujugo](https://discourse.julialang.org/u/josujugo)
#### Post date: [April 12, 2026, 9:20am UTC](https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687/6 "2026-04-12T09:20:37Z")

</div>

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

---

<div class="post-metadata">

### Author: ![josujugo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josujugo/32/216643_2.png) [@josujugo](https://discourse.julialang.org/u/josujugo)
#### Post date: [April 12, 2026, 9:21am UTC](https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687/7 "2026-04-12T09:21:55Z")

</div>

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

---

<div class="post-metadata">

### Author: ![josujugo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josujugo/32/216643_2.png) [@josujugo](https://discourse.julialang.org/u/josujugo)
#### Post date: [April 12, 2026, 10:19am UTC](https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687/8 "2026-04-12T10:19:08Z")

</div>

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/](https://help.juliahub.com/juliasimcompiler/stable/)

---

<div class="post-metadata">

### Author: ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)
#### Post date: [April 12, 2026, 1:20pm UTC](https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687/9 "2026-04-12T13:20:55Z")

</div>

> [@josujugo](#):
>
> Finally, I think that the reason of my failures is that my idea is not supported.

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](https://docs.sciml.ai/DiffEqDocs/stable/basics/integrator/).

Nice example: KiteModels.jl

A nice controller is included: [KiteModels.jl/examples\_3d/parking\_controller.jl at main · OpenSourceAWE/KiteModels.jl · GitHub](https://github.com/OpenSourceAWE/KiteModels.jl/blob/main/examples_3d/parking_controller.jl)

---

<div class="post-metadata">

### Author: ![josujugo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josujugo/32/216643_2.png) [@josujugo](https://discourse.julialang.org/u/josujugo)
#### Post date: [April 12, 2026, 2:02pm UTC](https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687/10 "2026-04-12T14:02:34Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Synthia\_Casper](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@Synthia\_Casper](https://discourse.julialang.org/u/Synthia_Casper)
#### Post date: [April 20, 2026, 10:14am UTC](https://discourse.julialang.org/t/circuit-measured-using-a-sampling-filter/136687/11 "2026-04-20T10:14:42Z")

</div>

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.
