From 337e7f092936e957677732836ecc21b4f76a0c21 Mon Sep 17 00:00:00 2001 From: Jake <jake.read@cba.mit.edu> Date: Thu, 12 Jul 2018 00:41:19 -0400 Subject: [PATCH] tmc2130 happy enough, bigger fish exist --- embedded/README.md | 3 ++- embedded/atkstepper17/atkstepper17/tmc2130.c | 23 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/embedded/README.md b/embedded/README.md index 5e7f196..c5cc60e 100644 --- a/embedded/README.md +++ b/embedded/README.md @@ -8,4 +8,5 @@ Two hardware timers run step timing, one fires every time a step is to be taken, ## Current Problems -- not really setting ihold or irun, what's up \ No newline at end of file +- step-delay on first step causing issues? +- trinamic fiddling... need different sense resistors? \ No newline at end of file diff --git a/embedded/atkstepper17/atkstepper17/tmc2130.c b/embedded/atkstepper17/atkstepper17/tmc2130.c index c51cf64..41533f1 100644 --- a/embedded/atkstepper17/atkstepper17/tmc2130.c +++ b/embedded/atkstepper17/atkstepper17/tmc2130.c @@ -35,23 +35,21 @@ void tmc2130_start(tmc2130_t *tmc){ // Write to GCONF uint8_t writeGConf = 0x00 | 0b10000000; - // set: diag0 to overtemp warn, diag1 to stall, - // use internal reference voltage (for now, so no PWM needed), use external sense resistors - uint32_t gConf = 0b00000000000000000000000101000000; + // actually nothing we want, for now + // 0b + uint32_t gConf = 0b000000000000000000; tmc2130_write(tmc, writeGConf, gConf); - // Write IHOLD_IRUN settings - uint8_t writeIHold_IRun = 0x10 | 0b10000000; - // 1st is 0->31/32 IHold, 2nd is 0->31/32 IRun, 3rd is 0->15 Delay after standstill - uint32_t IHold_IRun = 6 | ((uint32_t)8 << 8) | ((uint32_t)1 << 16); - tmc2130_write(tmc, writeIHold_IRun, IHold_IRun); - + // this writes to IHOLD_IRUN register + tmc2130_setCurrents(tmc, 16, 20); + // Write CHOPCONF uint8_t writeChopConf = 0x6C | 0b10000000; // with internal AIN, we have 2.5V at AIN, effective max. // bs, mstep, pwmsync, bs, vsense, blank time, chopper mode, random toff, bs, hysteresis, hysteresis, toff, // 0b 0010 0100 0000 00 1 10 0 0 00 0100 000 0010 - uint32_t chopConf = 0b00100100000000010000001000000010; + // 0b 0010 0100 0000 00 1 01 0 0 00 0100 010 0010 + uint32_t chopConf = 0b00100100000000101000000010010010; tmc2130_write(tmc, writeChopConf, chopConf); } @@ -62,10 +60,11 @@ void tmc2130_setCurrents(tmc2130_t *tmc, uint8_t ihold, uint8_t irun){ if(irun > 31){ irun = 31; } + // Write IHOLD_IRUN settings - uint8_t writeIHold_IRun = 0x10 | 0b10000000; // address + uint8_t writeIHold_IRun = 0x10 | 0b10000000; // 1st is 0->31/32 IHold, 2nd is 0->31/32 IRun, 3rd is 0->15 Delay after standstill - uint32_t IHold_IRun = ihold | ((uint32_t)irun << 8) | ((uint32_t)5 << 16); + uint32_t IHold_IRun = ihold | ((uint32_t)irun << 8) | ((uint32_t)1 << 16); tmc2130_write(tmc, writeIHold_IRun, IHold_IRun); } -- GitLab