Examples | Shop
 
Wireless DC Motor with OOPic-R
 
This example applxication demonstrates how DC motors can be controlled wirelessly using an OOPic-R connected to the Dual Channel PWM DC Motor Driver Board, WCM (Wireless Control Module) and WHC (Wireless Handheld Controller). It has been developed from the DC Motors with OOPic-R example.

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, Driver Board and WCM are connected very simply using the Dual DC Motor IO pins that are set-aside on the oopic board and the PRG header. 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
 
    OOPic-R   WCM
I2C Connector Cable - PRG Header (5 pin) - I2C Input (4 pin)
         
In this example the right motor is used.

Connect a 12-55v power supply (3A max) to the +12V and GND connections on the X3 header in the middle of the motor driver 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 accelerates and decelerates the motor.

At any time you can send a command from the WHC to the WCM, which will override the autonomous program. To use the WHC do the following:

• Set the WCM remote node to 2
• To perform a manual override command, send 4 (green indicator).

The application is now under manual control. It can be controlled in the following ways:

• Select the Red Indicator.
• Send 5 to move the motor forwards at full speed.
• Send 6 to move the motor backwards at full speed.
• Send 7 to accelerate the motor backwards.
• Send 8 to accelerate the motor forwards.
• Send 9 to stop the motor.

To return the motor back to autonomous control, do the following:

• Select the Yellow Indicator.
• Send 14 to exit manual mode.

The program will then continue in its autonomous mode until overridden again.

Download the code here.

 

'**************************************************************************
'**************************************************************************
'Description: This example code shows simple routines to drive a 12V DC Motor connected to the Dual ‘Channel PWM DC Motor Driver Board (magnevation) and controlled by the OOPic-R.
'It demonstrates how ‘to set up the Driver Board and how to set the speed of the motor, the brake function and a speed step loop.
'
'Compiler Version: 5.0.1 (B2.2.x+) OOPic-R
'Created: 18/02/03 Revision: 1.0
'Written by: Total Robots
'TR-33
'
'**************************************************************************
'**************************************************************************
Dim RMotor as new oDCMotor 'DCMotor object used with the Dual PWM Board
Sub Main()
RMotor.IOLineP = 18 'Set up the PWM IOLine
RMotor.IOLineD = 26 'Set up the Direction IOLine
RMotor.IOLineB = 24 'Set up the Brake IOLine
RMotor.Unsigned = 0 'Set up values of -128 to 127
'To use 0-255 set to 1.
RMotor.Operate = 1 'Set operate value to on
RMotor.Brake = 0 'Brake is off
RMotor.Mode = 1 'PWM gets +5v when brake is 1.
‘To use a mechanical brake, set to
'0 so the PWM will get 0v.
oopic.delay = 200 ‘2 second delay
RMotor = 127 'Motor at full speed in one direction
oopic.delay = 300 '3 second delay
RMotor.Brake = 1 'Set the brake to on
oopic.delay = 100 '1 second delay
RMotor.Brake = 0 'Brake is off
RMotor = -128 'Motor at full in the oposite direction
oopic.delay = 300 '3 second delay
RMotor.Brake = 1 'Set the brake to on
oopic.delay = 100 '1 second delay
RMotor.Brake = 0 'Brake is off
Do
For RMotor = -127 to 126 'This loop steps the speed up and down
OOPic.Delay = 2 'forwards and backwards.
Next RMotor
For RMotor = 126 to -127 step -1
OOPic.Delay = 2
Next RMotor
Loop
End Sub
'**************************************************************************
'**************************************************************************


Examples | Shop