@@ -381,15 +381,18 @@ class HighPowerStepperDriver
381381 void setCurrentMilliamps36v4 (uint16_t current)
382382 {
383383 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 );
385388 }
386389
387390 // / Sets the current limit for a High-Power Stepper Motor Driver 36v8.
388391 // /
389392 // / The argument to this function should be the desired current limit in
390393 // / milliamps.
391394 // /
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;
393396 // / higher currents might be sustainable for short periods, but can eventually
394397 // / cause the MOSFETs to overheat, which could damage them. See the driver's
395398 // / product page for more information.
@@ -413,18 +416,18 @@ class HighPowerStepperDriver
413416 //
414417 // TORQUE = (256 * ISGAIN * Risense * Ifs) / 2.75 V
415418 //
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
417420 // in milliamps, so:
418421 //
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
422425 //
423426 // We want to pick the highest gain (5, 10, 20, or 40) that will not
424427 // overflow TORQUE (8 bits, 0xFF max), so we start with a gain of 40 and
425428 // calculate the TORQUE value needed.
426429 uint8_t isgainBits = 0b11 ;
427- uint16_t torqueBits = ((uint32_t )768 * current) / 6875 ;
430+ uint16_t torqueBits = ((uint32_t )384 * current) / 6875 ;
428431
429432 // Halve the gain and TORQUE until the TORQUE value fits in 8 bits.
430433 while (torqueBits > 0xFF )
0 commit comments