>> How to Fix a Robot Using Duty Cycle Measurement on an Oscilloscope
IAN: Hi!
This is Tony and Ian from Tektronix.
This video is going to be something a little different.
We are going to show you a demo we did in front of a live audience a few weeks ago.
Tony, do you want to set the scene here?
TONY: Yes, and a live audience it was.
It was at the ACCESS Academy with all the eighth graders.
And Judy Berck was able to have an oscilloscope donated to them.
And she came to us and said, "Could you guys come and do a quick demo of how you would
use the oscilloscope?".
IAN: Right, and we decided we would work a little silliness into the presentation.
TONY: It was a little more than silliness too.
There was some danger!
IAN: Right.
Well for the presenters anyway!
TONY: ...No, just "the" presenter
IAN: Just Tony, right?!
We want to stress that the robot that we set loose was targeted only at Tony.
The audience was perfectly safe.
TONY: Yeah, and it wasn't really until we added this fork to the front of it that it
became very dangerous because it was heading to my eye.
But you'll see this in the demo.
IAN: So kids, if you try this at home, don't arm the robot!
TONY: So Ian, what did we do in the demo?
What was the main thing we showed?
IAN: Well, we showed how to do a duty cycle measurement with an oscilloscope.
And for those not familiar, a duty cycle measurement definition is if you imagine a signal turning
on and off like this... the duty cycle is the percentage of time that the signal stays
on.
So in this case, this signal is on about four-fifths of the time.
So the duty cycle would be 80%.
TONY: Ok, that makes sense.
That sounds like a really helpful demo that people could look at.
IAN: I hope so.
TONY: So we'd like to thank Judy Berck for setting this up and getting the oscilloscope
to the school.
And then the teacher, Mr. Garcia.
IAN: And Brett Nelson of Portland for building this awesome robot.
So without further ado, here's the demo.
TONY: Enjoy!
IAN: ...So it's a lovely robot.
But with the addition of a simple spork, we are going to turn it into a pain machine.
Now this is a very dangerous robot because it's got a spork.
This could really put an eye out.
TONY: And careful how you're talking about that because it's going to be my eye that
might be put out.
IAN: That's true.
We're going to set the robot chasing after Tony!
TONY: OK, let me get the First Aid kit just in case.
IAN: Can we get a volunteer.
Does anybody not mind the sight of blood... or guts?
GIRL: I don't!
TONY: OK, have this prepared just in case Ian here, the engineer, doesn't figure this
out right.
We've tested this a couple of times...
IAN: ...But you never know!
Just in case Tony, have you ever thought about becoming a pirate if things didn't work out
too well today?
TONY: I've not had that one before.
IAN: So this robot is programmed in this programming language with pieces of the program clipped
together like little puzzle pieces.
At the start of my program I want to set the power of my motors to three (we'll get to
what these numbers mean) and then I want to turn both motors on.
It has two wheels.
We're going to wait for three seconds, which is thirty-tenths of a second and then turn
the motors off.
And this number is the power level.
It goes from zero to seven, where seven means the motor is all the way on and zero means
the motor is completely off.
Now this is a bit of a trick because the motor doesn't actually have any speeds to it.
If you apply voltage to it, it's on.
There's no just giving half as much voltage and expecting it to go half as fast.
It doesn't work that way.
So if we want the robot to go at half speed, we'll have to do a trick.
Can anybody think of a trick we might use?
BOY: You would incrementally turn it on and off at the same amount of time repeatedly.
IAN: Yes, incrementally turn it on and off repeatedly.
So I'm the robot and I'm coming towards Tony...
TONY: Stop!
Go!
CLASS: Like a red light, green light.
IAN: Yes, same thing.
Like a red light, green light.
So the computer on that circuit board is going to be controlling the motors just like that.
And it's going to be really smooth though.
It's not really jerky like when I was walking just a second ago because it happens at hundreds
of times a second.
It's turning the motors on and off so fast that we'll just see the robot going at half
speed.
TONY: And that's a really good point, what he said is that things happen so quickly.
That's why we have this oscilloscope.
Like a heartbeat you can hear, right?
You can hear your own heartbeat.
Beep.
This thing goes so fast and that's why we need an oscilloscope to make sure this is
working right.
IAN: Right, because it helps you see things that you wouldn't have been able to see otherwise.
So, if we were to draw a graph of the voltage going to that motor.
I actually should've looked up how much this motor needs, but let's just say it's six volts...
and this is zero volts.
So as time goes on, what would this graph look like?
SO let's say we start off at zero volts and we suddenly jump up to six volts because we've
turned on the motor.
So we let it go for a little while.
And then we turn it off, so the voltage drops down to zero.
We let it go for a little while... and we turn it on.
SO it makes this pattern like this.
And we'll actually be able to see this on the screen of the oscilloscope.
And can you guys see these little graphs here?
CLASS: Yeah.
IAN: You notice these ones here have really narrow peaks.
We only turn it on for a short time and then we drop it down.
And then we go along.
And then we only turn it on for a short time... and then we drop it down.
So that would be a really low speed, right?
If we only let the motor go for a tiny amount of time and then shut it back off.
And that is what the graph would look like if we were in low speed.
Now all the way up at seven we would expect it to be on.
In six, on most of the time.
And so forth.
This technique of using the width of your signal to make something happen in the real
world is called, Pulse Width Modulation.
We're actually going to measure it now.
Actually, do we need to measure, or should we just risk Tony's life.
Let's go ahead and let's just risk it!
TONY: Alright, First Aid ready?
GIRL: Yes, First Aid Ready.
TONY: Ian, I hope this works.
IAN: Yeah, me too...
You know what?
I'm going to go ahead and test it anyway.
I'm glad I decided at the last second to test it.
TONY: Thanks, Ian.
I feel a lot better!
Let's check on this oscilloscope to make sure we got the power set right here.
IAN: So it looks something like this.
And we can actually see how many volts this was now.
So if this was zero volts here, and it's five volts per division, and we're just a little
over five volts.
So I wasn't off in my totally wild guess of about six volts.
It looks a little more like seven.
You can actually measure that more precisely but you can see that it's not on half the
time, off half the time.
It's on most of the time and only off some of the time.
TONY: Do you guys see that?
CLASS: Yes.
TONY: See the difference of that?
IAN: And now we can actually get a measurement of that.
We can say "Measurements", and we can pick "Positive Duty Cycle", and say "OK".
So, 84%... almost.
TONY: And so for my safety, I need it at 50%.
Ian?
IAN: Yeah, so now we have to decide, is the hardware turning the motors on for too long,
or is there a problem with the programming?
And now I'm actually going to look at the program that is driving this.
TONY: There are two parts of this.
One is the code that's been written by somebody -- that's what he's going to check.
But then we're also going to double check the code on the oscilloscope to make sure
that what he thinks he's coded in is correct.
IAN: So this is kind of a small screen, so we've blown it up here.
But basically this number here was supposed to be a three and we look at it, and it's
actually a six which is almost all the way on.
SO I've got to, for the first time ever, operate a mouse upside down...
TONY: This is on film too...
IAN: ...Yes, for posterity.
Awesome!
And now we need to download the new program to the robot...
There it is.
TONY: So you've sent the new code into the robot?
IAN: I did.
So now we should be able to hook it up and measure it.
TONY: And now we're going to double check what he just did.
If it changes from six to three.
Let's see if he really did it.
IAN: And see if the duty cycle actually changes.
So we're going to hook the oscilloscope back up.
So you can see now the duty cycle is 42%.
A little less than half which is what you would expect if it's zero to three, out of
seven.
So we would expect the robot now to go a little slower.
TONY: You guys recognize this here?
That's what we're shooting for and now we're checking on the oscilloscope and it's pretty
dang close to that.
It has a little more curve to it as the power kind of eases off and doesn't go "Off/On".
IAN: Are you feeling lucky?
TONY: OK, I feel a little better about this.
We've checked the code...
IAN: Alright, put your eyes down on the table...
And switch places now that I've proven that I can't program a robot, right?
Whoa, it's backwards!
Look at that.
TONY: I'm completely safe now.
IAN: Maybe we should just leave it that way.
This happens to us every time we rehearse this too.
You'd think I'd learn which way the connectors go by now.
There we go.
TONY: Go ahead.
I'm hoping for the best here.
IAN: And it stops!
TONY: AHHHHH...
IAN: Look at that!
TONY: Perfect!
That actually worked.
IAN: I think Tony has something he would like to say to the oscilloscope.
TONY: Thanks, oscilloscope.
IAN: So this is the kind of thing people use these things for.