Connecting the MD03 Motor Drive Module to the OOPic 

The MD03 motor drive module is connected to the OOPic via the OOPic's built in I2C bus. You will require 2 power sources for the motor board. A 5v supply for the OOPic and the control logic on the MD03, and a supply for the motor itself. This can be anything from 5v to 50v. The photo above has two 12v 7Ah batteries connected is series for 24v. If you go as low as 5v, make sure you don't use the same 5v as the OOPic/logic supply. You still require 2 separate power sources. The 5v regulator on the OOPic can supply one motor module. If you need more then use a separate 5v supply or change the regulator on the OOPic. There are instructions here for doing that.

Make the following connections to the signal terminals;
1.  Connect +5v to pin21 (+5v) on the OOPic 40 way connector
2.  Connect SCL to pin3 (LSCL) on the OOPic 40 way connector
3.  Connect SDA to pin1 (LSDA) on the OOPic 40 way connector
4.  Connect GND to pin2 (GND) on the OOPic 40 way connector

Now make these connections to the Motor/Power terminals; Take Care - High currents can cause injuries.
5.  Connect the MOT terminals to your motor.
6.  Connect the GND terminal to the -V on the Battery
7.  Connect +V to a 25Amp or 30Amp fuse. The FUSE is important, don't leave it out!
8.  Connect the other end of the fuse to the +v Battery terminal
If the motor runs in the wrong direction the MOT terminals can be reversed. Don't forget to disconnect the battery before you do so.

Circuit Schematic for connecting the OOPic to the MD03 Motor Drive Module

The sample code below can be downloaded here md03.osc


'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'                      MD03 Example Test Routine
' This program sets up and initializes an oI2C object called MD03
' It then goes into an endless loop, accelerating the motor to maximum
' forward speed, then decelerating it through zero to a slow reverse speed.
' It uses address 0xB0, which can be changed with the following;
' MD03.Node = 88 'Decimal of Hex address 0xB0 shifted right by 1
' MD03.Node = 89 'Decimal of Hex address 0xB2 shifted right by 1
' MD03.Node = 90 'Decimal of Hex address 0xB4 shifted right by 1
' MD03.Node = 91 'Decimal of Hex address 0xB6 shifted right by 1
' MD03.Node = 92 'Decimal of Hex address 0xB8 shifted right by 1
' MD03.Node = 93 'Decimal of Hex address 0xBA shifted right by 1
' MD03.Node = 94 'Decimal of Hex address 0xBC shifted right by 1
' MD03.Node = 95 'Decimal of Hex address 0xBE shifted right by 1
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim MD03 As New oI2C               'Create the MD03 object
Dim Status As New oByte            'Hold status reg. from MD03

Sub main()                         'Start of main program
MD03.Node = 88                     'Decimal of Hex address 0xB0 shifted right by 1
MD03.Mode = cv10bit                'I2C mode is 10-Bit Addressing.
MD03.NoInc = 1                     'Don't increment
MD03.Location = 3                  'Address of accel reg.
MD03 = 254                         'Gentle acceleration

While(1)
  MD03.Location = 2                'Address of speed reg.
  MD03 = 243                       'Fast speed
  MD03.Location = 0                'Address of command reg.
  MD03 = 1                         'Run motor forwards
  Do
    MD03.Location = 1              'Address of status reg.
    Status = MD03
    Status = Status And 1          'Only bit 0 is required
  Loop While(Status = 1)           'Wait for Acceleration to complete

  MD03.Location = 2                'Address of speed reg.
  MD03 = 30                        'Slow speed
  MD03.Location = 0                'Address of command reg.
  MD03 = 2                         'Run motor backwards
  Do
    MD03.Location = 1              'Address of status reg.
    Status = MD03
    Status = Status And 1          'Only bit 0 is required
  Loop While(Status = 1)           'Wait for Acceleration to complete
Wend
End Sub