Greetings. I'm Sandra Capri from Ambient Sensors in Boise, Idaho. First off, the most important thing, it's Pi Day. Greetings on Pi Day, and I'm giving my speech, so that's pretty cool. So in honor of Pi Day, I just want to say 3.14159265358979323846. Can't go any farther. And then that's kind of a lead in for those of you that know me, you'll know that when I get excited about things like technology, I tend to talk really fast about the speed that I do my Pi. So if I do that, I've got a co-worker in the back that's telling me, slow down, slow down. I'll try to stay under sublight speed today. And then, oh, if anybody has downloaded the slides already, I apologize, they got changed again last night. So if you want an up-to-date version of the slides, you're going to want to go out and get them again. The subject of the talk is going to be about a white paper that I wrote. The white paper is done, but being the engineer that I am, I'm not so good at the whole formatting thing. I have a co-worker who is currently desperately trying to format it into something that's a little more human readable. So hopefully by the end of today or by tomorrow, you will be able to see it. All right, so enough of the preliminaries. So I mentioned I'm from Ambient Sensors. We're in Boise, Idaho. We're an engineering services company. And as an engineering services company, we tend to do a lot of different things. You know, whatever a customer pays us to do and we agree to do it, we go out and branch a lot of different directions. So in the last few months or so, we've been doing a lot of various work. Some of the work has been with Bluetooth Low Energy for specifically version 5, Bluetooth Mesh, Wi-Fi, lots of IoT stuff. And we've even played around with connecting our IoT devices up to Alexa. And that was a lot of fun. Haven't had any customers be very excited about paying for that, but they love the demos. We do a lot of the smaller IoT systems. And we'll do like single threaded, small processor systems where there's no operating system, just our thread, on these low end SOCs. And those work out pretty well. But then some of the funner stuff is when we get to work on the higher end processors and we get to do something with Linux. So about a year ago, I was working with a customer and they had a question. And investigating what I could do with Linux for them and it led me to do an investigation and create this white paper, which is the subject of today's talk. So everyone's heard this Einstein quote, time is an illusion. And then you look it up and find out Einstein really didn't say that. I'm going to have to read his quote because it's a long one. The distinction between the past, present and future is only a stubbornly persistent illusion. You can see why that got simplified down to time is an illusion. But who's going to remember that quote? But the other reason for putting it up there is it makes a great segue for the next part of someone else's quote, a quote from our favorite author of The Hitchhiker's Guide. It wouldn't have gone with the actual Einstein quote, I fear. Now this painting in the background, this is Salvador Dali's The Persistence of Memory, which I forgot there for a second. To my knowledge, Salvador Dali really didn't do anything with Linux, but he certainly had an interesting perspective on time here. He's taking his representation of time, these clocks that are all melted and warped, and he's saying, you know, I can manipulate time to be my vision of art. And that's a really cool idea. I mean, you can do that with art. Sadly, with Linux and being able to do real-time control, we don't have this kind of control as much as we wish we did. When you're trying to use Linux to control some hardware, you're going to wish you had this capability. All right, I bet everybody knows that's a Bitcoin logo. So there's a couple of times in this presentation that I'm going to be asking questions of the audience. Now, I'm sorry, I can't gave you any Bitcoin if you participate. But if anyone was going to sleep a few minutes ago, you are now awake. So this is just a plea. I can't give you Bitcoin, but if I'm asking a couple of questions and you have a thought, don't be shy. Go ahead and give your thoughts on it. I'm certainly not going to mock you because I'm definitely in the hot seat here. So a general question for this talk. This is a rhetorical one, not looking for an answer. Can a small embedded Linux platform be deterministic enough to serve as a device controller? Now, specifically, we're talking about plain old vanilla Linux. We're not talking about real-time Linux. There's no kernel extensions here for this. So, you know, how you do on an everyday basis. You go to kernel.org, you grab a new version of the kernel and you build your own distro up from scratch. I'm sure we don't do that everyday.  All right, can I use this as a device controller? All right, first audience participation. Why is this difficult for a Linux system to do anyway? So, I was looking for a giant question mark on openclipart.org and I ran into this awesome pun. So, does anybody know what this is? Not a zipper. It's a good thought, though. Why not? You get a virtual bitcoin. Yes, someone asked you why. What does everyone love to answer? Why not? Okay, that was my really bad pun for today. So, I assume that everybody's got some kind of an understanding of what is the problem with Linux, or you wouldn't bother with coming to this talk, but just in case there's a quick summary. So, the Linux scheduler's job, let's see if I can find my pointer. All right, so Linux scheduler's job is to decide when each task in the system gets a chance to run. We've got task preemption going on for the first part. So, if a higher priority task wants to run, the scheduler's going to take care of that. Even kernel tasks are preemptible nowadays in modern Linux. When I first started, kernel tasks weren't quite preemptible. So, any time that the kernel is built with config preempt, which currently is pretty much the default, you're going to have preemption even in the kernel. So, here you see task A. Task A is just happily running along, and it gets to a certain point, and all of a sudden, an interrupt occurs. Hardware interrupt. Interrupt service routine is going to start running. Run, run, run. Does something that's going to wake up task B. Task B is a higher priority than task A. So, task B gets to run along, and task B gets done. Fortunately, there are no other higher priority processes. Finally, task A gets to finish out what it was doing. Okay, if task A was your controller, you just got into yourself into a bit of a problem there. So, in general, with most modern operating systems that aren't designed for real-time, you're going to be dealing with all kinds of operating system overhead. You're going to have interrupt latency, context switching time, memory allocation, paging, the list goes on and on. So, how could you ever do any sort of device control with an operating system like Linux anyway? Well, first you have to kind of figure out what control you need. Do you need hard real-time control? Enimus deadline is a system failure. Quite the system failure in this case. This is for mission-critical systems where failure to conform to timing constraints results in a loss of life or property. So, some examples of hard real-time systems would be airplane control systems where you're worried about losing people's life in the plane, car engine control systems where maybe you're going to destroy the engine, heart pacemakers, no explanation needed as to why you have hard real-time there, and industrial controllers where you could be losing some pretty big equipment. Or do you want soft real-time control? This allows for frequently messed deadlines and as long as tasks are executed in a timely manner, the results are going to continue to have value. But complete tasks may have less and less value after the deadline, but they can still be of value. Some good soft real-time examples, as you can see there, streaming audio and video, voice over IP games, that sort of thing. And then people will talk about firm real-time. Infrequently messed deadlines are acceptable if they don't happen too often. I guess that's the definition of it, infrequently. And then here is a don't sue me, don't blame me slide. I really don't want that responsibility. If anyone doesn't know what that logo is, that's the international symbol for a peacemaker. I had to actually look that one up. Seriously, you need to really understand your timing requirements, study them pretty carefully before you decide what's the best way to try to meet those timing requirements.  Now, there is a way to support real-time in a Linux system. For example, the preempt RT patches. That's going to remove the unbounded latencies. Okay, so if preempt RT is so powerful and you can really do real-time Linux, why doesn't everyone just run preempt RT? Well, there's some engineers or their companies that aren't comfortable with trying to support a Linux system. That has the preempt RT patches in it. It takes work. You don't just apply the patches and it's magically real-time. You've got to do a lot of testing. You've got to do a lot of tuning. If your project has generated new drivers or kernel modules or using someone else's drivers or kernel modules that haven't been part of the real-time system, then you're going to have potentially a lot of modification to do. Then potentially there's going to be lag in support for new kernel versions. A patched kernel could be a little more sensitive to certain kinds of bugs than an un-patched kernel. For those that are interested in actual preempt RT in real-time, that's not what this talk is about. Look up a couple of different talks. Andreas Amans did a great talk at last year's ELC. In addition to discussing just real-time Linux and how to deal with it, he had a really excellent section on how to do some debugging, finding bottlenecks, testing and tuning. It's actually really good information for anyone working on Linux, whether you're doing real-time or not. Some pretty good tools and walking through how to do some things. Then just yesterday, Julia Cartwright gave a very cool talk about driver development in real-time. The what every driver developer should know about RT is a good talk to go look up if you can. That gives really good information for driver writers. Now I'm going to restate the question as a customer attempted to explain it to us. Can a Linux single-board computer control a GPIO to create a very accurate pulse without the Linux real-time patches? The two proposed systems that they were talking about were the Raspberry Pi and the Beaglebone Black. I'm guessing those are familiar boards to pretty much everyone in here. Then the question you see I've got very accurate in quotes. What did they mean by very accurate? I tried to pin them down on that and sometimes it can be surprisingly difficult to get a customer to define certain terms. We started out with 11 milliseconds, plus or minus 250 microseconds. They wanted me to be able to essentially at any time generate a very accurate, in that definition, 11 millisecond pulse width. I said, come on, how hard can that be for Linux to do anyway? 11 milliseconds is an eternity in processor time. I started on the Raspberry Pi 3. That's the quad-core Pi, for those of you familiar with it. I loaded up Raspbian on it and I started working. At the start of the investigation, I was using kernel 4.4. It was about a year ago, but I've since re-verified the results, are still pretty much the same on 4.973, and that's the latest Raspbian as of December 2017. Those images are, of course, compliments of the respective companies. You see there's a pulse train there. The point of this project was not to generate an accurate pulse train, but I figured the easiest way to test generating an accurate pulse at any given time would be to just generate a whole series of pulses and then measure them, make sure the system is really busy, and if they're all nice and uniform at the right width, then I probably can, at any point, generate a pulse. So I'm not generating a pulse train to generate a pulse train. That was just the way to test what I was doing. And then to simulate a busy system, I decided I was just going to swamp the Linux system, just bury the poor thing, and I was pretty good at doing that because I actually got the poor Raspberry Pi to crash a couple of times. Sometimes it just can't deal with a lot of stuff in there. And then if I had it swamped that badly and I could still generate fairly accurate pulses, then I would know, okay, I've got something going here. Then for being able to measure it, I figured I could do, in some cases, internal measurements, ask the system to grab the time information and check on that, and then other times I would use the oscilloscope or the logic analyzer to try to measure it. So odd note, don't ask me why. Even though my original goal was an 11 millisecond pulse, I did all of my experiments with a 10 millisecond pulse. I don't know why. I was looking at my results. What's that? A number of fingers. A number of fingers. Well, yeah, that's very possible. And I looked at it and went, 11 milliseconds. It's prime. It's a palindrome. It's a great number. Why didn't I use 11? And I just don't know. So first, excuse me. First I needed to decide what is going to be the most accurate way to make a thread create a pulse of a requested width. So after I cert the GPIL, did I want to do a busy weight loop and just sit there and spin and spin and spin and when the time was up, then I did sort the GPIL. That burns a lot of processor time. Or do I assert the GPIL and just let the thread sleep? Linux does the work. And then when my thread is awake again, I go ahead and I drop the GPIL. That sounds like that's a pretty easy thing to do, but how much is accuracy going to suffer because of OS overhead? Good question. And then finally, is accuracy going to be better in kernel or in user space? Is user space going to be sufficiently accurate or do you have to be in the kernel? All right, kicking off the investigation, I thought I'll just start with a simple user space program. The job of this guy was to get the current time and store it. That's for my internal measurement. Then I'm going to drive the GPIO high. I'm going to do a microsleep. It's not a busy weight. I'm going to let Linux sleep the task for this first pass. Then I drive the GPIO low, get and store the time immediately after, compare it to the start time from step one, and then I store the shortest and the longest times. That way I can see what's my best case and what's my worst case. Now, in this first pass, I'm making no effort to try to minimize any latency. This is our control. I expect the accuracy to be horrible, and we will not be disappointed. This is going to demonstrate the problem. And that way we have something to compare. How much better did we do after we did some ways to fix the problem? Here's my first results. As expected, control is pretty pathetic. The shortest pulses aren't terrible. 30, I guess, 20 to 60 microseconds of slack there. But what is up with these longest times? I mean, that 20 milliseconds when it should have been a 10 millisecond, how can the processor go so far wrong? Anybody have any thoughts on that? Microsleep, does it use signals? I honestly don't know. I didn't look that up. On the Raspberry Pi, I knew that once. I probably knew it when I wasn't standing up here on the platform. But it's actually a more general reason why. It's something that I mentioned earlier. What's that? Definitely, the process could have been paged out. Yes, but more generally, remember that I'm running these terrible swamping tasks? I'm artificially swamping this poor Linux system horribly.  There are hundreds and hundreds of busy work tasks that are running. I start up the task. Its job is to fire off another version of itself and then start doing swamping things. So the new guy that gets generated, That's the next couple of slides. That's a really good segue. I like that. Here's your Bitcoin. That will be on the next slide as well. Another Bitcoin for you. So none of that stuff that you guys are talking about that immediately your mind jumps to got done here. There's no sort of way that we did. This is just plain old. This is how it came out of the Raspberry Pi box with Debian. And so we've got hundreds and hundreds and hundreds of these tasks that are doing. Let's see, I did a whole bunch of mathematics. There's one giant mathematical calculation. And so that's simulating a processor bound system. And then I'm doing a sync, which was easy to do in a script. And that sync is doing file system type work. So this poor system is just being swamped with hundreds and hundreds. And at one point it was hoping to get up like 5 or 10,000 tasks. But the poor Raspberry Pi keeled over at about 1200 of these swamping tasks running. And even when it was keeled over, 20 milliseconds isn't horrible for a totally swamped system like that. Now that of course doesn't count the case where the Raspberry Pi just stopped responding entirely because there were too many tasks. But still, it varies a lot. This is not going to meet the very accurate time that the customer was asking for. From 10 to 14 was too much, much less 10 to 20. Now I set that out as sometimes I got the 20 because I might have to run it for five, six minutes before I actually got the 20 milliseconds. And normally the worst case was around 14 milliseconds. But here we have Linux pulling the rug out from under us. And I mean the poor Linux, what else is it supposed to do? So we need to help it out, that's what we want to do. And you two guys gave some great, hey, did you do this? And that's the first things we ran for. So I was using the GPIO driver from Ask Me Afterwards when I'm not on the stage. I could give you all the details about that GPIO driver. But I was using one of the standard user space GPIO drivers. It's not known for being super fast, but it's not known to be onerous either. That was in C. I do play with Python, but at my heart I am programmed in C. So I first jumped to doing the scheduling thing. So I thought let's get, you know, tell the scheduler to be a little more intelligent. And I went for SCED FIFO. And then I said let's do top priority of SCED FIFO. And then so I didn't totally kill the system. I thought let's reserve a core just for this thread. So it's a quad core. It doesn't need four cores for Linux. It can use just three cores for Linux. So I stole one of the cores away and I said, we're just going to dedicate this specifically to our thread. We're going to make this thread the very highest priority and we're going to go with that. The idea being that no other threads do we want to run on this core at all, just us. Of course, this is only going to work on a multi-core system. If you did this on a single core system, I think things would go very badly very quickly. And then the last thing is to lock the task in memory to keep it from getting paged out. And this is something that obviously is only going to apply to user space. We don't so much worry about the kernel threads being paged at. So here are the results with those changes. We're minimizing latency. We're still in user space. We're just doing the things that we talked about. And pretty impressive when you see the difference here. We no longer have those scary 20 millisecond pulses. We've got some pretty decent time there. And we're definitely under that 250 microseconds that the customer talked about. And I let this run for quite a while. And there were a couple of runs that I maybe saw pop up to 120, 130. But I never could reproduce those. So I felt pretty good about, yeah, I think that'll stay under 250. But if you ever wanted to do something shorter, the customer was only asking for 10 milliseconds. But I always wanted to do the one millisecond and 100 microseconds and 10 microseconds and see where things were. The 10 microsecond one was a little distressing. It's like really, 10 to 97. That's kind of sad. Even the 100 wasn't great. 100 microseconds to 179. Okay, still meets the customer's requirements. But I really, yeah, 10 to 97. That's quite a margin of error there. I just, I wanted to see how much farther I could go. I certainly wasn't going to stop here. I'm sorry. Yes. Yes. Very good observation. We've got a 70 to 90 microsecond variance for all of them. So you're getting a pretty good look at the system overhead of a very swamp system. Now, again, remember, this is a very swamp system. So, again, this is pretty impressive. So in the swapping tasks that I'm doing, tasks are starting and dying. I didn't intentionally do that. But for some reason, these scripts at some point would start getting killed off. I think that the system was saying something's wrong here. And then new ones would start up because the task, every task is trying to start a new task. And yeah, there, and a few other things that I did. In fact, that's a very good point. Thank you. The 20 milliseconds that would occasionally pop up. I think that may have been in the case when I was secure shelling in just to start another window. So, but I also did that in these tests, try secure shelling in doing some different things. Not very deterministic because I'm just playing and, you know, typing on the keyboard at the time. But I never did see it go above the 92 microseconds above that. Sorry. The interrupt definition? Interrupt affinity. Oh, interrupt affinity. No, no. So far I've only used what it was that I talked about, that I explained in the previous slide. So no, no interrupt affinity yet. It very well could be, yes. And some further slides you'll be seeing some of the information that can lead you to that conclusion. I noticed that that shortest pulse is never going to be less than 10 milliseconds. One of the things that the customer was very insistent about is we can never have the pulse be less than 11 milliseconds. And so pretend it's 10 here. And I can't explain for confidentiality reasons what it was the customer was doing. But their requirement was the pulse could not even be, you know, a nanosecond less than their target's time. It could be a tad larger, but absolutely no smaller. So that's part of the reason I made sure to put up the times for the shortest pulse to make sure I never went under. But I took a look at the Linux man page for microsleep. So this is expected. And that page says the microsleep function suspends execution of the calling thread for at least the requested number of microseconds. The sleep may be lengthened slightly, slightly, by any system activity, or by the time spent processing the call, or by the granularity of the system timers, or, and you can add your own or as I'm sure there. Okay, then I pulled out our Saley logic analyzer, and I took some external measurements. And you can see I wanted to make sure that the internal measurements weren't terribly lying. And it turned out they were pretty good. During this for a second time, nice long four seconds, the desired 10 millisecond pulse was 30 to 80 microseconds longer than the ideal. So I got a pretty good feeling that the internal measurements weren't at least not horribly bad. All right, so the user space code was an interesting start, but I am a kernel developer. So once I got a few tests done in there, I'm like, all right, we're off to the core. We're just totally throwing away the user space code. So I didn't even try tuning that any farther. So in this case for the kernel, I decided just like before we're going to use SCED FIFO. We're going to use high real-time priority. We're going to reserve a core again. And this time we're writing to the GPIOs directly. That is, I understand, a bit of a no-no. You're bypassing the driver that has been put there for a reason, but if this is your system and you know no one else is going to be accessing the GPIOs, you're relatively safe. Just don't try to go do this on someone else's Linux system and go right to the hardware directly. As we all know in Linux, we have drivers for a reason, but I just wanted to make sure there wasn't going to be a problem with any latency for drivers I wasn't familiar with. I really wanted to get good timings. And then the question, can we disable kernel preemption? Another kind of a no-no, but you know, we're on our own core and if we're disabling preemption on our core, no one should have been preempting us anyway. Now, just to be a little more polite, I only turned off kernel preemption during the very important timing period, the entire time I had the core. Let's see. And then I wanted to compare the results between a sleep, using microsleep, or a busy weight, using micro-delay. And then because I'm doing kernel preemption, I also suppressed the CPU stalls. I kept getting lots of these, you know, kernel telling me the CPU is stalled because I've disabled preemption and I'm killing the core. And then turn off real-time throttling. I didn't want my real-time process not to get time because I'd taken up too much time already. So, here's the results. You can see, times are looking pretty similar to what we had in user space, which I guess isn't terribly surprising, but it's a little bit better in some and similar in others. And I will admit, being a kernel developer, I was a bit disappointed that it wasn't kernel rules, but we survived. But you'll notice the 40-microsecond delay and we're using microsleep for all these guys. Anybody have any idea, is this going to be, like, way better when we get around to using a micro-delay, you know, a busy loop? Is it going to be about the same or is it going to be worse? To be as much as you ask. How many are shorter? Yes, that is very true. That is a distinct possibility. I'm definitely not surprised. But what about the other end of it? Anybody got any guesses? Is it going to be better? Is it going to be worse? Better. Better. Better. Bitcoin for you. Okay, so comparing the busy-weight delay to the kernel sleep, a lot better. You look at some of these numbers. The longest worst-case pulses are 10 to 30 microseconds shorter than they were with the kernel sleep. The average is 10 to 35 microseconds shorter for busy-weight. And kernel sleep, you notice, we never get right dead on target there, whereas we seem to be really good with the busy-weight. Now, definitely take to heart the statement that was made earlier. If you absolutely positively can't have anything accidentally too short, be very careful using this because if you have to be sure of that, then you have to be careful about this. But even the averages, think about that. We have a totally swamped busy system here, and the average is a 5 microsecond over what you expected it to be. That's actually pretty impressive. Okay, now back to the busy-weight loop idea. Oh, sorry, Dave. I didn't draw them out. Because I was running on a Raspberry Pi, I was only keeping the maximum, the minimum, and the average. Storing a whole bunch of that stuff, I was afraid might actually end up skewing things, even though I guess that would have been even better to be having more disk access and all that, but no, I didn't do that. We were just more worried about what's the worst case, what's the best case, and what's the shortest case, I guess, and what's the longest case. For me, what I was looking for was, what's the very worst case? Because the customer wanted to know, am I guaranteed you're going to be able to give me a pulse no bigger than this? I kind of eyeballed the numbers, because I had print statements coming out so that I could take a look at. Every time I got a worse number or a better number, I would be seeing, okay, this happened. The worst cases tended to go through cycles and a distribution actually would have been really interesting to look at. Maybe that's something that would be good for our future investigation. All right, on the busy wait stuff, normally you're really cautious about running busy wait on a Linux system because you're burning processor time here and you're stealing from everybody else. But again, we're on our own core. Who are we stealing from? Nobody that we care about. But then the question comes up, well, what about some other things that might happen because you're running this processor so long? Is it going to start making the processor too hot? So if you're doing something like this, take a look at it and go, okay, am I running this busy wait loop 10% of the time, 20% of the time, 30% of the time, 5% of the time. If you're doing that, you're going to want to take a look. Am I going to have heat problem or are there any other side effects I'm going to need to deal with? So this is another one of these warnings. Don't blame me if you do this and something catches on fire. So I brought out the salient again and took a look at this four-second measurement and the pulses range between absolutely spot on to 30 microseconds too long. And then I did a close-up of the pulses so you could kind of see what they look like and this little range here, they're pretty much all at 10 milliseconds. And these pulses, like I said, attended to run in cycles. So this was a cycle when it was right there dead on at 10 milliseconds.  Oh, was there a hand raised? I'm sorry, Julia. Interesting thought, being out of phase with the scheduler. Oh, now that's interesting. Anybody want to do any experiments on that? Go for it. I would love to hear the results of that. Yeah, I like that. Okay, so here's the results with kernel preemption turned off. So the previous one was with kernel preemption on and I wanted to compare it. And I was kind of disappointed. Things are a little better, but not like significantly better. And then I thought about it and went, oh, there's nothing else running on our core pretty much. So what is there to worry about preemption with? Yes, that slide is coming. Now, I didn't do it specifically for that core, but I did take... I'll be showing you some top and top will show you how much time was spent in interrupts. Interrupt affinity. Yes, interrupt affinity is a very good thing that needs to be done in the future on that. I've got that on my list of things to think about. I can give the end of this sad story already. We told the customer that we had some good results and we thought this could be done. And they went off and did it themselves. So as we have learned, you don't always just want to tell people some answers without making sure that you have a contract signed. So in essence, we never did end up finishing the project because we started the investigation and we didn't get the contract. I don't remember on the previous slide. The worst case was, oh, for the hundred. No, no, that's a very good question. I do remember seeing that earlier, being a little puzzled by it. But again, since our target was the ten, that's the one that I concentrated on. But yes, that's a very good question. Why do we see the results for the busy weight being a bit worse than for the kernel sleep for the hundred and for the ten? And again, if anybody wants to investigate that, that would be a great thing to add to the white paper. Could be interrupts. Yes. Yes, it definitely could be another interrupt going on. Dave? When the system was completely idle, I did do that and it ended up everybody was just working great. We only had, I did not print that slide, I'm sorry. If I remember right, it was like never worse than like 20 microseconds off. It was for the busy weight. With the kernel sleep, I don't think it was much worse than that if I remember with the unloaded system. But take that with a grain of salt. That's numbers that I sillyly did not print, sorry. Back to... Okay, so here's top. The first question I wanted to know was, do we really own this core? So, let me find the pointer here. So you see, I've sorted things in top here by which processor core we're on. And my first shock was, oh my goodness, what are all of these threads? I thought I told Linux not to do that. Well, Linux has its threads. It's going to put on every kernel whether you tell it to or not. So here's these threads out here. But when you take a look, they really haven't taken up much of any time. Now, this guy is... I think this is the running one, right? Okay, yes, the R, I can see it. But again, he's really not taking much time. And then the SH here, my kernel thread is running under this shell. And you can see it's taking 100% of its core. If you look up here on the rest of it, 25.2% system. I'm assuming that 25 is my thread. And then 74.8% idle. That's like, oh, okay, pretty much 75%. The rest of the system is pretty well idle because those three cores have nothing running on it. This is obviously not a swamped version of the system. This is when I'm just running my test without any swamping going on. So if I were to print the rest of this, it would be an eye test.  Then I said, okay, let's do the same measurement when we have the total system being swamped. And pretty quickly, you go, ah, let's check this out. We have, I can't read that number. Is that 24.5? 14.5, thank you. 14.5, user sum number system. And down here is system interrupts. So this is back to your question that you were asking. We definitely have got some system interrupts going on here, and there's a very good chance that some of those may have been thrown on our core. And by doing some of the dealing with the interrupt affinity, sorry, I could have gotten, made sure none of that was happening on our core. So I don't have any good data on that. But taking a look at this, we definitely are completely swamping this poor system. There is no spare cycles anywhere. There is zero idle. And seeing how busy the system is, and seeing how good those results were, I was actually pretty impressed. We're way under what the customer said at 250 microseconds. Okay, now that was the Raspberry Pi. Even though we met with the customer...  CPU. I did not enable any frequency scaling. I don't know if that's standard in the Raspberry Pi, Debian or not. It does or it doesn't? Okay, you think the chip doesn't have frequency scaling, then that would definitely answer that question. Okay, okay, thank you. And what was your first question? I don't remember. Oh, how accurate was the timing? So were you referring to the timing as in my internal timing that I was doing? I was using the high-resolution timers. So the high-resolution timers go down too. I remembered at one point. Very nice. It wasn't in Jiffy's, I can tell you that. I immediately... Pardon? It's in nanoseconds. It's in nanoseconds. But I know the Raspberry Pi hardware doesn't support the nanoseconds. So it goes to whatever it is? Yeah, whatever the Raspberry Pi has in that case. So, yes. But that's part of the reason why I did a lot of external timings just to verify that my internal timings weren't going to be, at least, magnitudes of error off. They seem to be awfully close to what I was saying. Okay. Oh, thank you, yes. Yes, yes. Not for that one. I actually did throw it on the oscilloscope because I happened to be in the lab when I was first doing the tests. And then I went back to my desk and I was doing stuff with the logic analyzer. I wasn't seeing anything vastly different, so I wasn't terribly worried about what I was seeing. And plus, it was kind of verifying what my internal measurements were. So again, I wasn't really worried about it. Okay. So even though I met all of the user requests for using the Raspberry Pi, you can never get enough accuracy. So I thought, let's see how good we can get with the Beaglebone Black. I actually, before I started working on this, had very little familiarity with the Beaglebone Black from actually working on it other than, you know, just having, you know, people, you know, playing with it in the past and me seeing it running. So this is my first chance to really dive in there and get to know it. So for those that don't know, it's a single core arm, which is for, that's for the Linux. That's an A8. And there's two PRU cores. Now, the PRU cores are programmable real-time units. Now, we've got the single core A8. So this trick that we had of, let's take one of the cores and let's isolate it over here and let's make sure that nobody can touch it, obviously it's not going to work on a single core A8. But these two PRUs, let me give you some of their statistics here. They are 200 megahertz 32-bit processors with single cycle IO access. Each has 8K of program RAM and 8K of data RAM. There is a 12K shared data RAM between them. There are 25 low-latency IOs for the PRUs and at 200 megahertz, a PRU gives deterministic submicron GPIO control down to 5 nanoseconds. And they're not pipelined, so you're actually getting real-time response. So I thought, ooh, these PRUs are pretty nice. We could do some pretty nice stuff with this. Let's check that out. And notice that they're, this is a very, very simplified picture of a Raspberry Pi. I ripped out most everything out of there, but notice what I've left in there is there's a connection between the PRUs and the Cortex A8. Keep that in mind for the next few slides. So obviously you're not going to be running Linux on these PRUs. They're way not enough RAM for that.  So the thread's going to be running on the PRUs. And since there is no OS, there is no OS overhead, which is quite an advantage. All the advantages of an OS go away as well, and we know the advantages of having an OS. So you're going to create a thread, and in my case, I need to create an exact pulse width. So I'm going to count the number of lines of code I've got, because each one of those is going to be taking the execution time of five nanoseconds. And then I put the delay in there for how long, for how wide I want the pulse to be, and that's going to be my pulse width. And as I just mentioned, I've got a connection between the PRUs and the AA8. So a thread on the PRU can communicate with Linux on the AA8 and vice versa.  Okay, no. Oh, okay, okay. Yeah, I didn't look into them. I just knew they were the PRUs. I'm sorry? Oh, they look more like a CPLD. Interesting. Well, you know, I just sat down and learned the programming language and went for it. Oh, so for more information on the PRUs, three years ago, Rob Burkett did a presentation enhancing real-time capabilities with the PRU, and I ended up using that to figure some stuff out, so that was a pretty good presentation. All right, steps to getting stuff working on the PRUs. So you had another presentation, one that Jason Kridner did that's on the Beaglebone website. So you write and compile the firmware that you want running on the PRUs. You use the AA8 when it's going to be running Debbie and Linux to load this firmware onto the PRUs, then create device tree entries to configure the kernel and the IO pins. Obviously, I need to drive a GPIO, so I need to tell the system to let me have access to the GPIO pins. And then implement a communication mechanism between the AA8s and the PRUs. So the PRUs, these guys are very accurate, obviously, but they're limited. They don't have a lot of RAM. So you're not going to be implementing megabytes of code on them. You're going to need to figure out how to divide up your logic between the AA8 and the PRUs. You're going to be doing any non-real-time stuff on the AA8 in Linux and any real-time stuff on the PRUs. I was very fortunate that for my experiments, I really didn't need to have the AA8 do much of anything. It's just going to load up the PRUs because all of the work pretty much was being done on the PRUs. If you remember, I'm driving the GPIO line high, doing a weight, and then driving the GPIO line low. That didn't take a lot of code, so I was pretty much on the PRUs. Now, there's two commonly used drivers to load code on the PRUs from the AA8. One of them is called UIO-PRUS. It memory maps all of the PRU registers in the user space. Now, that can be a bit dangerous, but some people find it easier to use. What's actually much more highly recommended to use is PRU-RPROC. This is a proper Linux driver using remote PROC. It's very much preferred. I use PRU-RPROC. When I was talking to Jason about it, and I mentioned that I was using PRU-RPROC, he was like, thank you. Evidently, it's very strongly preferred. Eagle bone black results. Wow. My logic analyzer actually couldn't measure any error. I hit the Nyquist sampling limit, so I moved over to our high-speed oscilloscope, and it showed that the error was on the order of no more than tens of nanoseconds. I actually need to take a look at my code a little better and make sure that some of that error actually wasn't my fault in counting the instructions in my loop. If I were to create a chart for the Eagle bone black like my previous charts, I would have the ideal pulse, the shortest pulse, the longest pulse, and the average pulse all pretty much having the same values. That would be a really boring chart. I didn't bother creating that chart. Again, you can never have too much accuracy. What happens if you do a 25 microsecond pulse? Forget the whole 10 millisecond pulse. How accurate are we going to be down at 25 microseconds? Back to the oscilloscope, my high-quality photograph I took here. Some of the pulses are 25 microseconds, and you can see down at the bottom, maybe you can or can't see at the bottom. Some of the pulses were 24.95 microseconds. Pretty accurate. Then I decided to zoom way in just to see what the quality of these signals were. I was actually impressed how clean that was. Now, I didn't use any special connectors for the measurement. I just took the probe and popped it right on the little debug output of the header, so that is impressively clean. What's that? I would assume the ringing is the probe. Yes, exactly. I looked at that and went, huh, pretty impressive. These PRUs really impressed me. Yes. On this one, I didn't do any interaction between Linux and the PRUs other than Linux is loading up the PRUs and just saying go. At that point, it's completely self-contained.  The only other thing that I didn't do a slide for is I set up the other PRU. This is one PRU. I set up the other PRU to look for input from another line, and I could just stop the thing from running. I didn't even do any timing to see how quick that was. That's a really good question is how accurate, how quick is the communication between the two? The BeagleBone Black has set up some really good paths between Linux and the PRUs. If you use certain ones, you're definitely going to be getting a lot more accuracy than if you use other ways of communication. Oh, my goodness, time is just about up. I am so sorry. How did the busy work processes affect the PRUs? Eh, not really. I didn't expect that they would and they really didn't. The busy work processes run on Linux on the A8. The PRUs don't even know or care about them. Linux is the bootloader for the PRUs in this case, yes. That's a good way of looking at it. Now, the one thing to remember, if you do end up having a lot of A8 interaction with the PRUs, any busy work that is happening on the Linux processor could be impacting that. Which one should you use, the BeagleBone Black or the Raspberry Pi? It's one of my coworkers that's famous for saying, what problem are you trying to solve? Well, do you need deterministic control and you feel comfortable writing threads on the PRUs? Definitely go for the BeagleBone Black. That will work great for you. Do you feel more comfortable writing all of your code in Linux and you don't mind 100 microseconds, 200 microseconds moving around a little bit? Raspberry Pi is going to work for you. Future investigations, interrupt affinity, dedicated PRUs, cache misses, can we lock all the code in that L1 cache? And would we get any advantage driving spy instead of GPIO? And then, yeah, all of the stuff that people have been asking about. Someone really ought to do that. Great details of the experiment and go get the white paper. It actually isn't live right now. It will be very soon that white paper is being formatted as we speak. Go to the Downloads tab, which is currently under our Game Changers tab, and download it. Feel free to send us email, let us know. If you did anything with this, if you want more details, we'd be glad to talk to you. Thank you.


