Pi CNC Plotter Fail

A not-quite-successful attempt at a closed-loop CNC plotter using DC motors and a Raspberry Pi.

Public Chat
Similar projects worth following
This CNC plotter uses a Raspberry Pi and DC motors. The resolution is quite poor; this is probably because of low-quality motors.

Actuators: The robot uses DC motors with built-in worm gears.  Each motor uses a rotary potentiometer to get feedback.  The motors are rated as 6V, 6RPM.

Printed Parts: The blue plastic parts were designed in FreeCAD and 3D printed.

Misc. Electronics: The motors are driven by L298N h-bridges.  The h-bridges are connected to an Adafruit Servo Bonnet, which is connected to a Raspberry Pi Zero W.  An ADC (MCP3008) is used to get readings from the potentiometers.

Software: I couldn't find software to control this robot, so I wrote my own using Python.  The software can only draw straight lines.  It breaks the line into segments; the robot adjusts its motor speeds after drawing each segment.  To draw each segment, it uses the following steps:

  1. Use the potentiometers (and the ADC) to get the robot's current position.  Communication with the ADC uses bit-banged SPI (because I couldn't figure out how to use the hardware SPI without my code having GPL infection).
  2. Calculate the potentiometer readings at the desired position.
  3. Calculate the PWM duty cycles for each motor, so that each motor reaches the desired position at the same time.
  4. As the motors move, repeatedly get potentiometer readings.  When a motor has reached the desired position, stop its movement.
  5. Once all motors have stopped, proceed to the next line segment.

I wrote a gcode parser, but since the resolution is so poor I decided not to spend the time integrating the parser into the rest of my code.

Problems: The resolution is surprisingly poor.  I think this is because of looseness in the worm gears.  I can freely rotate the motor shaft several degrees before engaging the gears.  There is also room for improvement in the software, but I think this is less of an issue than the loose motor shafts.

A Note About Pi CNCs: It is often argued that it is impossible to build a Pi CNC without writing a real-time operating system.  This is usually because of concern that the Pi can't provide high-precision pulses for stepper motors.  (There is some evidence that the Pi is probably fine for hobby-level stepper CNCs, but that's beside the point).

    I attempted to circumvent these difficulties by replacing steppers with DC motors, and controlling them using a PWM Bonnet.  The Pi must regularly check the potentiometer readings, but this is probably less demanding than sending stepper pulses.

    While I was not successful enough to conclusively show that a Pi can control a closed-loop CNC, I still believe that the circuitry would work if the motors and software are of sufficient quality.

  • The Last Update For a While

    Daniel James Evans08/16/2018 at 23:08 0 comments

    Several issues have been pointed out that would not be fixed by replacing the wobbly worm gears.  Each issue could be addressed individually, but this would be time-consuming.

    Therefore I've decided to reduce the scope of my efforts.  I plan to continue testing the Pi and DC motors, but to use a conventional, cartesian robot that will be similar (or identical?) to existing open-source designs.  This will reduce complexity and make debugging much simpler.

    Since I'm rebuilding the robot anyway, I might as well invest in higher-accuracy sensors.  Perhaps I'll get some optical encoders.  Alternatively, I might make an attempt at using computer vision- others on this website have had success with this approach.  I would have to purchase and calibrate a camera of sufficient resolution, but OpenCV definitely has the capability to do this sort of thing (at least to moderate accuracy).

    I'll probably post something to this website when (if) I get another robot built and working.  But it will probably be a few months (or even a few years).

  • Loose Motor Shafts

    Daniel James Evans08/08/2018 at 02:19 0 comments

    This shows that the motor shafts are loose, causing inaccuracy.  I can rotate the motor shafts several degrees before encountering resistance from the gears.  This reduces the accuracy of the machine.

  • The CNC Works (Sort of)

    Daniel James Evans08/08/2018 at 02:15 0 comments

    The robot attempted to write "HI".  The writing is difficult to read, but it is possible to distinguish the letters if you look carefully.

View all 3 project logs

Enjoy this project?



ClearloveG wrote 03/14/2019 at 09:22 point


  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates