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)
piborg
Mon, 07/15/2019 - 10:55
Permalink
Controlling two Diablos from diabloJoystick.py
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 aDIABLO1
andDIABLO2
like this: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:
for
Where the motors are turned off:
change it to turn off both boards:
Finally the EPO reset:
should reset both boards:
That should be everything you need to change :)