Hello, welcome to the Koenig section YouTube live session today So those who have just joined in Please type in your name in the chat box so that I know who all are attending this session All right guys, so today's session We are going to start with the fact that why at all Koenig sections are known by the name Koenig sections okay, so Koenig section is basically Given the name because they have been obtained by the section of a right circular double cone with a plane Right, so these Koenig sections they are obtained by They are obtained by the cross section of a right circular double cone a right circular double cone by a plane Okay, so depending upon how these planes or how this plane passes through the right circular double cone Different Koenig sections are generated. Now. What is the right circular double cone a cone which has got? Let me explain this to you first a cone is basically Right the right circular double cone is basically a structure like this where this is called the axis of the cone So this line is called the axis of the cone. Okay, and these two lines are known as the generators These two lines are known as the generators When the axis of the cone makes 90 degree with the base of the each cone We call it as a right circular double cone. Okay, so I will now show you How basically these Koenig sections are generated? Okay, so let us focus on Let's focus on this structure So I can as you can see on your screen. Okay, so basically this is nothing but a right circular double cone Okay, so I've shown it in a 3d structure now this right circular double cone if I cut it by a plane which is perpendicular to the axis Right as you can see here I've cut it by a plane which is perpendicular to the axis the cross section area from the top You can see is that of a circle Okay, so the cross section area that you can see is that of a circle Okay, if you cut it by such a cone or Such a plane which is making some angle Okay Then you realize that you start getting different types of Koenig's Okay, in this case you end up getting a hyperbola Right, so these basics are all cleared in your mind and If there is any question regarding the basic of creating a Koenig section, please do ask in fact, I will quickly brush you through So when you cut this by a plane When you cut this by a plane Whose angle with the axis let's say is Let's say I call the semi vertical angle of this right circular cone as as alpha and let's say this angle is theta Okay, the angle of between the plane and the Axis is theta if theta is 90 degree it generates a circle Okay, and if this plane passes through the meeting point of these right circular double cone the circle would be a point circle Okay, if this theta is somewhere between 0 to somewhere between Alpha to 90 degree Alpha to 90 degree it will create an ellipse It will generate an ellipse Again here. I'm assuming that it is not passing through the meeting point of the generators okay, if Theta is exactly equal to alpha That means the angle made by the plane is parallel to either of these generators The cross-sectional area left would be that of a parabola. Okay, and if theta lies between 0 to alpha Then it would end up cutting both the Naps these are called naps Okay, both the naps of this right circular double cone and You will obtain a hyperbola in that case If it passes through the meeting point if it passes through P if the conic section passes through Or if the plane passes through P if the plane happens to pass through the point P Then the next we call the conic generated as a degenerate conic Okay, and pair of straight lines is an example of a degenerate conic So first I will spend some time on the degenerate conic in order to explain you What is the general form of the equation of a conic section? So let's talk about pair of straight lines briefly What's a pair of straight lines? pair of straight lines is basically a kind of a degenerate cone where you obtain the Equation of this pair of straight line by multiplying two lines Okay So if you start by multiplying two such lines which are passing through Let's say origin y equal to m1x and y equal to m2x Okay, if I ask you these are the lines which make that pair of straight lines Then the combined equation of the pair of straight lines would be y minus m1x times y minus m2x equal to 0 right, so this is the Equation of a pair of straight lines which is passing through origin Which is passing through or intersecting each other at origin So both the straight lines are passing through the same point origin. Okay, if you clearly look at this expression It's very important for you to appreciate that This expression will be a homogeneous Expression in x and y okay, so we call this as a Homogeneous function or homogeneous equation in two variables This is going to be a homogeneous equation in two variables of degree two of Degree two so what is a Homogeneous equation a homogeneous equation is basically a equation where you would realize all the variables are having the same degree for example x square Y square x y they are all having the same degree. Okay, so any second degree Equation which is homogeneous in nature in two variables that would always represent a pair of straight lines passing through origin This is very very important so always remember this Any equation of this nature a x square plus 2 h x y plus b y square Will always represent a pair of straight lines Passing through origin Now it is not necessary that both the lines would be real in nature It may happen that you may also end up getting non real lines as well, right? You may end up getting imaginary lines as well that depends upon some relationship between h a and b that I will discuss with you later on Okay, now taking a clue from this You would realize that any conic that you see is going to be having a general formula or the general equation as a x square plus 2 h x y plus b y square plus 2 g x Plus 2 f y plus c equal to 0 Right, this is the general structure of any conic section that you would come across Right, which is called a second-degree general equation of a conic section. So even your straight lines as you can see here The the homogeneous its equation itself is basically is a second-degree equation Even circle parabola ellipse will have these six terms appearing not on it's not necessary that all of them will appear together It may happen that some of them may be absent Now, how why is this a second-degree equation? Guys, if you if you see a very specific case from the example which I cited a little while ago the equation of the equation of if you see the equation of Cone I've taken passing through the origin as z square equal to x square plus y square, right? So this is the equation of the cone okay, and If you take any line any plane, okay, let's say I take this plane x plus y plus z equal to 1 Okay, and you try to Eliminate your z from these two equations So from the plane equation and the cone equation if you try to eliminate your z Okay, you would realize that Let's say this was the equation of the cone Okay, and let's say this is the equation of the Plane any plane. Okay, so I'm taking just a simple Example of a cone and a plane if you try to eliminate your z that means replace your z with 1 minus x minus y in this You yourself would see that When you square such terms You'll end up getting some terms in x square Some terms in y square You'll see some term with x y You'll see some term in x you'll see some term in y and you'll see a constant, isn't it? So that is what we are trying to state in the previous slide that Any conic section would have This kind of a structure. Sorry this kind of a structure a x square Plus 2 h x y plus d y square plus 2 g x plus 2 f y plus c equal to 0 Right so far any questions with respect to this Okay, so this is the general structure of any conic section Now depending upon your values of a b and a b h g f and c this conic section can represent various things Right, so now we'll discuss the condition to represent various conics Condition to represent various conics The first condition that I'm going to talk about that's the very important condition if a x square plus b y square plus 2 h x y plus 2 g x plus 2 f y Plus c equal to 0 has to represent a pair of straight lines If it has to represent a pair of straight lines then an expression delta which is given as a b c plus 2 f g h minus a f square minus b g square minus c s square will be equal to 0 that is In a simpler form the determinant made by these terms Will be equal to 0 Right now first of all I will prove how these condition comes so let us prove how this condition comes Okay So let us start with the fact that let a x square Plus b y square plus 2 h x y Plus 2 g x plus 2 f y plus c equal to 0 represent a pair of straight lines Okay, let's say this represent a pair of straight lines Of course since this is not a homogeneous equation that means Their point of intersection of these lines is not origin because had it been origin These three terms would have been absent right So let's say these pair of straight lines This pair of straight lines intersect each other at Let's say they intersect each other at x1 y1 and we are assuming that these lines are also not parallel to each other. Okay Then do one thing then apply the concept of shifting of origin shifting of origin to x1 y1 That means I'm assuming the point of intersection now to be my new origin okay, so when we do that all of you remember the concept of Shifting of origin where you replace your x with Where you replace your x with capital x plus x1 and y with capital y plus y1 So this was the concept which we had discussed in the beginning of the coordinate geometry chapter in class 11 So when you do these replacements in your equation given to you you get something like this a x plus x1 square Okay, b y plus y1 square plus 2h x plus x1 y plus y1 2g x plus x1 2f y plus y1 Plus c equal to 0 okay, and If you simplify this you are going to see something like this a x square by square 2h x y and Apart from that you will see terms like 2a x1. I'm collecting terms having capital X in it so 2a x1 I will see then from here. I will get h y1 and I will also get term like 2g Similarly, if I collect terms containing capital Y I Will get 2b y1. I will get 2h x1 and I will get 2f term correct and If I collect the constant terms, I will get a x1 square b y1 square 2h x1 y1 2g x1 2f y1 plus c equal to 0 Okay Now all of you please listen to this very very carefully if You want this pair of straight lines to pass through origin It is passing through origin Then it is very clear that it has to be a homogeneous equation And if it has to be a homogeneous equation that means this term this term and This term should be 0 Remember, I discussed with you Any homogeneous equation of Second-degree is basically representing a pair of straight line passing through origin and Since I am shifting my origin to the point of intersection x1 y1. It means that I am assuming that These terms are going to be 0 This term is going to be 0 This term is going to be 0 and this term is going to be 0. Is that clear? Because if these three become 0, I will only end up getting this term Which is a second-degree term and hence it will represent a pair of straight lines passing through origin so this implies We have a x1 H y1 plus g equal to 0 We have this is x1. Yeah, this is H x1 plus b y1 plus f equal to 0 and Guys, if you note your expression very very carefully If you note these expressions very very carefully you'd realize that you can write this as x1 into a x1 plus H y1 plus g plus This expression I am simplifying plus y1 into H x1 plus b y1 plus f and The remaining terms would be g x1 f y1 plus c So what I did is I took an x common from this term and One of these terms I split it open as H x1 y1 plus H x1 y1 So I took a x1 common from this term and I took x1 common from One of these terms.  I will get this term, okay, and the remaining terms that is G x1 f y1 and c I am writing it over here Is that clear any question regarding this so far now from 1 and 2 we already know that these two are Zero this is zero. This is zero Correct. That means I get a third equation from here. That is g x1 f y1 plus c also equal to zero So I get three equations altogether Like this. So this is my third equation now using these three equations I would now eliminate x1 y1 Okay, so from this you try to eliminate x1 y1 Okay, and how do I eliminate it if you remember the trivial solution concept of a System of homogeneous equation or a system of linear homogeneous equation the determinant If this determinant is equal to zero Okay, then this system of equation.  They are not going to be a trivial solution over here Okay, so if this system of equation doesn't have any trivial solution We can say that the determinant formed by the coefficients Okay, so basically let me treat one over here if nothing is there So the coefficient of these variables would form a determinant, which is equal to zero, right? And if you expand this you are going to end up getting the desired result, which is a b c plus 2 f gh Minus af square Minus bg square minus c s square equal to zero. Is that fine? Is that clear? So this is the condition which we write in a very short form as delta Okay, so if delta is zero your second-degree equation will definitely represent a pair of straight lines Now what about the rest of the conics? What about the rest of the conics like circle parabola ellipse hyperbola? What can you comment about all these things? So for that we have to understand the locus definition of all the conics Okay So what is a conic section? The conic section is basically locus of a point which moves in a plane in such a way in Such a way that the ratio of its distance from a fixed point perpendicular distance from a fixed Line is always a constant Okay, and this constant is known by the name of eccentricity and this fixed point it can be fixed points as well They are known by the name of focus and this fixed line is known by the name of directx. That is what we already know okay now there is This word eccentricity which comes up and this eccentricity actually helps us to differentiate between different different conics Okay, if e is equal to 1 It would represent a parabola okay, if e is Between 0 and 1 it will represent an ellipse if e is greater than 1 it will represent a hyperbola if e is equal to 0 it would represent a circle and if e is tending to infinity a very very large number Then it will become a pair of straight lines. So hyperbola is a Limiting case when e tends to infinity your hyperbola will start behaving as a pair of straight lines Now, how is this e connected to your? Second-degree equation. How is my e connected to the second-degree equation that we had learned a little while ago? So we realize that if e is equal to 1 if e is equal to 1 That means if it represents a parabola Then these coefficients of these this equation would actually satisfy the condition h square is equal to AB Okay, now a question will arise in your mind. How? Right, we have been studying this when h square is equal to AB in this equation It will represent a parabola. So, how is this e equal to 1 linked to this h square equal to AB? Okay, for that I would write the equation of a general conic Okay, so let's say the fixed point focus Let's say it is a point which is I can say alpha comma beta Or let's say h comma k and let's say the fixed line or what we call as the directrix So let the directrix be Lx plus my plus n equal to 0 now from the locus definition From the locus definition of a conic section This is going to represent a conic for me that is the distance from the fixed point is e times the distance of The point x comma y from this fixed line right I should not take h and k because h and k has already been used. Let's take alpha beta for the sake of More clarity Let's say alpha beta Okay, here also we'll take an alpha beta Okay Now let us square both the sides if you square both the sides you get x minus alpha square y minus beta square is equal to e square by l square m square l square m square And lx plus my plus n whole square Okay, let's cross multiply l square m square times x minus alpha square y minus beta square is equal to e square And we have lx plus my plus n whole square Okay, now We all see that a is basically when you say h square is equal to ab h is basically the Half of the coefficient of x y half the coefficient of x y a is basically the coefficient of x square b is basically the coefficient of y square, right? So let us focus only on these terms.   Okay minus e to the power 4 l square m square.   So 2 I have taken out common Okay, so if I take a 2 out common I will be left with this Sorry, it will be plus in between It will be plus in between. Okay Now this is clearly 1 minus e square times l square plus m square whole square. Isn't it? Okay Now guys listen to this explanation very very carefully. In fact, I will take you to the next page So, we know a b a b minus h square is 1 minus e square times l square plus m square whole square So, let me take you to the next page Now you realize that when e is 1 When e is 1 What will happen to the right side of the expression? What will happen to the right side of this expression? You will say that the right-hand side of the expression will become 1 minus 1 times l square plus m square whole square That is equal to 0 Isn't it and that is the reason why we get h square is equal to a b For a parabola getting this point Yes or no When e is between 0 and 1 what happens? When e is between 0 and 1 what happens?  So, how is this e related to h square minus a b is what I am trying to explain you over here If e is greater than 1 What happens? What happens?  So negative into positive will be a negative term That means a b minus h square will be less than 0 That means if h square is greater than a b it would represent a hyperbola It would represent a hyperbola Is the point clear? So how these conic sections are coming it is clear to you and if e is equal to 0 what is happening?  That for a circle we have an additional condition that a should be equal to b And H would become 0 Are you getting this point? Now for all these cases which I have discussed so far Your delta should not be 0 Your delta should not be 0 for all these conditions Else it will become pair of straight lines Is that fine? So guys, this is the basic introduction of a conic section And today I'm going to start my discussion with a circle In fact, I'm quickly going to Take you through j e main and j e advance concepts But at the same time I would quickly revise whatever you have learned in circles so far without you know much delay So let us start our discussion with the first conic which is the simplest of all which is the circle Okay I'm not going to take a lot of time For revision just a few things that I want you to all know first You should know the equation of the circle in various forms Okay, so we'll start with equation in various forms first one is the center radius form the center radius form which is quite Familiar to all of you guys So if we have a circle Okay, if you have a circle Whose center is at h comma k and whose radius is going to be a units Its equation is given as x minus h whole square y minus k whole square equal to a square No doubt about it very simple concept Second is the equation of a circle in parametric form For the same circle, which I have mentioned right now over here For the same circle if you write the equation in parametric form We write it as x equal to h plus a cos theta And y is equal to k plus a sin theta Here theta is a parameter Theta is a parameter if you try to eliminate this parameter You will end up getting the center radius form of the equation of the circle Okay Quickly moving on this is all known to you So I'm not going to spend too much time on it Third is The general form The general form of the equation of a circle As we have already seen in case of a general second degree equation A and B should be same So what I did is I assumed them to be one or you say you can divide throughout with A or B And this becomes the general form of the equation of a circle Where the center of the circle is given as minus g minus f And the radius is given as Under root of g square plus f square minus c So this is also known to you guys no need to waste too much time on this The fourth form is the diametrical form Diametrical form Of the equation of a circle so whenever a circle is given to you Whose extremities of the diameter? So let's say this is the diameter So let's say extremities of the diameter are given to us as x1 y1 and x2 y2 Then we write the equation of this circle as x minus x1 x minus x2 Plus y minus y1 times y minus y2 equal to zero Okay So nothing hard and fast about this. This was all known to you fourth is The equation of a circle equation of a circle passing through passing through three non-colinear points three non-colinear points Very important normally people tend to forget this It is in a form of a determinant Okay Where the first of the determinant is x square plus y square plus x y1 Second row is x1 y1 square passing through three non-colinear points. So let the point be x1 y1 x2 y2 and x3 y3 x3 y3 So it will be a determinant given by x square plus y square x y1 x1 square plus y1 square x1 y1 1 x2 square plus y2 square x2 y2 1 And x3 square plus y3 square x3 y3 1 Now guys, how does this equation come about this equation comes in a very simple way So let the equation be x square plus y square plus 2g So i'm going to prove this quickly 2 fy plus c equal to zero let this be the equation of the circle Okay And since it satisfies these three points x1 y1 So x1 y1 will satisfy this equation x2 y2 will also satisfy this condition And x3 y3 will also satisfy this condition Okay now All I need to do is I need to eliminate Eliminate gf and c from this equation Okay Now again treat these numbers as coefficients Okay These numbers as coefficients Of gf and c and 1 Okay Treat them as coefficients So these are all coefficients of g f and c and 1 And the determinant formed by them should be equal to zero Okay So the determinant formed by all these coefficients should be zero because you know Your gf c etc and 1 cannot be trivial Right So treat this in light of a trivial solution of system of homogeneous equation You directly get this expression I would request you to remember this expression because it proves To save a lot of time You cannot afford to sit and derive this in the examination hall Right and it's very easy to use this formula Okay So these are the various forms of the equation of a circle Now we are moving to the next concept intercepts made by The x and the y axis is In fact, you can say intercept made on The axis is By a circle So let's say There is a circle like this Okay This is my y axis and this is my x axis So basically if I want to know how much intercept has been cut by this circle, let's say it's x square plus y square plus 2 gx Plus 2 f y plus c equal to zero on the x axis Okay That means I need to know what is the length ab Please note that ab is not the diameter. It is the intercept Cut on the x axis So how can I find ab? Very simple. You'll say put y as zero Right when you put y as zero You get x square plus 2 gx plus c equal to zero And we know that this point Will be something like x 1 comma zero this point will be something like x 2 comma zero And what I need is what I need is mod of x 1 minus x 2 correct So how will I get that very simple? You know its roots are going to be x 1 and x 2 Correct. So x 1 plus x 2 will be minus 2 g x 1 into x 2 will be c So we know the formula x 1 minus x 2 whole square Is x 1 plus x 2 whole square minus 4 x 1 x 2 That is going to be 4 g square minus 4 c So x 1 minus x 2 mod will be under root of this which is going to be 2 under root g square minus c So remember this result. It's very very helpful in many cases However, you can also find it out by using the fact that you know the distance of the origin from the x axis that is nothing but the Ordinate of the center and you know the radius So you can always find this length and double it up. That's another way But it's very important to understand or look at this concept from quadratic equation point of view as well Similarly the intercept cut on the y axis. Let me call it as cd Okay intercept cut on the y axis will be 2 under root f square minus c So please remember this result cd is 2 under root f square minus c And ab is 2 under root g square minus c Please remember this result as well moving on Next concept is position of a point position of a point With respect to a circle With respect to a circle So if you have been given any circle whose equation is x square plus y square plus 2 g x plus 2 f y plus c equal to zero The first thing that I want to discuss over here guys This term henceforth would be referred to by the name s Okay s stands for second degree equation So this is a second degree term. So I will represent this term by s Okay So this expression is x This expression is called s Okay Now when I substitute let's say I talk about this point x1 y1 being inside the circle Okay, let's say it is at position a When you substitute x1 y1 into In place of x and y I would call that expression as s1 Okay So if the point is located within the circle that means in case Where the point is at a You realize that your s1 would be negative that is The value of this term that would be obtained by substituting such a point which is within the circle would be a negative number Okay, if it lies on the circle that is your case b Of course, you know the point is going to satisfy the equation. So s1 is going to be zero And if it is outside the circle, let's say at point c So for case c it would be greater than zero Okay By the way s1 is called the power of the point With respect to the circle With respect to the circle So we say power of a point if it is negative at the point lies within the circle If the power of a point is equal to zero it lies on the circle And if power of the point is greater than zero it lies outside the circle And one important thing I wanted to discuss over here is that If the point actually lies outside the circle Let's say I take a small case over here Let's say this is the point x1 y1 Okay So when you draw a tangent from this line on to this circle, so let's say I call it as pt Then length of pt is going to be under root of s1. Please remember this Okay, so if you square root the power of a point You will end up getting the length of the tangent drawn from the external point on to the circle and as you can clearly see If the point is within the length of the tangent will come out to be imaginary And if the point is on the circle, it will come out to be zero And if it is outside the circle, it will come out to be positive Next is the concept of intersection Of a line And a circle Intersection of a line and a circle So let me draw a circle quickly over here. So let's say this is a circle And let's say we have a line Then this line And this circle will interact in three ways One is this Another is like this And another is like this Okay So there can be three situations The line may cut the circle as in a or touch the circle as in b Or not even touch the circle as in c Okay So now let the equation of I'll take a very simple case. Let the line be y is equal to mx plus c And let the circle be the standard case Of a circle That means having its center at origin and radius as a Okay Now in order to know the condition for a b and c what I will do I will simultaneously solve the equation of this line with the circle So I will simultaneously solve this So I would replace y with mx plus c in the second equation Which will end up giving me this quadratic equation Okay And if this quadratic equation has So let's say I call this one So if one has real roots Okay, if one has real roots Then it will lead to the case a Okay if one has Sorry real and distinct roots. I should say real and distinct roots. It will lead to condition a If one has real and equal roots It would lead to condition b that is the line would touch the circle and if one has Imaginary roots it will lead to your condition c correct So real root means b square minus 4 ac should be greater than zero that will give you 4 m square c square minus 4 1 plus m square c square Minus a square would be greater than zero Right So if you simplify this you will end up getting a square Let me drop the factor of 4 from everywhere So if you drop the factor of 4 you'll get m square c square minus This greater than zero expand it Okay So these two terms will get cancelled So you'll get c square lesser than a square plus a square m square That is Your c square will be less than a square 1 plus m square for you to have Real and distinct roots. So this is your case a So this becomes your case a Correct Similarly Without wasting much time. I can say for case b Your c square will become equal to a square 1 plus m square Okay, this condition is of importance to us because we call this as the condition of tangency We call this as a condition of tangency For a line y equal to mx plus c to be tangent to The standard case of a circle x square plus y square is equal to a square and finally You can say situation number c Where c square will be greater than a square 1 plus m square Is that clear? So now we'll discuss more about the second condition over here. That is the condition of tangency So again, let me first make a circle over here So this is the standard case of a circle Now this is called the point of contact p is called the point of contact Now if I mention that this line has a slope of m This line has a slope of m And it happens to be tangent to this circle Okay Then what could be the possible equations of this line? So you can say that there can be two situations for A line having a slope of m to be tangent to this given Circle one can be a line as shown to you and another can be a line like this Right both these lines will have the same slope of m correct So how do we get these two equations? How do we get the equation of line? root Plus minus a under root 1 plus m square Okay That means the equation of L1 and L2 Can be written as y equal to mx plus minus a under root 1 plus m square Okay, guys, this is called the Slope form of the equation of a tangent slope form of equation of a tangent to this circle now Can you guys help me to get the point of contact? How do I find p and q that is the point of contact of this line with the circle? Guys, is it audible? Can you see the screen? Am I visible to you guys? Tapas, Atmaish, Matli Can you see the screen? Oh Let me check Can you see it now? Oh voice is audible, but the screen is black Still not visible But it says you are Sharing the screen already Now is it visible? Some problem has occurred Now is it visible? Just Let me try Please let me know when it is visible Is it visible now? Let me let me drop this and send you a new link, okay? Let me just end this broadcast


