Skip to content

Electronics

For this assignment, my colleage Zahra & me were responsible for the electronic part. We did research about the topic & these are some of the references:

Arduino CNC Shield 1) , Arduino CNC Shield 2 , Arduino CNC Shield 3 , Arduino CNC Shield 4 & Machine Building .

c2

Things we need:

  • An Arduino Uno and a PC to upload the firmware.

  • Three bipolar stepper driver such as the DRV8825 or the A4988. One for each motor. We got two A4988.

  • Three bipolar stepper motor with a dupont connector with 4 pins.

  • A power supply for the motors. Normally it will be 12V and at least 5A.

  • Arduino CNC Shield (we got Version 3. 0) runs on 12-36V DC.

Flashing GRBL

Grbl is a no-compromise, high performance, low cost alternative to parallel-port-based motion control for CNC milling. This version of Grbl runs on an Arduino with a 328p processor (Uno, Duemilanove, Nano, Micro, etc).

I have downloaded the grbl v1.1 files through their official github link . Then, I have added the (grbl) folder contained within it as a library in the arduino IDE through Sketch > Include Library > Add .ZIP Library

g2 g1

An example called GrblUpload apeared in examples. Then, opened it, compiled and uploaded it.

g3

The settings can be customized to your needs through the config.h. I tried to edit this file by opening the grbl confg.h file (one of the libraries in the arduino grbl code) and comment out any lines regarding Z_homing

#define HOMING_CYCLE_0 (1<<Z_AXIS)to remove the Z-axis homing 

g4

but I got an error, so I returnd it to how it was.

Stepper Motor

A stepper motor is a motor controlled by a series of electromagnetic coils. The center shaft has a series of magnets mounted on it, and the coils surrounding the shaft are alternately given current or not, creating magnetic fields which repulse or attract the magnets on the shaft, causing the motor to rotate.

It converts digital pulses into mechanical shaft rotation. Every revolution of the stepper motor is divided into a discrete number of steps, in many cases 200 steps, and the motor must be sent a separate pulse for each step. The stepper motor can only take one step at a time and each step is the same size. Since each pulse causes the motor to rotate a precise angle, typically 1.8°, the motor’s position can be controlled without any feedback mechanism. As the digital pulses increase in frequency, the step movement changes into continuous rotation, with the speed of rotation directly proportional to the frequency of the pulses. These links, link1 & link2 have some useful information & codes.

We added/changed the motor connectors to increase the length of the wire & to be able to connect it to the shield.

w1

Linear Motion Control

The rotary motion of a stepper motor can be converted to linear motion using a lead screw/worm gear drive system. The lead, or pitch, of the lead screw is the linear distance traveled for one revolution of the screw. If the lead is equal to one inch per revolution, and there are 200 full steps per revolution, then the resolution of the lead screw system is 0.005 inches per step. Even finer resolution is possible by using the step motor/drive system in microstepping mode.

in the group documentation, we mentioned that we found that the steps were not accurate. So, we changed the “V carve sheild” steps by adding jumpers in the right position as shown.

Arduino CNC Shield

Arduino CNC Shield Version 3.0 GRBL 0.9 compatible 4-Axis support (X, Y, Z , A-Can duplicate X,Y,Z or do a full 4th axis with custom firmware using pins D12 and D13) 2 x End stops for each axis (6 in total) Coolant enable Compatible with A4988 or DRV8825 stepper driver Runs on 12-36V DC

It is the PCB that we will need to control the stepper motors. This PCB is perfect to assemble CNC low cost machine such as a laser cutter, using an Arduino Uno. It is compatible with the GRBL firmware. It has endstops and relays output, and support the speed control by PWM.

Motor Driver

A4988 Stepper Motor Driver Board is a breakout board for Allegro’s A4988 DMOS Micro stepping Driver with Translator and Overcurrent Protection The motor driver takes the pulse signals from the arduino (direction and step pulse) and converts them to motor motion signals outputed to the motor coils to energize them accordingly.

