1
00:00:01,170 --> 00:00:08,760
In this lecture, I'll show you how to control these simple five volt DC motor using the the RV eight

2
00:00:08,760 --> 00:00:10,200
eight seven one to break out.

3
00:00:10,440 --> 00:00:14,080
The particular one that I'm using here is from the fruit.

4
00:00:14,130 --> 00:00:20,340
It's actually a really good and small package, actually, to control motors like this one.

5
00:00:20,970 --> 00:00:25,500
Before we get started with the actual demonstration, I just wanted to talk a little bit about this

6
00:00:25,500 --> 00:00:26,120
module.

7
00:00:26,640 --> 00:00:34,140
Now, the first thing to notice is that in order for the motor to operate, you need to provide at least

8
00:00:34,140 --> 00:00:41,310
six point five votes of power to this power as crude terminals.

9
00:00:41,310 --> 00:00:48,360
From here, I have connected mine to my benchtop power supply and I'm connected on in a moment.

10
00:00:48,810 --> 00:00:54,330
If you provide anything less than six and a half volts, your motor is not going to work at all.

11
00:00:55,020 --> 00:01:03,090
The other thing to notice that is important is that this device is able to take instructions, basically

12
00:01:03,120 --> 00:01:06,810
work with logic levels up to five point five volts.

13
00:01:07,140 --> 00:01:13,720
So it's going to work well, both with your UNO, which operates at five volts logic level and with

14
00:01:13,720 --> 00:01:16,470
the SB 32, which operates at three point three.

15
00:01:17,250 --> 00:01:22,050
So really, you can take it from one project to the other and just use it without having to worry about

16
00:01:22,380 --> 00:01:25,110
the logic level of each device.

17
00:01:25,860 --> 00:01:32,840
OK, now part of that, I'm going to show you what the wirings and then have a look at the software.

18
00:01:33,360 --> 00:01:39,780
So first of all, in this row of pins down here at the bottom with conchi and connected to the ground,

19
00:01:39,780 --> 00:01:46,550
of course, so that there is a common ground between my external benchtop power supply and the ability

20
00:01:46,590 --> 00:01:51,060
two, then for VM, I haven't connected it.

21
00:01:51,070 --> 00:01:55,800
That is the the power voltage for the logic circuit.

22
00:01:56,190 --> 00:02:03,050
But I've opted to just power the V eight eight seven one from the power supply.

23
00:02:03,060 --> 00:02:11,820
So I'm leaving the room and connected and I've got in one and into in one in to allow you to control

24
00:02:11,820 --> 00:02:19,260
the direction of the spin of the rotor of the motor and its speed, the way that have configured it

25
00:02:19,260 --> 00:02:29,790
here, using in one to control the direction and that is connected to Tapio 21 and into I'm using it

26
00:02:29,790 --> 00:02:36,530
to control the speed of the rotor and that is connected to Tiberio two on my PSP thirty two.

27
00:02:37,290 --> 00:02:46,590
And finally I've got my motor connected to the motor scooter and if it does really matter which way

28
00:02:46,620 --> 00:02:50,430
you connect the wires, it's a symmetrical device.

29
00:02:51,360 --> 00:02:51,840
All right.

30
00:02:52,110 --> 00:02:56,190
Now let's have a look at the software side.

31
00:02:56,760 --> 00:03:01,770
There's no particular library that you need to install in order to control this motor or when it really

32
00:03:01,770 --> 00:03:03,060
is pinned.

33
00:03:03,090 --> 00:03:13,170
And and I've also imported the sleep module so can add a bit of delay in between speed settings then.

34
00:03:13,170 --> 00:03:17,190
I am creating that in one and in two objects.

35
00:03:17,190 --> 00:03:23,280
So in one, again, it's just a simple G.P.A. pin object used to control the direction.

36
00:03:23,610 --> 00:03:31,210
So I'm simply turning to Peio twenty one on and off and then control it.

37
00:03:31,470 --> 00:03:35,070
Which way the rotor is going to spin.

38
00:03:35,580 --> 00:03:40,730
And then I'm using GWM signals on Tapio two to control the speed.

39
00:03:41,130 --> 00:03:48,710
Now the speed with it's fast or slow depends on the direction of travel of the rotor.

40
00:03:49,080 --> 00:03:51,920
So I'll explain the frequency here.

