From d0fd7833c18fed78c53ae0c085fb5ea8bd0d0a4e Mon Sep 17 00:00:00 2001 From: Jonas Schumacher Date: Wed, 6 Mar 2024 10:13:32 +0100 Subject: [PATCH] WIP --- docs/src/client.md | 8 +++++++- src/client/julia/src/EEPROM.jl | 21 +++++++++++++++++---- src/client/julia/src/RedPitayaDAQServer.jl | 5 +++++ src/client/julia/src/Sequence.jl | 14 +++++++------- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/docs/src/client.md b/docs/src/client.md index b3efcdb5..59ac95a2 100644 --- a/docs/src/client.md +++ b/docs/src/client.md @@ -2,6 +2,7 @@ This page contains documentation of the public API of the Julia client. In the Julia REPL one can access this documentation by entering the help mode with `?` and then writing the function for which the documentation should be shown. + ## Connection and Communication ```@docs RedPitayaDAQServer.RedPitaya @@ -40,6 +41,7 @@ RedPitayaDAQServer.calibADCOffset RedPitayaDAQServer.calibADCOffset! RedPitayaDAQServer.calibADCScale RedPitayaDAQServer.calibADCScale! +RedPitayaDAQServer.updateCalib! ``` ## DAC Configuration ```@docs @@ -65,6 +67,8 @@ RedPitayaDAQServer.calibDACOffset RedPitayaDAQServer.calibDACOffset! RedPitayaDAQServer.calibDACScale RedPitayaDAQServer.calibDACScale! +RedPitayaDAQServer.calibDACUpperLimit! +RedPitayaDAQServer.calibDACLowerLimit! ``` ## Measurement and Transmission ```@docs @@ -77,7 +81,9 @@ RedPitayaDAQServer.SampleChunk RedPitayaDAQServer.PerformanceData RedPitayaDAQServer.readSamples RedPitayaDAQServer.readFrames -RedPitayaDAQServer.convertSamplesToFrames +RedPitayaDAQServer.readPeriods +RedPitayaDAQServer.convertSamplesToFrames(::Union{RedPitaya, RedPitayaCluster, RedPitayaClusterView}, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) +RedPitayaDAQServer.convertSamplesToPeriods!(::Union{RedPitaya, RedPitayaCluster, RedPitayaClusterView}, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any) ``` ## Slow IO ```@autodocs diff --git a/src/client/julia/src/EEPROM.jl b/src/client/julia/src/EEPROM.jl index f6388e46..8ae6ec08 100644 --- a/src/client/julia/src/EEPROM.jl +++ b/src/client/julia/src/EEPROM.jl @@ -14,6 +14,7 @@ function calibDACOffset!(rp::RedPitaya, channel::Integer, val) end scpiCommand(::typeof(calibDACOffset!), channel::Integer, val) = string("RP:CALib:DAC:CH", Int(channel) - 1, ":OFF $(Float32(val))") scpiReturn(::typeof(calibDACOffset!)) = Bool + """ calibDACOffset(rp::RedPitaya, channel::Integer) @@ -34,6 +35,7 @@ function calibDACScale!(rp::RedPitaya, channel::Integer, val) end scpiCommand(::typeof(calibDACScale!), channel::Integer, val) = string("RP:CALib:DAC:CH", Int(channel) - 1, ":SCA $(Float32(val))") scpiReturn(::typeof(calibDACScale!)) = Bool + """ calibDACScale(rp::RedPitaya, channel::Integer) @@ -54,6 +56,7 @@ function calibDACLowerLimit!(rp::RedPitaya, channel::Integer, val) end scpiCommand(::typeof(calibDACLowerLimit!), channel::Integer, val) = string("RP:CALib:DAC:CH", Int(channel) - 1, ":LIM:LOW $(Float32(val))") scpiReturn(::typeof(calibDACLowerLimit!)) = Bool + """ calibDACLowerLimit(rp::RedPitaya, channel::Integer) @@ -74,6 +77,7 @@ function calibDACUpperLimit!(rp::RedPitaya, channel::Integer, val) end scpiCommand(::typeof(calibDACUpperLimit!), channel::Integer, val) = string("RP:CALib:DAC:CH", Int(channel) - 1, ":LIM:UP $(Float32(val))") scpiReturn(::typeof(calibDACUpperLimit!)) = Bool + """ calibDACUpperLimit(rp::RedPitaya, channel::Integer) @@ -103,7 +107,7 @@ end Store calibration ADC offset `val` for given channel into the RedPitayas EEPROM. Absolute value has to be smaller than 1.0 V. -See also [convertSamplesToPeriods](@ref),[convertSamplesToFrames](@ref). +See also [convertSamplesToPeriods!](@ref),[convertSamplesToFrames](@ref). """ function calibADCOffset!(rp::RedPitaya, channel::Integer, val) if abs(val) > 1.0 @@ -114,12 +118,13 @@ function calibADCOffset!(rp::RedPitaya, channel::Integer, val) end scpiCommand(::typeof(calibADCOffset!), channel::Integer, val) = string("RP:CALib:ADC:CH", Int(channel) - 1, ":OFF $(Float32(val))") scpiReturn(::typeof(calibADCOffset!)) = Bool + """ calibADCOffset(rp::RedPitaya, channel::Integer) Retrieve the calibration ADC offset for given channel from the RedPitayas EEPROM. -See also [convertSamplesToPeriods](@ref),[convertSamplesToFrames](@ref). +See also [convertSamplesToPeriods!](@ref),[convertSamplesToFrames](@ref). """ calibADCOffset(rp::RedPitaya, channel::Integer) = query(rp, scpiCommand(calibADCOffset, channel), scpiReturn(calibADCOffset)) scpiCommand(::typeof(calibADCOffset), channel::Integer) = string("RP:CALib:ADC:CH", Int(channel) - 1, ":OFF?") @@ -129,7 +134,7 @@ scpiReturn(::typeof(calibADCOffset)) = Float64 calibADCScale(rp::RedPitaya, channel::Integer) Store calibration ADC scale `val` for given channel into the RedPitayas EEPROM. -See also [convertSamplesToPeriods](@ref),[convertSamplesToFrames](@ref). +See also [convertSamplesToPeriods!](@ref),[convertSamplesToFrames](@ref). """ function calibADCScale!(rp::RedPitaya, channel::Integer, val) rp.calib[1, channel] = Float32(val) @@ -137,12 +142,13 @@ function calibADCScale!(rp::RedPitaya, channel::Integer, val) end scpiCommand(::typeof(calibADCScale!), channel, val) = string("RP:CALib:ADC:CH", Int(channel) - 1, ":SCA $(Float32(val))") scpiReturn(::typeof(calibADCScale!)) = Bool + """ calibADCScale(rp::RedPitaya, channel::Integer) Retrieve the calibration ADC scale for given channel from the RedPitayas EEPROM. -See also [convertSamplesToPeriods](@ref),[convertSamplesToFrames](@ref). +See also [convertSamplesToPeriods!](@ref),[convertSamplesToFrames](@ref). """ calibADCScale(rp::RedPitaya, channel::Integer) = query(rp, scpiCommand(calibADCScale, channel), scpiReturn(calibADCScale)) scpiCommand(::typeof(calibADCScale), channel::Integer) = string("RP:CALib:ADC:CH", Int(channel) - 1, ":SCA?") @@ -152,6 +158,13 @@ calibFlags(rp::RedPitaya) = query(rp, scpiCommand(calibFlags), scpiReturn(calibF scpiCommand(::typeof(calibFlags)) = "RP:CALib:FLAGs" scpiReturn(::typeof(calibFlags)) = Int64 +""" + updateCalib!(rp::RedPitaya) + +Update the cached calibration values. + +See also [calibADCScale](@ref), [calibADCOffset](@ref). +""" function updateCalib!(rp::RedPitaya) rp.calib[1, 1] = calibADCScale(rp, 1) rp.calib[2, 1] = calibADCOffset(rp, 1) diff --git a/src/client/julia/src/RedPitayaDAQServer.jl b/src/client/julia/src/RedPitayaDAQServer.jl index bddf1b3b..c9f9b819 100644 --- a/src/client/julia/src/RedPitayaDAQServer.jl +++ b/src/client/julia/src/RedPitayaDAQServer.jl @@ -76,6 +76,11 @@ function receive(rp::RedPitaya) return readline(rp.socket)[1:end] end +""" + receive(rp::RedPitaya, ch::Channel) + +Receive a String from the RedPitaya command socket. Reads until a whole line is received and puts it in the supplied channel `ch`. +""" function receive(rp::RedPitaya, ch::Channel) put!(ch, receive(rp)) end diff --git a/src/client/julia/src/Sequence.jl b/src/client/julia/src/Sequence.jl index b83a8649..db223879 100644 --- a/src/client/julia/src/Sequence.jl +++ b/src/client/julia/src/Sequence.jl @@ -8,6 +8,7 @@ Return the number of sequence channel. seqChan(rp::RedPitaya) = query(rp, scpiCommand(seqChan), scpiReturn(seqChan)) scpiCommand(::typeof(seqChan)) = "RP:DAC:SEQ:CHan?" scpiReturn(::typeof(seqChan)) = Int64 + """ seqChan!(rp::RedPitaya, value) @@ -29,7 +30,8 @@ Return the number of samples per sequence step. """ samplesPerStep(rp::RedPitaya) = query(rp, scpiCommand(samplesPerStep), scpiReturn(samplesPerStep)) scpiCommand(::typeof(samplesPerStep)) = "RP:DAC:SEQ:SAMP?" -scpiReturn(::typeof(samplesPerStep)) = Int64 +scpiReturn(::typeof(samplesPerStep)) = Int64 + """ samplesPerStep!(rp::RedPitaya, value::Integer) @@ -41,7 +43,6 @@ end scpiCommand(::typeof(samplesPerStep!), value) = string("RP:DAC:SEQ:SAMP ", value) scpiReturn(::typeof(samplesPerStep!)) = Bool - """ stepsPerFrame!(rp::RedPitaya, stepsPerFrame) @@ -65,7 +66,7 @@ scpiCommand(::typeof(setSequence!)) = "RP:DAC:SEQ:SET" scpiReturn(::typeof(setSequence!)) = Bool """ - clearSequences!(rp::RedPitaya) + clearSequence!(rp::RedPitaya) Instruct the server to remove all sequences from its list. Return `true` if the command was successful. """ @@ -92,10 +93,9 @@ length(seq::SequenceLUT) = seq.repetitions * size(seq.values, 2) AbstractSequence Abstract struct of client-side representation of a sequence. - -See [`appendSequence!`](@ref), [`prepareSequence!`](@ref), [`ArbitrarySequence`](@ref). """ abstract type AbstractSequence end + """ SimpleSequence <: AbstractSequence @@ -160,6 +160,7 @@ struct HoldBorderRampingSequence <: RampingSequence enable::Union{Array{Bool}, Nothing} rampUp::SequenceLUT rampDown::SequenceLUT + """ HoldBorderRampingSequence(lut::Array{Float32}, repetitions::Integer, rampingSteps::Integer, enable::Union{Array{Bool}, Nothing}=nothing) @@ -197,6 +198,7 @@ struct ConstantRampingSequence <: RampingSequence lut::SequenceLUT enable::Union{Array{Bool}, Nothing} ramping::SequenceLUT + function ConstantRampingSequence(lut::Array{Float32}, repetitions::Integer, rampingValue::Float32, rampingSteps::Integer, enable::Union{Array{Bool}, Nothing}=nothing) if !isnothing(enable) && size(lut) != size(enable) throw(DimensionMismatch("Size of enable LUT does not match size of value LUT")) @@ -264,8 +266,6 @@ computeRamping(rp::RedPitaya, stepsPerSeq ,rampTime, rampFraction) = computeRamp sequence!(rp::RedPitaya, seq::AbstractSequence) Transmit the client-side representation `seq` to the server and append it to the current list of sequences. Return `true` if the required commands were successful. - -See [`prepareSequence!`](@ref), [`clearSequences!`](@ref). """ function sequence!(rp::RedPitaya, seq::AbstractSequence) result = true