the social media influencers, the memes, the chainsaws, which I want to talk about because he is fan, there he is on the cover of an AP article, wielding a chainsaw, his supporters. There's videos of them running chainsaws. I even saw a guy with a chainsaw mask, like walking into the voting booth. The title of this article for our listeners is a man, a plan, a chainsaw. And that's because Millay has presented something called the chainsaw plan. Here, this quote at the beginning, to your point, he says, the cast is trembling. He yells while brandishing a chainsaw. And he presented the chainsaw plan in central Cordoba province in June, 2022. It is his blueprint for the wholesale reform of the state to slash public spending, scrap half the government's ministries, sell state-owned companies and eliminate the central bank. That all sounds pretty good to a libertarian. If he is elected, what are the political realities? How much of that of his agenda do you believe that he could accomplish? Well, that's a good question because it's key to what many voters are considering when thinking about voting for Millay. The reality is that if he gets elected president, his party will not have more than 15% of Congress seats, neither in the House of Representatives nor in the Senate. So he will command a minority and not even the first one. The first minority will be the Peronist party. Then you will have the Juntos por el Cambio Coalition. If it still exists, and otherwise you will have many small parties, and then you get his. So he will not have more than 15% of all Congress people, which is going to be a problem for sure if he doesn't cut any alliances. Now the question is, after Bullrich's endorsement last night, and we're expecting an endorsement by, a formal endorsement by President Macri, who's just, he hasn't formally endorsed him, but not officially yet. If he cuts an alliance with them, he may increase the size of his legislative group, but it's going to be hard for him to form majorities in Congress. And then there's the question of who would be, part of his team, of his economic team, who would be his ministers, his minister of economy, for example. We don't really know much about that. There's some expectation that an alliance with Bullrich and Macri will provide him with the kind of people he needs, people with the expertise, people who know what the challenges inside the state are, but it's unclear really what would happen. Also because after he won the August primaries and there was this panic in markets, he sort of backed down in a way from his proposals, because before that he was just saying, he was talking about dollarization, but there were no specifics in the program and it just seemed like he would dollarize the economy on day one, but after the August primary and to try to calm everyone down, he said, dollarization is something that will happen in the, not in the long term, but not immediately either, like in 12 months or 24 months, and there will be a transition period and things will be smooth so as to not hurt people. So in a way, it's unclear exactly what he will do and with whom he will do all of his proposals, which is what's scaring people now. Many people on the center right are thinking, well, the election is over. Even if I vote for Mille, he's probably gonna lose, but if he wins, he will not be able to do anything. So many people, what I sense these days is a lot of sadness on the center right, just because Mille didn't do better on the Sunday election and because the math doesn't really add up neither for the run-off nor for a potential administration. But Argentina is like a Pandora box, everything changes significantly week to week, so everything could change. How much autonomy or how much cooperation would he need in order to push that, what's really the central proposition of his campaign, the dollarization, the abolition of the central bank? Is that something he would have much leeway in doing even if he had a uncooperative legislature? And is there a way, we talked about it a little bit at the beginning, but is there a way to implement dollarization? Do you think that would not create the sort of nightmare scenario that spooked the markets? Well, the alternative to hyperinflation, if you wanna dollarize, is to borrow money basically. And now that's where Mille's capacity to attract investments gets sort of calling to question. If Mille, for example, were to seal an alliance, an executive alliance with Mulrich or Macri, then those people may be able to convince investors to borrow, to lend the Argentine state money so that the state actually has some dollars to dollarize and so that the exchange rate doesn't need to go through the roof. That's the alternative. It will require that the state take a lot of debt. It's unclear whether Mille would be able to do that. And if he were to do that, then he would have to proceed with his fiscal adjustment plan much more quickly than expected because he would have to pay that debt down, of course, and the state is already indebted. So that would be a problem. And what was the first question? I forgot about that. Sorry. It was just, could he, how much buy-in does he need from the employer to do it? And he needs, yeah, and I'm not sure about technicalities. I think that he may have people on his legal team trying to figure out whether he could bypass Congress for many of the proposals that he wants to implement. I'm not sure he can do that. Argentine presidents do get a lot of leeway through degrees, but there are some areas in which it is constitutionally forbidden to issue a decrease. I don't think, I'm not sure if monetary policy fits into one of those categories. I don't think so, but it's likely that if Millet does something that Congress doesn't like, Congress does have the authority to override the decree. If Congress gets two thirds of a majority, then they can override whatever it is that the government is trying to do. And so if that's the case and Millet can't get one third of Congress to support him, then he would be in danger. He would be, in my view, the most important danger that he would face as president is that he would get impeached. Impeachment would be a real possibility because if he only has 15% of the vote, whatever he does that the opposition doesn't like, they will turn that into grounds for impeachment and it will impeachment for sure. If he's unpopular enough, of course, if the opposition thinks that it will be in their benefit to impeach Millet, they will do it. That's, of course, assuming he will actually get elected president. But I think that's, his biggest concern right now should be that, really, because the election for Congress has been done already. That's not gonna change with the runoff and he will just not have many Congress people. So that's what I would be focusing on right now, how to avoid impeachment on day one or day two. Hey, thanks for watching that clip of our talk with Marcos Falcone about the presidential candidacy of Javier Millet. You can watch the full conversation here or another clip over here.


