New feature: high speed continuous recording

Discussions about active development projects
Post Reply
keramatnejad
Posts: 3
Joined: Tue Jul 10, 2018 7:47 pm

Re: New feature: high speed continuous recording

Post by keramatnejad » Thu Dec 20, 2018 9:00 pm

Hi,

My issue may sound primitive and unrelated to this discussion. However, since it is sort of a data acquisition issue that I'm dealing with, I hope someone would help me fix it.

I am using the current code to perform: 1- real-time plotting and 2- real-time data recording vs time of the "iq2" and "iq2_2" outputs of the iqs module. Although the animation seems to be wokring, the t (x axis) is not updates as the time goes by. In addition, I am not exactly sure how to save the data for these two curves. I am planning to run this code for at least 30-120 seconds and continuously save the iq2 and iq2_2 in a CSV file. I would appreciate it if anyone could share some insight on this. Here is the code:

from matplotlib import pyplot as plt
from matplotlib import animation
from pyrpl import Pyrpl
import csv
import os
import math
import numpy as np

duration = 20

#p = Pyrpl(hostname="169.254.99.100")
p = Pyrpl('LIA')

r = p.rp

##Redpitaya (RP) Oscilloscope Settings

s = r.scope
s.input1 = "iq2" #Output X from the RP Locked-in Amplifier
s.input2 = "iq2_2" #Output Y from the RP Locked-in Amplifier

s.trigger_source = 'immediately'

s.threshold = 0

s.hysteresis = 0.01

s.trigger_delay = 0

s.decimation = 65536

##Locked-in demodulation settings:
iq_I = r.iq2
iq_I.setup(frequency=500, bandwidth=[0,1.186], gain=0.0, phase=0, acbandwidth=0, amplitude=0.2, input='in1', output_direct='out1', output_signal='quadrature', quadrature_factor=1)

print("Available decimation factors:", s.decimations)

R = np.zeros((1907,))
ch1 = np.zeros((16384,))
ch2 = np.zeros((16384,))

ch1 = s._data_ch1
ch2 = s._data_ch2

##Real-time figure plot

fig, ax = plt.subplots()
signal_axis = ax.twinx()
signal_axis.set_ylabel('X (Volt)', color=(31 / 255., 119 / 255., 180 / 255.), size=20)
ax.set_ylabel('Y (Volt)', color=(255 / 255., 127 / 255., 14 / 255.), size=20)
ax.set_xlabel('Time (s)', size=20)
ax.set_ylim(-1.0, 1.0)
signal_axis.set_ylim(-0.2, 0.2)
ch1, = ax.plot([], [], color=(255 / 255., 127 / 255., 14 / 255.))
ch2, = signal_axis.plot([], [], color=(31 / 255., 119 / 255., 180 / 255.))

def animate(i):
ax.set_xlim(0, s.times[16383])
ch1.set_data(s.times[0:16384], s._data_ch1[0:16384])
ch2.set_data(s.times[0:16384], s._data_ch2[0:16384])

ani = animation.FuncAnimation(fig, animate, interval=50)
plt.show()

##Saving the data

#tempDir=os.getcwd()
#csvDirectory = 'C:\Users\kkera\Desktop\Python data'
#os.chdir(csvDirectory)
#with open('iq-R5.csv', 'wb') as csvfile:
# spamwriter = csv.writer(csvfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL)
# spamwriter.writerow(["t", "iq2", "iq2_2"])
# spamwriter.writerow(s.times)
# spamwriter.writerow(s._data_ch1)
# spamwriter.writerow(s._data_ch2)


#os.chdir(tempDir)

Post Reply
jadalnie klasyczne ekskluzywne meble wypoczynkowe do salonu ekskluzywne meble tapicerowane ekskluzywne meble do sypialni ekskluzywne meble włoskie

Who is online

Users browsing this forum: No registered users and 1 guest