From 984f12b9fc5620cca6f2c646f20f10965e0e021b Mon Sep 17 00:00:00 2001 From: mattmcw Date: Sat, 22 Jun 2024 09:00:20 -0400 Subject: [PATCH] initial commit --- .gitignore | 1 + LICENSE | 21 ++++++++++++++ TB6600MotorDriver.h | 71 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 TB6600MotorDriver.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ccc9fd9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.DS_Store \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..56d1176 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Matthew McWilliams + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/TB6600MotorDriver.h b/TB6600MotorDriver.h new file mode 100644 index 0000000..67227a3 --- /dev/null +++ b/TB6600MotorDriver.h @@ -0,0 +1,71 @@ +#ifndef TB6600MotorDriver_h +#define TB6600MotorDriver_h + +#include + +/** + * D2 X Step + * D3 X Direction + * D4 X MS1 setting + * D5 X MS2 setting + * D6 Y Step + * D7 Y Direction + * D8 Y MS1 setting + * D9 Y MS2 setting + * + * MS1(X/Y) MS2(X/Y) Description + * L L Full step + * H L Half step + * L H Quarter step + * H H Eighth STEP + **/ + +class TB6600MotorDriver { + private: + + + + const uint8_t _directionA = 3; + const uint8_t _directionB = 7; + const uint8_t _stepA = 2; + const uint8_t _stepB = 6; + + const uint8_t _settingsA1 = 4; + const uint8_t _settingsA2 = 5; + const uint8_t _settingsB1 = 8; + const uint8_t _settingsB2 = 9; + + volatile uint32_t _usStepA = 300; + volatile uint32_t _usStepB = 300; + + //const uint8_t _microsteps = 8; //8 or 16 + volatile uint8_t _modeA = 1; //1, 2, 4, or 8 + volatile uint8_t _modeB = 1; + + void _single(uint8_t motor); + void _micro(uint8_t motor); + void _both(); + + public: + + IteadDualStepperShield(); + + uint16_t revsteps = 200; // # steps per revolution + + volatile uint8_t directionA = 1; + volatile uint8_t directionB = 1; + void setup(); + + void setDir(uint8_t motor, uint8_t dir); + void setSpeed(uint8_t motor, uint16_t speed); + + //full + void step(uint8_t motor, uint64_t steps, uint8_t dir); + void stepBoth(uint64_t steps); + void onestep(uint8_t motor, uint8_t dir); + void setStepperMode (uint8_t motor, uint8_t mode); + + void release(); +}; + +#endif \ No newline at end of file