From 9ba7f4b65f8805ca8e89567c8a23d36df124789c Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Mon, 15 Apr 2024 02:38:44 +0200 Subject: [PATCH 1/2] Extend Ruida laser property with focus --- .../liblasercut/drivers/Ruida.java | 10 +++++----- ...inMaxPowerSpeedFocusFrequencyProperty.java} | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) rename src/main/java/de/thomas_oster/liblasercut/properties/{FloatMinMaxPowerSpeedFrequencyProperty.java => FloatMinMaxPowerSpeedFocusFrequencyProperty.java} (81%) diff --git a/src/main/java/de/thomas_oster/liblasercut/drivers/Ruida.java b/src/main/java/de/thomas_oster/liblasercut/drivers/Ruida.java index 0cf8fdab..48b0ced9 100644 --- a/src/main/java/de/thomas_oster/liblasercut/drivers/Ruida.java +++ b/src/main/java/de/thomas_oster/liblasercut/drivers/Ruida.java @@ -54,7 +54,7 @@ /* for serial/usb i/o */ import java.util.concurrent.TimeUnit; -import de.thomas_oster.liblasercut.properties.FloatMinMaxPowerSpeedFrequencyProperty; +import de.thomas_oster.liblasercut.properties.FloatMinMaxPowerSpeedFocusFrequencyProperty; import de.thomas_oster.liblasercut.properties.LaserProperty; import purejavacomm.CommPort; import purejavacomm.CommPortIdentifier; @@ -178,19 +178,19 @@ public Ruida clone() { @Override public LaserProperty getLaserPropertyForVectorPart() { - return new FloatMinMaxPowerSpeedFrequencyProperty(); + return new FloatMinMaxPowerSpeedFocusFrequencyProperty(); } @Override public LaserProperty getLaserPropertyForRasterPart() { - return new FloatMinMaxPowerSpeedFrequencyProperty(); + return new FloatMinMaxPowerSpeedFocusFrequencyProperty(); } @Override public LaserProperty getLaserPropertyForRaster3dPart() { - return new FloatMinMaxPowerSpeedFrequencyProperty(); + return new FloatMinMaxPowerSpeedFocusFrequencyProperty(); } @Override @@ -641,7 +641,7 @@ public void writeJobCode(LaserJob job, ProgressListener pl) throws IOException { case SETPROPERTY: { LaserProperty pr = cmd.getProperty(); - FloatMinMaxPowerSpeedFrequencyProperty prop = (FloatMinMaxPowerSpeedFrequencyProperty) pr; + FloatMinMaxPowerSpeedFocusFrequencyProperty prop = (FloatMinMaxPowerSpeedFocusFrequencyProperty) pr; if (first_prop) { first_prop = false; currentMinPower = cmd_layer_percent("c631", part_number, currentMinPower, prop.getMinPower()); diff --git a/src/main/java/de/thomas_oster/liblasercut/properties/FloatMinMaxPowerSpeedFrequencyProperty.java b/src/main/java/de/thomas_oster/liblasercut/properties/FloatMinMaxPowerSpeedFocusFrequencyProperty.java similarity index 81% rename from src/main/java/de/thomas_oster/liblasercut/properties/FloatMinMaxPowerSpeedFrequencyProperty.java rename to src/main/java/de/thomas_oster/liblasercut/properties/FloatMinMaxPowerSpeedFocusFrequencyProperty.java index d0b7b17f..1175b1f7 100644 --- a/src/main/java/de/thomas_oster/liblasercut/properties/FloatMinMaxPowerSpeedFrequencyProperty.java +++ b/src/main/java/de/thomas_oster/liblasercut/properties/FloatMinMaxPowerSpeedFocusFrequencyProperty.java @@ -27,17 +27,17 @@ * Add 'min power' to FloatPowerSpeedFrequencyProperty */ -public class FloatMinMaxPowerSpeedFrequencyProperty extends FloatPowerSpeedFrequencyProperty { +public class FloatMinMaxPowerSpeedFocusFrequencyProperty extends FloatPowerSpeedFocusFrequencyProperty { private float min_power = 10.0f; private static final String MIN_POWER = "min power"; - public FloatMinMaxPowerSpeedFrequencyProperty() + public FloatMinMaxPowerSpeedFocusFrequencyProperty() { super(); } - public FloatMinMaxPowerSpeedFrequencyProperty(LaserProperty o) + public FloatMinMaxPowerSpeedFocusFrequencyProperty(LaserProperty o) { for (String k : o.getPropertyKeys()) { @@ -48,7 +48,7 @@ public FloatMinMaxPowerSpeedFrequencyProperty(LaserProperty o) } } } - + /** * Get the value of min power * @@ -128,9 +128,9 @@ public void setProperty(String name, Object value) } @Override - public FloatMinMaxPowerSpeedFrequencyProperty clone() + public FloatMinMaxPowerSpeedFocusFrequencyProperty clone() { - FloatMinMaxPowerSpeedFrequencyProperty result = new FloatMinMaxPowerSpeedFrequencyProperty(); + FloatMinMaxPowerSpeedFocusFrequencyProperty result = new FloatMinMaxPowerSpeedFocusFrequencyProperty(); Object p; for (String s:this.getPropertyKeys()) { @@ -147,10 +147,10 @@ public boolean equals(Object obj) { if (obj == null) { return false; } - if (!(obj instanceof FloatMinMaxPowerSpeedFrequencyProperty)) { + if (!(obj instanceof FloatMinMaxPowerSpeedFocusFrequencyProperty)) { return false; } - final FloatMinMaxPowerSpeedFrequencyProperty other = (FloatMinMaxPowerSpeedFrequencyProperty) obj; + final FloatMinMaxPowerSpeedFocusFrequencyProperty other = (FloatMinMaxPowerSpeedFocusFrequencyProperty) obj; if (this.min_power != other.min_power) { return false; } @@ -167,7 +167,7 @@ public int hashCode() { public String toString() { - return "FloatMinMaxPowerSpeedFrequencyProperty(min power="+getMinPower()+", max power="+getPower()+", speed="+getSpeed()+", frequency="+getFrequency()+")"; + return "FloatMinMaxPowerSpeedFocusFrequencyProperty(min power="+getMinPower()+", max power="+getPower()+", speed="+getSpeed()+", focus="+getFocus()+", frequency="+getFrequency()+")"; } } From 321110292a3f3efdca3e36469ccff6d0f0e3d9fd Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Mon, 15 Apr 2024 02:34:47 +0200 Subject: [PATCH 2/2] Add software focus capability to Ruida driver This feature is not configurable at the moment; we could make it configurable if needed. Tested on an OMTech Polar with a Ruida 6442s controller. --- .../liblasercut/drivers/Ruida.java | 22 +++++++++++++++++-- ...thomas_oster.liblasercut.drivers.Ruida.out | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/thomas_oster/liblasercut/drivers/Ruida.java b/src/main/java/de/thomas_oster/liblasercut/drivers/Ruida.java index 48b0ced9..414a0709 100644 --- a/src/main/java/de/thomas_oster/liblasercut/drivers/Ruida.java +++ b/src/main/java/de/thomas_oster/liblasercut/drivers/Ruida.java @@ -582,7 +582,6 @@ public void writeJobCode(LaserJob job, ProgressListener pl) throws IOException { for (JobPart p : job.getParts()) { - float focus; boolean engrave = false; if ((p instanceof RasterPart) || (p instanceof Raster3dPart)) @@ -642,13 +641,27 @@ public void writeJobCode(LaserJob job, ProgressListener pl) throws IOException { { LaserProperty pr = cmd.getProperty(); FloatMinMaxPowerSpeedFocusFrequencyProperty prop = (FloatMinMaxPowerSpeedFocusFrequencyProperty) pr; + float focus = prop.getFocus(); if (first_prop) { first_prop = false; currentMinPower = cmd_layer_percent("c631", part_number, currentMinPower, prop.getMinPower()); currentMaxPower = cmd_layer_percent("c632", part_number, currentMaxPower, prop.getPower()); // prop speed is in %, ruida speed is in mm/s (0..1000) currentSpeed = cmd_layer_absoluteMM("c904", part_number, currentSpeed, prop.getSpeed() * getMaxVectorCutSpeed() / 100); - // focus - n/a + + // negative focus is not applicable on the test device (uses 6442s) + if (focus <= 0) { + focus = 0; + } + + // configure axis velocity, affects move speed of Z axis + stream.hex("c903").absoluteMM(5); + // move Z axis to desired focus valueu + // the value depends on the device + // on an OMTech Polar, for instance, focus needs to be set to 17 - + // for instance, for a 3mm thick material, one needs to configure a focus of 14.0 + stream.hex("800B").absoluteMM(focus); + // frequency stream.hex("c660").byteint(part_number).hex("00").longint(prop.getFrequency()); // color - red for now @@ -681,6 +694,11 @@ public void writeJobCode(LaserJob job, ProgressListener pl) throws IOException { currentSpeed = -1; } + // configure axis velocity, affects move speed of Z axis + stream.hex("c903").absoluteMM(5); + // move Z axis back to 0 + stream.hex("800B").absoluteMM(0); + /* work interval */ stream.hex("DA010620").longint(travel_distance).longint(travel_distance); /* stop */ diff --git a/test-output/de.thomas_oster.liblasercut.drivers.Ruida.out b/test-output/de.thomas_oster.liblasercut.drivers.Ruida.out index 0e029041..5eefc777 100644 --- a/test-output/de.thomas_oster.liblasercut.drivers.Ruida.out +++ b/test-output/de.thomas_oster.liblasercut.drivers.Ruida.out @@ -1 +1 @@ -Ò›úâ‹p ým{ý‰z‹‰Ò‰p‰‰‰‰‰‰‰‰‰‰p ‰‰‰ õ‰‰‰‰‰p‰‰鉉 …ùpÙ‰‰‰ õ‰‰‰‰‰pY‰‰鉉 …ùp‰ ‰ ‰‰‰‰‰‰‰‰‰‰p ‰Ä«‹pÛ‰‰‰‰ õ‰‰‰‰‰p[‰‰‰鉉 …ùpi‰‰‰‰ õ‰‰‰‰‰p뉉‰鉉 …ùÐ9‰wwл‰wwB‰‰‰5ÉÐ鉉‰‰‰ ýĉ‰‰‰‰íÄI‰‰Ä ‰Ä‹‰Ä B‹‰‰5ÉÐ wwЋwwÄ Ä™‰‚‰‰‰ õ‰‰‰ õ¢‰‰ ϱ‰‰ …ù¢‰‰ …ù‰‰‰‰‰‚‰‰鉉‰‰‰¢‰‰[/‰‰‰/Ñ¢‰‰Û}‰‰ —é"‰{"w±m"‰;/Ñ¢‰‰[/‰‰‹m‘¢‰‰鉉 …ùpÛ ‰‰‰ ‰‰‰‡_p[ ‰‰‰U‰‰‰™]pi ‰‰‰ ‰‰‰‡_pë ‰‰‰U‰‰‰™]Ð9 wwл wwB ‰‰5ÉÐé ‰‰‰‰ ýÄ ‰‰‰‰íÄI ‹Ä Ä‹ Ä B‹‰‰5ÉÐ wwЋwwÄ Ä™‰‚‰‰‰ ‰‰‰‡_¢‰‰‰ q‰‰‰‡_¢‰‰‰W‰‰‰‡_¢‰‰‰›‰‰‰‡_¢‰‰‰£‰‰‰‡_¢‰‰‰U‰‰‰‡_‚‰‰‰U‰‰‰ƒ¢‰‰‰£‰‰‰ƒ¢‰‰‰M‰‰‰ƒ¢‰‰‰W‰‰‰ƒ¢‰‰‰¥‰‰‰ƒ¢‰‰‰ ‰‰‰ƒ‚‰‰‰ ‰‰‰5¢‰‰‰U‰‰‰5‚‰‰‰U‰‰‰ù¢‰‰‰ q‰‰‰ù¢‰‰‰ ‰‰‰ù‚‰‰‰ ‰‰‰™«¢‰‰‰U‰‰‰™«‚‰‰‰U‰‰‰™]¢‰‰‰ q‰‰‰™]¢‰‰‰ ‰‰‰™]pÛ‹‰‰‰™]‰‰‰—Op[‹‰‰‰—‰‰‰©Mpi‹‰‰‰™]‰‰‰—Op닉‰‰—‰‰‰©MÐ9‹wwл‹wwB‹‰‰5ÉÐ鋉‰‰‰ ýÄ‹‰‰‰‰íÄI‹‹Ä Ä‹‹Ä B‹‰‰5ÉÐ wwЋwwÄ Ä™‰‚‰‰‰3‰‰‰—O¢‰‰‰›©‰‰‰—O‚‰‰‰›[‰‰‰—O¢‰‰‰剉‰—O‚‰‰‰剉‰—󢉉‰‰‰‰—󂉉‰›©‰‰‰—󢉉‰e‰‰‰—󂉉‰™]‰‰‰%ЋWw¢‰‰‰‰‰‰%‚‰‰‰3‰‰‰%¢‰‰‰—‰‰‰%‚‰‰‰—‰‰‰éЋɉ¢‰‰‰3‰‰‰邉‰‰™]‰‰‰©MЋww¢‰‰‰3‰‰‰©MÔ ©‰‰‰‹e‰‰‰‹ep‰` \ No newline at end of file +Ò›úâ‹p ým{ý‰z‹‰Ò‰p‰‰‰‰‰‰‰‰‰‰p ‰‰‰ õ‰‰‰‰‰p‰‰鉉 …ùpÙ‰‰‰ õ‰‰‰‰‰pY‰‰鉉 …ùp‰ ‰ ‰‰‰‰‰‰‰‰‰‰p ‰Ä«‹pÛ‰‰‰‰ õ‰‰‰‰‰p[‰‰‰鉉 …ùpi‰‰‰‰ õ‰‰‰‰‰p뉉‰鉉 …ùÐ9‰wwл‰wwB‰‰‰5ÉB ‰‰‰/Š‰‰‰‰‰Ð鉉‰‰‰ ýĉ‰‰‰‰íÄI‰‰Ä ‰Ä‹‰Ä B‹‰‰5ÉÐ wwЋwwÄ Ä™‰‚‰‰‰ õ‰‰‰ õ¢‰‰ ϱ‰‰ …ù¢‰‰ …ù‰‰‰‰‰‚‰‰鉉‰‰‰¢‰‰[/‰‰‰/Ñ¢‰‰Û}‰‰ —é"‰{"w±m"‰;/Ñ¢‰‰[/‰‰‹m‘¢‰‰鉉 …ùpÛ ‰‰‰ ‰‰‰‡_p[ ‰‰‰U‰‰‰™]pi ‰‰‰ ‰‰‰‡_pë ‰‰‰U‰‰‰™]Ð9 wwл wwB ‰‰5ÉB ‰‰‰/Š‰‰‰‰‰Ðé ‰‰‰‰ ýÄ ‰‰‰‰íÄI ‹Ä Ä‹ Ä B‹‰‰5ÉÐ wwЋwwÄ Ä™‰‚‰‰‰ ‰‰‰‡_¢‰‰‰ q‰‰‰‡_¢‰‰‰W‰‰‰‡_¢‰‰‰›‰‰‰‡_¢‰‰‰£‰‰‰‡_¢‰‰‰U‰‰‰‡_‚‰‰‰U‰‰‰ƒ¢‰‰‰£‰‰‰ƒ¢‰‰‰M‰‰‰ƒ¢‰‰‰W‰‰‰ƒ¢‰‰‰¥‰‰‰ƒ¢‰‰‰ ‰‰‰ƒ‚‰‰‰ ‰‰‰5¢‰‰‰U‰‰‰5‚‰‰‰U‰‰‰ù¢‰‰‰ q‰‰‰ù¢‰‰‰ ‰‰‰ù‚‰‰‰ ‰‰‰™«¢‰‰‰U‰‰‰™«‚‰‰‰U‰‰‰™]¢‰‰‰ q‰‰‰™]¢‰‰‰ ‰‰‰™]pÛ‹‰‰‰™]‰‰‰—Op[‹‰‰‰—‰‰‰©Mpi‹‰‰‰™]‰‰‰—Op닉‰‰—‰‰‰©MÐ9‹wwл‹wwB‹‰‰5ÉB ‰‰‰/Š‰‰‰‰‰Ð鋉‰‰‰ ýÄ‹‰‰‰‰íÄI‹‹Ä Ä‹‹Ä B‹‰‰5ÉÐ wwЋwwÄ Ä™‰‚‰‰‰3‰‰‰—O¢‰‰‰›©‰‰‰—O‚‰‰‰›[‰‰‰—O¢‰‰‰剉‰—O‚‰‰‰剉‰—󢉉‰‰‰‰—󂉉‰›©‰‰‰—󢉉‰e‰‰‰—󂉉‰™]‰‰‰%ЋWw¢‰‰‰‰‰‰%‚‰‰‰3‰‰‰%¢‰‰‰—‰‰‰%‚‰‰‰—‰‰‰éЋɉ¢‰‰‰3‰‰‰邉‰‰™]‰‰‰©MЋww¢‰‰‰3‰‰‰©MB ‰‰‰/Š‰‰‰‰‰Ô ©‰‰‰‹e‰‰‰‹ep‰` \ No newline at end of file