diff --git a/docs/make.jl b/docs/make.jl index 148b4b180..cca2df1cf 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -21,6 +21,6 @@ end deploydocs( repo = "github.com/JuliaControl/ControlSystems.jl.git", latest = "master", - julia = "0.4", + julia = "0.5", deps = myDeps ) diff --git a/src/pid_design.jl b/src/pid_design.jl index 0a1d062c8..1dfb9c1fc 100644 --- a/src/pid_design.jl +++ b/src/pid_design.jl @@ -57,20 +57,11 @@ function pidplots(P::LTISystem, args...; kps=0, kis=0, kds=0, time=false, series pz_ = in(:pz ,args) nichols_ = in(:nichols ,args) - - if nyquist_ - nq = Plots.plot() - end - if gof_ - bd = Plots.subplot(n=4,nc=2) - end - if pz_ - pz = Plots.plot() - end - if controller_ - cplot = plot() - end - + Cs = LTISystem[] + PCs = LTISystem[] + Ts = LTISystem[] + labels = Array{String,2}(1,length(kps)) + colors = Array{Colors.RGB{Float64},2}(1, length(kps)) for (i,kp) = enumerate(kps) ki = kis[i] kd = kds[i] @@ -78,46 +69,23 @@ function pidplots(P::LTISystem, args...; kps=0, kis=0, kds=0, time=false, series C = pid(kp=kp,ki=ki,kd=kd,time=time,series=series) S,D,N,T = gangoffour(P,C) - - if nyquist_ - NQ = nyquist(P*C,ω) - redata = NQ[1][:] - imdata = NQ[2][:] - ylim = (max(-20,minimum(imdata)), min(20,maximum(imdata))) - xlim = (max(-20,minimum(redata)), min(20,maximum(redata))) - Plots.plot!(nq,redata,imdata, ylims=ylim, xlims=xlim, lab=label, c=getColorSys(i)) - end - if gof_ - BD = bode(S,ω) - Plots.plot!(bd[1,1],BD[3][:],BD[1][:], lab=label, c=getColorSys(i)) - BD = bode(D,ω) - Plots.plot!(bd[1,2],BD[3][:],BD[1][:], lab=label, c=getColorSys(i)) - BD = bode(N,ω) - Plots.plot!(bd[2,1],BD[3][:],BD[1][:], lab=label, c=getColorSys(i)) - BD = bode(T,ω) - Plots.plot!(bd[2,2],BD[3][:],BD[1][:], lab=label, c=getColorSys(i)) - end - if pz_ - pzmap!(pz,T) - end - if controller_ - BD = bode(C,ω) - Plots.plot!(cplot,BD[3][:],BD[1][:], lab=label, c=getColorSys(i)) - end + push!(Cs, C) + push!(PCs, P*C) + push!(Ts, T) + labels[i] = label end - nyquist_ && Plots.plot!(nq,legend=true, title="Nyquist curves") + if nyquist_ + nq = nyquistplot(PCs, ω, lab=labels, title="Nyquist curves") + end if gof_ - Plots.plot!(bd[1,1],legend=true, title="S", xscale=:log10, yscale=:log10) - Plots.plot!(bd[1,2],legend=true, title="D", xscale=:log10, yscale=:log10) - Plots.plot!(bd[2,1],legend=true, title="N", xscale=:log10, yscale=:log10) - Plots.plot!(bd[2,2],legend=true, title="T", xscale=:log10, yscale=:log10) + bd = gangoffourplot(P, Cs, ω, lab=labels) end if pz_ - Plots.plot!(pz,title="Pole-zero map") + pzmap(Ts, title="Pole-zero map") end if controller_ - Plots.plot!(cplot,title="Controller bode plot",legend=true, xscale=:log10, yscale=:log10) + cplot = bodeplot(Cs, ω, lab=labels, title="Controller bode plot") end diff --git a/src/plotting.jl b/src/plotting.jl index 3bede2d5c..5945d18c9 100644 --- a/src/plotting.jl +++ b/src/plotting.jl @@ -488,12 +488,11 @@ Gang-of-Four plot. function gangoffourplot(P::Union{Vector, LTISystem}, C::Vector, args...; plotphase=false, kwargs...) S,D,N,T = gangoffour(P,C) fig = bodeplot(LTISystem[[S[i] D[i]; N[i] T[i]] for i = 1:length(C)], args..., plotphase=plotphase; kwargs...) - lower = plotphase ? 3 : 2 - s2i(i,j) = sub2ind((2,(plotphase?4:2)),j,i) - Plots.plot!(fig,title="\$S = 1/(1+PC)\$", subplot=s2i(1,1)) - Plots.plot!(fig,title="\$D = P/(1+PC)\$", subplot=s2i(1,2)) - Plots.plot!(fig,title="\$N = C/(1+PC)\$", subplot=s2i(lower,1)) - Plots.plot!(fig,title="\$T = PC/(1+PC\$)", subplot=s2i(lower,2)) + titles = fill("", 1, plotphase ? 8 : 4) + # Empty titles on phase + titleIdx = plotphase ? [1,2,5,6] : [1,2,3,4] + titles[titleIdx] = ["\$S = 1/(1+PC)\$", "\$D = P/(1+PC)\$", "\$N = C/(1+PC)\$", "\$T = PC/(1+PC\$)"] + Plots.plot!(fig, title = titles) return fig end