Hi guys,
I'm trying to plot a real time signal with python and PyQtGraph has
improved the speed a lot, but still with some delay. The data comes from a
DLL and it's store in a NumPy Vector.
I wan't to plot this buffer every 0.1s with 100 points(the signal has 1kHz
sampling rate). At the beginning this seems to work but after few seconds
starts
to get behind the plot.
This is part of my code:
def coleta():
global cnt
global t
nsample = c_ulong(int(0.1 * sampleRate.value))
status = emgSampleNSeconds(handle.value, 50)
if status == 0:
print("Inicia a amostragem")
else:
print("Não foi possível iniciar a amostragem")
emgIsSampling(handle.value, byref(isSampling))
canal = c_ulong(0)
emgbuffer = (c_double * nsample.value)()
emgDataPlot = np.zeros(10000, dtype=float)
curve1 = p1.plot(emgDataPlot, pen='r')
sleepVar = 0.1
pltStart = pg.ptime.time()
while isSampling:
time.sleep(sleepVar)
emgGetRealUnitDataBlock(handle.value, canal.value, emgbuffer,
byref(nsample))
now = time.time()
for value in emgbuffer:
emgDataPlot = np.append(emgDataPlot, value)
if len(emgDataPlot) > sampleRate.value * 10:
emgDataPlot = np.delete(emgDataPlot, 0)
if t == 0:
p1.enableAutoRange('xy', False) ## stop auto-scaling after the
first data set is plotted
t += 1
curve1.setData(emgDataPlot)
app.processEvents()
#print(t)
emgIsSampling(handle.value, byref(isSampling))
#p1.enableAutoRange(True, True)
print(pltStart - pg.ptime.time())
What I need to do?
Thanks.
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/f3c66f2c-5c13-4b2b-b442-f55aaeda21c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.