Fighting with computers

Computers are not always friendly.

Monday, August 31, 2015

Using a tablet to control a CNC machine

I do have some CNC routers using Arduino Mega and Marlin as pulse generators and g-code interpreters. Usually they are connected to a computer for selecting and streaming g-code files to the machine.

Lately I was testing a new machine and I found an old Android tablet laying around, so I wondered if it could be used for the task of controlling the machine. I am aware of programs like Octoprint that can do exactly that using a RaspberryPi and I have seen it does a great job. However, unless some more hardware is added to the mix, no display or user input is possible. But a tablet already has the display and touch screen that can be used for that purpose, plus Wifi and Bluetooth for wireless communication. What was needed was a USB connection but for that a cheap OTG USB cable was all that I needed.

Well, once the hardware side is solved, you need some software and after checking and testing different options I ended up with GcodePrintr. A software that is designed for controlling a 3D printer that will do a nice graphical representation of the printing commands too.

The best thing is that though the program is not free, there is a version called GCodeSimulator that allows you to test your setup but will not send a g-code file to the printer (or CNC).

So I bought the program and it all seems to be working as expected even though the size of my "bed" is much larger than the graphical presentation allows, but that is not a big deal for me.

Have a look at some moves streamed from the tablet:

Tuesday, August 18, 2015

Closed-loop motor control for 3D printers

It is been a while since I brought this topic in my blog. I recently bumped into this thread on element14 about the same topic too.

I was naive enough to assume that what shows up on eBay or Aliexpress can be available for quite a long time. It appears that some the units just pop up for a while to never be seen again. That has been the case with some of the motors I have been doing tests with.

Since I realized that steppers could in fact be replaced in our 3D printers by a closed-loop DC motor I have been tinkering. One of the key ideas was to find a steady supply of motors that would enable anyone interested into building the same contraption. And while the brushed motors I used worked as expected and were cheap enough, they seemed a bit too weak (not enough torque for higher accelerations) and I was quite worried about how long they will last.

On one hand there is the argument that if inket printers replaced steppers by closed-loop brushed DC motors, we could do the same and get away with it. After all, how many of you have needed to replaced a DC motor on any of your inkjet printers because their brushes were wear out? However, if you have a look at how inkjet printers work you will notice not much in common to how 3D printers (I mean FDM ones) work.

An inkjet carriage moves from side to side of the paper at a [constant] speed while the readings of the optical stripe help the processor to trigger the inkjets to spite ink at the right spots.  Each movement comprises the whole paper width and takes a few hundred milliseconds. Therefore there is one or two full cycles (start-coast-stop) per second while the printer is active. Each start/stop operation will require the motor to receive/deliver a significant amount of current for a few instants while motor is accelerated (or decelerated). It is these high-current operations what will put more stress on motor brushes.

On the other hand, a 3D printer moves each axis by tiny bits whenever a part is being printed. Each movement will required the motor to accelerate and decelerate (sometimes till reaching a full stop) before the next movement takes place. Each one of this little movements can take as tens of milliseconds or more and usually they are fused in such a way that carriages do not need to fully stop between them. But that means the closed-loop position control is putting several tens of start/stop operations per second on the motors. If we use similar brushed motors as the ones present in inkjet printers, it is expected to see their lifetime to be definitely much shorter in this new role.

Therefore, I decided that most RepRappers will be disappointed with a "new" closed-loop DC motor if it only lasts for a few months before motors had to be replaced. Specially when stepper motors usually last forever (or almost, in most systems). Steppers do not have brushes, so unless severely overheated it is the lifetime of the bearings what limits its service life.  If we use brushless DC motors instead of brushed ones, we can get a similar lifetime as stepper motors.  However, brushless motors are usually more expensive and they need more complex electronic drives.

I found several models that could work and while not ideal, they were more than powerful enough. Unfortunately, just a few weeks after I bought some samples they became unavailable. Still I was kind o happy with the results but realized no other people could use the same solution as the model could not be obtained anymore.

I contacted some manufacturers, most notably Nidec, which has some very interesting units, but the company seemed not to have any interested on talking to me (I guess their business is good enough to turn down sales of tens of units per month, as that was the projected sales figure in my request).  Other manufacturer had very nice motor prices but above $60 which looked to me a difficult pill to swallow.  Maxxon can create custom motors to fit all you needs but you may be willing to pay their price.

I had more luck talking to smaller companies so I settled with a Taiwanese motor manufacturer that was brave enough to explore this application space with me. So as you read this a sample brushless motor is being develop and the goal is for it to be able to replace at least X and Y axis in RepRap 3D printers while it can be directly plugged in to regular electronics (you remove the Pololu and plug the motor cables in).  A setup process will be needed before we can obtain the most of the new motor, though we will try to have an initial configuration that may allow most people to skip setup process.

Working together with a manufacturer, cost has been all the time a priority, as I want this to be available at an affordable price. After all, you can do this right now if you buy a brushless motor and a driver electronics that could accept step and direction inputs.  The problem is these available solutions will easily cost $150 per axis or more. You can buy ten steppers and their driver electronics for that price, so to me that is not a choice and I do not see any conversion to happen at that price range.

I have moved away from optical encoders and I am currently testing magnetic encoders that hopefully will give us a higher angular resolution (12 bits) at a lower cost. More on this once we have a working unit.