41
00:03:51,930 --> 00:03:59,670
Default is one thousand but of five hundred hertz frequency work with my motor and again you can experimentally

42
00:03:59,670 --> 00:04:05,850
try different settings to see which ones work best in the case of your motor.

43
00:04:06,750 --> 00:04:10,400
Then we go into an infinite loop and I've got two things happening here.

44
00:04:10,410 --> 00:04:19,080
First, I am sending different settings to the motor so that I change its speed.

45
00:04:19,080 --> 00:04:26,550
And notice, for example, that when I am moving the motor in one particular direction by turning in

46
00:04:26,550 --> 00:04:37,200
one two on, then M0 is its fastest setting and the other extend the M one thousand and twenty three

47
00:04:37,200 --> 00:04:39,810
is when the motor is actually stopped.

48
00:04:40,380 --> 00:04:43,050
But the exact opposite is happening in reverse.

49
00:04:43,050 --> 00:04:52,860
So when I turn the in one typical of and that causes the rotor to shift its direction to the other direction

50
00:04:53,940 --> 00:04:59,770
in the opposite direction, then a high number of m the.

51
00:04:59,930 --> 00:05:10,210
Value for the duty cycle will cause the Rotha to spin fast where it was slow in the previous direction,

52
00:05:10,210 --> 00:05:19,660
the opposite direction, and then as the values drop towards zero, the speed of the rotor stops as

53
00:05:19,660 --> 00:05:25,670
well, where zero in the opposite direction is the fastest setting.

54
00:05:25,990 --> 00:05:34,960
So we just need to keep in mind that the speed and value and speed have to do with the direction of

55
00:05:34,960 --> 00:05:36,370
travel of the road.

56
00:05:37,000 --> 00:05:45,490
So these numbers need to be taken into conjunction with the direction of the rotation and no go together.

57
00:05:46,180 --> 00:05:47,890
All right, let's do a demonstration.

58
00:05:47,890 --> 00:05:50,230
So I'm going to turn on my power supply.

59
00:05:50,770 --> 00:05:59,470
I've said the voltage to six and a half volts, which is the minimum that the Davíð eight eight seven

60
00:05:59,470 --> 00:06:00,820
one will work with.

61
00:06:01,180 --> 00:06:06,940
I've got a maximum of two ends and will tend the power supply on.

62
00:06:07,360 --> 00:06:07,710
All right.

63
00:06:08,620 --> 00:06:11,530
And can you start the script?

64
00:06:13,750 --> 00:06:18,780
So moving one direction, let's call that forward and then moving the other direction.

65
00:06:18,790 --> 00:06:20,500
Let's call that reverse.

66
00:06:21,610 --> 00:06:31,060
And I can control the speed each time from high to low, just passing the appropriate value for that

67
00:06:31,060 --> 00:06:33,580
direction of travel of the rotor.

68
00:06:48,430 --> 00:06:49,870
OK, we'll stop that here.

69
00:06:50,320 --> 00:06:58,300
Just remember that it is possible to use the chill here in order to figure out what the numbers are

70
00:06:58,330 --> 00:07:00,090
before you commit them into your sketch.

71
00:07:00,400 --> 00:07:02,770
So I'll just give you a quick demonstration.

72
00:07:02,800 --> 00:07:16,510
Let's say that we've got these two Io's in one and two to go for the default frequency, which is 1000

73
00:07:16,510 --> 00:07:16,900
hertz.

74
00:07:17,320 --> 00:07:26,440
And let's say that in one is on so called the road of travelling in that direction.

75
00:07:29,030 --> 00:07:35,930
That seems to be clockwise, let's call it clockwise, for I change duty cycle to zero.

76
00:07:38,210 --> 00:07:43,790
Is its maximum speed and scope for 1023.

77
00:07:45,420 --> 00:07:50,070
That stops I for a change in one two of.

78
00:07:52,410 --> 00:08:01,760
I can see that now it's spinning at the maximum speed, but in the opposite direction for them, go

79
00:08:01,760 --> 00:08:03,050
for two cycles zero.

80
00:08:04,760 --> 00:08:05,720
In this direction.

81
00:08:06,510 --> 00:08:11,940
The rotor stops, whereas in the previous direction, he was at maximum speed, so that's how you can

82
00:08:12,150 --> 00:08:21,150
just empirically and easily figure out which speed he is setting and direction works best for the situation.