Clint, what was Waka doing tonight that made him so tough on you guys? Um, he was, I mean, I can only really speak to what he was doing directly to me. You know, it was just like throwing a lot of pitches that are going in different directions and I'm assuming that's what he did to other guys. And when guys do that, it makes it really hard to focus in on a location that you want to swing at, especially when the ball is going, you know, opposite directions half the time. So he was on and obviously he pitched pretty well, but, you know, we're, we're going to turn the page and look forward to tomorrow. What keeps you confident that you can turn the page based on what's been going on lately? Uh, our track record, you know, um, we have a lot of really good players that, you know, have performed really well for a long time and it's what the 13th game. So I think, you know, it's, it's not obviously you want to perform better collectively and individually, but, you know, things happen and, and like I said, we have a lot of guys with a lot of really good track records that I think can, can prove that we're going to be able to get out of this. Aaron said that he addressed the team. What did you take away from, from that?  So, you know, I'm not going to get into everything that he said, but, you know, we need to come ready to go tomorrow. And that, that was the message that I took from it. Brian Hope, please unmute. We're obviously angry. You were at the plate, I believe when the ball started raining out of the, uh, the stands on the field. What was your reaction when that was going on? That was the first time that I think I've experienced that. Um, I mean, you never wanted to come to that, obviously. Um, and hopefully, you know, moving forward, we play, we play well enough to where that does not happen again. Ken David off. You have the next question. Go ahead. You think that was at all an issue, uh, tonight or has been an issue at all? It's hard to, it's, I mean, obviously everyone wants to, uh, to be able to figure out why they're struggling or why we're struggling. And that's what makes it hard, you know, and, and I don't think personally that anyone shows up here, not ready to go, but you know, we're playing, we, we, we as a team and we as players have set the bar and the expectations so high that when we don't meet those expectations, obviously people get upset, we get upset and we have to find a way to meet the expectations for ourselves and, and, and go out there and, and figure it out. And, and if it was that easy, then obviously, you know, I don't think I'd be sitting here answering a question like that. So I think that every one in that locker room is going to be a hundred percent ready to go tomorrow. I'm sorry if I could just follow. What, what do you think is going on with you at the play point? Um, I, I've been asking myself that question the last couple of days. And I think that it's a, it's a timing issue.  So with that being said, like I'm, I feel like right now as a hitter, I'm timing up off speed rather than timing up fastball. So whenever they throw a fastball, I'm a click late and that's been addressed. I talked to Jay a lot about it today and, um, it's never been a, it's never been an issue with me not being able to swing the bat. So I think with me not being able to pull the trigger on pitches that I normally would, it's, it's all a timing issue. There's no mechanics. It's just, I got to come ready to go in that plate.