I've taken the sample code to plot from an analogue input, and combined it with some code from a live-plotting tutorial, but the graph still doesn't update with new values, and I'm not sure which part of the code is preventing it from doing so (but I think it's to do with the triggering?)
My code is below, any help is appreciated.
Code: Select all
#------PLOT FAST ANALOGUE SIGNAL FT. MATLAB------
#---importing---
import sys
import time
import redpitaya_scpi as scpi
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from matplotlib import style
#---connecting to Pitaya---
rp_s = scpi.scpi('ip_address_here')
rp_s.tx_txt('ACQ:START')
rp_s.tx_txt('ACQ:TRIG NOW')
#---making a figure---
style.use('fivethirtyeight')
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
#---getting the data and updating---
def animate(i):
plt.ion()
while 1:
rp_s.tx_txt('ACQ:TRIG:STAT?') #get trigger status
if rp_s.rx_txt() == 'TD': #TD is disabled
break
rp_s.tx_txt('ACQ:SOUR1:DATA?')
buff_string = rp_s.rx_txt()
buff_string = buff_string.strip('{}\n\r').replace(" ", "").split(',')
buff = map(float, buff_string)
ax1.clear()
ax1.plot(buff)
#---Plotting---
ani = animation.FuncAnimation(fig, animate, interval = 1000)
plt.show()