I am using Piasereal module with Arduino Uno. The partners have been able to generate the plot of time in the ECG price (volts) with the help of Stackworflow users. However, there is a problem.
When I start the serial port by adding Arduino to my computer (via USB), data starts flowing automatically. Now when I run my Python file, it reads the current value coming from the serial port and then starts again at zero (which I want to do). I can ignore those primary values, flush or whatever is appropriate, you can find video clips of Arduino sketch, Python code and what is happening below:
Arduino Sketch:
Add # & lt; EHealth.h & gt; Unsigned long time; // Setup retin runs once when you press reset: zero setup () {Serial.begin (9600); } // loop routine is always eliminated again: zero loop () {float ECG = eHealth.getECG (); Time = mills (); Serial.print (time); Serial. Print (""); Serial. Print (ECG, 3); Serial.println (""); Delay (25); // Waiting for 50 milliseconds}
Python: Import the mfig as GUI PyQt4.QtGui as matplotlib.backends.backend_qt4agg Import FigureCanvasQTAgg import from matplotlib.figure Importing import time as import code imported into PyQt4.QtCore Core code serial.Serial ('/ dev / tty.usbmodem1411', 9600) refreshMillis = 25n = 200xs = collections.deque (maxlen = N) YS = archive .deque (maxlen = n) application = gui.QApplication ([]) fig = mfig.figure () canvas = figureCanvasQTAgg (image) ax = fig.add_subplot (111) ax.set_ylim ([0,5] ]) Line2D, = ax.plot (xs, ys) canvas.show () def proce Ss_line (): line = ser.readline () data = map (name, line.split ("")) xs.append (data [0]) YS Attached (data [1]) line2D.set_data (xs, ys) print data xmin, xmax = min (xs), max (xs) if xmin == xmax: ax.set_xlim ([xmin, xmin + 1]) and: Ax.set_xlim ([xmin, xmax]) canvas.draw () timer = core. QTimer () timer.timeout.connect (process_line) timer.start (refreshmilis) a.p.xac_ () ser.flush () ser.close ()
video clip:
As you can when I see the Python file shown above, the first few values that are in the left column and the current value from the voltage value port on the right column, then they can be reset And this can be seen in this plot which causes this initial disturbance to save me.
Why do not you send "starting signal" to dragon script In zero setup ()
/ html>
Comments
Post a Comment