However after rummaging around in the code while developing a driver for my telescope mount, I noticed that the Adafruit code is pretty basic and makes no attempt at optimisation.
With some simple changes to the Adafruit code I have managed to improve the step rate to around 280 per second peak. This also means that there is less jitter in the pulse timing as well.
Here are a couple of graphs of the outputs as seen from inside the python code (so the physical signals may vary from this).
When the steps to the 2 motors coincide it impacts one or both motors.
The step rates of the varying speed motor here are twice as fast as the previous version, even when the second motor is stepping twice as fast as before the jitter is far lower for both motors. The version can also step significantly faster, but the jitter does start to build up at really fast step rates.
The code changes are all in the Adafruit_I2C.py module. These changes are incompatible with anything other than stepper motors, and could short out the power supply through the HAT if anything goes wrong - which would probably trash the HAT.
add to the constructor:
self.regvals = [None] * 256and the method write8 should be amended as follows:
def write8(self, reg, value):
"Writes an 8-bit value to the specified register/address"
if self.regvals[reg] is None or self.regvals[reg] != value:
self.bus.write_byte_data(self.address, reg, value)
self.regvals[reg] = value
print("I2C: Wrote 0x%02X to register 0x%02X" % (value, reg))
except IOError as err: