GPU-Accelerated Arduino Data Logging and Telemetry

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
everyone in this video I'm going to show an update to the program that I released about a month ago or so basically it's a program that makes it very easy to view telemetry from an Arduino or any microcontroller or FPGA and it can also do data logging so I'll start off with a couple really short demos so I have my balancing robot right here which is in a couple earlier a couple of my earlier videos it isn't the motors aren't powered on but sensors are all up and running and you can kind of see here that we have a lot of live data being charged so we have the accelerometer readings up here we have the gyro readings over here we have the calculated pitch angle right here we have that shown as a line graph and then also as a histogram which you can kind of see as a what you'd expect a nice Gaussian distribution and then we have it kind of been like a dial or gauge type of visualization and and it's auto scaling like the line chart so that's why it's kind of jumping around if I I just get that Auto scale up then it'll pretty accurately if I give this to the frame see that dial moving pretty accurately uh in response and then down here at the bottom we have so there is this transmitter that I made for the robot and down here at the bottom we have the two gimbal measurements and so if I move the gimbal up-down left-right you're going to see it moving along and then over here we have the three knobs which are leaves so if I try to get this to the frame it can turn the knobs and they all show there and so you might be noticing that they're the measurements are pretty noisy like right here and that's because this is a really old design I made this about three years ago when I didn't really know as much as I do now and I didn't have nearly enough decoupling capacitors so that's why if you look here these are all raw ATC readings on the bottom and you see we have like you know plus and minus almost seven or ten counts of noise which is horrible but it's just because they don't have enough decoupling capacitors anyway and then my second demo is I have a little Arduino here and I have a potentiometer I have a light sensor and then I have a thermistor and let me show you that all right so here we have the potentiometer is over here the top graph we have the light sensor in little and thermistor down here at the bottom and I just have sort of a time domain chart and then I have dials and I have histograms so we'll start with the potentiometer if I turn the potentiometer you can see it will respond accordingly and now there is auto scaled the thing you can see the dial looks reasonable instead of jumping around because of how auto scaling works and then we have the light sensor in the middle and it's this little guy right here a little cadmium sulphide cell if I cover it up you can kind of see it responding accordingly aim it up towards the light get even brighter and then we have the thermistor which is a little surface mount part that I have soldered into a header here so if I touch it you can see the temperature ramping up and if I let go you can see it ramped down okay so um what I'll do now is I'll explain some of the updates since the previous version so that way if you if you've used the older version you kind of know what to look for after that I'll kind of cover what I did in the previous video I'll show you how to write the arduino sketch so you can have your arduino talk to my software it's really easy takes about ten or fifteen lines of code not a big deal after that i'll go in more in-depth into how to use the program so that way you can figure out you know how to how to draw the charts and what what the options are and where you can put them and then finally i'll go over the source code and show you guys where everything is laid out my camera just cut out but so picking up where I was cut off yeah I'll go over the source code and show you guys how it's all laid out and if you feel like learning Java and OpenGL you can play run with the code and make it do whatever you want it's it's free and open source so for the the brief demo of the new features I'm going to go ahead and switch back to the balancing robot demo all right so here we are back at the bouncer about demo and the first reading is corrupt because it probably connected right in the middle of a line but we'll see that go away in a second there we go and so the new features for people that have seen the first video it's been all ported to OpenGL which means it'll be quite a bit faster especially for large data sets and in order to do that I had to rewrite pretty much all the charting stuff so I'm no longer using J free chart I wrote all of my own charts from scratch so you can kind of see here we have the the line chart up top and I added the ability so before if you wanted to remove charts you'd remove all of them you need to click down here at reset and I added the ability to just click on a little X icon up top so a small feature but you know it's a helpful if you want to modify things another feature that I added probably much more important is before you can only watch live like right now we're seeing the live data come but obviously you would if you want to look at the past like you know here we have an event that looks kind of weird well now if you use the scroll wheel you can rewind so you can scroll forward and backwards and then if you want to get back to the live view to scroll all the way back down until you at the end and it will switch back to live view automatically and so here we have this weird event and you might want to take a closer look at it so what you can do is you can hold down control hmm hold down control while you scroll and you can zoom in so the zoom in like the the center of the zoom is at the end of the chart so I'm going to go ahead and scroll that way you can kind of see here we we can get a much closer look you can scroll and when you can zoom in as far as you want to the individual the individual uh samples and then you can scroll back up and then a feature that I'm not sure if you guys would benefit from as much but one of the things that I really wanted to do is I'd want to leave this running live on a computer and then I could be across the room working on something else and I want to be able to glance over and kind of see you know what's happening and obviously if it's small like this if you're across the room you can't really see that so I wanted to be able to adjust a scaling factor that would make the text bigger and the lines thicker you know basically scale everything up and so if you hold down shift while you scroll you can do that so you can kind of see it makes everything bigger so the fonts are the most obvious changed but it also makes the the lines thicker proportionately as well and so you can make it ridiculously big and as you can see here in the in the dial chart I didn't really add much error checking as far as if things are overlapping so it gets kind of ridiculous but I'll have to work on that later and so obviously if you're going to be across the room you might want to you can remove all charts by clicking reset and then just have one big chart so let's do one for pitch and auto scale showing the new stuff so rewind and then yeah so if you hold down shift you can make it you know really obvious like you can be across the room and you can see that anyway not sure if you guys would find that is useful but it's one thing that I really wanted to do yeah restore the old layout so we're back to the original layout we uh we saw earlier and so there's a few other types of charts let me remove the pitch chart over here and so there's the Fourier transform which is a frequency domain type chart and we could look at anything really um let's look at the accelerometer and so it'll do a Fourier transform and give you the frequency domain it it assumes that the units of the input are in volts and it assumes that the output is a 1 ohm load like a unit load so this scale in power is obviously not accurate but you kind of get an idea for how it works and I plan to make the frequency domain chart much more advanced in later versions of this program and that's useful like if you're like with the balancing robot you'd want to maybe look at the Fourier transform of the pitch and that way you could see if it's oscillating at a certain frequency stuff like that one of the things that I changed is for pretty much everything except for the dial everything can chart multiple things so if we go back to that Fourier transform in a frequency domain you know to get a frequency domain chart if I do you know all three it can it can overlay them so you can kind of if you have similar signals and you want to get a visual comparison that'll be quite helpful and same for the histogram so if we do a histogram you can check multiple values and they'll all be overlay and so if I move yeah kind of see that it's not going be kind of helpful um the the time-domain chart and the time to main chart cashed didn't change very much I kind of went over those so the histogram one thing I forgot to mention so I wanted it to show both the relative frequency which is here on the left that's like a percentage and then the frequency which is like the count the the size of each bin so that's one thing I added so that way I could see both at the same time if you have an unusual sample length like if you make the duration of that chart like you know 1234 instead of like a nice clean number you'll see that these will be independently drawn and in fact I can kind of show that so you can kind of see that the the two acts er that the divisions on on the left and the right are independent and I did that on purpose I wanted it to be kind of clean division so here there you know point zero one per division and here is ten per division so it'll look kind of weird but it's intentional and I find it helpful because I often want to look at both the count and the relative frequency and then for the dial chart it replaced the statistics chert and it kind of shows similar information so the the dial that's moving rapidly right now is going to show the current reading and it's scaled for the minimum is down here the maximum is over here we have the mean over here in the corner and a standard deviation in the top right corner so it kind of shows a similar information I didn't really break it apart into percentiles I might add that back in later anyway let's get into the tutorial basically where I show you how to write they're doing a sketch and then all in more detail show you how to use the program step by step how to go from you know configuring it to talk to the Arduino creating all of your charts saving a layout opening a layout and so on oh and there was one more feature that I forgot to bring up earlier we are able to log all data to a CSV file that you can open up in a spreadsheet program like Excel or OpenOffice but I'll get to that later so yeah let's cover how to write the Arduino sketch so go ahead and open up Arduino and you're going to go ahead and open up the analog read serial template which is already open but if you go to file examples basics and a lot reads serial it'll come up if you don't have that already okay I'll go ahead and write the code and then I'll explain it afterwards all right so there's the code as you can see it's very short for now you can ignore this part but basically what you need to do is you need to set up the serial port at some baud rate the default of 9600 should be fine in your loop you're going to want to get your sensor readings or or whatever it is you want to visualize as integers well actually you could use some floats or doubles if you want but generally on Arduino you wouldn't need to anyway so you get your three numbers create a character array called text and just make it bigger well you'll see in a second yeah I'm sorry okay I'll get back to that and then so what you need to do is use s printf and it will copy into that text variable the three sensor values and this format string tells it how to do that so % D means print the number as a decimal which is you know base 10 what you would expect and so print a number is decimal print a comma another number is decimal print a comma and another number is decimal and then you tell the three numbers so sensor 1 sensor to sense or 3 and then you do serial print line and you just give it the that variable and the reason why I had to do this is I'm actually powering my thermistor from the a 2 and a 4 pins because I didn't have enough power pins and it was just a convenient way to do it so basically I'm using pin a2 as an output and I'm driving it high so that's basically my 5 volt pin and I'm using a4 as an output and I'm driving it low so it's my ground pin for the thermistor you probably need to do that but that's that's why that code is there but you generally you can ignore that code yeah and so if if we verify the code so that's good done compiling no errors and if you upload it and good donut loading no errors so if you go to the serial monitor it'll connect and then we have our values and let me kind of explain what we're looking at so sensor one over here which is a I've set it to pin a zero it's going to be printed out in this first column the 469 and that happens to be the potentiometer so I'm going to go and turn the potentiometer right now and you can see it changing so that first column is my potentiometer and it varies from 0 to 1023 and that would be sensor 1 here the second column is sensor 2 and it's the one here 390 to 394 and I have that connected or wired up to my light sensor the cadmium sulfide cell and so if I move my finger over it you'll see that number change and a particular away it'll change back and then and then finally a sensor 3 is the third number and I have it connected to pin a3 and that is my thermistor so if I put my finger on it to heat it up you'll see that number slowly change and if I take my finger off it will slowly change back down all right so that's basically all you need your arduino to do you need it to send it's called a comma-separated value or CSV well values multiple ones um and that's what we're doing here so earlier I was talking about how you need this to be 40 characters it doesn't need to be 40 it needs to be bigger than whatever you're going to print here so in in this case the maximum number will be 10 20 3 4 for any of these numbers and that would be 4 characters so there could be 4 characters in the first column second column and third column that's 12 characters and then two commas that brings us up to 14 characters and so I only need a really 14 or actually 15 because eating that last number to be a mill character but if you make it 40 it's you know plenty of big enough to where you know you're not going to run out of space but that's why that's why I put 40 not a big deal anyway and so if you have more sensor values you just you put more here so you can do another comma percent D and then you could put you know sensor for there and then you would have a fourth column over here but yeah really simple really easy to do very straightforward so now let me go ahead and go back to my program and I'll show you how to connect to the Arduino and how to use the program oh one thing before you close your Arduino software take note of what comport your dueño zap some might happens to be a comm 3 yours could be different so just to keep that in mind so there will be a link in the video description of the code and well the draw file which is the program and then the source code for it so if you download the jar file and you double click on it the program will come up and you will need Java installed so if you do not have Java just go to Google type in download Java and then download it be through Oracle is the provider of Java but you probably already have it installed if you're doing Arduino stuff anyway so here's the program and the first thing we the first things we need to do is down here in the bottom right corner the sampler is how often we're getting those samples from the Arduino and if you recall the last line of the code was to have the Arduino wait 10 milliseconds and so basically that means I'm sending 100 samples per second because 100 times 10 is a thousand and there's a thousand milliseconds per second so I'm gonna go and type in a hundred there for the sample rate this value is not critical but I'll explain why it's helpful in just a few minutes leave this first one as ASCII CSVs there's option for binary it doesn't really work correctly yet um I wanted to have a higher efficiency mode where you could do binary packets I actually I have it kind of working but it isn't really polished and it'll be really confusing so don't try it yet always leave it at ASCII CSVs and then choose the comport which would be calm 3 and then the baud rate which we left at 9600 but make sure it matches whatever you whatever you wrote in your arduino code and so you click connect and then we have a data structure window and this will let you tell the software what those columns mean and so column number 0 is the first column and you give it a name and so in my case that first column that we saw in the Arduino serial monitor was my potentiometer so you give it a name I'll type it in this potentiometer you can set a color which is what the the line color will be or the bars in the histogram or the color of the dial so if you click that you can pick a color here normally this will be bigger but I'm using display scaling because I'm actually on a 4k monitor and for some reason this java color picker doesn't scale but anyway it should be a little bit easier to see for you and there's also other ways to to enter numbers are to enter colors I'm going to leave it as the default red so i'll cancel and then for unit I'm going to go ahead and scale these numbers into volts so we'll make the unit volts and then the Arduino has a 10-bit ADC which will give you a number from 0 to 1023 so it's a maximum of 10 23 and I have a 5 volt Arduino so it'll be 5 volts basically we're telling it scale the numbers so that 10 23 is equal to 5 volts LSPs means least significant bits that's just a kind of a technical term for like the wrong number the count and then you click Add and now we can define column 1 which is the the second column and for that I have my light sensor and we'll go ahead and pick a different color let's go with green I'm not going to calibrate it so I'm going to leave the unit blank and I'm going to go and erase these scaling factors and click Add and then the third column which is column number 2 was my thermistor and we'll change that color we'll make it blue and I'm not saying I'm not going to give it a unit I'm not going to scale it just click Add so we kind of see here this is what the software knows so the first column column 0 is the potentiometer it'll be drawn as red it will be scaled to volts and the conversion ratio is an input of 10 23 will be mapped to an output of 5 volts and it's just a simple linear scaling factor and then we have the other two rows and you keep on adding roads if you have more values if you made a mistake you can click reset and that will delete all the roads down here and you can start back at column number zero when you're done click done and now you're ready to make all of your charts so if you click and then drag so click and drag and let go you can add a chart so the first option here is the chart type and there are five types you have time domain chart time domain chart cached frequency domain histogram and dial so I'll go through all them I will start with the time domain short duration is basically your domain how many samples do you want to see on screen the default is a thousand which in our case because our Arduino is sending about 100 second means we'll get a graph of about 10 seconds and let's take a look at another potentiometer and then click Add shirt and there are the values so it has scaled the potentiometer reading into a voltage and you kind of see that over here on the left and the potentiometer is just sitting there so it's kind of bouncing between two different values with a little bit of noise if I move the potentiometer you can kind of see it'll go all the way from zero up to five and my potentiometer has detents which is why that looks kind of nachi but if you if you have a regular potentiometer it would you know smoothly reflect the rotation and so we can add another chart you click and drag like before and the next chart would be time to main chart cached and it's very similar I'll go ahead and leave the duration back at a thousand and same as potentiometer you can see that it looks basically identical the most obvious difference is when it auto scales it's not as obvious yet let's wait for it to when an auto scales and it gets rid of this stuff you'll see that on the charger on the left it'll very smoothly auto scale back down and this one is going to cut it a little more Chompy yeah like that okay so the reason why is the cached version instead of redrawing the chart every single frame it actually records little strips and they're kind of moving across the screen it's you know caching the actual pixels and if you're you doing something simple with Arduino you don't need to use the cached version but if you're going to chart a large number or a very large data set like a hundred thousand points five hundred thousand points a million points it'll really struggle to do a real-time if you don't use the cached version because that'll be a whole lot of I use to draw you know live at you know 60 frames per second at whatever your resolution is so the cached will help if you're using very large datasets if you're not then you don't need to use it don't worry about it let's make another chart so click and drag you can do a frequency-domain chart and let's look at the light sensor because I don't have a little more you know movement to it so you can kind of see there is um there's a few Peaks here there's a one around you know 30 37 there's some things there I'm not sure that might be from a in fact I don't know there's an LED a little status LED from my computer that the light sensor is aimed at I wonder if maybe there's a some PWM harmonics that are for some reason all the way down at that lower frequency anyway um yeah so you kind of get a feel for the frequency content on the signal if you don't what that mean just don't worry about it it's just when you get into more advanced signal processing you often want to look at frequencies instead of just time but let's look at another graph the histogram chart which you guys saw earlier we can do that as well and it will show you you know a probability distribution so right now that the thermistor isn't changing also it's constantly at 532 and that would be one for relative frequency 100 percent and a thousand counts if I touch the thermistor you'll see that kind of changes and if I let go it will get cold again so yeah this is kind of a neat way to look at the distribution of values just a nice kind of statistical tool and I think we kind of covered most of how that works earlier let's go ahead and remove a few of these charts so oh yeah so if you move your mouse over the chart you'll see this X in the top right corner and if you click on that it will close the chart for you so we'll go ahead and add another chart and we can do a dial chart and that will be able to show one value at a time so you could show the light sensor and it's going to auto scale so when we set that duration of a thousand it'll be all here going to show you a line graph see yeah there we go so you can kind of see it's jumping around here on the dial because the auto scaling is only between you know 395 and 389 so there's there's not much going on there if I move my hand in front of it now you can see we have a much bigger range and so the dial is is going to you know look a little more normal so the dial is going to show the current value the minimum value is down here on the left maximum is over on the right mean is up at the top left and standard deviation at the top right and so let me go if you click the reset button down here you can it will erase every chart so it's like a clicking the X for everything and I'm going to go ahead and add in bunch of line graphs so and so I made these two three roads high but there's only two down here well we can make we can resize the grid so you have the number of columns and then the number of roads so if I want to make nine rows put a nine there and there we go so now we have room here show the thermistor and then well you know okay I want to add more charts over here on the left so I can add more columns we can make that say twelve and we could do you know our histograms which we kind of neat and so you can see it's very easy and quick to add charts on I wanted to be very straightforward kind of a not like it's not like a hardcore engineering tool where you have to know entering a whole bunch of stuff I wanted it to be kind of a quick just data visualization tool um and so if I move my hand in front of a light sensor and if I rotate the potentiometer let's get these charts to look a little interesting if I touch the thermistor there we go okay so and then like I mentioned at the very beginning of the video if you rotate your scroll wheel you can rewind in time so I can rewind time and everything will update the line charts the histogram is all everything would would update and then you could zoom in so if you hold down control and then move your scroll wheel it will zoom in and like I mentioned earlier the it will scale about the the end of the chart so that's why like this part of stationary and these are kind of flowing away from you and you can zoom it as far as you want and see the individual samples let's again zoom back out and then again like I mentioned earlier if you hold down shift you can do the display scaling where it will make everything really big so you can read it from literally across the room if you want to that's pretty much the majority of what you need to know to use the program if for example you want to save your your layout like if you want to open this up again later on without having to you know entering the data structure and then click and drag to create all the charts you can go down here click save layout I'll go ahead and put on the desktop and I'm going to call it tests one two three four press ENTER and if we close the program we now have that file here and if I open the program again you can go to open layout and find the file and it will open the layout so there we are see I already covered reset if you click on help it just tells you kind of what I've been telling you over the video so it tells you to use the controls at the lower right to connect and then you you know you to find your data structure you click and drag and then you know how the scroll wheel works so yeah that's the majority of or that's pretty much all of it um I wanted to keep it very simple and easy to use oh one thing I forgot to mention the the sample rate in theory it it isn't important you could leave it out but it does two things for you one if you do the frequency domain chart it doesn't need to be accurate if you want your frequency scale to be accurate and then even if you don't care about that chart when you scroll like if you if you rewind and fast forward in time it will try to make one click of your scroll wheel to be one tenth of a second so in this case one click of the scroll wheel would be about ten samples kind of see that and so if you have this number way off then when you scroll it might look kind of weird but that's it it's not really a critical thing that's legit only two times that number comes into play so if you close the program you'll notice that there will be a file called log CSV it'll be in the same folder as the program so it happens to be on my desktop so it'll be on my desktop and that is just a log of all the readings so you can do um more professional analysis if you if you have a need to so if you open up the CSV file I have OpenOffice installed and then it's a comma separated values so make sure it's only going to separate based on a comma you don't want it to separate based on you know spaces or anything like that just comma and then there's your relia so we have our potentiometer readings in this column the light sensor readings and the thermistor readings and then we have a timestamp over here on the left if you are sending data very fast keep in mind that this will not be a perfect timestamp windows is not a real-time operating system so it will not be it will not be as consistent with things that are very fast so even if your Arduino is actually sending data once per millisecond you may get timestamps that kind of jitter around you know a couple milliseconds or whatever the operating system will buffer the data on the serial port so that's why you get that there's really no way around that and then finally you notice that in here the potentiometer reading is it is not scaled in two volts and that's intentional these are all the raw values from the arduino or whatever is talking to the software whatever microcontroller you use I didn't want it to store the scaled values because then you have you know floating point error that is potentially adding up I mean it would be a small amount of floating point error but you know it'd be imperfections that it might be easier to look at the raw values anyway so this is you know your log of data and so you could maybe make a chart if you wanted to you could pick the light sensor I don't really do much with spreadsheets but I think it would be yeah insert and then chart and you could pick your chart type I guess probably a line chart would make sense and go there and yeah so that's kind of a weird-looking x-axis but yeah that's the data anyway I'm sure if cell would look better or are many people that know better than me with spreadsheets could figure it out but anyway there's all your raw data and it can be a useful tool I hope you guys found the program helpful there are links to the program and the source code in the video description and now I'll go ahead and look both I'll go through the source code so you guys can get a feel for how the code is laid out if you feel like playing around with the code and maybe modifying it making it do whatever you want alright so here we have the source code open say a folder called telemetry viewer and it's written in Java and of course I'm using OpenGL for the data visualization part and I'll kind of walk through how all the code is laid out so it all starts in main of course and that would be in main dot Java and there's not really a whole lot going on this particular file I start off by telling it to use the the look and feel of the operating system operating system which would be like Windows to make it look like a Windows program and then I create a jframe and I give it a title the OpenGL charts region let me go ahead and bring the program up ultrix region is this grid area where all the charts would be and the controls region is the the bar at the bottom with all of the controls and then I lay out the window and I set it to be maximized and I show it and that's really all there is in main all the the work is elsewhere so if we look at the controls region this is that bar at the bottom with all the buttons and so we have all of our buttons and it registers event handlers to do all the work so you can kind of poke through there if you want to modify that or figure out what happens when you click on a button and then the trucks region go here and this draws that grid and then all of the charts so and it also handles all of the mouse events when you're over the charts so it keeps track of the grid and where you've clicked and dragged to create the chart and the GL canvas object is where we're actually drawing that grid and all the charts for a GL canvas you have to add a GL event listener event handler and that interface has an init uh yeah in an init a init method and that will be called at the beginning to initialize your open GL code so I turn on blending which is like anti-aliasing and I enable it for lines and points I used to have it enabled for polygons but I find that on Nvidia drivers if you draw a quad it will actually anti-alias the two like implicit triangles of the quad separately so it gets as you have this really weird transparent diagonal in your quad looks kind of funny but anyway that's why I commented that out the reshape event handler I guess you could call it it just changes the projection matrix and keeps the log of the current width and height and the rule the real work is done in the display method and basically draw the background draw the grid background draw the vertical lines the horizontal lines the bounding box for wherever you click and drag when you're trying to create a new chart and then all the trips and yeah there's a whole lot going on here the animator is what tells the GL canvas to repaint every frame so in my case 60 times a second and then I have a mouse listener to keep track of you know when the user clicks and releases and you know all that mount Mouse motion listener same thing wheel listener or that and then I tell the controller that I want to be notified if the grid changes and that's about it for that so you could then look at the charts if you want we all of the charts start with OpenGL so you have the dial chart frequency domain chart histogram chart time domain time domain cached just take a look at the regular time domain chart so every chart has a get descriptor method static method and it is used by the code to figure out the how do i phrase that okay if I if I load up that Arduino demo real quick so I'm going to go and delete a chart if if you were to create a chart here or anywhere this window it it needs to know know what options are available for each chart so like the dial chart can only take one option but the time domain chart you can have as many as you want and so that's what the descriptor does it tells it the default duration the minimum and maximum you know the inputs and then if the user clicks the on chart button it can create that chart object when we create the object we're basically calling the constructor of the parent class which is a position to chart I'll get into that in a second and then we create a object for auto-scaling the y-axis and I'll get into that more as well and so yeah one thing is I have Javadoc written for most of the code not all most of it so if you move your mouse over a method it'll it'll tell you it'll tell you what it does and why anyway and so then the bulk of the work is done in the draw chart method of any chart and so it will draw a background color and then will draw a rectangle around the perimeter and then it will calculate it will get the samples and calculate you know all of your domain and range values it will auto scale them accordingly and then it will calculate the positions of every little part it'll get the divisions and then it will draw a grey background in the plot area and then we'll draw the vertical division lines and horizontal division lines and so on and so kind of you get the feel here I don't I don't want to bore you guys I'm not going to really walk through every single part of every trick but that's kind of how it works for for all the types of similar kind of process for all of them the cash chart like I mentioned earlier it uses cached data like it'll actually cache the pixels that will keep a 32 it'll render the entire chart as a bunch of 32 pixel wide strips or slices and that is what this object is that OpenGL time-domain slice and basically it will create a frame buffer and a texture and then it will render into that texture so you can cache the data it will keep the data as a samples jailed object or an array of them because you can have multiple things being charted in one chart like you could chart like gyro X gyro Y and gyro Z all in the same shirt and so when you create the object it will create the frame buffer and the texture and if you call up to it samples it will get new samples from you know the database basically and it will calculate the min and Max and then if you call update slice texture it will determine if it needs to redraw the texture and if it does it will so there's a whole lot of logic in there and then we update that frame buffer and then there's render slice app which will draw that texture at a particular location on the screen and so yeah that's about it for that C Auto scale is what handles well auto scaling and axis and there's kind of two modes for that the exponential mode is what you mostly saw where it will smoothly transition to a larger or smaller scale as needed the sticky mode is used in the cached time domain chart and it basically will only auto scale if it has to so if you push too far if you go too high and you'd be off the screen it will rescale because it has to and if you get really far away from the edge and you're wasting a lot of space then it will rescale but it will not constantly rescale and that's because with the cache you know ideally you don't want to be flushing that cache every frame and so there's just the logic in here for all that the binary processor is for the binary packet mode which isn't really polished yet so I'm not going to go into too much detail there chart utilities this is used for the size of the X&Y divisions so it will try to give you a nice clean number instead of you know just randomly splitting it up she get there's a version I'll give you Y divisions as a floating-point number Y divisions as a log so basically that's only used for the frequency domain chart because the power is shown as a log axis otherwise it would look well yeah it would look weird it would be you wouldn't see many detail and then get the X divisions either as integers or as floating-point numbers and that's a little helper function to get a number formatted as a string using a specific number of characters if possible that's used in the the dial chart for example the minimum and maximum values oh here let me show you so if I put a dial chart here so I wanted the minimum and maximum numbers over here on the two corners to show you know basically six digits of resolution and that's what that function does it's like it will it will try to show up to six values and but it will if there's a you know a decimal point and there's way more than six it will cut off that but it won't cut off integers so yeah I have the code set up as a model view controller and so the controller is what handles the like mediates access to the data which is the model and so that's it's a big long class and it handles you know pretty much all of that yeah I'd be born if I kind of went through everything but you can kind of scroll through there's methods related to the datasets and the serial ports or serial port and everything else in there let's see data set a data set is an object that stores all the data for like one of those CSV columns and so it needs to know the location which would be like is it column 0 column 1 column 2 we're not doing binary packet mode yet so you can ignore that the name would be like you know potentiometer or thermistor or whatever you want the color and the unit conversion factor and you can get samples you can insert samples all that is handled here so yeah I'll try not try to make this quick I know it's been kind of drawn out the model is basically where all the data is stored and there's a some of the limits too so the grid has a default of 8 columns but it has a minimum of one and a maximum of 20 you can change those if you want and so on and so there's default values here and this is where all the datasets are stored all the charts are keep a list of them in here the new chart window is the window that pops up when you try to make a new chart so this is the new chart window that's all here pretty straightforward try to get through this little bit quicker and are you guys you're probably really bored position chart is the parent class for all the charts so it has values that every chart would need to have the chart needs to know its position so the x and y-coordinate of its top left and bottom right it needs to know its duration which is how many samples it should show and it needs to know what it's going to show and so when you create the object it'll log all that there's a helper function where if you give it a coordinate in the grid it can tell you if that chart is overlapping with that area and then reconnect data sets will let when you if you disconnect from a port and then reconnect it's possible that if you change the data structure a little bit that the data sets would change their location in memory so this reconnects them kind of confusing but you'd only need to worry about it samples and samples geo so I kind of go over all that right here but basically when you need to get data from a data set you can get an individual sample you can get a float array you can get an object which would be this class the samples object which will have the float array and it will also tell you the minimum the maximum the color name and unit and then there's a GL data set version which is this object and it will give you basically the same information but instead of being a float array it's a float buffer and it's formatted in a way that you can basically give directly to OpenGL and it's more efficient if you're going to draw a line graph it just stores the X to my coordinates and you treat it as a vertex array and then I have a lot of the theme details in the theme class so you can change colors and stuff like that the default lengths of various parts default fonts and then font util is kind of handles the rest of the theme as far the you know relating specifically to fonts and it's also used by all the chart classes to draw text on screen so it will queue up data for each chart and then you can at the end of the chart after you draw the chart you can empty that queue and draw the text and so each chart would call these draw functions and that would put stuff in the queue and then the OpenGL charts region will automatically call the draw cube text for you and it will empty the queue and draw the text for you that's pretty much hold all the code as you can see there's comments everywhere so feel free to look around feel free to ask questions I don't want to go into too much more detail because I'm sure you guys are already bored and it's been a long video so sorry about that anyway that's um that's the program there is links to the program and the source code in the video description if you guys have any questions or comments please leave them down below and if you know anybody that might benefit from the video or the software please share a link to this video I'd appreciate it alright have fun
Info
Channel: upgrdman
Views: 42,707
Rating: undefined out of 5
Keywords: Arduino, Data logging, Telemetry, Data Visualization, CSV, UART, Serial Communication, Serial Port, Line Chart, Line Graph, Histogram, Fourier Transformation, Time Domain, Frequency Domain, Dial, Gauge, Java, OpenGL, Microcontroller, FPGA, Open Source, STM32, GPU, GPU Accelerated, Gyro, Accelerometer, Magnetometer, 9DOF, 10DOF, Potentiometer, CdS Cell, Light Sensor, Thermistor, Temperature Sensor, Statistics, Standard Deviation, RS232, JOGL, JogAmp
Id: yYyW16FYqE0
Channel Id: undefined
Length: 57min 40sec (3460 seconds)
Published: Sun Nov 27 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.