Using Processing to display data graphs


+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default Using Processing to display data graphs

    I have been working on a hobby project, telemetry on a model rocket, and wanted to be able to display some nice graphs from the data it generates. There are a lot of examples on how to use processing for different applications on-line. It's pretty easy to grab data from a serial device (such as a PIC, or a PIC connected to a data radio), and have a base computer log the data into a .csv file. Graphing was a little harder to find examples for. Hopefully this will help someone that might be interested in using Processing to enhance their project. Hope this gets some people thinking about how they might use it in their projects.

    Here are a few of the things that my program does:

    1. Scale the graphs so that 30,000 foot flights, and 300 foot flights would both max the scale of the graph.
    2. Allow you to scroll through the different flight .csv log files within the directory with your mouse, and have it draw a graph of the data
    3. Allows for portability by allowing for different display sizes without screwing up the graphs

    I don't have any actual samples from any test flights yet .... so collecting altitude data while driving some hills in my car had to suffice. Notice the units change between some of the sample files.
    The graphing program (data.pde) can be downloaded here along with the samples: https://github.com/radiohound/NXPMot...RocketNXP/data
    More info about the entire project, which is a work in progress: https://hackaday.io/project/15425-ro...ponder-and-gui

    Name:  sample1.jpg
Views: 272
Size:  160.3 KB

    Name:  sample2.jpg
Views: 369
Size:  173.4 KB

    Name:  sample3.jpg
Views: 290
Size:  138.2 KB
    Last edited by ScaleRobotics; - 28th October 2016 at 06:12.
    http://www.scalerobotics.com

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,713

    Default Re: Using Processing to display data graphs

    interesting hobby , would like to see real data

    just for comparison I did this with python, python allows you to zoom in/out on any portion of the graph and save it a png,pdf or whatever too
    for just a dozen lines of code

    Code:
    import csv, sys
    import matplotlib.pyplot as plt
    filename = 'candaroad.csv'
    t=[]   #time
    a=[]   #altitude
    with open(filename, 'rb') as f:
        reader = csv.reader(f)
        for row in reader:
                #print row
                a.append(float(row[4]))
                t.append(float(row[1]))
    plt.plot(t,a,'b-',label='altitude')
    plt.show()
    #print a

    graph looks a bit different to yours , I may have misinterpreted the data

    O:,359.54,-16.05,5.61,577.59
    O:,359.72,-15.96,5.55,577.02
    O:,359.82,-15.97,5.59,576.49
    O:,0.00,-15.96,5.55,576.06
    O:,0.14,-16.01,5.50,575.67
    O:,0.25,-15.96,5.53,575.77
    O:,0.40,-15.97,5.48,575.86
    I assumed the 577.xx is height and 359.xx is time but the time figure seems to rollover at 360 so I must have guessed wrong
    Attached Images Attached Images  
    Attached Images Attached Images
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    1,713

    Default Re: Using Processing to display data graphs

    derr ,I get it the readings are at 1sec intervals
    Attached Images Attached Images  
    This is more entertaining than Free to Air TV

  4. #4
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default Re: Using Processing to display data graphs

    Wow Richard,

    That's very impressive what Python can do with so few lines of code! The readings are received at a rate of 100 times per second, but yes, that is basically it. I am sure I can zoom in and out as well .... with only 50 more lines of code
    I am also using processing to show the 3d orientation of the rocket during flight, as it records the flight data. But I have seen people do the 9dof orientation displays with Python as well.

    Yes, I am anxious to see get some real flight data too. I am curious how the 9dof will report 3d orientation while in flight, and how well the filtering of the altimeter will work in flight conditions.

    Walter
    http://www.scalerobotics.com

  5. #5
    Join Date
    May 2013
    Location
    australia
    Posts
    1,713

    Default Re: Using Processing to display data graphs

    with a click of the finger the x axis can be made a datetime object and will auto scale from years through months ,days ,hours, minutes ,seconds to microseconds

    Code:
    import csv, sys
    import matplotlib.pyplot as plt
    import datetime
    filename = 'test0.csv'
    t=[]   #time
    a=[]   #altitude
    n=0
    date=datetime.datetime.now()
    with open(filename, 'rb') as f:
        reader = csv.reader(f)
        for row in reader:
                #print row
                n +=1
                tn=date+datetime.timedelta(seconds=n/100.0)
                a.append(float(row[4]))
                t.append(tn)
    plt.title('Canadaroad')
    plt.ylabel('Altitude Feet')           
    plt.gcf().autofmt_xdate(bottom=0.2, rotation=30, ha='right')            
    plt.plot_date(t,a,'b-',label='Altitude')
    plt.legend(loc=0,numpoints=1) 
    plt.figure(num=1,figsize=(14,10),dpi=80)           
    plt.show()
    #print a
    i'm yet to tackle 3d objects in python but I think it should not be too difficult
    Attached Images Attached Images  
    This is more entertaining than Free to Air TV

  6. #6
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530

    Default Re: Using Processing to display data graphs

    I attended the local club's rocket launch yesterday, and was able to get some actual flight data. The telemetry system worked pretty well, giving a 3d rendering of the position of the rocket while it collected the data and wrote to the log file. For this flight I used a G-64 motor with a 10 second delay. I was impressed that the 9dof sensors did not get confused seeing the higher g's. Processing was used to render the 3d position of the rocket, and the video was recorded from the computer at time of flight. I tried to get one more recording, but my small battery ran out of juice on the launch pad before the second flight.

    There was a small bit of data loss, especially after getting down toward 100 feet above ground level. The transceivers I used are rated to about 2 miles line of sight with standard antennas. I used a directional patch antenna for the base station, pointed nearly directly upward, in the grass near the launch area. The rocket landed about 1800 feet away, and behind a small hill. So the area at the end of the graph shows the signal coming back into view as I walk around the hill back into line of sight. But at 230,400 baud, and a 400 mph rocket, where its a little hard to orient the antenna, I am really pleased by the results.





    Name:  11-5-16-Flight.jpg
Views: 216
Size:  182.3 KB
    http://www.scalerobotics.com

  7. #7
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869

    Default Re: Using Processing to display data graphs

    That is truly AWESOME Walter!!!

    Nice to see sensors used for something other than multirotors
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

Similar Threads

  1. Custom data pin for display.
    By Ziko87 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 19th July 2011, 14:12
  2. how to display data receiving from xbee to LCD
    By NURULHAIZA in forum mel PIC BASIC
    Replies: 2
    Last Post: - 19th November 2010, 21:24
  3. display received data
    By NURULHAIZA in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 12th May 2010, 06:03
  4. Better processing of a serial bitstream
    By breesy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th June 2007, 00:13
  5. audio processing
    By mischl in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 7th August 2006, 17:36

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts