2 Diablos

Forums:

Hello,

Is it also possible to use 2 Diablos in the diabloJoystick.py script. 1 Diablo for the left motors and 1 Diablo for the right?

Goestings Thieu

piborg's picture

Yes, the script can be easily changed to use two Diablos, one per side :)

First set the Diablos to have different addresses as explained in the Diablo - Getting Started, Multiple Boards section. Make a note of the two addresses you are using.

Next duplicate the Set up the Diablo so that you have a DIABLO1 and DIABLO2 like this:

# Setup the left Diablo
DIABLO1 = Diablo()
DIABLO1.i2cAddress = 10
DIABLO1.Init()
if not DIABLO1.foundChip:
    boards = ScanForDiablo()
    if len(boards) == 0:
        print('No Diablo found, check you are attached :)')
    else:
        print('No Diablo at address %02X, but we did find boards:' % (DIABLO1.i2cAddress))
        for board in boards:
            print('    %02X (%d)' % (board, board))
        print('If you need to change the I2C address change the set-up line so it is correct, e.g.')
        print('DIABLO1.i2cAddress = 0x%02X' % (boards[0]))
    exit()
#DIABLO1.SetEpoIgnore(True)                 # Uncomment to disable EPO latch, needed if you do not have a switch / jumper
DIABLO1.ResetEpo()

# Setup the right Diablo
DIABLO2 = Diablo()
DIABLO2.i2cAddress = 11
DIABLO2.Init()
if not DIABLO2.foundChip:
    boards = ScanForDiablo()
    if len(boards) == 0:
        print('No Diablo found, check you are attached :)')
    else:
        print('No Diablo at address %02X, but we did find boards:' % (DIABLO2.i2cAddress))
        for board in boards:
            print('    %02X (%d)' % (board, board))
        print('If you need to change the I2C address change the set-up line so it is correct, e.g.')
        print('DIABLO2.i2cAddress = 0x%02X' % (boards[0]))
    exit()
#DIABLO2.SetEpoIgnore(True)                 # Uncomment to disable EPO latch, needed if you do not have a switch / jumper
DIABLO2.ResetEpo()

Change the i2cAddress lines so that the numbers match the values you set the boards to.

Now all we need to do is change the old lines which use DIABLO so that they talk to the right board.

For the motor outputs swap:

                # Set the motors to the new speeds
                DIABLO.SetMotor1(driveLeft)
                DIABLO.SetMotor2(driveRight)

for

                # Set the motors to the new speeds
                DIABLO1.SetMotors(driveLeft)
                DIABLO2.SetMotors(driveRight)

Where the motors are turned off:

DIABLO.MotorsOff()

change it to turn off both boards:

DIABLO1.MotorsOff()
DIABLO2.MotorsOff()

Finally the EPO reset:

DIABLO.ResetEpo()

should reset both boards:

DIABLO1.ResetEpo()
DIABLO2.ResetEpo()

That should be everything you need to change :)

Subscribe to Comments for "2 Diablos "