Laser power control via modbus.Mach3 is a great program. People have used it to control a vast diversity of machine, but it has some issues when controlling lasers.
![]()
This is especially true when it comes to the beam control.The beam can be compared to the spindle of a mill. It does the cutting and has an on/off state and power level (like RPM). On a mill, the spindle can safely stay on during rapid moves above the work and dwell at points without issue. A laser cannot do that because it does not retract from the material.
It must only be on during G1 feed moves and must not dwell at any point or excessive burning will occur. The normal spindle logic does not work well with lasers.I thought it would be a fun experiment to try to enhance the control using a slave device. Modbus devices are basically remote device that allow a host to read and write data registers.
The remote device can then use the data registers to give information to the host or do a task when a register is written to by the host. The devices typically communicate using a serial port or Ethernet.
Nov 02, 2019 Probably the biggest issue on MACH4 is the plugin support. There are a hand full of plugins for motion controllers. I have the ESS, which has a plugin that works it has been updated three times since the first version was released for MACH4. The ESS is pretty stable under MACH4. They also have Art's parallel port plugin which costs $25. Mach3 plugin for Huanyang VFD. So spindle and serial port all working as designed. Issue is either with my MACH3 config (and this is very likely) or your program. Mach3 Serial Port Control' title='Mach3 Serial Port Control' /Last updated on Friday, December 0. 3 Probe Plug in.
You can view the.There are a lot of commercial Modbus devices like and the, but I wanted a cheaper home grown version. I thought an would be a good choice because it has a built in USB to serial port, it is less cheap (less than $20) and it is open source. The next change is to add the new M666 line before each first feed move to set the power level.begin FIRSTFEEDMOVE“NM666 S”Next stepsThe next step is to use a Mach3 feature called “Brains”. This is a ladder logic type programming method that works much faster than macros and can run in parallel with Mach3.
This can allow some really interesting ideas.Possible Future Ideas. Tie power level to feed rate. When a move starts out it accelerates to the desired feed rate. Therefore the power per speed is not constant. A Brain could adjust for this. Control beam enable on with “is move G1” logic. Rather than using the E1P1 method common with many laser users, you could have a Brain toggle the beam on whenever the code is in a G1 move.
Return water temp to Mach3. The Arduino could read water temp and Mach3 could display it on in a DRO.
Mach3 could act on a high temperature value and do a feed hold and turn off the beam. LCD display. The Arduino could control a simple LCD display of feed rates, power levels, axes positions. Jog buttons. A simple jog button panel could be implemented.
Feed rate offset. A pot could be used to adjust the feed rate plus or minus while the job is running. Feed hold with beam off: A feed hold button could be implemented where the motion stop and the beam goes off at the same time.
Click here to go back to Getting Started: Setting up my PC
*** If you will be using Mach4, you should be at this page instead: Setting up the SmoothStepper with Mach4. ***
If you are just getting started with Mach, seriously consider using Mach4 and NOT Mach3. Mach3 is essentially end of life, and not supported with any new development. Mach4 has new features under development and has much more in terms of capabilities and flexibility - especially with lua scripts. However, the number one reason in our book is diagnostics, in Mach3 it is hard to determine what went wrong when something doesn't work. In Mach4 the diagnostics log and the screen set messages make it much easier to understand what is going wrong.
The USS will only work with Mach3, not Mach4.
Mach3 Software
Initial Mach3 setup with the ESS:
To help you with the setup process for Mach3, we have a YouTube video playlists for Mach3 + ESS setup.
Initial Mach3 setup with the USS:
To help you with the setup process for Mach3, we have a YouTube video playlists for Mach3 + USS setup.
Remaining Mach3 setup for ESS or USS:
(Please make sure you have completed the initial Mach3 setup for your ESS or USS just above here.)
After each major step, try using your hardware to see if you set it up correctly. I have you exiting Mach3 often, since it will save the settings to the XML file, and it helps to prevent mistakes.
1. Start by assigning the EStop input pin in Mach3 -> Menu -> Config -> Ports and Pins -> Input Signals. Scroll down to EStop and place a green check in the Enabled column. Assign it to the desired ESS Port (1, 2, or 3) or USS Port (1 or 2). Assign it to the desired input pin. You may need to change Active Low depending on your hardware. Press OK to close that window.
Keep in mind that the picture you see below is for example only. You can do this to test and verify that the SmoothStepper is communicating with Mach, but you really need to make sure you assign it to your EStop button afterwards!
2. Exit Mach3 to save your settings, and then reopen Mach3.
3.Press the Red Reset button in the lower left corner of Mach3. The flashing red border should be replaced by a solid green border (if it is, Mach is communicating with your SmoothStepper). If you press your hardware EStop button the Mach3 Reset button should start flashing Red again.
You can also look at the Mach3 screen set's Diagnostic tab and see if the Emergency signal turns on and off then you activate the EStop button.
4. Now assign the Axes that you will be using. Go to Mach3 -> Menu -> Config -> Ports and Pins -> Motor Outputs. For each axis you will use, click on the red X to change it to a green check mark. Assign a Step pin and Dir pin for each axis, and then assign a Step Port and a Dir Port, ESS Port (1, 2, or 3) or USS Port (1 or 2). You may need to change Active Low for Dir and Step.
If you use two motors to move the same axis, the A axis would typically be your first slave motor. Make sure to go to Mach3 -> Menu -> Config -> Slave axis, and slave the A axis to the X or Y primary/master axis.
5. If your BOB (Break Out Board) needs a Charge Pump signal, you should set it up now. Mach3 -> Menu -> Config -> Ports and Pins -> Output Signals. Set the Port and Pin as appropriate for you hardware.
6. Exit Mach3 to save your settings, and then reopen Mach3.
7. Tune your motors for each of your axes in Mach3 -> Menu -> Config -> Motor Tuning. We have a FAQ section here. How do you calculate your steps per unit? Try this Excel spreadsheet made by RICH.
a. Click on X Axis on the right. Set your Steps per unit, your Velocity and your Acceleration. Click on SAVE AXIS SETTINGS.
b. Click on Y Axis on the right. Set your Steps per unit, your Velocity and your Acceleration. Click on SAVE AXIS SETTINGS.
c. Repeat for the remaining axes. To modify which axes are available, go back to the Motor Outputs step.
8. Exit Mach3 to save your settings, and then reopen Mach3.
9.Test to see if your motors will move by pressing the arrow keys on your keyboard.
10. Calculate and set your Max Step Frequency, for each of your axes.
11. Exit Mach3 and reopen it to save your settings.
12. Set the Controller Frequency to 1 kHz. This will be a good starting point for most users.
13.Exit Mach3 and reopen it to save your settings.
14. In the MDI tab try out some GCode like G1 X1 F10 which is explained here. This will let you move your Axes around a little.
15. Set the look ahead to 100 or 200 lines. If you get a 'Run out of data' message, adjust your watchdog.
16. Exit Mach3 and reopen it to save your settings.
17.Configure your constant velocity settings as needed. Here is a good PDF from MachSupport.com or our local copy.
18. Exit Mach3 and reopen it to save your settings.
19. Set your home switches and your limit switches(this step is optional).
20. Exit Mach3 and reopen it to save your settings.
21.Debounce your switches (this step is optional).
22. Exit Mach3 and reopen it to save your settings.
23.Set your soft limits (this step is optional).
24. Exit Mach3 and reopen it to save your settings.
25.Set up your spindle control here or set up your THC control here.
26. Exit Mach3 to save your settings.
27. Place your license file 'Mach1Lic.dat' into 'C:Mach3' and reopen Mach3. Make sure the 'Menu -> Help -> About Mach3 CNC Controller' shows your name and not 'Demo Version'. If it shows 'Demo Version' you will have problems like these.
28. ***IMPORTANT*** Once you have Mach3 running the way you want it to, make a copy (or many copies) of your whole 'C:Mach3' folder and store it somewhere safe. If I ever need to restore or replace my computer, I can just install Mach3, and then use my copy of the 'Mach3' folder to replace the one on the PC and I am all set to run. It can save hours and hours. You should also back up your G-Code projects as well.
29. Now would be a great time to adjust the Virtual Memory on your PC. There are some other PC setup steps that may help improve your windows experience in the article that follows too.
30. If you see a Watchdog message on the bottom line of your screenset right after you launch Mach3, that is totally normal. The Mach3 application's watchdog is set to too short of a duration, and the ESS plugin takes longer to load than the time specified. Every time you start Mach3, Mach3 will likely post that message - it is nothing to worry about. However, since Mach3 is no longer supported (by developers) there is nothing we can do to increase the watchdog timeout value.
31. You are now ready to load a G-Code program and run it! We suggest to practice running with an air cut first (no tools in your spindle) so you can see exactly what the machine will do, and make corrections to your program if necessary. Also you should re-read all of the safety information you have, including ours.
With Mach3, NEVER run your Feed Rate Override above 100%, only use it to slow down your feedrate. If you want to go faster, regenerate your G-Code from your CAD/CAM software. Running your FRO above 100% will cause jerkiness and misshaped circles.
Spindle Setup for Mach3 ESS:
1. Go to Mach3's Menu -> Config -> Ports & Pins -> Motor Outputs tab. For the Spindle row:
2. Next go to Mach3's Menu -> Config -> Ports & Pins -> Spindle Setup.
3. Now go to Mach3's Menu -> Plugin Control -> Main Config: ESS-M3-version.
For a PWM Spindle:
For a Step and Direction Spindle:
For a Quadrature Spindle:
For a CW/CCW Spindle:
![]()
*Set the 'Max Step Frequency' to a setting that is a little bit above the max step frequency that your system is expecting. If you have a BOB that converts the Step and Dir step frequency to an Analog 0 V to 10 V, they will tell you what they expect the steps per second to be. If they are expecting 25,000 steps per second, then you would go to the next higher value and choose 32 kHz.
4. Now go to Mach3's Menu -> Config -> Motor Tuning. Under Axis Selection, click on Spindle.
For a PWM Spindle:
For a Step and Direction, Quadrature or CW/CCW Spindle:
5. Finally go to Mach3's Menu -> Config -> Spindle Pulleys
Mach takes a spindle speed and uses that to create a ratio value (between the Min and Max speed).
The following documentation explains how the ratio value works with PWM. Step and Dir mode operates under the same basic principle as PWM, but needs a video or pictures to properly explain it.
Assume you have an external controller that is set to a min of 12,000 RPM and a max of 24,000 RPM. Mach would then use the ratio value to produce a 0% PWM for the min speed of 12,000 RPM, and produce a 100% PWM for the max speed of 24,000 RPM.
Now we need make sure Mach’s expectations match the external hardware’s expectations. If the hardware is expecting a 0% PWM to mean 12,000 RPM, then you are set! However, if your external hardware interprets that 0% PWM means a speed of 0 RPM, then you will be off. Mach thinks it is commanding 12,000 RPM and the hardware is creating 0 RPM. That means you should set the Min Speed to 0 RPM. When Mach is told generate 12,000 RPM, Mach would create a 50% PWM signal in order for the hardware to create 12,000 RPM. This explanation assumes open loop mode. Once we implement closed loop mode, then it won’t matter, since Mach won’t command a value less than the minimum, and the closed loop means we would adjust the PWM to meet the commanded RPM.
6. Testing your spindle:
To test your Spindle output, use 'M3 S#####' where ##### is the desired speed in RPMs (M3 S500 would give 500 RPM). Your speed will be limited to your max speed declared in the pulley section above (assuming your VFD controller is configured correctly).
M3 will rotate the Spindle clockwise.
M4 will rotate the spindle counter clockwise.
M5 will stop spindle rotation.
Displaying your spindle RPM (Speed) in Mach3:
To display the real world RPM (speed) of your spindle or router in Mach3, you will need a sensor or an index output on your spindle or router. You will hook that sensor/index output to any available SmoothStepper input pin. Then go to Menu -> Config -> Ports and Pins -> Inputs, and go down to the Index line and assign it the correct Port, Pin and Active High/Low state. The displayed RPM speed in Mach3 will likely be off. To adjust the displayed RPM, go to Mach3's Menu -> Config -> Spindle Pulleys and adjust the ratio to achieve a displayed RPM that matches your real world RPM. The higher your ratio value, the lower your displayed RPM will be.
Spindle Speed During Threading
During threading, Mach3 uses closed loop feedback, where the actual RPM is measured once per rev, and the feed rate of the linear axes are compensated to match the spindle's RPM.
THC (Torch Height Control) setup for Mach3 ESS:
To be totally blunt, THC sucks in Mach3. Yes it can work well, but when things don't work, it is a pain to try and solve them - especially since Mach3 can silently prohibit it and not tell you why.
We have THC running with Mach4 now, and it is done totally within the ESS! (Mach4 still handles all of the normal movement aspects like in milling or routing, but all of the THC is in the ESS and its plugin.) THC is much, much easier to set up now, and if something goes wrong, the screen set or the log file will tell you what happened. If you value your time whatsoever, the Mach4 version is worth it, and you can run it in demo mode for 5 minutes at a time without buying Mach4 (you will then need to restart Mach4).
THC in Mach3 will ONLY work with a valid Mach3 license!
To enable THC (Torch Height Control), you need to:
1. Go to Menu -> Plugin Control -> Main Config for the ESS, and then Activate THC Mode with a check.
2. Go to Menu -> Config -> Ports & Pins -> Input Signals. You will need to ENABLE the following three inputs, and assign the Port number, Pin number and active high / low state:
3. Go to Menu -> Config -> Ports & Pins -> Mill Options. ONLY ENABLE 'Allow THC UP/DOWN Control even if not in THC Mode' if you are manually controlling the height of an Oxy Acetylene torch. Never choose this in normal THC Mode.
4. In the included Plasma Screen Set for Mach3, you will see this area of the Screen:
Lasers
Whenever you use a laser, please remember to wear laser eye protection!
Post Processors (generates the GCode files)
These are other peoples post processors, and we do not provide direct support.
There are two main types of lasers: ones that accept a Digital control via PWM and ones that accept an Analog input voltage control.
Lasers using Digital PWM input signals can be controlled directly via PWM (Pulse Width Modulation) on any output pin of the USB and Ethernet SmoothSteppers.
Most Analog input lasers using a 0V to 5V DC input signal can be controlled via PWM (Pulse Width Modulation) on any output pin of the USB and Ethernet SmoothSteppers. However, in this case we are relying on there being sufficient capacitance in the laser's analog input that it creates a low pass filter. This low pass filtering, will cause the PWM signal to be seen as a 0V to 5V DC signal. This effect improves as you use higher frequencies for the PWM with 1 kHz being the recommended minimum and 10 kHz or 100 kHz usually being better.
Some lasers also have a Gate input, which is not only an on/off control on your laser, but also allows for fine control over the firing timing of your laser.
Our Mach4 ESS plugin (starting with build 221) offers more flexibility and features than the Mach3 plugins will ever offer, especially with respect to Gate Delay, Gate Duration and the ability to laser Raster gray scale images.
Setting up Mach3 to control a laser is as follows:
1. Connect the 0V to 5V DC input signal from your laser to an output pin on your SmoothStepper's breakout board, this will be your PWM's 0V to 5V DC output. (I will assume Port 1 Pin 17 for the rest of this example, but you may chose any available output pin). In Mach3's Menu -> Config -> Ports & Pins -> Motor Outputs tab, enable your Spindle with a green check, set your Step Pin to Pin 17 (or the one you are using) and the Step Port to 1 (or the one you are using). You can ignore the Dir Pin and Port fields.
2. In Mach3's Menu -> Config -> Ports & Pins -> Spindle Setup tab:
3. In Mach3's Menu -> Config -> Ports & Pins -> Output Signals tab, chose an available output (1 through 6, I will choose #1), and then chose any available output pin for the Gate signal (I will chose Port 1 Pin 1). If your laser does not have a Gate or On/Off input, you will still want to do this, but you could chose an output on port 3 which you may not even be using. Enable your Output# with a green check, set your Port to Pin 1 (or the one you are using) and the Pin to 1 (or the one you are using). If you use an Output # other than 1 you will not use M11P1 or M10P1, you will use M11P# or M10P# with the # replaced bu the number 1 through 5 that you are using.
4. In Mach3's Menu ->Plugin Control -> Spindle, THC & Laser Config:
5. In Mach3's Menu ->Plugin Control -> Main Config, in the M11P#/M10P# area:
6. In Mach3's Menu -> Config -> Pulley Selection:
Operational Description:
The M3 command will enable the laser's PWM signal (but not activate the PWM signal), it only needs to be done once at the beginning of each GCode program.
The M5 command will disable the laser's PWM signal (and shutoff any active PWM signal), and should be done once at the end of each GCode program.
S50 or S100 or any number between your Min and Max speed will set the laser's power level, via the PWM duty cycle.
M11P1 followed by a G0, G1, G2 or G3 command on the next line will activate the PWM signal, and also the Gate or On/Off signal (if you need that signal). The M11 command allows for the laser output to be synchronized and turned on with the start of the next motion command, and prevents the burning of holes in your material or burning before you get to the starting point of the line you want it to turn on at.
M10P1 followed by a G0, G1, G2 or G3 command on the next line will deactivate the PWM signal, and also the Gate or On/Off signal (if you need that signal). The M10 command allows for the laser output to be synchronized and turned off with the start of that next motion command, and prevents the laser from shutting off before you get to the end of the line you are burning.
All macros, including M3 and M5, are not synchronized in time with the GCode commands, and may be off by 100 ms or even as much as a full second off. That is why the M11 and M10 commands are used, which will synchronize the laser with motion. Here is an example using M3 and M5 only.
Here is an example using M11 and M10.
Here is some example GCode that will demonstrate the functionality. Comments are inside the (...).
Updating a SmoothStepper plugin in Mach
The SmoothStepper's plugin file contains not only the PC side code that works with Mach3, but it also contains the ESS's firmware applications for the microprocessor and the FPGA. Every time the plugin is run, it will make sure that the SmoothStepper is running the correct firmware and automatically update them if they are not.
When you decide it is time to update to a new SmoothStepper (ESS or USS) plugin, here is the procedure:
1) Make a copy of your entire current 'C:Mach3' folder. This is your entire setup, and a copy of it can get you right back to where you are instantly. You should keep a few copies of your setup on a different PC PC or USB stick or on DropBox so you always have a backup in case your PC dies.
2) Go into your 'C:Mach3Plugins' folder and delete your existing ESS***.dll or USS*.dll files. This will ensure that the old ones are gone and make it easier to switch to the new ones in a moment.
3) Download your new ESS Mach3 plugin or USS Mach3 plugin from here. Once the file downloads, open it up and double click on the installer (ends with .m3p) or just drag and drop the .dll file into your 'C:Mach3Plugins' folder.
4) Open Mach3, and select your profile. You may be prompted to select your plugin or device, which will correspond to your new plugin.
5) You will be running the new plugin now!
6) If things didn't work right, you could replace the new plugin with the old plugin. If things were to go badly, you can just delete your 'C:Mach3' folder and replace it with the version you made before you started this process.
Here are our Documentation (manual) pages:
This concludes the Getting Started walk through. If you need more help, please look at our Troubleshooting guide and our Help page.
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2023
Categories |