 J.S. Fu becomes a platform for the young and so to speak. This is Amaya Kaurve. He's come all the way from IIT Madras. He's an IIT and so Give it up for him. Yeah, he's a he loves JavaScript. He keeps putting stuff on guitar Keeps putting stuff up on GitHub and he has a cool project that kind of failed yesterday No, like the actual project, but you have a video of a thing which is totally fine So go for it. I'm at the stages all yours here. It's another robot All right, so before I begin. Yeah, it was a hack It's I wouldn't call it anywhere close to a near product and it actually failed yesterday The half of my circuit is down, but I'll try to compensate it with a real video to make up for it So, okay the idea so the premise is that you know robotics in JavaScript is like really coming up You saw a couple of very nice ones recently. I went the quadcopter. That is like really awesome That would do flips and whatever so The premise again behind building this was what if I could have a robot? Except it's controlled from my mobile phone or from my computer or from a browser for that matter So it doesn't need to be any specific device. I could literally plug my device in and control the thing So if you look at your, you know, typical devices say a mobile phone for that matter a computer Now any robot it will have you know some inputs coming in some data exchanges and then there is the output now The only tangible outputs I have are the screen data, which is more or less useless and in a lot of them We have the sound output. So the idea was that if I can somehow use the sound signal and Control a bunch of motors with it. So and that would be really cool I just plugged my device into my headphone jack and I'm able to run, you know, a bunch of motors and do things with it So I'll begin So Robo control with the HTML5 a body of API This is me. I'm studying at IIT Madras right now. I'll graduate this summer That's my email address my Twitter handle if you want to get in touch So the overview so what was at least intended to be designed was a Robo the Robo consisted of a device that has a browser with HTML5 support, so that could have been my iPad iPod phone Mike I could connect my computer if my Robo was big enough The phone had and you know the audio cable which connected to a very minimal circuit that I made That I could use to actuate the motors and the sense, you know servers and so on Now this HTML5 device. I meant assuming it has internet connectivity I have a Wi-Fi network or 2g 3g 4g so on so this guy is connected with our node. Yes server You can make it real time if you need to if your motor that sensitive enough you can use something socket.io and Then I can have a lot of controllers really connected to the node server and controlling what the robot does actually Controlling what the robot is physically through a server. So this is a brief overview of what I'm going to be doing So I'll talk about the various aspects of this and yeah, just move So today's talk, let's see. It's the motors the audio signals using the web audio API I'll probably not go very deep into that because Jason had a very nice thing about it. No the same demo, I'll probably just play a video QA So the motors now You basic kinds of motors. I have your regular DC motors. They're the ones with two pins I just give it a voltage at DC voltage. It will run I have servers so a server is a special kind of a motor now the idea about a server is I can control the angle Where my server is gonna get to so I basically give him a signal that looks like this now This is my voltage signal across time and I give him pulses these pulses happen every 20 milliseconds as this thing shows So say 50 times every second I give him pulses like this of width about one to two milliseconds It's like that's what it like it can happen thousand times a second if I do that So really fast signals and if I vary this width now between one millisecond to two millisecond I can control the angle where I'm going at so if it's at one millisecond It will be at one extreme two milliseconds. It'll go to the other extreme. So this is our server works Now the audio signals now the audio jack for that matter the 3.5 mm jack if you have any You know used up headphones or something you can cut it open. You'll actually have a jack like that so Typically it's a stereo jack and stereo jacks will have you know the ground that is the biggest one and the two pins are for the left And the right channels The signals are electrical signals. They are low It's so it's point six on my mobile phone that I checked a one volt amplitude on my this thing on my computer and They are very low power. So it's technically impossible to power a motor or something using this The three pins again as I explained and they're ac coupled So quick show of hands. How many of you are like into music or audio editing or maybe electrical engineers out here? All right, so if you've ever used something called a high-pass filter, this is something that would do something similar So if I have anything that is like somewhat constant, he'll just eliminate that signal So if you look at the previous slide if you look at you know the kind of signal here It is constant for this period and constant for this period So unfortunately if I try to use it with the audio jack the signal will be eliminated I'll just show you things later, but it's a practical limitation of an audio jack So an example again, so if I have a signal that's a plane wave that is the first one There is no change So you see a pulse in the beginning and the signal is eliminated this thing is a constantly changing signal So it remains so now this guy this is somewhat similar to the signal that we need So he just gives you pulses whenever the change is happening and then for the rest of the times nothing happens So what this is what we intend, but that is what we are going to get which is a problem This is a problem because you know the kind of signal that we need is like that And we are in trouble here because we can't directly even if I say I make a file that looks like this The actual output is not going to be like that so Yeah, the classic Gandalf thing Gandalf won't allow it. We can't get the DC signals through so we've got to do some improvisations to get this done So we have something called the comparator now a comparator is a very simple circuit component a good way of looking at it Is return a greater than B So if I have two signals a and b which have a signal is greater He'll return true I mean if the signals if a is greater it will return true if B is greater return false and true corresponds to say some static 5 volts Falls will correspond to a zero world So how we are going to use this is I'll just show you so if I say I have a signal like this And I set the b value at 0 so a greater than 0 Will give you a true pattern like that And similarly if I have a you know a bunch of sine waves like this over here, and I again set it to You know a greater than 0. I'll get a pattern like that, which is what we need now This can be used to power your normal motors your DC motors the limitation Of course is you'll have to run it at half power because you know you'll only get it for half the times And this is the kind of pulse signal that you need to feed to a servo so The web audio API okay, I won't get too deep into it. I'll just try to explain things which might not be that obvious So the web audio API it's a very high level API important point You can't mess around with the signal that a very low level at a data level you can apply generic filters And so on but you can't really go and say all right. This is my value I'm going to change this intensity right now from say 5 to 10 or so on You can load sounds into an array buffer You can load a lot of audio with modern browsers and the array buffer can be manipulated. This is the high level things You can use stuff like filters. Yeah, again, the music people you'll probably know what filters will be like and Sections of a buffer can be sent to the speaker So I can say okay send whatever is there in my buffer from say one second to two seconds and play that I Can actually send it to the actual speaker sources What I can also do is I can generate some common patterns something like a sine wave or a square wave Some common patterns you can do this with something called oscillators which I've used in one of them So the array buffer. I think this code is precisely almost similar to what Jason put up. So I'll move on with the code This is something that plays a sound. So it's like really simple. You create a source You connect your buffer to it and then you just say play play whenever you want to play when to play argument that I've added here And a scheduling now this is one way to schedule it. So this is like really simple I'm like every thousand seconds play the tune now this to this is kind of specific because I put my tunes at one second each Of course, you can sort of modify it and actually the set interval is not a very great way of doing it because The JavaScript clock lags a lot. So actually there is a nice way in which this guy tries to sync two clocks So he can either sync the JavaScript clock and the this thing there's a clock provided by the web audio API Otherwise, you can sync the JavaScript clock and the one that you know renders the frame rates So there is some syncing mechanisms. I've got code up. So I'll show it to you on my github You can have a look at the code at my github whenever you want to later It's again a hack you could please contribute to it if you're going to work on this Uh, the demo, I'm sorry the demo wouldn't work out this half of my circuit is fried So I'd only be able to use the other half of it But I'll show you a video of how I've, you know, tried to control a servo with the thing So this guy So I'm giving him a signal. I'll be, you know, moving it by The audio jack connected to my computer It's sort of connected to the circuit and I have the servo So what I'm going to do is I'm going to make it rotate by about 15 degrees every Few milliseconds and make a full sweep from zero degrees to 180 So here goes So he's rotating by the fixed angle. This angle is controlled. I can have this precise top to half a degree in rotation So you have like a real lot of control over here So now I'm just going to stop it and make him oscillate a little so Never mind the dirty room Yeah, here goes Yeah So I have my circuit all right, so I'll move on to the Next one. So basically a few of my friends, they really helped me a lot with this all the way from You know coming up with the initial poster to a little help with the circuits, which one are some with Yeah, they're really awesome people. Thank you guys. Thank you and uh Questions any questions Questions Anything about the implementation anything basic anything advanced time file recruiter stay away until he graduates Just saying sorry. Yeah, so, uh, you want the github this thing, huh? Yeah, so github.com. I'll make our way audio hack So just check the description file. In fact, I might have it in my browser. Yeah So there are a couple of this thing's files. So Uh, is this updated It's not updated It's not updated on my browser But when you go in so there are two demos that I try to generate one for a differential drive That is your normal dc motors and you control the speeds you can give it variable speeds The second was for the servo. Maybe if you go up there The files are over here There is one thing called It'll be in the public directory Oh, there's no internet. I'm sorry. So there will be a differential drive and a servo drive a couple of javascript files All the code will be in there. I can probably show it to you from my editor or something. Uh I'll show it here Anyhow, so That again is a very simple one. So this one. I've actually used the oscillator the other one the one with the Servo drive. I've just put a very simple get audio tags and play it because Uh, because yeah, there are some problems. I tried to do some very beautiful looking code and fast things But the guy wasn't fast enough to handle it and the garbage collector sort of crashed my thing So supposedly it's a chromium bug, but hopefully it will be fixed in a while. So yeah, the thing is still very quirky things are coming up But uh Yeah, again, it's a hack and I hope we can actually go on with this I I have a I have a question sure here. Um, so the the audio The uh, so when you generate the audio signals, do you uh, directly wire up that audio output to the motors directly? Or are you passing that to me? There's a very small circuit. There's a very minimal circuit The only components are the comparator. So the comparator is this true false thing And uh, the only reason is I need to generate the specified waveform. So the comparator is like a very small chip It's some 14 pin chip and I the intention was minimum circuitry, but we should be able to get it done I don't need to buy a an Arduino or a pie for that. There's no microcontroller. No microcontroller nothing It's pretty basic. It's great that you're using a comparator, but do you think the comparator can Amountable Okay, uh, see the the comparator that you used Can it serve multiple motors? Is it capable of handling that much amount of current? Uh, so it doesn't serve motors directly. So the servo for that matter Uh, if I use the servo the logical input doesn't carry much current The powering is external to that. So it's imagine it as a switch No, no, not not for serve. Uh, no, not for not for normal motors for that You would have to use something called a motor driver. Exactly. Yeah, exactly. Okay But servo it should work fine without it I was just curious that if you could It's not possible Uh, so anyone else All right, fine. Thanks. And if anyone is like wanting to contribute do tell me