More on DC motor "stepper emulation"

The code I developed a while ago for using a DC motor (or a BLDC) to replace a stepper has got quite an interest among youmagine users. Over time I realized that some of the quick and dirty things I did were preventing the easy exploration of system parameters for users. Using different PID parameters required a recompile and of the sketch.

I recently received a Printrbot Simple from Brook Drum with the goal of testing with that printer my closed-loop solution.  As usual, simple things (in theory) become tougher that initially expected. First of all, it took forever for the printer to clear through customs and while Printrbot provided and shipped the printer for free, the taxman wanted its cut no matter what, and it took more than too weeks for that to be worked out.

We settled on the Simple because it had more room for the motors to fit in though carriages might be heavier than the Play.

At the time I did not know the CAD of both models was available on Youmagine, so I only had a vague idea of the potential problems of fitting the DC motors I was planning to use on each model.

Once I downloaded the Simple CAD model and imported into Onshape I was able to redesign one of the plates so it will fit the DC motor instead of the stepper.
That part will help attaching the motor to Y-axis of the Simple but there was no may I can make that while I keep Z-axis threaded rod in place. They do that with the stepper because it has a long shaft but that is not the case with the DC motor I am using. Ok, time to think about it. Maybe I will use some fishing line and a couple of pulleys to have a crane-like Z-axis. For now, let's focus on the drive. While the original part was made of metal, I though I will save some time just 3D printing that part. On hindsight that was not a wise move as the plastic part does not help motor heat to spread to the rest of the metal body, so heat becomes a problem. 

I knew that the axis was heavy so the first test was to determine whether or not the motor could handle the load. I learned that 12V might be a bit on the low torque side but a few more volts in the supply voltage will make the same tiny motor to get much more authority. Same driver electronic could do with a higher voltage so no big deal.

Next problem was to replace the axis belt as unfortunately my motor came with MXL pulley. I managed to get an acceptable setup, but due to my pulley lacking a belt guide I later needed to add a big washer to one of the bearings so the belt could not derail on fast moves.

But once everything was up and running I realized how inconvenient was to need a recompile every time I wanted to test a new set of PID parameters. So what I did was to include some additional serial commands so I could set parameters on-the-fly using the serial port. 

And then, I realized that once you have set the right set of values, it will be great if you can save them so they are not lost when you power cycle the controller. EEPROM was the logical choice and after a bit of fiddling with the EEPROM library (as I have an old iMac I cannot update due to a SMART harddisk error, which forces me to still using an old Arduino IDE) I get the thing working nicely.

Not only you can select P, I and D values, but you can also check current encoder value, output value and target location, command manual moves or set a sequence of random moves, plus you can store current parameters into Arduino EEPROM so next time you power it on it will remember them. 

While all previous code was just uploaded to youmagine, this time I created a github repository so hopefully that will make collaborators life easier.

Meanwhile I still need to figure out how to get another DC motor to X-axis.


Popular posts from this blog

VFD control with Arduino using RS485 link

4xiDraw: Another pen plotter

Software I2C for Arduino