It is fairly easy to change the diddy2Web.py script so that it uses a Diablo instead of a ThunderBorg.
First change the import line:
import ThunderBorg
to
import Diablo
Next change the board setup lines:
TB = ThunderBorg.ThunderBorg()
#TB.i2cAddress = 0x15 # Uncomment and change the value if you have changed the board address
TB.Init()
if not TB.foundChip:
boards = ThunderBorg.ScanForThunderBorg()
if len(boards) == 0:
print 'No ThunderBorg found, check you are attached :)'
else:
print 'No ThunderBorg at address %02X, but we did find boards:' % (TB.i2cAddress)
for board in boards:
print ' %02X (%d)' % (board, board)
print 'If you need to change the I²C address change the setup line so it is correct, e.g.'
print 'TB.i2cAddress = 0x%02X' % (boards[0])
sys.exit()
TB.SetCommsFailsafe(False)
TB.SetLedShowBattery(False)
TB.SetLeds(0,0,1)
to the version in the Diablo examples:
# Setup the Diablo
DIABLO = Diablo.Diablo()
#DIABLO.i2cAddress = 0x44 # Uncomment and change the value if you have changed the board address
DIABLO.Init()
if not DIABLO.foundChip:
boards = Diablo.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:' % (DIABLO.i2cAddress)
for board in boards:
print ' %02X (%d)' % (board, board)
print 'If you need to change the I²C address change the setup line so it is correct, e.g.'
print 'DIABLO.i2cAddress = 0x%02X' % (boards[0])
sys.exit()
#DIABLO.SetEpoIgnore(True) # Uncomment to disable EPO latch, needed if you do not have a switch / jumper
DIABLO.ResetEpo()
After that look for the power settings:
# Power settings
voltageIn = 1.2 * 10 # Total battery voltage to the ThunderBorg
voltageOut = 12.0 * 0.95 # Maximum motor voltage, we limit it to 95% to allow the RPi to get uninterrupted power
and change the values so that match your robot.
Now look for any lines containing
TB.SetLedShowBattery
or
TB.SetLeds
and remove them.
Finally change any lines which have TB in them to have DIABLO instead. Some text editors have a find and replace function which can help with this.
Now the script should work exactly like in does on DiddyBorg v2, but using a Diablo instead :)
Thanks for this, its very much appreciated, I'm also learning code so doing this helps a heap more than reading a book.
Am I right in assuming that the code for each of the different boards is pretty similar and just needs a few adjustments? or are there some with fundamental differences
I have a DFRobot Devastator platform that is screaming out for a ThunderBorg as a later project, can I assume if I use the Diddy build examples as they are?
You are right, generally speaking the code for our motor control boards is very similar and most examples can be easily changed to work with a different one. The largest differences tend to be where the functionality is different. For example removing the LED related lines was necessary because Diablo does not have an RGB LED like ThunderBorg.
If the motors are wired the same way as DiddyBorg v2 then the examples should work without any significant changes. All you will need to do is change the voltages in the scripts to match your battery and the motors :)
If the wiring is a bit different you may need to change the values given to TB.SetMotor1 and TB.SetMotor2 slightly.
piborg
Wed, 09/12/2018 - 17:44
Permalink
Changing diddy2Web.py to use Diablo
It is fairly easy to change the
diddy2Web.py
script so that it uses a Diablo instead of a ThunderBorg.First change the import line:
to
Next change the board setup lines:
to the version in the Diablo examples:
After that look for the power settings:
and change the values so that match your robot.
Now look for any lines containing
or
and remove them.
Finally change any lines which have
TB
in them to haveDIABLO
instead. Some text editors have a find and replace function which can help with this.Now the script should work exactly like in does on DiddyBorg v2, but using a Diablo instead :)
jasontimothyjones
Thu, 09/13/2018 - 08:19
Permalink
Thanks for this, its very
Thanks for this, its very much appreciated, I'm also learning code so doing this helps a heap more than reading a book.
Am I right in assuming that the code for each of the different boards is pretty similar and just needs a few adjustments? or are there some with fundamental differences
I have a DFRobot Devastator platform that is screaming out for a ThunderBorg as a later project, can I assume if I use the Diddy build examples as they are?
piborg
Thu, 09/13/2018 - 17:37
Permalink
That's right
You are right, generally speaking the code for our motor control boards is very similar and most examples can be easily changed to work with a different one. The largest differences tend to be where the functionality is different. For example removing the LED related lines was necessary because Diablo does not have an RGB LED like ThunderBorg.
If the motors are wired the same way as DiddyBorg v2 then the examples should work without any significant changes. All you will need to do is change the voltages in the scripts to match your battery and the motors :)
If the wiring is a bit different you may need to change the values given to
TB.SetMotor1
andTB.SetMotor2
slightly.jasontimothyjones
Tue, 09/18/2018 - 17:53
Permalink
Why Syntax maters
It took me a few days, but I finally figured out why I couldn't get this working, I replaced TB with Diablo, not DIABLO