Enter a drawing to win a SideStop work stop and receive our free weekly newsletter.Enter Now!
Debugging and Testing Your Mach3 + Geckodrive CNC Electronics
This is probably an entirely over-ambitious task, but I wanted a place to document all the tricks I've learned to debug the electronics of these Mach3 + Geckodrive CNC systems. I'll primarily focus on a servo system, because its more complex, but I'll try to capture relevant thoughts and notes for steppers along the way.
The idea is to document a systematic way to debug one of these systems. We wire up such a system from a bunch of components, often components from a variety of vendors, we flip the switch, and we wonder why it doesn't work! What's needed is a systematic way to go through the system and find and fix the problems.
The idea here is to understand how the different components are interconnected, how each component needs to be set up, and to document what to look for at the connections between components to track down problems. To be perfectly honest, I have no idea how well this will work, but after spending hours and hours piecing together clues from reading hundreds of different posts on various Internet boards, I needed some way to organize that mess.
Before we begin, think carefully about whether you should be doing this:
Power supplies and other aspects of CNC electronics are dangerous. If you're not completely comfortable with this stuff and knowledgable enough to understand what I'm saying, STAY AWAY FROM DEBUGGING! The voltages inside the cabinet can kill you! A wrong move and the motors can started turning at high speed and injure you. It isn't worth it. Get someone else who knows what they're doing to troubleshoot for you! Remember, these voltages are feeding powerful motors via the Geckodrives. That dangerous voltage is there all along the way.
Also, remember where your E-stop is. Make sure it works properly. Practice hitting it a couple of times. Be ready to use it if an axis takes off at top speed or some other problem develops. It should be the fastest way to cut power to the system.
The CNC Servo System Block Diagram
The CNC Servo System Block Diagram is our roadmap for debugging. It shows the different components, and how they fit together. It's a roadmap because signals have to successfully travel from left to right to make the servo (or stepper) motor spin under Mach3 computer control. Problems can develop at any point along the way, interrupting our journey, as well as the excitement and fun of our CNC project. So the focus will be to move from left to right on the diagram using various means to test whether the magic signals that control our machines are able to get to the next stage. Many (I was!) will be tempted to connect it all up and throw the switch. Things might just work the first time for you. But if you hit a glitch, try following the roadmap until things are going again. If things are terribly wrong, connecting everything will expose more components to damage as well. For that reason, the most prudent approach is to connect one axis at a time as much as possible and get it working all the way through for that axis before going to an additional axis. Once you have one axis working all the way through, it becomes much easier to get the others running too, because you have confidence in what works.
Accordingly, each section below is about one of the building blocks in the block diagram and how you can verify things are functioning correctly up to that point.
Power Switch, Master Control, E-Stop Circuitry, and Power Supplies
Why start with the power supplies? In a word, because it's easy. All you need to check the power is a voltmeter. It doesn't take but a few minutes to go through and check it out.
Be sure to set it for AC or DC depending on which one you want to measure. In some cases you'll be checking for continuity with the ohmeter. The power swtich, master control, and E-stop circuitry are all there to make sure power is applied when desired and taken away instantly if the situation calls for it.
Here are some useful checks to make:
|Start with the power switch off. No power measured coming in, right?||You're making sure the main AC wiring is correct.|
|Flip the switch on. Check visually for any smoke being ready to switch off immediately if you see any signs of trouble.||The infamous "smoke test".|
|Master Control and E-Stop Circuitry|
|Check the AC current going into the Master Control or E-Stop circuitry. Are you getting the right AC voltage? Typically it is either correct (e.g. 110V) or 0.||
If the voltage is 0, work back to the socket the cord is plugged into. Is your power switch on? Is it getting juice from the cord? Is the cord plugged in to the outlet? Is the breaker on the outlet blown? Perhaps a fuse or switch on a power strip you're connected to?
Sorry if this sounds too elementary, but these are all things that can and do go wrong that we forget to check!
You may have a chicken and egg problem here. I use a CNC4PC Master Control Board. It shuts everything off if there is any of the following:
- An E-Stop
- A Servo Fault
- A Limit Switch Tripped
- Charge Pump Signal Missing from Breakout Board
It can also be finicky about the Start button if it isn't held long enough.
Try turning it on. You may get lucky and it just fires up. If it faults, see what is faulting and follow directions to the right.
- E-Stop Faults: Check E-Stop wiring. First time I had the E-Stop and Start reversed. Remember, one is Normally Open (Start) and one is Normally Closed (E-Stop). Use you ohmeter to verify the right switch behavior and check connections to the board as well.
- Limit Switch: Like the E-stop, there ain't much to check. These are normally closed. If they're open, its a wiring problem, a bad switch, or perhaps they really are tripped. Fix the problem and continue.
- Servo Fault: This one is the chicken and egg. A lot of downstream reasons can fault the servos. For now, disconnect the Err/Res from the board and see if it'll start up ok. Scan ahead to the Geckodrive section to figure out how to debug a servo fault. Also, if a servo oscillates or makes a lot of noise at this stage, its out of tune. Don't run the system for more than a minute or two in this condition. The Gecko and motor will get hot and you run the risk of frying a drive. To get it under control, tune the servo. It's good news if there is enough going on that you can even worry about that.
- Charge Pump: Disable it with the DIP switches or jumpers for the time being. We'll revisit when we set up Mach3.
|Cycle E-Stop manually. Does it shut down the system?||Don't get too far into this without making sure your E-Stop works reliably!|
|With the Master Control/E-Stop working properly, check the AC current going into each power supply. Are you getting the right AC voltage? Typically it is either correct (e.g. 110V) or 0.||
If the voltage is 0, is there a problem with the relay feeding the supplies?
If you are using a solid state relay, make sure you're feeding it a control voltage that is suitable to trigger it according to its specs. Check this with your voltmeter. Even try triggering it directly by jumpering your logic power supplies to it.
If it triggers ok when directly connected to a power supply but not when driven by your Master Control, there may not be enough capacity in the logic power supply. Try a more powerful supply.
Some other weird things I noticed with the Master Control Board:
It had to be configured for the right servo drive for the relay to work.
It was touchy about how long I held down the Start button, so I learned to hold too long rather than too short.
Your circuitry may have similar quirks.
|Power Supply Terminals:|
|Check the Logic supplies. These are low voltage supplies that go to the various boards, not the higher voltage hefty supply that goes to the Geckos. Are you getting the right DC voltage from these supplies? For example, my CNC4PC boards need 23V and 5V.||If you have no logic supply, none of your boards will work. If there is AC into the power supply, but no DC at logic levels out, check for fuses, on/off switches, 110/220 switches, and the like on your power supply. If all else fails, try another supply. PC power supplies frequently have the right voltages to act as temporary stand ins as do many wall warts. If you try a wall wart, hopefully it has enough current and the correct voltages to do the job.|
|Check the DC motor power supply voltage out. Lots more voltage and current here, so be careful!||
If the DC supply is producing the wrong voltage or no voltage, lots of possibilities. The transformer can be shorted or open, the rectifier or capacitor could be blow, and so on.
Start by checking for AC voltage into the transformer, then see what the AC voltage is out of the transformer. It will be a little different than your finally DC voltage, but not a lot.
|Check the ripple from your DC motor supply. Set your meter for AC and put it across the terminals. A good meter will ignore the DC and show you an AC voltage that is the variation or "ripple" in the power supply.||
Too much ripple can lead to over voltage and other problems. Assume the ripple is on top of the normal DC reading. Are you giving the Geckos too much voltage? Mine say 80V maximum. If I feed them 75V DC and have 10V of ripple on top of that it won't be helpful because it means I may be feeding my Geckos 85V when they are only rated to 80V.
If your power supply is at the low end of the Gecko's capabilities, subtract the maximum ripple from the measured DC voltage. Is the result lower than the Gecko is rated for? If so, you need a power supply that delivers more voltage for reliable operation. More voltage will give you better performance anyway.
For most of these motor supplies, too much ripple is an indication of too small a capacitor, or capacitors that aren't working or wired correctly.
Another rule of thumb is that the AC voltage should not read more than 3% of your DC voltage. If it does, your main filter cap is too small or is failing. This can destroy the drive because the cap is too small to absorb returned energy.
|Verify that appropriate status LEDs and other indicators light up for each board.|
|Having verified that the power supplies are outputting the voltages expected, verify that the voltages arrive at each board intact. Check every screw terminal with you voltmeter. Be sure to measure the voltage between the board's positive terminal and the board's ground and not some other ground connection. Ideally you've grounded everything to the same spot (star ground), but sometimes connections wiggle loose. We'll check the connection between grounds later!||You're checking for bad connections are miswiring in this step.|
|Don't forget to check the encoder power coming from each Gecko, and the Common (+5V) going into the Geckodrive. Measure the encoder power at the Gecko Enc+ and Enc- terminals. It should be +5V DC. Check common from the Common (may also be labeled +5V) and Ground on the Gecko. It should be +5V.||Each signal has to have the right voltage relative to the right reference or ground. The Common or +5V for the Gecko is its reference for the Step and Dir signals. As such, that +5V should be coming from the breakout board.|
There are many different approaches to grounding. I favor the star grounding approach where every single ground goes to one terminal. Note that improper application may circumvent the protection opto-isolation provides. I can't really comment on that, but I know that good grounding is important.
Check continuity of every ground connection and make sure each connection is tight.
Ground cables only at the CNC cabinet end, not at the machine end.
|Got good fuses?||Lots of folks put fuses in the system between the DC supply and the Geckos. Keep an eye on them and make sure they're not blown.|
PC Running Mach3
All your boards are getting juice. Now is a good time to jump into Mach3 and check on a few things.
|Motor Ports and Pins:|
Set the appropriate pins on the Mach3 Motor Ports and Pins screen for each axis to enable the axis, and set Active Lo for step and direction. You can set pulse width to 2, which is a good setting for most breakout boards, but Smoothstepper ignores that setting.
Mariss says there is no advantage to a pulse width greater than 2 usec.
|Start at the low end of inches per minute and acceleration. On my IH mill, this was 100 IPM and 0.15 acceleration. Even lower on the Z-axis may help, because this is the heaviest axis on many machines. Too much axis speed or acceleration can be a source of servo faults or inaccuracy.|
|Set the steps per inch based on your calculated value. For my servos, I have 500 cpr encoders, which give 2000 "steps" per revolution due to quadrature (4 * 500). Multiply 2000 by your pulley ratio if you have a timing belt reduction, and then by the number of turns needed to move your leadscrew 1 inch. That's your starting point.||Note: We'll calibrate this value more precisely down below. Check the section on Performance Tuning for details.|
Breakout Board or Other PC Interface
I'm assuming a Smoothstepper here. You may be using a parallel card or other interface. Some details may vary with those cards. By now we have good power everywhere, and we think we've got Mach3 configured properly. Time to see if your breakout board is passing along STEP, DIR, and the Safety Charge Pump properly.
|Smoothstepper has a blinking red "heartbeat" LED that indicates it is connected to Mach3. In addition, Mach3 and the plugin know when contact has been lost.||If you don't get a heartbeat, something is wrong with your USB connection or the install of the Smoothstepper USB driver and Mach3 plugin. Double check all of that. Reinstall the driver and plugin. Make sure Windows sees the Smoothstepper as the USB device. Unplug and replug the USB capable and see if Windows tells you it connected to the Smoothstepper. If that fails, try another USB cable, and another USB device to make sure your computer's port is operating properly.|
|Smoothstepper has a diagnostic screen that tells you whether it is getting the signal from Mach3. Jog Mach3 (press the arrow keys on the keyboard) and check it and see that the signal is getting through the USB.||Same as above.|
Jog the axis you are debugging by holding down the right key or mousing on the jog panel in Mach3. Using your voltmeter, check what's coming out of the appropriate STEP and DIR terminals on your breakout card. Voltage should go up to between 3.3 and 5V when you hold down the key and go back to 0 when you release. Set your meter to DC when taking this reading, and measure between ground and the STEP terminal.
If you have an oscilloscope, you can also monitor STEP and DIR. You should see a good clean set of square wave pulses going into STEP. Beware of any noise you see there as it can cause false steps.
|If you can't see the step pulses on the voltmeter or the oscilloscope, there are a couple of possibilities. Most likely, you haven't configured Mach3 properly on the Ports and Pins page so it isn't sending the STEP pulses to the output you expect. Another possibility is a problem of some kind with the breakout board. If you've got good pulses into the Gecko, you're ready to move on to another test.|
Now is a good time to enable and test the Safety Charge Pump.
Enable the appropriate pin and see if you can measure a charge pump pulse train with your voltmeter or see the pulse train with your oscilloscope. Turn it on and off to see the difference.
Make sure that pin where you saw the charge pump running is properly connected to your Master Control Board and the DIP switches are set to process it properly.
Test by shutting down Mach3. When the Charge Pump goes away, does the Master Control Board fault?
The Safety Charge Pump is designed to ensure that if Mach3 crashes or the PC is inadvertently shut down that an E-Stop is triggered.
It is possible to configure Mach3 to send the Charge Pump signal to more than 1 pin. That is usually a bad idea!
Servo Drive + Encoder
By now we have verified that the Geckodrive (or other servo drive) is receiving the right power supply voltages, and that it is getting STEP and DIR signals in accordance with what Mach3 wants to send.
|If the Gecko faults immediately at startup, it may be because the encoder's sense of direction is reversed relative to the motors. Because of this, when it sees an error, it tries to move the motor to reduce the encoder error, and the error just gets bigger, which quickly leads to a fault.||Try reversing the motor leads or the encoder Phase A/B leads (but not both!). If the fault goes away, you found the problem.|
Power up with the motor armature outputs disconnected from the Geckodrive. See if the drive faults immediately.
If the drive doesn't fault, twist the motor shaft (by moving the pulley if need be). Can you make the servo fault? If not, the Gecko doesn't really see the encoder, although it thinks it does, else it would fault. There are certain failure modes where it can think the encoder is there, but it can't read it.
If there is an immediate fault, there may be a problem with the encoder cabling or the encoder.
If you can't make it fault, check the cabling. Try another encoder. Make sure everything has power (see the Power Supply checks above!). Make sure the encoder +/- are showing proper voltage and grounding.
|The Geckodrive documentation describes a voltmeter test of the encoder. Try that to see if your encoder is working properly and the Gecko is communicating with it properly.|
Listen for excessive noise from the servo. They should be nearly silent, perhaps with a slight "ticking" or other noise every so often. That noise is encoder dithering. If there is too much constant noise, it is a symptom the servo is out of tuning. Don't let it sit that way for too long, or you may burn up the drive or the motor.
Note: A stepper should be silent at idle. Ticking on a stepper is likely an indication of noise firing random steps.
Tune the servo.
Other sources of noisy motor operation on a stepper or servo:
On steppers, if you get lots of low speed "growling", check into:
|Try jogging. If the Gecko faults when you change direction suddenly, that is a sign of bad tuning.||Tune the servo.|
Still getting a lot of faulting? You can tie Err/Res to Enc+ to keep automatically resetting the drive. Ultimately you'll want to figure out why, but this is a technique to eliminate the vagaries of your Master Control board or other Err/Res circuits until everything is tuned up.
Note: A powerful and properly tuned servo system will snap an end mill off without faulting!
Now make sure you run your servos through a program that includes a variety of speeds and lots of reversal of direction to flush out any unwanted oscillation and be sure they're really tuned up well. I like to use the circular interpolation wizard in Mach3 to do this. Choose a circle diameter of 1 or 2 inches and try different feedrates. That'll work for the X and Y axes.
Use the peck drilling wizard on the Z-axis to get some direction change going.
The first time I tuned my servos by ear, I lost a cap to some oscillation from a poorly tuned Geckodrive. The oscillation didn't show up until I was in the middle of making a part and I couldn't hear it over the sound of the mill cutting. But I did see it at the last minute before the drive blew.
|Tune the servos as needed during this test!|
|Motors move, but they may not move accurately and sometimes "twitch" a little bit||
Check for proper Step/Dir signals to the Gecko Drives as described above.
You may have a noise problem. Check the Noise Problems page for ideas.
|I keep blowing fuses!||On stepper
drives, Mariss says drives that blow fuses usually have 1 or more
damaged MOSFET power transistors. Here's how to check the health of
1) Pull the main connector block from the drive to expose the connector header pins.
2) Set your multimeter to Ohms. Set it to the '200K' range if the meter isn't auto-ranging.
3) Connect one probe lead to terminal 1 (GND) of the drive.
4) Use the other probe to measure the resistance to term. 3, 4, 5 and 6.
5) Now connect the first probe lead to terminal 2 (+SUPPLY).
6) Repeat step (4).
7) All 8 readings should be 100K Ohms or more for a good drive. A bad reading will be near zero Ohms and indicates a blown MOSFET.
|Possible issue: I burned up the capacitor on my servo drive!||
Another possible cause: the leads between your power supply's big capacitor(s) and the servo driver are too long. Mariss talks about 18" max to a Gecko, while Larkin wants 6" max. Larken says you can burn up the on board cap if the leads are too long. Mariss talks about installing an additional cap near the Geckos to fix this problem.
Other Geckodrive checks you can try:
If the wiring to the motor coils checks out, you will need to tests your Gecko stepper drives as recommended by Mariss F.:
|Try directly connecting the motor to the Arm +/- inputs to the DC supply, with the motor removed from the machine. This should spin the motor at top speed. Don't try this with the motor on the machine as the axis will move at max speed!||This test removes the Gecko from the loop and runs the motor directly from the power supply. If the motor won't spin, the cable is bad, there is an open connection inside the motor, or there is a short inside the motor.|
By now you should be able to get all of your servo motors spinning. This is the very coarsest level of debugging. Now it's time to move on the Performance Tuning to make sure your moves are accurate and fast.
Before attempting to do much here, check the tram on your mill. No sense trying to eek out accuracy below a thousandth if the mill isn't square. For more information on tramming and squaring mills, check here.
Calibrate steps per inch on each axis. Start out with the calculated steps per inch for your machine based on steps per rotation on your motor, leadscrew revolutions per inch, and any gearing.
Use an accurate standard that is clamped down so it won't move. The longer the better.
A number of different standards may be considered so long as you very accurately know their length. Ideas include 1-2-3 block (checked with a micrometer), 2-4-6 block (better still because it's longer-check with micrometer), or even a micrometer standard held in your vise. An accurate DRO is probably the ideal on the low end of the cost spectrum. Commercial machines use lasers to precisely measure moves. Ensure the standard is parallel to axis motion by indicating it in.
Now use an edge finder to accurately find one end of the standard. Place a 1-2-3 block or other reference at the other end so you can find the other end with the same edge of the edgefinder without reversing direction. After picking up one edge, zero the DRO on the axis you are measuring and then move the axis until you pick up the other edge. DO NOT REVERSE DIRECTION! If you do, you may have backlash and have to start over.
Compare your DRO's indicated distance to the precise length of you standard. Use the difference between the two to calibrate your steps per inch (or mm) on that axis. Check several times to understand the repeatability of these measurements.
You can see how I did this for my IH mill with 2-4-6 blocks on the CNC conversion home page. It made quite a difference to my accuracies. Note how far out the 2-4-6 blocks were too on their dimensions. Important to know exactly how long your standard is!
This calibration eliminates a lot of error sources. Ballscrews have inaccuracies as do gear drives. The longer the standard, the more local errors are averaged.
What if I can't get things repeatable?
There are several possibilities:
You can be losing or gaining steps electronically because of:
- A parallel port with an incompatible output voltage relative to your driver or breakout board. Newer PC's often output 3.3V and a lot of boards and drivers want to see a full 5V.
- Problem with the pulse width parameter on step/dir for Mach3. Some conflicting info out there, but this is easy to fool around with, so worth a try. I have read in a number of places that Geckos like 5 uS pulse duration, and that more won't help you. Failure to set a long enough pulse duration can manifest as apparent lost steps ala this example using a Gecko 540 stepper system.
- Noise adding or hiding bogus steps.
- Cabling that is susceptible to noise. Encoder cabling for servos is extremely noise sensitive. Longer cables are more so.
For more on diagnosing and fixing noise problems in CNC systems, check this page.
- Too much binding
- Too much acceleration, deceleration, or speed is making the motor work too hard.
A thought from Mariss F.: If a stepper motor sounds smooth, you're probably not losing steps mechanically. Steppers are noisy if they are losing steps. If it is noisy, check carefully for mechanical losses. It's easy to turn down your speeds and accelerations to see if that helps.
|Possible Issue: HEDS encoders. Many popular servos use US Digital sourced HEDS encoders. Per Mariss F., these encoders often lack a proper power supply bypass capacitor. This can lead to encoder errors (manifested as positioning errors in the servos), especially if your cables are at all long. This is discussed at length in many places, such as this CNCZone thread.||
Use a 100nF ceramic capacitor at the encoder from GND to +5VDC. Place it as close to the encoder as you possibly can (0.25" or 5mm lead lengths). Parallel it with a 10uF Aluminum electrolytic.
Do you want to be a better CNC'er?
Get Better Tool Life, Surface Finish, and Material Removal Rates.