Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
MrFreeze committed Oct 13, 2020
1 parent e2689cf commit 7ca60ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
16 changes: 7 additions & 9 deletions examples/example1.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Basic acquisition example
using AcqSynth
using AcqSynth, PlotlyJS, Statistics
const acq = AcqSynth
using PyPlot

# Let's see if we have a board plugged in
acq.get_num_boards()
Expand Down Expand Up @@ -33,15 +32,14 @@ acq.get_frequency(boardnum)
numblocks = 4 # let's grab a bunch of blocks
acq.setup_acquire(boardnum,numblocks) # acquisition starts here!

# Grab the data from the card
blocks = Vector{UInt8}(numblocks*acq.DIG_BLOCK_SIZE)
acq.get_blocks!(blocks,boardnum,numblocks) # transfer blocks
data = acq.get_samples12(blocks) # interpret blocks as 12-bit samples
data = reshape(data,2,:).'
# Grab the data from the card with get_samples_12 utility function
samples = acq.get_samples_12(boardnum,numblocks) # transfer data as 12-bit samples
data = permutedims(reshape(samples,2,:))

# Plot the stuff
t = (0:size(data,1))/2E9 # time vector, we are sampling at 2GSPS
plot(t[1:500],data[1:500,:]); legend(["AIN0","AIN1"]); grid(true)
t = (1:size(data,1))./2E9 # time vector, we are sampling at 2GSPS
plot([scatter(x=t[1:2000],y=data[1:2000,1],name="AIN0"),
scatter(x=t[1:2000],y=data[1:2000,2],name="AIN1")])

println(" AIN0: $(mean(data[:,1])) ± $(std(data[:,1]))")
println(" AIN1: $(mean(data[:,2])) ± $(std(data[:,2]))")
10 changes: 4 additions & 6 deletions examples/example2.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Example showing the use of waveform triggering
using AcqSynth
using AcqSynth, PlotlyJS
const acq = AcqSynth
using PyPlot

# As in the first example, we setup the board
boardnum = 0
Expand Down Expand Up @@ -30,9 +29,8 @@ numblocks = 2 # let's grab 2 blocks
acq.setup_acquire(boardnum,numblocks)

# Grab the data from the card
blocks = acq.get_blocks(boardnum,numblocks) # transfer blocks
data = acq.get_samples12(blocks) # interpret blocks as 12-bit samples
data = acq.get_samples_12(boardnum,numblocks) # transfer data as 12-bit samples

# Plot the stuff
t = (0:length(data))/4E9 # time vector, we are sampling at 4GSPS
plot(t[1:500],data[1:500]); legend(["AIN0"]); grid(true)
t = (1:length(data))./4E9 # time vector, we are sampling at 4GSPS
plot(scatter(x=t[1:2000],y=data[1:2000],name="AIN0"))
10 changes: 4 additions & 6 deletions examples/example3.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Example showing the use of waveform triggering and segmented capture
using AcqSynth
using AcqSynth, PlotlyJS
const acq = AcqSynth
using PyPlot

# As in the first example, we setup the board
boardnum = 0
Expand Down Expand Up @@ -38,12 +37,11 @@ numblocks = 100 # let's grab 2 blocks
acq.setup_acquire(boardnum,numblocks)

# Grab the data from the card
blocks = acq.get_blocks(boardnum,numblocks) # transfer blocks
data = acq.get_samples12(blocks) # interpret blocks as 12-bit samples
data = acq.get_samples_12(boardnum,numblocks) # transfer data as 12-bit samples

# Plot the stuff
t = (0:length(data))/4E9 # time vector, we are sampling at 4GSPS
plot(t[1:1000],data[1:1000]); legend(["AIN0"]); grid(true)
t = (1:length(data))./4E9 # time vector, we are sampling at 4GSPS
plot(scatter(x=t[1:2000],y=data[1:2000],name="AIN0"))

# # We can configure other things
# # ECL trigger
Expand Down

0 comments on commit 7ca60ae

Please sign in to comment.