Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Delay component? #24

Closed
hzgzh opened this issue May 15, 2020 · 3 comments
Closed

add Delay component? #24

hzgzh opened this issue May 15, 2020 · 3 comments

Comments

@hzgzh
Copy link

hzgzh commented May 15, 2020

struct Delay{OF, IB, OB, TR, HS, CB, DL,IP} <: AbstractStaticSystem
    @generic_static_system_fields
    τ::KD
    interp::IP
    intial_value:IV
    function Delay(τ=1,intial_value=0; callbacks=nothing, name=Symbol())
                
        input = Inport() 
        output = Outport()
        trigger = Inpin() 
        handshake = Outpin{Bool}()
        function outputfunc(uu, tt)
            update_interpolator(interp,uu,tt)
            if tt<τ
                return intial_value
            end
            return interpolate(interp,tt-τ)
        end
        new{typeof(outputfunc), typeof(input), typeof(output), typeof(trigger), typeof(handshake), typeof(callbacks), typeof(kd), typeof(t), typeof(u)}(outputfunc, input, output, trigger, handshake, callbacks, name, uuid4(), kd, t, u)
    end
end

I think the Delay component like this,but don't know how to make it work

@zekeriyasari
Copy link
Owner

zekeriyasari commented May 15, 2020

To delay signals, you can use Memory component. See an example from the example directory. If you run the script, you get the following plots.

memory

In the plots, just the first 5 samples are plotted. Note that the output of :gen is delayed for one step size (1 second). You can give get any amount of delay by using the Memory block properly.

@hzgzh
Copy link
Author

hzgzh commented May 17, 2020

Thank very much,another question is if I want do some model parameter estimate using Optim.jl,because in staticsytem.jl the type like "Gain","Memory"," Differentiator" is immutable, so the component parameter "Gain.gain","Memory.delay","Differentiator.kd" can't change,can the type change to mutable

@zekeriyasari
Copy link
Owner

In the context of Jusdl, StaticSystems like those need not be mutable. But, I will consider making them mutable after carrying out some benchmarks.

@hzgzh hzgzh closed this as completed May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants