Placeholder Image

字幕列表 影片播放

  • Hello for this video.

  • I wanted to do something a little bit different, and that's been made possible by the very generous support from my patriotic or patriots, depending on where you're from for a while, I wanted to tackle embedded systems as a topic, but I've looked for a suitable entry point that simply enough to make into a nice video but also lays the foundations for future video work.

  • So let's get to it.

  • Let's make and program over biotic arm.

  • The aim of this video is to control a robot arm while asleep.

  • Fear my computer here, I've got my computer on on the screen.

  • I want to have some sliders, which allow me to set the joint positions off the robot's movable parts on my computer.

  • I have a USB port on into that I have a Bluetooth jungle the Bluetooth jungle is going to transmit to a Bluetooth receiver.

  • This receiver is going to then communicate with a microcontroller micro.

  • See, in this case, it's an embed L.

  • P C 17 68 on.

  • It's going to do that communication via what's known as a you are out on.

  • I will go through all of these terms as part of this video vote.

  • Bottom consists of six degrees of freedom.

  • That means he's got six movable components.

  • These are known as servos on the servos require a pulse width modulation signal P W M from the microcontroller to set their positions.

  • So from the microcontroller bones have six lots of P w m.

  • We also need to think about power.

  • It's a power my system from a small supply connected into the mains, which is going to convert it to six volts and then want to power my microcontroller by this six faults.

  • But then I also want to power all of my servos bythe same six volts.

  • I'm going to use the pixel game engine to draw some sliders on the screen on.

  • I want to communicate with the Bluetooth jungle Veer, a virtual calm part.

  • And so the ultimate aim is that when we move a slider, we see a joint move in real time.

  • This is the robot arm I intend to build.

  • It's the D i y more rock through you.

  • Six degrees of freedom aluminium robot arm with a claw on this specific purchase from Amazon, you can upgrade to also include the six servos, and I did just that.

  • So thank you to my patrons for funding this project.

  • But there is no doubt it is the cheapest and nastiest robot arm on Amazon.

  • But I think that's OK, because if we can get this to work and get it to work, well, then you know it just goes to show you don't have to pay a fortune for some really cool stuff.

  • The microcontroller I'm going to use is the embed L.

  • P C 17 68 and this is a really nice microcontroller.

  • I know a lot of you will be familiar with things like our DWI.

  • No, I don't tend to use those very much.

  • I prefer using this instead, mainly because it's also quite applicable to use in industry.

  • I like the fact that it's so small and it's so modular on.

  • It's so easy to program and we'll see just how easy to program it is later on.

  • They're not the cheapest microcontroller modules available, however.

  • It is entirely open source, both from a firmware aunt hardwork perspective on it has lots of ready to go peripherals just simple and easy to use.

  • It also has a form factor, which makes it very easy to plug into prototyping board and a quick look at some of the specifications here.

  • It's an arm cortex M three, which is a low respect, armed process, sir, but it's a tremendously capable process.

  • Er, it can clock in about 96 megahertz.

  • It's got 32 K of RAM on 512 K of Flash has got a whole bunch of io for us to exploit, but the bits I love about it, the most of these programming is dragon Drop.

  • It pops up like a flash drive, and you just drag the program file onto it.

  • Very nice on all of the coding that can be done via the browser.

  • And you might be thinking, Oh, dear May, That sounds dreadful.

  • Actually, it's not that bad and experience it all.

  • It's quite a sophisticated Web interface.

  • You can use offline tools if you want to, but that does require a bit of setting up.

  • I like embeds.

  • I've been using them for quite a number of years, even an industry as we can see, it's quite a small device, so it measures here.

  • About 53 millimeters by 25 millimeters.

  • And it's designed to fit into standard 2.54 millimeter pitch headers on the back here because it is also two things going on on.

  • This is what makes it easy to use.

  • This is the user interface circuitry.

  • There'll actually just plug it into your computer and program it quite simply.

  • But on the on the top is that where the real stuff happens?

  • And there's not that many features, really.

  • We have a big button in the middle.

  • This is to reset the module, that this is the arm cortex M three process itself, and we have four little L.

  • Edie's, which are under user control.

  • The other two big components on here are just power regulation because we can provide power to this very the pins or via the USB, and there's an advantage to being able to power it by the pin.

  • So here we've got ground involved a gym, but because that's accepts the vaulted range between 4.5 to 14 faults.

  • Where is from us being?

  • We just get five.

  • It's more convenient sometimes to just power your system from one place, particularly in this case because the sober motors I'm going to use I'm going to power those at six volts.

  • They would work at five volts.

  • But I don't have the current capacity from the U.

  • S.

  • Be hope in order to drive all of them.

  • So I'm having to drive the servers from a separate power supply every time you buy an embed and I must support about 50 off them.

  • By now, you get a little card like this, so I'm quite a stack of these things.

  • But it's a really convenient thing to show you where all the pins up so we can see we've got power pins here, labeled in red on all of the other pins are music configurable.

  • I owe in one way or another.

  • So we've got two lots of espionage bosses on.

  • We've got to lots of new art on this side.

  • We've also got a You are on this side, too.

  • Well, look at you out for communicating between the computer on the control module.

  • We've also got some analog in pain.

  • So there's a built in analog to digital converter on here and that will accept up to six inputs.

  • It's it's okay it's not the fastest, and it's not the most noise free.

  • But for most applications, it's fine.

  • And with some twit Lee of the hard work, this sort of assembly level in my control, you can actually tidy that up quite a bit.

  • There's a single analog out employing the opposite.

  • There is a digital time low convertible.

  • We've also got two I scored.

  • See bosses.

  • They're usually quite popular.

  • I don't like them as much as SP I, but it depends on the application.

  • But most importantly for today we've got six pw em out pin.

  • So these are hard work and figured so.

  • The PW M is handled by the hard work, meaning we don't have to maintain that in software.

  • There's also us peace.

  • If you doing USB on the go applications.

  • These the pigeons use for that.

  • And finally, there's Ethernet.

  • At best.

  • It's a functional level.

  • Ethernet.

  • It's not for any high speed streaming.

  • The whole device is really only clock Kable at 96 megahertz, which doesn't sound like a lot, but it's enough to do a lot of interesting things for sure.

  • The embassy also really conveniently provides a regulated 3.3 faults output on will be using that to power the Bluetooth module.

  • This is the Bluetooth module.

  • I'm intending to use the D S D tec H c 05 Bluetooth serial passed through module with while a serial communication with button.

  • They says for Arduino, but doesn't matter.

  • It's just a Bluetooth module that gives us access to a U art.

  • And I've chosen this because I'm literally just going to plug it straight into the bread board and hope that it works.

  • I have a little USB dongle on my main computer and this is my Bluetooth module.

  • And I chose this just because of its simplicity.

  • It's entirely contained.

  • So here you can see we've got the Bluetooth antenna on.

  • We've got some interface checks to handle the radio.

  • I guess on on the back, it very conveniently labels what the pins are.

  • We're not interested in all of the what we're interested in his VCC, which will go to power from now.

  • We're gonna parrot from 3.3 volts.

  • Not the recommended 3.6 faults you can see here.

  • Exactly.

  • It's OK.

  • It works on dhe.

  • We've got the t, X t and R X d lives there.

  • The ur lives.

  • That's where our communication is going to be happening.

  • So the computer is going to transmit via Bluetooth to this module, and this module will convert it into three vault three level you are which the embed can understand quite naturally, the other pins.

  • I'm not too interested in what they do when you enter the world of embedded systems development.

  • One of the first things you'll come across is the need to have things very overtime in a kind of analog e type way.

  • But all you've got is a bunch of digital pins.

  • Well, one way to satisfy this is to use pulse width modulation, which sounds very complicated but is in fact, quite a simple thing.

  • If I create an axis which represents time on, I take two points along that access.

  • This is more commonly known as the period, because what I'm going to assume is that we're going to have some repeating signal between these two points.

  • Digital signals, of course, can only really be zero on Dwan.

  • Just to make this clear, I'm going to add in another timeline.

  • So I've got two sections of time here a digital clock is a signal that isolates between one and zero.

  • So, for example, it may look something like this.

  • The time that the clock is high is the same as the time that the clock is low on this.

  • Repeats for a P W M Perspective O'clock is P W M at 50%.

  • Let's consider a P W M A 25% Well, in this case, it's high for 25% of the period, but low for 75% of it.

  • And it repeats.

  • I'm sure you've already worked out by now.

  • But if we wanted something like 75% P W.

  • M, it's highly for 75% of the period on low for the remaining 25%.

  • So to specify a PW EM signal, we need two pieces of information.

  • We need the period, which is this duration of time, and we need the duty cycle.

  • There are variations of this depending on the polarity of your signals, but I'm not going to look into that today.

  • So let's program the microcontroller now.

  • Now, firstly, I must apologize.

  • Unlike Visual Studio, I don't have as much graphical control over how the browser Integrated development environment looks for embed, so I can't really change the font and zoom in quite as easily as I can in visual studio, so we'll just have to make do.

  • But all of the source code for this will be available in the getup and is Linka ble from the description below a blank embed program.

  • Looks like this on this is the environment have put on the dark theme, so I don't blind myself and it looks just like a C plus plus programming environments.

  • I've got some files and projects down here on the left.

  • I've got a coding window here and I've got some output window at the bottom on that.

  • This is the skeleton stub program.

  • You include embed dot H, which provides you with all of the tools and new Cilla sees of the board on it gives you an in Maine and says, Well, have at it.

  • You compress control and be or click build from the menu appear and it builds it and gives you the syntax error.

  • And this is all happening in the browser now, since we've just been looking at Peter, you am.

  • I think the first thing to implement is a simple PW AM exercise, so I'm just going to specify a pin called pw em out.

  • So this is an object which will facilitate the coordination of the PW em peripherals for specific pin.

  • I'm going to give that pin the name led Led one.

  • Actually, we're goes, we're going to blink one of the ladies on the board according to the P W M Signal on, I could specify which particular piece of hardware I want when I'm constructing this pin and on the embed conveniently it's led one now, thinking back to PW em if you em.

  • But they're two bits of information you need to specify.

  • The first is the period.

  • So on my pin object led one.

  • I'm going to specify the period I'm going to set the period to be one second.

  • I'm not going to specify the duty cycle by writing to that P W.

  • M.

  • Pin.

  • The duty cycle is a percentage.

  • So if I set this as no 0.5, what we should expect to see is the led blinking on enough at 1/2 2nd interval on because I'm old fashioned and I don't want main to exit just in case it resets the embed controller.

  • I'm just going to sit in a loop.

  • It's compile it.

  • So compiling it was very simple.

  • Well, actually, all have done was building.

  • But if I click compile, it will run through the build process on Dhe gives me a file to download, which we've just seen here on this file is called Robot arm dot lpc 1768 dot been, which means it's a binary file on That's the file that I'm going to Dragon drop onto the embed when it appears like a flash drive.

  • So I'm just going to plug the embedding.

  • You take my embed.

  • I'm going to insert the USB connected directly to my computer, and we could see it's powered up the embed on that This led here tells you that the bed has power.

  • The embed itself pops up just like a regular flash drive.

  • So I'm going to take the binary file that's just been given to me by the chrome browser on.

  • I'm going to drag it onto the flash drive.

  • And as you just saw on the camera, the led blinked.

  • That's telling us that the file has been flashed onto the memory of the embed.

  • I no need to press the button on the amber to reset it, and we can see now led one flashing with a 50% duty cycle on a period of one.

  • And that's just been done via P.

  • W N.

  • This doesn't mean we can flash.

  • The other led is, too.

  • So I'm going to duplicate this code for the four ladies on the board.

  • But I'm going to set the duty cycles to be different, so we'll have led to moving at 75%.

  • Led three moving at 25% on led four.

  • Moving at I don't know.

  • Let's pick something like 10%.

  • Click the compile button and straightaway.

  • There's an error, of course, simply because I'm not defined.

  • What the pins are.

  • Welcome to embedded.

  • Try that again.

  • There we go.

  • Success, and it's giving me the file.

  • So I'm going to drag that file onto the embed and program it Now.

  • You can see there's multiple files now on the M bet That's okay.

  • The most recently written thing to it is the thing that flashes.

  • So going back to our device, I'm going to reset it by pressing the button on the top.

  • We can see we've never led ease with different duty cycles, a bit tricky to tell which one was which.

  • But we can see that led four.

  • Here is a very brief pulse that was our 10%.

  • Where is led to was 75% led.

  • One was 50% and we see that extinguished before the 75% 1.

  • But we see the 25% 1 extinguished before the 50% 1.

  • So it is working on the period of the people here are all in sync.

  • I'm going to remove the other l E D's on Just show one last thing regarding Peter, we went.

  • We've set the period here to be one second, which is actually quite slow.

  • So I'm going to set that Toby 10 milliseconds instead on I'll introduce an additional variable time on in my wild loop.

  • I'm going to set the duty cycle for that particular pin to be a function off time.

  • In fact, specifically, I'm going to set it to be a sign of time.

  • But Signe will, of course, give me a value between minus one and plus one.

  • So I'm gonna add one to that and divide the whole thing by two.

  • I want time to increase, so I'm just going to add a little tiny bit to it.

  • Let's take a look.

  • So I just reprogrammed the embed on I've reset it, and what we see now is a nice, gently pulsing led one S o P.

  • W M is really used for whenever you want something to look analog e in a digital domain, the led is flashing on enough so quickly, and we're in control of how quickly it is flashing on enough that we could make it look like different intensities, a very common technique on anything where you see ladies with this sort of behavior.

  • Pulse width modulation is also used to regulate power efficiency in battery powered circuits, because most of the time you don't want your led on all the time.

  • It's quite sufficient, tohave it, pulsing it perhaps a 50% duty cycle to the human.

  • I'd still just as bright.

  • It's still usable tool, but it's only using 50% of the power you aren't stands for universal asynchronous received transmit, and it's a mechanism for sending and receiving data between two devices.