All-in-one CNC machine controller (stepper motors)
ManAtWork
Posts: 2,176
I've invested the time I have saved from my forum abstinence the last two months to make an new P2 controller board. It's designed to handle everything that needs to be controlled in a small milling machine or lathe, especially
- up to five stepper motors for positioning
- one induction motor to drive the tool or workpiece
- drive relays or solenoids for coolant, tool changer etc.
- handle sensor inputs for home switches, tool length probe etc.
- provide safety features (door lock, emergency stop, limited jog speed...)
The controler consists of a main board holding several plug-in cards with power stages for the stepper motors.
The single-row pin header on the left side is for the power stage for the induction motor (VFD, not shown) which runs directly from mains voltage (230VAC). I plan to use the power stage of this old P1 project which is a simple "sixpack" driver (3 phase bridge) with some additional protection features.
All data is transmitted from a PC via ethernet (100Mbit) so the P2 doesn't need much RAM and no display. Well... almost. I'll connect a small OLED display module so that status and diagnostics can be displayed as plain text and without cryptic LED blinking codes.
The stepper motors are powered from a 48V SMPS. Power to the 48V supply and the VFD is cut off completely for emergency stop and slow jog mode (when safety doors are open) with two relays. The relay contacts are monitored with a special redundant circuit so that any posiible failures of one relay can be detected before the second also fails. All safety related circuits (door switches and emergency stop) are also monitored for faults and cross conduction.
I know, I have already designed many boards for the P2 but haven't managed to really finish a single project. I hope I'll have more luck, this time. But one of my bigger customers already showed interest, so I'm optimistic. Integrating the safety features should result in a competitive price. Chinese drives are damn cheap but you have to add all those safety devices externally which not only costs money but also adds complexity and work to the assembly and wiring.
Comments
I know, there have been several suggestions and experiments of how to drive stepper motors with the MOSFET drivers and current sense resistors connected directly to the P2. (see Universal motor driver from parallax or this and this discussions). However, time-to-market is crucial. So I hope I've learned my lesson and decided not to start from scratch, this time, but instead use a ready-to-use chipset from Trinamic. Unlike older ICs from Trinamic which were very limited in terms of drive current and voltage the TMC5160 uses external MOSFETs and drivers.
Driving all MOSFETs with individual smart pins for each motor would require more than one P2 for five or six motors, anyway. So the cost penalty of the 5 Trinamic ICs is almost balanced out. Controlling all the step/dir signals, the SPI bus for configuration, the ethernet interface, PWMs for the induction motor and all the IOs also requires more than 64 pins. But the slower IO signals can be handled with external shift registers and multiplexers as I'm already used to from my P1 projects.
Very Cool
I was just watching the video of your machine, making the KISS modules. Very nice
Craig
Time well spent. Hats off to you. You got me interested again.
Please, let us (ok, maybe just me) know when these are available.
I'm still suffering the "forum lurking, not doing stuff" syndrome. But not for much longer unless you resume posting .
Looks very nice 👌
@ManAtWork
Just to recap; Your Windows CNC is your own development, correct?
How capable is it, compared with LinuxCNC, etc?
Presumably your control can provide step/direction to standard servo drives that accept these signals?
I have been looking at making Delta (brand) my standard but in my case, I'll be analogue command and running in torque mode.
Craig
@ManAtWork Looks really nice! I don't know a whole lot about CNC, but do have a Shapeoko XL from carbide 3D: https://carbide3d.com/shapeoko/
presume this would be able to control that? think the basic machine is just 3 axis.
kind of think of it as 2.5D in that it's mostly 2D, but can do some 3d things.
Love to be able to make a better version that would machine stainless. Don't know what that would take though.
Shapeoko can do aluminum if you adjust some speeds.
For this type of product, isn't the software the key? Do you have a solution for that?
This is it....
But the new hardware is probably also compatible with Mach4 etc(?)
Craig
LinuxCNC is a completely different thing. It's not just a single application software, it's a construction kit. That's one of it's most important advantages. You can do everythinbg with it: control robots, pick&place machines, milling machines or lathes. But it's also a big drawback. You need expert knowledge to install and configure it. My software is only for milling, at the moment, but it's very easy to install and use. And I think there one criteria where it beats LinuxCNC performance wise: complex trajectory planning and surface quality.
Yes, I'm used to SanyoDenki servos but they are all quite similar. They support step/dir input or analogue torque or velocity commands. I've even rolled my own. So yes, it happily runs machines with servos but it's probably not suited for your tube bending machines.
No. That would be technically possible but commercial suicide. Artsoft takes $1000 for the software license and the hardware manufacturer must be content with ~$20 profit. If something doesn't work they all blame the hardware so you have to do all the work and provide support and Artsoft takes all the money.
Those routers look quite good. At least they have ball screws and fully supported linear rails. I can't tell from the pictures if they use NEMA24 or NEMA34 motors. Do you have any specifications about the drivers they use?
I think if you would just build a smaller machine with the same components it could cut stainless. The problem with big routers is not power but flexibility of the long beams. When cutting harder materials it rattles and vibrates like hell so you quickly break the cutters. Deflection increases with the 3rd power of length. So making the machine smaller helps a lot. Rigid bearings are also important. A spindle with ISO30 taper runs a lot smoother in steel than ISO20 simply because the bearings have a larger diameter.
Yes. The frontend for my Propeller based CNC controller is called "Beamicon2". There's not as much on the internet as for Mach3/4 but "workbensch" and "Sorotec" have some videos on youtube (example).
No, completely different animal and no GCODE involved. But I have a couple of braindead Bridgeport Series II, Interact 4 machines. This could be perfect
I'll be in touch by email when I get the chance.
Craig
Initial smoke test passed, all voltage regulators are OK, no smoke - check
OLED diplay working - check
Ethernet MAC working - check
(at least the link status LED is flashing. Everything else should work as I copied it from the ethernet PHY accessory board project)
ManAtWork - great job in this CNC circuit board design project.
How can I say this anymore forcefully & loudly: We in the USA need a lot more of this type of design work to counter the attacks of CHINA on our industrial base, technical expertise, and all the rest.
Searching the Internet, you would be very hard pressed to find a CNC lathe, mill, press, welding, assembly, or any other industrial machinery made in the US. All of these machines are made in CHINA... That's scary.
Ken
Your boards look good. I was wondering if you worked out post processer for your controller to work with autocad , master cam etc.
Thanks @PropGuy2 and @DigitalBob for the praise. I have postprocessors for Autodesk fusion, Solidcam, Filou, VCarve and VicualMill. It's easy to add others as it processes generic G-code. There are only a few special cases that need attention.
Well, China... That's a political problem. It's how capitalism works. Too many people make too much money by importing cheap stuff from China. Currency exchange ratios are calculated based on virtual stock prices and not actual value. Politicians make their decisions based on how to win the next election and not what would be good for the people in the long run. But it's easy to complain about things you cannot change.
What you can do is to tell the customers about the actual cost of something. Most people only see the price on the tag. If you add the cost of the hours you spend fighting with badly translated manuals, fixing missing safety features and replacing broken parts you end up with the higher quality western product actually being cheaper.
so true.
Kenny Larken at Larken Automation makes some nice CNC products. Check out Viper servo.com too. He's up in Canada and he's not a fan of the China products either. He won't use the cheap board mfr. company's in China.
@DigitalBob
Hmm, complete AC servo package from China....
Or brushed DC from Canada...
This is gonna be a tough one
Craig
Brushed servo drives are much simpler but it's hard to get the motors, theese days. Only suitable to retro-fit old machines where the motors are already there (and still working). And you have to be careful, DC servos tend to run away when the encoder (or cable) fails.
Yes, you can't beat the price/power ratio of those Chinese drives. But there are several problems:
For a bit above €500 I get a 1kW motor&lifier kit from Sanyo. They have digital encoders so only 4 wires are sufficient. I use 5 pin M12 sensor connectors for them, small, cheap and water tight.
Yeah, I would never consider brushed DC although I miss the simplicity.
Encoder failure: I maintain a Ki>0 and constantly monitor for a count "waggle" (steady-state). No waggle and I shut down. This is one more reason why I prefer dual-loop feedback but this is only feasible on the machines that I actually built (I patented it for tube-formers...German company, Robitec tried to copy )
Waterproof connectors: I swear by this stuff Easy to remove, should the need arise.
Sanmotion: I became excited about this but can't find a UK source. Mouser has their stepper stuff but not servo.
Craig
Servos offer high torque, high horsepower, and high speed that Steppers can't match. Normally the servos operate with -10/+10 input on the amplifier. If you put a meter on the motor output, you'll see the voltage constantly switch plus/minus volts at rest to hold the position.
So steppers are for light jobs unless you get them with a planetary gearbox, then you sacrifice speed. Euro power normally runs 380 volt 3 phase 50Hz. and 220 v is your single phase norm, vs the US 120 volt.
Yup, still the fastest way to go (not that it really matters). The bigboys of the industry like to push ridiculously fast servo cycles as a means of one-upmanship (my opinion). OMRON purchased Delta-Tau's (USA) PMAC (programmable multi-axis controller) technology and now they boast "the world's fastest...5 axes in 25usec".
However, the P2 laughs at this
Galil, just around the corner from Parallax, well their flagship controller can hit 32usec but only with a single axis and special "fast firmware". Add more axes and it soon becomes 125usec, 250usec, etc. and they lose features like electronic gearing and dual-loop feedback. P2 eats them alive
Craig
3 phase installations in the UK typically include a neutral, so no problem but I need to double-check something; when I looked closely at the Chinese product, I seem to remember that they offered a 400V+ option.
Craig
Oh, I have the manual on my Dropbox:
Dropbox Link
Craig
@ManAtWork
The above motor/drive combo is available with 17bit absolute encoder but with this option, there is no simulated encoder output. However, this isn't required with your control, correct?
This could be a very nice solution for milling machines
Craig
Next milestones:
I ran out of pins even though there are 64 on the P2. So I had to expand the digital IOs with 74HC166 and 74HC595 shift registers. They share the SCLK and MOSI pins with the SPI bus for the configuration of the Trinamic chips. The decoder for the chip select lines shares the address lines with the analogue multiplexer to further reduce pin count. This makes everything a bit complicated because no seperate driver software could be used. Instead, I have to write a dedicated driver that serves all the peripherals in a time-multiplexed way.
On the other hand, the P2 helps a lot simplifying the production test. With each smart pin being able to monitor analogue voltage and digital timings I can implement an extensive power on self test. I can check all supply voltages, measure the temperatures of the power stages and even check if the bus termination is there by checking RC decay timing.
Next thing is the safety circuit. K1 and K2 control power to the motor supply and VFD. K3 is the latch circuit.
The basic safety, e.g. everything stops if emergency stop is pressed and nothing randomly starts moving as long as the door is open, does not rely on any electronics or software but is implemented by pure electromecanical switches. There are two completely independent signal paths so a safe halt is guaranteed even if any one single switch fails to open.
The software state machine is only there for surveillance. It's contantly checking for any suspicous states (both paths do not match) and prevents the machine from re-entering into service if a fault is detected. This enforces that any single fault is repaired before a second fault can occur.
Wiring errors, shorts to ground, to supply and cross conduction (shorts between the two signal paths) can be detected by using PWM with 2.5% or 95% duty cycle instead of continous DC signals (0 / 100%).
Hmmm, checking for "suspicious states" is a great idea
This is a pet-peeve of mine; here's what happened to me:
Production rates weren't acceptable so the always-overruling production management had the maintenance department bypass the safety gates.
Operator gets hurt, runs to an attorney and I end-up paying him six-figures (typical in USA)
Those who come-up with "dual-redundant, forced contact relays" are out-of-touch with the real world.
Personally, I would prefer intelligent monitoring devices that communicate directly with the control CPU using a protocol that can't be bypassed.
Craig
A good safety design does not place unnecessary restrictions to the operator. Bad designs come with obstacles and delays and therefore are subject to (illegal but sometimes understandable) manipulations.
Example: most if not all cheap CNC controllers and motor drivers do not have the "slow jog mode" that allows the operator to move the machine (carefully) while the doors are open. The consequences are: power to the motor drives are completely cut off when the door is open at cheap machines (if there are doors at all). Of course the encoders do not have batteries and loose their position count each time. So I have to repeat the homing procedure each time I change the workpiece. This sucks! Of course, everyone wants to put jumpers across the door switches.
A clever design has either absolute encoders or drives that keep the encoders permanently powered. No need for annoying delays and the safety circuit has a much higher chance to remain functional.
I don't like those. Everything that has a microcontroller in it needs programming and configuration and is (murphy's law!) not available when you need it urgently. Simple mechanical switches can be replaced with any brand. And they are still available in 20 or even 100 years. Or in most cases you disassemble and clean them and they work, again.