Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/client/julia/src/Counter.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export counterSamplesPerStep, counterSamplesPerStep!

"""
counterSamplesPerStep(rp::RedPitaya)

Return the number of samples per sequence step.
"""
counterSamplesPerStep(rp::RedPitaya) = query(rp, scpiCommand(counterSamplesPerStep), scpiReturn(counterSamplesPerStep))
scpiCommand(::typeof(counterSamplesPerStep)) = "RP:COU:SAMP?"
scpiReturn(::typeof(counterSamplesPerStep)) = Int64

"""
counterSamplesPerStep!(rp::RedPitaya, value::Integer)

Set the number of samples per sequence step. Return `true` if the command was successful.
"""
function counterSamplesPerStep!(rp::RedPitaya, value::Integer)
return query(rp, scpiCommand(counterSamplesPerStep!, value), scpiReturn(counterSamplesPerStep!))
end
scpiCommand(::typeof(counterSamplesPerStep!), value) = string("RP:COU:SAMP ", value)
scpiReturn(::typeof(counterSamplesPerStep!)) = Bool
1 change: 1 addition & 0 deletions src/client/julia/src/RedPitayaDAQServer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ include("Acquisition.jl")
include("SlowIO.jl")
include("EEPROM.jl")
include("CounterTrigger.jl")
include("Counter.jl")
#include("Utility.jl")

function destroy(rp::RedPitaya)
Expand Down
51 changes: 51 additions & 0 deletions src/examples/julia/instantResetRamping.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using RedPitayaDAQServer
using CairoMakie

# obtain the URL of the RedPitaya
include("config.jl")

rp = RedPitaya(URLs[1])

serverMode!(rp, CONFIGURATION)

dec = 32
modulus = 12480*64
base_frequency = 125000000
samples_per_period = div(modulus, dec)
periods_per_frame = 2

decimation!(rp, dec)
samplesPerPeriod!(rp, samples_per_period)
periodsPerFrame!(rp, periods_per_frame)
triggerMode!(rp, INTERNAL)
frequencyDAC!(rp, 1, 1, base_frequency / modulus)
signalTypeDAC!(rp, 1 , 1, SINE)
amplitudeDAC!(rp, 1, 1, 0.5)
offsetDAC!(rp, 1, 0)
phaseDAC!(rp, 1, 1, 0.0)

# Ramping
# Ramping commands can be specified for each channel individually
enableRamping!(rp, 1, true)
enableRamping!(rp, 2, true)

rampingDAC!(rp, 1, 100/(base_frequency/modulus)) # Ramp for 10 Periods = 5 Frames
rampingDAC!(rp, 2, 100/(base_frequency/modulus)) # Ramp for 10 Periods = 5 Frames


# Start signal generation + acquisition
# Ramp Up starts with trigger start
serverMode!(rp, ACQUISITION)
masterTrigger!(rp, true)

uFirstPeriod = readFrames(rp, 0, 6)

sleep(0.5)
uCurrentPeriod = readFrames(rp, currentFrame(rp), 6)

# Instant Reset
# Now one should connect the instant reset DIO3_P with 3.3 Volt (i.e. set it to high)
# and the result will be a ramp down that can be seen on an oscilloscope
# To run the script again, one needs to run
# masterTrigger!(rp, false)

66 changes: 66 additions & 0 deletions src/examples/julia/multiplexerTest.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using RedPitayaDAQServer
using GLMakie

# obtain the URL of the RedPitaya
include("config.jl")

rp = RedPitaya(URLs[1])
serverMode!(rp, CONFIGURATION)

dec = 8
modulus = 128
base_frequency = 125000000
periods_per_step = 1
samples_per_period = div(modulus, dec)
periods_per_frame = 1000
steps_per_frame = periods_per_frame

time = collect(0:samples_per_period*periods_per_frame-1) ./ (base_frequency/dec)

decimation!(rp, dec)
samplesPerPeriod!(rp, samples_per_period)
periodsPerFrame!(rp, periods_per_frame)

freq = base_frequency / modulus / periods_per_frame

@info "Sampling Frequency: $(base_frequency / dec / 1e6) MS/s"
@info "Multiplexer Frequency: $(base_frequency / modulus / 1e6) MS/s"
@info "Effective Sampling Frequency: $(base_frequency / modulus / 1e3 / 8) kS/s"
@info "Tx Frequency: $freq Hz"

frequencyDAC!(rp,1,1, freq)
signalTypeDAC!(rp, 1 , 1, "SINE")
amplitudeDAC!(rp, 1, 1, 0.99)
phaseDAC!(rp, 1, 1, 0.0 )
frequencyDAC!(rp,2, 1, freq)
signalTypeDAC!(rp, 2 , 1, "SINE")
amplitudeDAC!(rp, 2, 1, 0.99*0)
phaseDAC!(rp, 2, 1, π/2*0 )
triggerMode!(rp, INTERNAL)

# Sequence Configuration
clearSequence!(rp)
stepsPerFrame!(rp, steps_per_frame)
seqChan!(rp, 1)
lut = collect(range(-0.5,0.5,length=steps_per_frame))*0
seq = SimpleSequence(lut, 1)
sequence!(rp, seq)

counterSamplesPerStep!(rp, modulus ÷ (dec) )

serverMode!(rp, ACQUISITION)
masterTrigger!(rp, true)

sleep(0.1)
uCurrentFrame = readFrames(rp, 0, 1)

masterTrigger!(rp, false)
serverMode!(rp, CONFIGURATION)

fig = Figure(size = (1200, 600))
ax = Axis(fig[1, 1], title = "Multiplexer Test", xlabel = "Time [s]")
lines!(ax, time, vec(uCurrentFrame[:,1,:,:]), label = "Rx1")
lines!(ax, time, vec(uCurrentFrame[:,2,:,:]), label = "Rx2")
axislegend(ax)
#save(joinpath(@__DIR__(), "images", "sequence.png"), plot)
fig
8 changes: 5 additions & 3 deletions src/examples/julia/seqRamping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ rp = RedPitaya(URLs[1])
serverMode!(rp, CONFIGURATION)

dec = 64
modulus = 12480
modulus = 124800*4
base_frequency = 125000000
periods_per_step = 5
samples_per_period = div(modulus, dec)
periods_per_frame = 50 # about 0.5 s frame length
frame_period = dec*samples_per_period*periods_per_frame / base_frequency
steps_per_frame = div(50, periods_per_step)
numFr = 8


decimation!(rp, dec)
samplesPerPeriod!(rp, samples_per_period)
Expand All @@ -36,15 +38,15 @@ lut = collect(range(-0.5,0.5,length=steps_per_frame))

# HoldBorderSequence holds the first and last value for the given amount of steps
rampingSteps = steps_per_frame
seq = HoldBorderRampingSequence(lut, 1, rampingSteps)
seq = HoldBorderRampingSequence(lut, numFr, rampingSteps)
sequence!(rp, seq)


serverMode!(rp, ACQUISITION)
masterTrigger!(rp, true)

samples_per_step = (samples_per_period * periods_per_frame)/steps_per_frame
uCurrentFrame = readFrames(rp, 0, 4)
uCurrentFrame = readFrames(rp, 1, numFr+1)

masterTrigger!(rp, false)
serverMode!(rp, CONFIGURATION)
Expand Down
Loading
Loading