It’s important to pay attention to the orientation of stepper drivers. The potentiometer (pot) on A4988 and DRV8825 are at the opposite side.

c1 c3

Motor testing 3

Dispenser

We took the dispenser of an old Dettol’s no-touch hand wash system. We connected a DC motor driver directly to the dispenser motor (not to the circuit of the system). We used M3 command to operate the dispenser & M4 to close it.

Duplicate Axis

We tried duplicating X-axis by adding two jumpers to connect the X-axis pins.

c3

Some motor control testing

Motor testing 1

Software

BCNC

BCNC is a GRBL CNC command sender, autoleveler and g-code editor. It can import/export g-code, dxf and svg files. We had some problems with the connection to bcnc at some times but we were able to connect to it eventually.

b1 b2

Checking motor control using BCNC

Motor testing 2

Easel

Easel is a web-based software platform that allows you to design and carve from a single, simple program.

e1

Checking motor control using Easel

Motor testing 4

Below is a list of G-Code commands and what they do. source:

S command: Sets the Spindle speed.(0-1000 with default build)

M3 Command: Sets Spindle Pin to the PWM rate as specified by the S command. (Clockwise) Sets Spindle Direction pin High

M4 Command: Sets Spindle Pin to the PWM rate as specified by the S command.(Counter Clockwise) Sets Spindle Direction pin Low

M5 Command: Sets Spindle pin Low. (PWM 0) Keeps the Direction Pin as is.

In gCode as grbl understands it, there are two commands that are used to turn the spindle on and off .source.

M3S10000: Start the spindle spinning Clockwise (M3) at 10,000RPM (S10000) M5: Stop the spindle

We tried generating g-code for a drawing using Easel & We used M3 command to operate the dispenser & M4 to close it.

%
(Header)
(Generated by gcodetools from Inkscape.)
(Using default header. To add your own header create file "header" in the output dir.)
M3
(Header end.)
G21 (All units in mm)
(Tool diameter should be at least 0.803173857027 mm)
(Depth, as a function of radius w, must be 10)
(Rapid feeds use safe Z=5.0 mm)
(Material surface at Z=0.0 mm)
(Change tool to Default tool)

G00 Z5.000000
G00 X144.741280 Y38.061905

