This example application
demonstrates how DC motors can be controlled using an OOPic-R connected
to the Dual Channel PWM DC Motor Driver Board.
In this example a 12V DC motor with sumo tyre and hub is connected
to one of the driver ports on the Motor Driver Board. The OOPic then
controls the motors direction, speed and brake status.
The OOPic-R and Driver Board are connected very simply using the Dual
DC Motor IO pins that are set-aside on the board. They are connected
as follows: |
| |
| |
|
OOPic-R |
|
Driver Board
Pin |
| Dir.Right Motor |
- |
26 |
- |
36 |
| Brake Right Motor |
- |
24 |
- |
40 |
| Speed Right Motor |
- |
18 (PWM1) |
- |
29 |
| Dir.Left Motor |
- |
27 |
- |
34 |
| Brake Left Motor |
- |
25 |
- |
38 |
| Speed Left Motor |
- |
17 (PWM2) |
- |
27 |
| +5 Volts |
- |
+5v |
- |
21 or 22 |
| Ground |
- |
GND |
- |
23 or 24 |
| |
|
|
|
|
|
In this example the right motor
is used.
Connect 12-55v to the +12V and GND connections on the X3 header in
the middle of the board. The right and left motors are isolated from
each other but a single battery can be used to power both sides as
long as it can take the voltage and current demands.
Do not take power from the OOPic to power the motors!
The 12v DC Motor should have a 0.1uf capacitor connected across its
two legs to smooth the signal and reduce electrical noise. The two
pins should then be connected to the Right motor connection (the outer
connectors). The middle one is used if your motor has a ground wire
connected to its casing.
When you are connected, power up the OOPic and download the program.
After a 2 second delay, the motors will move at full speed in one
direction. 3 seconds later it brakes and goes full speed in the reverse
direction again for 3 seconds. It brakes again then goes into a loop
that accelerates and decelerates the motor.
Download
the code here. |