@@ -381,15 +381,18 @@ class HighPowerStepperDriver
381
381
void setCurrentMilliamps36v4 (uint16_t current)
382
382
{
383
383
if (current > 8000 ) { current = 8000 ; }
384
- setCurrentMilliamps36v8 (current);
384
+
385
+ // The 36v4 is just like the 36v8, except Risense is twice as large, so
386
+ // TORQUE/ISGAIN has to be doubled.
387
+ setCurrentMilliamps36v8 (current * 2 );
385
388
}
386
389
387
390
// / Sets the current limit for a High-Power Stepper Motor Driver 36v8.
388
391
// /
389
392
// / The argument to this function should be the desired current limit in
390
393
// / milliamps.
391
394
// /
392
- // / WARNING: The 36v4 can supply up to about 8 A per coil continuously;
395
+ // / WARNING: The 36v8 can supply up to about 8 A per coil continuously;
393
396
// / higher currents might be sustainable for short periods, but can eventually
394
397
// / cause the MOSFETs to overheat, which could damage them. See the driver's
395
398
// / product page for more information.
@@ -413,18 +416,18 @@ class HighPowerStepperDriver
413
416
//
414
417
// TORQUE = (256 * ISGAIN * Risense * Ifs) / 2.75 V
415
418
//
416
- // The 36v4 and 36v8 have an Risense of 30 milliohms, and "current" is
419
+ // The 36v8 has an Risense of 15 milliohms, and "current" is
417
420
// in milliamps, so:
418
421
//
419
- // TORQUE = (256 * ISGAIN * (30 /1000) ohms * (current/1000) A) / 2.75 V
420
- // = (7680 * ISGAIN * current) / 2750000
421
- // = (768 * (ISGAIN/40) * current) / 6875
422
+ // TORQUE = (256 * ISGAIN * (15 /1000) ohms * (current/1000) A) / 2.75 V
423
+ // = (3840 * ISGAIN * current) / 2750000
424
+ // = (384 * (ISGAIN/40) * current) / 6875
422
425
//
423
426
// We want to pick the highest gain (5, 10, 20, or 40) that will not
424
427
// overflow TORQUE (8 bits, 0xFF max), so we start with a gain of 40 and
425
428
// calculate the TORQUE value needed.
426
429
uint8_t isgainBits = 0b11 ;
427
- uint16_t torqueBits = ((uint32_t )768 * current) / 6875 ;
430
+ uint16_t torqueBits = ((uint32_t )384 * current) / 6875 ;
428
431
429
432
// Halve the gain and TORQUE until the TORQUE value fits in 8 bits.
430
433
while (torqueBits > 0xFF )
0 commit comments