[Tutor] Tkinter and matplotlib

Dennis Lee Bieber wlfraed at ix.netcom.com
Fri Feb 11 19:02:27 EST 2022


On Sat, 12 Feb 2022 09:36:00 +1100, Phil <phillor9 at gmail.com> declaimed the
following:


>The code that I posted was a simplified version of a project that I 
>found on the Internet, I simplified it even further so that I could 
>provide relevance for my question. I probably should have removed 
>removed even more of the original code.

	Or left more of the original -- that incrementing "cnt" logic was
rather baffling: it would just produce a diagonal line for evenly spaced
time points; the only divergence would be if you "stop" for a few seconds
and then "start" again, as the adjacent times would now be more than a
second apart.

>
>I've constructed a simple capacitor / resistor oscillator using an 
>Arduino board. I'm plotting two cycles of the waveform with matplotlib 
>by popping the first value from the collected readings when the count 
>reaches 50. This way the displayed wave doesn't compress and so more 
>resembles the view normally seen on a CRO.

	There seem to be many examples of Python display & Arduino sampling
"oscilloscopes" out there (search terms in Google: python arduino
oscilloscope) -- but I haven't seen one using Tkinter (yet).

https://circuitdigest.com/microcontroller-projects/arduino-oscilloscope-code-circuit
uses "drawnow" library to allow for dynamic updating matplotlib

https://maker.pro/arduino/tutorial/how-to-make-a-basic-arduino-pc-oscilloscope
uses pygame library for display/control; appears to be snapshot mode
(collect readings, then display)

https://pypi.org/project/SerialScope/
pip installable package using (copied) pysimplegui (which does default to
Tkinter <G>, full pysimplegui has variants for gtk and wx if that's one's
preference). There's also something using C++ in the github sources; I
don't know if that's an addition beyond the Python or used by the Python.

	Many of these don't seem to have logic for controllable time-base --
they seem to collect the data as fast as possible, and just scale it to the
width of window. Time base may need some interaction between Python and
Arduino code (Python sending rate to Arduino which does the interval
timing).




-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
	wlfraed at ix.netcom.com    http://wlfraed.microdiversity.freeddns.org/



More information about the Tutor mailing list