@@ -627,7 +627,30 @@ private double speedPercentToMmPerSec(double speedPercent) {
627
627
* @return time in seconds
628
628
*/
629
629
private double cuttingTimeForPxDistance (double distancePx , double resolution , double speedPercent ) {
630
- return Util .px2mm (distancePx , resolution ) / speedPercentToMmPerSec (speedPercent );
630
+ double speedMmPerSec = speedPercentToMmPerSec (speedPercent );
631
+ double distanceMm = Util .px2mm (distancePx , resolution );
632
+ // for the value of the acceleration, we assume the same as configured for "joint tangential curve".
633
+ if (!isUseTangentCurves ())
634
+ {
635
+ // acceleration is not configured, fall back to simple computation without acceleration
636
+ return distanceMm / speedMmPerSec ;
637
+ }
638
+ // v = a t, x = 1/2 a t² => t = v² / a², x = 1/2 v² / a
639
+ // distance x for accelerating to full speed:
640
+ double accelDistanceMm = 0.5 * Math .sqrt (speedMmPerSec * speedMmPerSec / tangentCurveMaxAcceleration );
641
+ if (distanceMm > 2 * accelDistanceMm )
642
+ {
643
+ // Accelerating to full speed.
644
+ // during acceleration, the effective speed is half the speed.
645
+ return (distanceMm + 2 * accelDistanceMm ) / speedMmPerSec ;
646
+ }
647
+ else
648
+ {
649
+ // path is too short for full acceleration.
650
+ // x = 1/2 v² / a => v_max = sqrt(2 a x), where x is half the length
651
+ double peakSpeed = Math .sqrt (tangentCurveMaxAcceleration * distanceMm );
652
+ return 2 * distanceMm / peakSpeed ;
653
+ }
631
654
}
632
655
/**
633
656
* cutting time for cutting a line at the current speed
@@ -1844,8 +1867,10 @@ private double engraveBitmapLine(PrintStream out, ByteArrayList bytes, Point lin
1844
1867
out .write (b );
1845
1868
}
1846
1869
// TODO: this time estimate doesn't include the travel time to the start point
1847
- final double engraveSpeedFactor = 2 ; // FIXME: this is a rough estimate. Calibrate the engrave speed and take acceleration into account.
1848
- return cuttingTimeForPxDistance (bytes .size () * pixelsPerByte , resolution , currentSpeed * engraveSpeedFactor );
1870
+ // TODO make the following parameters configurable
1871
+ final double engraveSpeedVersusCutSpeed = 6.4 ; // Factor between full engrave speed and full cut speed.
1872
+ final double engraveExtraSecondsPerLine = 0.1 ; // extra time per engrave line
1873
+ return engraveExtraSecondsPerLine + cuttingTimeForPxDistance (bytes .size () * pixelsPerByte , resolution , currentSpeed * engraveSpeedVersusCutSpeed );
1849
1874
}
1850
1875
1851
1876
0 commit comments