LaserWeb / deprecated-LaserWeb3

Open Source Laser Cutter / Engraver software. Supports gcode, svg, dxf, stl, png, jpg, bmp
265 stars 68 forks source link

marlin and laserbot code added #216

Closed mertyGit closed 7 years ago

mertyGit commented 7 years ago

Hi there.

I've bought a 'Makeblock Laserbot' (http://learn.makeblock.com/laserbot/), which is a fine, decent laser cutter/engraver, 1.6Watts, 0.1 mm precision. But...the software 'mLaser' (https://github.com/Makeblock-official/MLaser) - although open source - wasn't that great. Digging deeper in both the software code and firmware, I discovered it's a bunch of open source code "stitched together". Firmware is based on marlin with a few hacks to turn on and set the value of the laser power. Also, the X=0,Y=0 coordinates are in the _right_bottom.. I could have write "decent" firmware, flip the X-as, but it would be more usefull to other customers of the laserbot - mainly in education field- to use the software without altering hardware or firmware.

So...thats why I ended up with Laserweb...Since it is based on Marlin 1.0.2x I've checked the original Marlin code against the Laserbot one and adjusted mainly the "server.js" part of the Laserweb3.

I introduced "dialect" option, since laserbot uses marlin, but for laser commands and - strange engough- the "ok" reply is differend. It should work with other marlin engines, however, users has to supply the commands to turn on or off the laser ('S' argument isn't used by default).

Further on I've added a few functions:

Last but not least, I've 'corrected' the "flipped X" by 'hacking' the addQ code and flipping the X-coordinates. (Of course, only when firmware="marlin",dialect="laserbot" !) Not the cleanest way to do it, but otherwise I would end up in changing/messing up a lot of GUI and rasterization code.

My guess this code is safe to use and doesn't interfere much wich the rest.

Hope you like it, let me know if I can help in any other way.

Regards,

Remco

cprezzi commented 7 years ago

I will review your additions and check if they conform with our server logic and future plans (especially the new universal comms server).

cprezzi commented 7 years ago

Are you sure you don't have your laserbot turend 180° on your table or just plugged your x-motor the wrong way around? 25-1
(Picture from Makeblock laserbot setup)

Most machines have plus x/y directions to the right/top and set zero point to left/bottom.
Professional cnc-machines have zero point on right/top (but still plus direction is to right/top, so all workspace is in minus).

I makes no sense to change x-direction in server.js, as you could just flip your motor wires or change the direction option in the firmware (marlin: #define INVERT_X_DIR true). Same apply to endstops.

You also misunderstud the overrides. They change the commands in queue/planner of the firmware (immediate response), not the gcode-programm. Changing the gcode before sending it to the controller would lead to a massive delay until the commands get executed. Marlin has a feed factor override feature (M220), which can be used for our feed override, but it has no real spindle pwm override.

I am working on a complete rework of the server for a universal communications server. When this is done, I will probably implement a clean marlin interface. Problem is, Marln doesn't yet support real laser mode and will therefore not deliver practical raster engraving performance.

cprezzi commented 7 years ago

I suggest to read about grbl-Mega (https://github.com/gnea/grbl-Mega)? That's grbl 1.1 for ATmega2560. Not sure if it works with MegaPi, because of different pin usage.

Grbl has the best laser support for the moment!

ghost commented 7 years ago

Never violate the Cartesian system! Fix the hardware. Follow https://github.com/LaserWeb/LaserWeb3/wiki/Settings:--Image-Position

On Jan 6, 2017 6:53 PM, "Claudio Prezzi" notifications@github.com wrote:

Closed #216 https://github.com/LaserWeb/LaserWeb3/pull/216.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LaserWeb/LaserWeb3/pull/216#event-914278988, or mute the thread https://github.com/notifications/unsubscribe-auth/AHVr27Zk0PcUJNH-6ROI_MYj7R3GQ7EOks5rPnFugaJpZM4Lcyht .

mertyGit commented 7 years ago

Hi,

You wrote:

Are you sure you don't have your laserbot turend 180° on your table or just plugged your x-motor the wrong way around?

Nope, checked with pictures and video (and mLaser will mirror image internally before sending out). Even the cable for the contact switch for X is to short to put on on other end.

The idea was not to mess with out-of-the-box hardware/firmware, to make it easier for (other-) beginners, thats why I didn't rebuild the firmware (or try flashing it with a grbl one). I know about INVERT_X_DIR ...thats exactly what they did with their firmware..

But, I think to keep software clean, swapping the the lines of the stepper motor and contact switch (+extending cable) might not be a hard task for others if explained.

You also misunderstud the overrides...

Not really, I just used it as a quick hack :) as you an see in the code I send out M220 for 'F', but not for 'S'.

However, since on laserbot I can control the power, I'm able to burn with grey values, however, I have to replace the S value there with M4 P, thats why. This or altering the rastering code to take into account the "laser on" + adding power value prefix or something..

Changing the gcode before sending it to the controller would lead to a massive delay until the commands get executed. Well, that is the sad thing...marlin firmware doesn't really buffer much, its a request/response pattern, you have to wait till 'ok' comes back. Sending to much without waiting for answer will drop commands (one of the bugs I encountered in their mLaser software). So, replacing GCode before it goes on the queue will have not much impact on overall speed.

Maybe its still beter to create a seperate GRBL firmware for the MegaPi, I'll take a look into this. I think marlin firmware is slowing down the burning speed, despite a 11500 baud serial connection..

Anyway, thanks for checking out. You mind if I keep the fork up for others to use in mean time ? (of course with proper credits licence, etc.) just want to help other users of laserbot, the hardware is still ok...

Regards,

Remco