G01 Z-0.401574 F100.0(Penetrate)
G01 X145.142854 Y37.660303 Z0.000000 F400.000000
G01 X144.741280 Y38.061905 Z-0.401574
G01 X144.739671 Y38.061905 Z-0.401574
G01 X141.917449 Y38.050786 Z-0.390483
G01 X139.095227 Y38.039666 Z-0.379363
G01 X136.273005 Y38.028546 Z-0.368244
G01 X133.450782 Y38.017455 Z-0.357124
G01 X130.628560 Y38.006336 Z-0.346033
G01 X127.806338 Y37.995216 Z-0.334913
G01 X124.984116 Y37.984125 Z-0.323794
G01 X122.161893 Y37.973005 Z-0.312702
G01 X119.339671 Y37.961886 Z-0.301583
G01 X116.517449 Y37.950794 Z-0.290463
G01 X113.695227 Y37.939675 Z-0.279372
G01 X110.873004 Y37.928555 Z-0.268252
G01 X108.050782 Y37.917464 Z-0.257133
G01 X105.228560 Y37.906344 Z-0.246041
G01 X102.406338 Y37.895225 Z-0.234922
G01 X99.584115 Y37.884105 Z-0.223802
G01 X96.761893 Y37.873014 Z-0.212683
G01 X93.939671 Y37.861894 Z-0.201591
G01 X91.117449 Y37.850775 Z-0.190472
G01 X88.295227 Y37.839683 Z-0.179352
G01 X85.473004 Y37.828564 Z-0.168261
G01 X82.650782 Y37.817444 Z-0.157141
G01 X79.828560 Y37.806353 Z-0.146022
G01 X77.006338 Y37.795233 Z-0.134930
G01 X74.184115 Y37.784114 Z-0.123811
G01 X71.361893 Y37.772994 Z-0.112691
G01 X68.539671 Y37.761903 Z-0.101572
G01 X65.717449 Y37.750783 Z-0.090480
G01 X62.895226 Y37.739664 Z-0.079361
G01 X60.073004 Y37.728572 Z-0.068241
G01 X57.250782 Y37.717453 Z-0.057150
G01 X54.428560 Y37.706333 Z-0.046030
G01 X51.606337 Y37.695242 Z-0.034911
G01 X48.784115 Y37.684122 Z-0.023820
G01 X45.961893 Y37.673003 Z-0.012700
G01 X44.550782 Y37.667443 Z-0.007140
G01 X144.741280 Y38.061905 Z-0.401574
G01 X42.736516 Y37.660303 Z0.000000
G01 X144.741280 Y38.061905 Z-0.401574
G01 X43.141279 Y37.661912 Z-0.001580
G01 X45.963502 Y37.673003 Z-0.012700
G01 X48.785724 Y37.684122 Z-0.023820
G01 X51.607946 Y37.695242 Z-0.034939
G01 X54.430168 Y37.706362 Z-0.046030
G01 X57.252391 Y37.717453 Z-0.057150
G01 X60.074613 Y37.728572 Z-0.068270
G01 X62.896835 Y37.739692 Z-0.079361
G01 X65.719057 Y37.750783 Z-0.090480
G01 X68.541280 Y37.761903 Z-0.101600
G01 X71.363502 Y37.773022 Z-0.112691
G01 X74.185724 Y37.784114 Z-0.123811
G01 X77.007946 Y37.795233 Z-0.134930
G01 X79.830168 Y37.806353 Z-0.146022
G01 X82.652391 Y37.817444 Z-0.157141
G01 X85.474613 Y37.828564 Z-0.168261
G01 X88.296835 Y37.839683 Z-0.179380
G01 X91.119057 Y37.850803 Z-0.190472
G01 X93.941280 Y37.861894 Z-0.201591
G01 X96.763502 Y37.873014 Z-0.212711
G01 X99.585724 Y37.884133 Z-0.223802
G01 X102.407946 Y37.895225 Z-0.234922
G01 X105.230169 Y37.906344 Z-0.246041
G01 X108.052391 Y37.917464 Z-0.257133
G01 X110.874613 Y37.928555 Z-0.268252
G01 X113.696835 Y37.939675 Z-0.279372
G01 X116.519058 Y37.950794 Z-0.290491
G01 X119.341280 Y37.961914 Z-0.301583
G01 X122.163502 Y37.973005 Z-0.312702
G01 X124.985724 Y37.984125 Z-0.323822
G01 X127.807947 Y37.995244 Z-0.334913
G01 X130.630169 Y38.006336 Z-0.346033
G01 X133.452391 Y38.017455 Z-0.357152
G01 X136.274613 Y38.028575 Z-0.368244
G01 X139.096835 Y38.039666 Z-0.379363
G01 X141.919058 Y38.050786 Z-0.390483
G01 X143.330169 Y38.056345 Z-0.396042
G01 X144.741280 Y38.061905 Z-0.401574
G01 X145.142854 Y38.466668 Z0.000000
G01 X144.741280 Y38.061905 Z-0.401574
G01 X144.741280 Y38.061905 Z-0.401574
G00 Z5.000000


(Footer)
M5
G00 X0.0000 Y0.0000
M2
(Using default footer. To add your own footer create file "footer" in the output dir.)
(end)
%

Motor testing

Testing motors with the dispenser

Motor testing 5

Dispenser control testing by using M3 command to operate the dispenser & M4 to close it.

Motor testing 6

We found that the steps was not accurate so we changed the “V carve sheild” steps by adding jumpers in the right position as shown.

Then we tested the machine by plot test.

After that we installed the pumping system to pump water to wash the car.