Setting up the Hardware & Electronics
Controlling the Plotter
The control of the plotter from the iPad is done in two steps:
- The iPad connects connects to the ESP32-CAM via bluetooth low energy (BLE).
- The ESP32-CAM sends a command to the Arduino Uno via serial.
- The Arduino Uno controls the stepper motors and servos which allow a drawing to be displayed.
An important thing to note is the coordinate transformation from the iPad to the plotter. The motors are setup such that regular CNC commands are rotated by 45 degrees compared to the actual commands. See the drawing below (source: IEEE Spectrum).
As such the ESP32-CAM computes the rotation of the iPad's coordinates on the fly to accurately plot correct coordinates.
The following video explains how the wiring is done.
Controlling the hardware
Flashing the ESP32-CAM
This is laborous work as the ESP32-CAM has neither a builtin programmer nor a USB port.
You will need to either get an FTDI or an ESP32-CAM programmer (the latter will save you lots of time) to flash code the the ESP32-CAM. Note that to put the ESP32-CAM into flashing mode you will need to place a jumper wire connecting the IO0 and GND pins should you choose to use the FTDI.
You also need to install the ESP32 library from the Arduino IDE. Instructions here.
Controlling the stepper motors
We use a CNC shield placed on an Arduino Uno to control the stepper motors.
To set up the motor drivers, the driver's current limiter must be adjusted to match that required by the NEMA 17 stepper motors. This can be done by following a tutorial such as this one.
Wire the stepper motors as such:
Note that the stepper motor drivers are placed with the screws towards the center of the board. The stepper motors normally come with cables that allow you to connect them directly to the CNC Shield without too much of a hassle.
Then to make sure the plotter will work with the iPad, you need to make sure the X and Y axes point in the correct direction.
- If you haven't done so already, build the plotter!
- Follow this guide to flash the Arduino Uno with GRBL, the firmware needed to control the stepper motors.
- Download and install the Universal Gcode Sender.
- Open the Universal Gcode sender and run the setup wizard (under Machine > Setup Wizard).
- Set the X and Y feed rate to 300 steps/mm.
- Press the X+/- and Y+/- buttons to observe the behavior of the stepper motors. The directions should match the following sketch:
Controlling the pen servo
The ESP32-CAM controls the pen servo by setting it to either UP (180°) or DOWN (10°). The servo is controlled by PWM through the ESP's IO15 pin.
Controlling the laser
The laser uses a pan-and-tilt mechanism with two servos. See the plotter build section for how the pieces work. The servos should be connected to the IO14 and IO2 pins, each one controlling a separate axis (alpha and beta).
To power the Uno, we used a 9V battery pack. The power can be supplied to the board by either soldering the battery's wires to the Vin and GND ports on the prototyping board, or by soldering them to a male power jack and connecting that to the Arduino's female power jack.
Final circuit design
The final circuit should consist in a "sandwich" with the Arduino at the bottom, the prototyping shield in the middle, and the CNC shield on top.
Servos and laser powering
We used an external breadboard connected to the 5V and GND pins of the top CNC shield to power the laser and servos. The laser should be wired in parallel to the servos (which are chained in series).
Prototyping shield circuit
To wire the ESP32-CAM, we soldered two 8-pin female headers to the prototyping shield, and then soldered the 5V, GND, U0T pins from the ESP32 to the Uno's pins. We also soldered wires to the IO15, IO14 and IO2 pins to control the servos via PWM. The ESP32-CAM then can be placed on top of the headers in a snug position.