AccelStepperI2C
v0.2.2
I2C wrapper (and a bit more) for the AccelStepper Arduino library
|
Arduino library for I2C-control of stepper motors connected to another Arduino which runs the associated AccelStepperI2C firmware.
See the AccelStepperI2C class reference for differences to the methods of the original AccelStepper class and for new methods of class AccelStepperI2C. Functions which address not a single stepper but the slave as a whole are documented here (I2Cwrapper).
Copyright (c) 2022 juh
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
add emergency stop/break pin for slave (just use reset pin for the moment)
ATM data is not protected against updates from ISRs while it is being used in the main program (see http://gammon.com.au/interrupts). Check if this could be a problem in our case.
ESP32: make use of dual cores?
use interrupts for endstops instead of main loop polling (not sure how much of a difference this would make in practice, though. The main loop is't doing much else, what really takes time are the computations.)
Multimaster? Master stop/start bit?
update keywords.txt
clean up example sketches
implement runToPosition() and runToNewPosition() in master - implemented
test (and adapt) slave firmware for ESP8266 - implemented. However, I2C slave mode on ESP8266s is no fun. Run only with 160MHz CPU and start testing with 10kHz (that's right: ten kHz) I2C clock speed.
checking each transmission with sentOK and resultOK is tedious. We could use some counter to accumulate errors and check them summarily, e.g. at the end of setup etc. - AccelStepperI2C::sentErrors(), AccelStepperI2C::resultErrors() and AccelStepperI2C::transmissionErrors() added
make time the slave has to answer I2C requests (I2CrequestDelay) configurable, as it will depend on µC and bus frequency etc. - setI2Cdelay() implemented
Versioning, I2C command to request version (important, as library and firmware always need to match) - getVersion() and checkVersion() implemented
Implement interrupt mechanism, so that the slave can inform the master about finished tasks or other events - setInterruptPin() and enableInterrupts() implemented
implement diagnostic functions, e.g. measurements how long messages take to be processed or current stepper pulse frequency - done, performance graphs included in documentation
add ESP32 compatibility for slave - done, but needs further testing
Make the I2C address programmable and persistent in EEPROM. - done
Error handling and sanity checks are rudimentary. Currently the system is not stable against transmission errors, partly due to the limitations of Wire.requestFrom() and Wire.available(). A better protocol would be needed, which would mean more overhead. Need testing to see how important this is in practics. - CRC8 implemented
Implement end stops/reference stops. - endstop polling implemented, interrupt would be better