diff --git a/src/client/julia/src/Cluster.jl b/src/client/julia/src/Cluster.jl index 76c2ab87..aa20bc15 100644 --- a/src/client/julia/src/Cluster.jl +++ b/src/client/julia/src/Cluster.jl @@ -121,7 +121,7 @@ for op in [:currentFrame, :currentPeriod, :currentWP, :periodsPerFrame, :samples end for op in [:periodsPerFrame!, :samplesPerPeriod!, :decimation!, :triggerMode!, :samplesPerStep!, - :keepAliveReset!, :serverMode!, + :keepAliveReset!, :serverMode!, :counterTrigger_enabled!, :counterTrigger_presamples!, :counterTrigger_arm!, :counterTrigger_reset!, :counterTrigger_referenceCounter!, :counterTrigger_sourceType!, :counterTrigger_sourceChannel!] diff --git a/src/examples/julia/batch.jl b/src/examples/julia/batch.jl index 7a5d0f34..5687647c 100644 --- a/src/examples/julia/batch.jl +++ b/src/examples/julia/batch.jl @@ -1,5 +1,5 @@ using RedPitayaDAQServer -using PyPlot +using CairoMakie include("config.jl") @@ -58,11 +58,10 @@ uLastPeriod = readFrames(rp, currentFrame(rp), 2) masterTrigger!(rp, false) serverMode!(rp, CONFIGURATION) -figure(1) -clf() # Frame dimensions are [samples, chan, periods, frames] -plot(vec(uFirstPeriod[:,1,:,:])) -plot(vec(uCurrentPeriod[:,1,:,:])) -plot(vec(uLastPeriod[:,1,:,:])) -legend(("first period", "current period", "last period")) -savefig("images/batch.png") \ No newline at end of file +plot = lines(vec(uFirstPeriod[:,1,:,:]), label = "first period") +lines!(plot.axis, vec(uCurrentPeriod[:,1,:,:]), label = "current period") +lines!(plot.axis, vec(uLastPeriod[:,1,:,:]), label = "last period") +axislegend(plot.axis) +save(joinpath(@__DIR__(), "images", "batch.png"), plot) +plot \ No newline at end of file diff --git a/src/examples/julia/cluster.jl b/src/examples/julia/cluster.jl index b4cf5d7e..be554659 100644 --- a/src/examples/julia/cluster.jl +++ b/src/examples/julia/cluster.jl @@ -1,5 +1,5 @@ using RedPitayaDAQServer -using PyPlot +using CairoMakie # obtain the URL of the RedPitaya include("config.jl") @@ -44,14 +44,12 @@ uCurrentPeriod = readFrames(rpc, currentFrame(rpc), 1) masterTrigger!(rpc, false) serverMode!(rpc, CONFIGURATION) -figure(1) -clf() -subplot(2, 1, 1) -plot(vec(uFirstPeriod[:,1,:,:])) -plot(vec(uFirstPeriod[:,3,:,:])) -legend(("Channel 1", "Channel 3")) -subplot(2, 1, 2) -plot(vec(uCurrentPeriod[:,1,:,:])) -plot(vec(uCurrentPeriod[:,3,:,:])) -legend(("Channel 1", "Channel 3")) -savefig("images/cluster.png") \ No newline at end of file +fig = Figure() +plot = lines(fig[1,1], vec(uFirstPeriod[:,1,:,:]), label = "Channel 1") +lines!(plot.axis, vec(uFirstPeriod[:,3,:,:]), label = "Channel 3") +axislegend(plot.axis) +plot = lines(fig[1, 2], vec(uCurrentPeriod[:,1,:,:]), label = "Channel 1") +lines!(plot.axis, vec(uCurrentPeriod[:,3,:,:]), label = "Channel 3") +axislegend(plot.axis) +save(joinpath(@__DIR__(), "images", "cluster.png"), fig) +fig \ No newline at end of file diff --git a/src/examples/julia/clusterView.jl b/src/examples/julia/clusterView.jl index 795d6bd4..e0a52e2f 100644 --- a/src/examples/julia/clusterView.jl +++ b/src/examples/julia/clusterView.jl @@ -1,5 +1,5 @@ using RedPitayaDAQServer -using PyPlot +using CairoMakie include("config.jl") @@ -46,12 +46,7 @@ sleep(1.0) # ClusterView only reads from selected RedPitayas uCurrentPeriod = readData(rpcv, currentFrame(rpc), 1) -fig = figure(1) -clf() -subplot(1,2,1) -plot(vec(uCurrentPeriod[:,1,:,:])) +fig = Figure() # Channels from result can be mapped to channels in the cluster -PyPlot.title("Cluster channel $(viewToClusterChannel(rpcv,1))") -subplot(1,2,2) -plot(vec(uCurrentPeriod[:,3,:,:])) -PyPlot.title("Cluster channel $(viewToClusterChannel(rpcv,3))") \ No newline at end of file +lines(fig[1, 1], vec(uCurrentPeriod[:,1,:,:]), axis = (title = "Cluster channel $(viewToClusterChannel(rpcv,1))",)) +lines(fig[1, 2], vec(uCurrentPeriod[:,3,:,:]), axis = (title = "Cluster channel $(viewToClusterChannel(rpcv,3))",)) \ No newline at end of file diff --git a/src/examples/julia/config.jl b/src/examples/julia/config.jl index 8d5f511a..6e2da7e9 100644 --- a/src/examples/julia/config.jl +++ b/src/examples/julia/config.jl @@ -1,5 +1,4 @@ # URLs= ["rp-f08ccb.local", "rp-f08caa.local"] -URLs= ["192.168.2.22"]#, "192.168.2.17"] -URLs= ["192.168.178.65"]#, "192.168.178.95"] - +URLs= ["192.168.1.100"]#, "192.168.2.17"] +# URLs= ["192.168.178.65"]#, "192.168.178.95"] mkpath("images") \ No newline at end of file diff --git a/src/examples/julia/counterTrigger.jl b/src/examples/julia/counterTrigger.jl index f68c57b8..09b5dde9 100644 --- a/src/examples/julia/counterTrigger.jl +++ b/src/examples/julia/counterTrigger.jl @@ -1,5 +1,5 @@ using RedPitayaDAQServer -using PyPlot +using CairoMakie using Statistics using Base.Threads @@ -108,15 +108,12 @@ counterTrigger_enabled!(rp, false) close(t) -figure(1) -clf() -# Frame dimensions are [samples, chan, periods, frames] -plot(vec(uFirstPeriod[:,1,:,:])) -plot(vec(uCurrentPeriod[:,1,:,:])) -plot(vec(uLastPeriod[:,1,:,:])) -legend(("first period", "current period", "last period")) -savefig("images/counterTrigger.png") - +plot = lines(vec(uFirstPeriod[:,1,:,:]), label = "first period") +lines!(plot.axis, vec(uCurrentPeriod[:,1,:,:]), label = "current period") +lines!(plot.axis, vec(uLastPeriod[:,1,:,:]), label = "last period") +axislegend(plot.axis) +save(joinpath(@__DIR__(), "images", "counterTrigger.png"), plot) +plot #== 0: enable 1: trigger_arm diff --git a/src/examples/julia/counterTriggerCluster.jl b/src/examples/julia/counterTriggerCluster.jl index f2659855..2f835404 100644 --- a/src/examples/julia/counterTriggerCluster.jl +++ b/src/examples/julia/counterTriggerCluster.jl @@ -1,5 +1,5 @@ using RedPitayaDAQServer -using PyPlot +using CairoMakie using Statistics using Base.Threads @@ -108,15 +108,14 @@ counterTrigger_enabled!(rpc, false) close(t) -figure(1) -clf() chan = 3 # Frame dimensions are [samples, chan, periods, frames] -plot(vec(uFirstPeriod[:,chan,:,:])) -plot(vec(uCurrentPeriod[:,chan,:,:])) -plot(vec(uLastPeriod[:,chan,:,:])) -legend(("first period", "current period", "last period")) -savefig("images/counterTrigger.png") +plot = lines(vec(uFirstPeriod[:,chan,:,:]), label = "first period") +lines!(plot.axis, vec(uCurrentPeriod[:,chan,:,:]), label = "current period") +lines!(plot.axis, vec(uLastPeriod[:,chan,:,:]), label = "last period") +axislegend(plot.axis) +save(joinpath(@__DIR__(), "images", "counterTriggerCluster.png"), plot) +plot #== 0: enable diff --git a/src/examples/julia/delay.jl b/src/examples/julia/delay.jl index 909afad2..8ac8d23d 100644 --- a/src/examples/julia/delay.jl +++ b/src/examples/julia/delay.jl @@ -1,5 +1,5 @@ using RedPitayaDAQServer -using PyPlot +using CairoMakie # obtain the URL of the RedPitaya include("config.jl") @@ -44,10 +44,9 @@ uUncorrected = readSamples(rp, 0, 45, correct_filter_delay = false) masterTrigger!(rp, false) serverMode!(rp, CONFIGURATION) -figure(1) -clf() # Sample dimensions are [chan, samples] -plot(vec(uCorrected[1, :])) -plot(vec(uUncorrected[1, :])) -legend(("first period", "Corrected", "Uncorrected")) -savefig("images/delay.png") \ No newline at end of file +plot = lines(vec(uCorrected[1, :]), label = "Corrected") +lines!(plot.axis, vec(uUncorrected[1, :]), label = "Uncorrected") +axislegend(plot.axis) +save(joinpath(@__DIR__(), "images", "delay.png"), plot) +plot \ No newline at end of file diff --git a/src/examples/julia/producerConsumer.jl b/src/examples/julia/producerConsumer.jl index c8ddcf77..6987bd28 100644 --- a/src/examples/julia/producerConsumer.jl +++ b/src/examples/julia/producerConsumer.jl @@ -1,6 +1,6 @@ using RedPitayaDAQServer using ThreadPools -using PyPlot +using CairoMakie include("config.jl") @@ -141,9 +141,7 @@ else # Wait for the consumer since otherwise Julia just terminates in non-interactive mode. wait(consumer) - figure(1) - clf() # Frame dimensions are [samples, chan, periods, frames] - plot(vec(buffer[:, 1, :, :])) - savefig("images/producerConsumer.png") + plot = lines(vec(buffer[:, 1, :, :])) + save(joinpath(@__DIR__(), "images", "producerConsumer.png"), plot) end \ No newline at end of file diff --git a/src/examples/julia/ramping.jl b/src/examples/julia/ramping.jl index c1c6105b..f4ad9f8a 100644 --- a/src/examples/julia/ramping.jl +++ b/src/examples/julia/ramping.jl @@ -1,5 +1,5 @@ using RedPitayaDAQServer -using PyPlot +using CairoMakie # obtain the URL of the RedPitaya include("config.jl") @@ -37,9 +37,8 @@ masterTrigger!(rp, true) uFirstPeriod = readFrames(rp, 0, 6) - -fr = currentFrame(rp) -uCurrentPeriod = readFrames(rp, fr, 6) +sleep(0.5) +uCurrentPeriod = readFrames(rp, currentFrame(rp), 6) # Start ramp down asynchronously # Note that we might not see the actual ramping in this example, see seqRamping.jl for that @@ -52,11 +51,10 @@ masterTrigger!(rp, false) serverMode!(rp, CONFIGURATION) enableRamping!(rp, 1, false) -figure(1) -clf() # Frame dimensions are [samples, chan, periods, frames] -plot(vec(uCurrentPeriod[:,1,:,:])) -plot(vec(uFirstPeriod[:,1,:,:])) -plot(vec(uLastPeriod[:,1,:,:])) -legend(("regular", "start", "end")) -savefig("images/asyncRamping.png") \ No newline at end of file +plot = lines(vec(uCurrentPeriod[:,1,:,:]), label = "regular") +lines!(plot.axis, vec(uFirstPeriod[:,1,:,:]), label = "start") +lines!(plot.axis, vec(uLastPeriod[:,1,:,:]), label = "end") +axislegend(plot.axis) +save(joinpath(@__DIR__(), "images", "asyncRamping.png"), plot) +plot \ No newline at end of file diff --git a/src/examples/julia/seqRamping.jl b/src/examples/julia/seqRamping.jl index 17017cc2..cbf90b5c 100644 --- a/src/examples/julia/seqRamping.jl +++ b/src/examples/julia/seqRamping.jl @@ -1,5 +1,5 @@ using RedPitayaDAQServer -using PyPlot +using CairoMakie # obtain the URL of the RedPitaya include("config.jl") @@ -46,13 +46,12 @@ masterTrigger!(rp, true) samples_per_step = (samples_per_period * periods_per_frame)/steps_per_frame uCurrentFrame = readFrames(rp, 0, 4) -fig = figure(1) -clf() -plot(vec(uCurrentFrame[:,1,:,1:4])) - masterTrigger!(rp, false) serverMode!(rp, CONFIGURATION) enableRamping!(rp, 1, false) clearSequence!(rp) -savefig("images/seqRamping.png") \ No newline at end of file +plot = lines(vec(uCurrentFrame[:,1,:,1:4])) + +save(joinpath(@__DIR__(), "images", "seqRamping.png"), plot) +plot \ No newline at end of file diff --git a/src/examples/julia/sequence.jl b/src/examples/julia/sequence.jl index 331eb291..9cccf903 100644 --- a/src/examples/julia/sequence.jl +++ b/src/examples/julia/sequence.jl @@ -1,5 +1,5 @@ using RedPitayaDAQServer -using PyPlot +using CairoMakie # obtain the URL of the RedPitaya include("config.jl") @@ -42,13 +42,11 @@ samples_per_step = (samples_per_period * periods_per_frame)/steps_per_frame timing = seqTiming(seq) uCurrentFrame = readFrames(rp, div(timing.start*samples_per_step, samples_per_period * periods_per_frame), 2) -fig = figure(1) -clf() -plot(vec(uCurrentFrame[:,1,:,:])) -plot(vec(uCurrentFrame[:,2,:,:])) -legend(("Rx1", "Rx2")) - masterTrigger!(rp, false) serverMode!(rp, CONFIGURATION) -savefig("images/sequence.png") \ No newline at end of file +plot = lines(vec(uCurrentFrame[:,1,:,:]), label = "Rx1") +lines!(plot.axis, vec(uCurrentFrame[:,2,:,:]), label = "Rx2") +axislegend(plot.axis) +save(joinpath(@__DIR__(), "images", "sequence.png"), plot) +plot \ No newline at end of file diff --git a/src/examples/julia/sequenceMultiChannelWithOffsetAndEnable.jl b/src/examples/julia/sequenceMultiChannelWithOffsetAndEnable.jl index 3d4c0431..9b1bceba 100644 --- a/src/examples/julia/sequenceMultiChannelWithOffsetAndEnable.jl +++ b/src/examples/julia/sequenceMultiChannelWithOffsetAndEnable.jl @@ -1,5 +1,5 @@ using RedPitayaDAQServer -using PyPlot +using CairoMakie # obtain the URL of the RedPitaya include("config.jl") @@ -29,7 +29,7 @@ phaseDAC!(rp, 1, 1, 0.0) amplitudeDAC!(rp, 1, 1, 0.1) # No waveform on second channel -amplitudeDAC!(rp, 2, 1, 0.0) +amplitudeDAC!(rp, 2, 1, 0.2 ) clearSequence!(rp) @@ -42,8 +42,7 @@ lut = collect(cat(lutA,lutB*0.1,dims=2)') # Alternate in disabling the DAC output of the channels from step to step lutEnableDACA = ones(Bool, steps_per_frame) lutEnableDACA[1:2:end] .= false -lutEnableDACB = ones(Bool, steps_per_frame) -lutEnableDACB[2:2:end] .= false +lutEnableDACB = map(!, lutEnableDACA) enableLUT = collect( cat(lutEnableDACA,lutEnableDACB,dims=2)' ) seq = SimpleSequence(lut, 1, enableLUT) @@ -57,11 +56,9 @@ uCurrentPeriod = readFrames(rp, 0, 1) masterTrigger!(rp, false) serverMode!(rp, CONFIGURATION) -fig = figure(1) -clf() -plot(vec(uCurrentPeriod[:,1,:,:])) -plot(vec(uCurrentPeriod[:,2,:,:])) -legend(("Rx1", "Rx2")) +plot = lines(vec(uCurrentPeriod[:,1,:,:]), label = "Rx1") +lines!(plot.axis, vec(uCurrentPeriod[:,2,:,:]), label = "Rx2") +axislegend(plot.axis) +save(joinpath(@__DIR__(), "images", "sequenceMultiChannelWithOffsetAndEnable.png"), plot) +plot - -savefig("images/sequenceMultiChannelWithOffsetAndEnable.png") \ No newline at end of file diff --git a/src/examples/julia/simple.jl b/src/examples/julia/simple.jl index 82bcdd28..fd4e1981 100644 --- a/src/examples/julia/simple.jl +++ b/src/examples/julia/simple.jl @@ -1,5 +1,5 @@ using RedPitayaDAQServer -using PyPlot +using CairoMakie # obtain the URL of the RedPitaya include("config.jl") @@ -52,11 +52,10 @@ uLastPeriod = readFrames(rp, currentFrame(rp), 1) masterTrigger!(rp, false) serverMode!(rp, CONFIGURATION) -figure(1) -clf() # Frame dimensions are [samples, chan, periods, frames] -plot(vec(uFirstPeriod[:,1,:,:])) -plot(vec(uCurrentPeriod[:,1,:,:])) -plot(vec(uLastPeriod[:,1,:,:])) -legend(("first period", "current period", "last period")) -savefig("images/simple.png") \ No newline at end of file +plot = lines(vec(uFirstPeriod[:,1,:,:]), label = "first period") +lines!(plot.axis, vec(uCurrentPeriod[:,1,:,:]), label = "current period") +lines!(plot.axis, vec(uLastPeriod[:,1,:,:]), label = "last period") +axislegend(plot.axis) +save(joinpath(@__DIR__(), "images", "simple.png"), plot) +plot \ No newline at end of file diff --git a/src/examples/julia/waveforms.jl b/src/examples/julia/waveforms.jl index b5020efa..f979c29b 100644 --- a/src/examples/julia/waveforms.jl +++ b/src/examples/julia/waveforms.jl @@ -1,5 +1,5 @@ using RedPitayaDAQServer -using PyPlot +using CairoMakie # obtain the URL of the RedPitaya include("config.jl") @@ -27,10 +27,8 @@ phaseDAC!(rp, 1, 1, 0.0 ) signals = zeros(4*N) -figure(1) -clf() +fig = Figure() -color = ["g", "b", "orange", "k"] for (i,name) in enumerate(["SINE", "TRIANGLE", "SAWTOOTH"]) # Set different waveforms signalTypeDAC!(rp, 1, 1, name) @@ -39,11 +37,9 @@ for (i,name) in enumerate(["SINE", "TRIANGLE", "SAWTOOTH"]) masterTrigger!(rp, true) local fr = 1 local uFirstPeriod = readFrames(rp, fr, 1) - subplot(2,2,i) masterTrigger!(rp, false) serverMode!(rp, CONFIGURATION) - plot(vec(uFirstPeriod[:,1,:,:]),color[i]) - title(name) + lines(fig[mod1(i, 2), div(i -1, 2) + 1], vec(uFirstPeriod[:,1,:,:]), axis = (title = name,)) end # Fourth component of each channel is used for arbitrary waveforms @@ -68,11 +64,9 @@ masterTrigger!(rp, false) masterTrigger!(rp, true) fr = 1 uFirstPeriod = readFrames(rp, fr, 1) -subplot(2,2,4) masterTrigger!(rp, false) serverMode!(rp, CONFIGURATION) -plot(vec(uFirstPeriod[:,1,:,:]),"k") -title("Arbitrary") +lines(fig[2, 2], vec(uFirstPeriod[:,1,:,:]), axis = (title = "ARBITRARY",)) -subplots_adjust(left=0.08, bottom=0.05, right=0.98, top=0.95, wspace=0.3, hspace=0.35) -savefig("images/waveforms.png") +save(joinpath(@__DIR__(), "images", "waveforms.png"), fig) +fig \ No newline at end of file diff --git a/src/lib/rp-daq-lib.c b/src/lib/rp-daq-lib.c index 821cb013..5393cac2 100644 --- a/src/lib/rp-daq-lib.c +++ b/src/lib/rp-daq-lib.c @@ -685,6 +685,13 @@ int getRampDownDAC(int channel, int index) { return (*((int16_t *)(pdm_cfg + 2*(2+4*index))) >> bitpos) & 1; } +int setRampDownDACAll(int8_t value, int channel) { + for(int i=0; i= 2) { return -1; diff --git a/src/lib/rp-daq-lib.h b/src/lib/rp-daq-lib.h index e608591b..74628671 100644 --- a/src/lib/rp-daq-lib.h +++ b/src/lib/rp-daq-lib.h @@ -147,6 +147,7 @@ extern int setResyncDACAll(int8_t, int); extern int setResyncDAC(int8_t, int, int); //extern int setResetDAC(int8_t, int); extern int setRampDownDAC(int8_t, int, int); +extern int setRampDownDACAll(int8_t, int); extern int getRampDownDAC(int, int); // Counter trigger diff --git a/src/server/control.c b/src/server/control.c index d0e86c8c..4b95eca7 100644 --- a/src/server/control.c +++ b/src/server/control.c @@ -102,11 +102,13 @@ void clearSequence() { setPDMAllValuesVolt(0.0, 2); setPDMAllValuesVolt(0.0, 3); - for(int d=0; d<6; d++) { + for(int d=0; d<6; d++) { setEnableDACAll(1,d); - setResyncDACAll(0,d); - } - + setResyncDACAll(0,d); + } + for(int d=0; d<2; d++) { + setRampDownDACAll(false,d); + } } bool isSequenceConfigurable() {