Real time plotting in raspberry pi using python - Page 1
Forum section: electronics / projects

author: bharatcs
author_rank: Contributor
timestamp: December 28, 2015, 03:54:10 pm
content: I'am totally confused .I need to plot adc value input at real time in a raspberry pi and also store it.these are the things program needs to do1.real time plot the value from an adc whole day2.store it as a file3.if needed open old filescan some guide me on how to do it? which library should i use?

author: Richard Crowley
author_rank: Super Contributor
timestamp: December 28, 2015, 04:27:07 pm
content: Where are you starting from?What experience do you have writing code?What experience do you have writing Python for RasPi?Do you know how to interface with the ADC, scale the data, etc?Do you know how to display things in the video frame?Do you know how to create, write, read files?Do you know how to use clock/timing functions?Do you know how to devise a user interface?These are all things you will need to do for a project as you describe.You must evaluate your knowledge and experience and determine what areas you need to learn to execute your project. If you break it down into specific skills like that, then you can assemble the knowledge together for your project.

author: bharatcs
author_rank: Contributor
timestamp: December 29, 2015, 08:18:28 am
content: thankscan you tell me where to refer about display things in the video frame ,devising a user interface and using clock/timing functions?I'am very familiar with c language and interfacing of adc but a beginner in python.

author: branadic
author_rank: Super Contributor
timestamp: December 29, 2015, 09:57:26 am
content: If then, why you want to start with Python? Use codeblocks and wxwidgets instead. There is GNU Octave available for Raspi, that can also plot realtime data.

author: bharatcs
author_rank: Contributor
timestamp: December 29, 2015, 10:26:39 am
content: Actually In this project I'am only allowed to use python for logging.GNU Octave seems interesting I will try to plot the graph with it.Thanks

author: branadic
author_rank: Super Contributor
timestamp: December 29, 2015, 11:23:24 am
content: Some extra hint, you need to install instrument-control library for GNU Octave. I guess the actual version 4.0.0 is currently not available, but version 3.8.x., which is a lil' bit disappointing. I haven't yet managed to make version 4.0.0 build.

author: Richard Crowley
author_rank: Super Contributor
timestamp: December 29, 2015, 01:46:19 pm
content: Quote from: bharatcs on December 29, 2015, 10:26:39 amWhat kind of project is this? Is this some kind of assignment from a school?If you are only allowed to use Python, what other requirements and restrictions are there for this project?

author: bharatcs
author_rank: Contributor
timestamp: December 29, 2015, 02:12:07 pm
content: You are right it's an academic project .The only constrain is that I have to use python .Since there are so many approaches possible it's bit confusing.I was able to create a python code to log the data as a csv file.but I have no idea about real time graph plotting also there are many libraries available, choosing one is harder as I have no experience .Can you please guide me

author: branadic
author_rank: Super Contributor
timestamp: December 29, 2015, 02:30:56 pm
content: You could also use Python together with GNUplot. Here is an examplehttp://www.forum-raspberrypi.de/Thread-tutorial-1wire-temperaturmessung-mit-datenerfassung-und-visualisierung

author: dom0
author_rank: Super Contributor
timestamp: December 29, 2015, 03:47:49 pm
content: There are various software plotting libraries available for Python. E.g. matplotlib, a few Qt things with Python bindings, and various other bindings (GNU plot, octave and I think R?).These are all software plotters. For real time applications on a small processor like the Raspi's with only one core and a few hundred ARM MHz these will be rather slow. Depending on your desired update rate they can be too slow (some are faster than others, which often also has to do with complexity / flexibility of their data models, e.g. matplotlib is one of the most flexible and very high quality plotters available, but is very slow compared to e.g. QCustomPlot or Qwt).With larger datasets eventually all software plotters become too slow for real time use (pan/zoom/append dataset in RT). Excellent escape route is GPU plotter. Don't know/care if any libraries exist, written quickly for specified visualization, and of course not overly flexible in that case, but by far the fastest way to plot data. On the raspi the limit isn't how fast the GPU is but how fast you can push buffers to it and how smart you are about buffer management, slicing and stuff (plotting stuff even in complicated ways is a really, really simple task even for an older GPU). Of course, requires GPU programming.

author: SteveLy
author_rank: Regular Contributor
timestamp: December 30, 2015, 12:56:00 pm
content: Matplotlib (plotting library for Python) would be one good option. There are loads of examples here:http://matplotlib.org/examples/index.htmlThis tutorial should be helpful for what you're trying to do:

author: bharatcs
author_rank: Contributor
timestamp: December 30, 2015, 06:40:04 pm
content: Thanks I am going to try that?Thanks all of you guys for providing me with your valuable information