Skip to content

10. Mechanical and Machine Design

Group Assignment

Design a machine that includes mechanism+actuation+automation

Build the mechanical parts and operate it manually

Actuate and automate your machine

Document the group project

Assignment

Document your individual contribution

With my group mates we decided to divide the work so that everyone deals with a specific aspect of the project. I asked to be able to take care of the electronics and the automation of the system since I felt quite knowledgeable about the mechanics part not to see it as a challenge (in the end it was the one that fooled us … as my grandmother used to say “only fools are sure of what they do!”).

Having already the actuation in my mind (3 axis movement and another “movement” to close/open the claw) it was actually an easy task to accomplish, I just needed to know what kind of hardware to use and how to control the interface for the movement.

Antonio suggested me to use stepper motors and servomotors and, since we have not yet dealt with the interface and programming discourse, to use a sketch for Arduino which, through the insertion of the movement coordinates in the form of g-code, would allow to automate the whole. Moreover, a real-time controller that can be controlled with the mouse is also available from the same program. But let’s go in order …

(DISCLAIMER: some of the following parts are taken from the Antonio’s Machine Design Assignment, technical information were very clear and useful)

Process

Stepper Motors & Servomotors The easiest way to move things in the world of making is with the help of stepper motors and servo motors, which can rotate to a given degree with a given speed with relative easyness (servo motors usually can rotate from 0° do 180°). Stepper motors are made out of several coils, which are polarized and synchronized in precise steps in order to move a shaft at the given parameters. To operate this coils is necessary an integrated driver which transforms a digital input from an interpreter into pulses of the voltage required by the motor.

This operation is often accomplished with the help of a shield which is nothing more than a breakout of the wires in a more significant and standard way.

So, to recap, to actuate a stepper motor what I needed and what I used were:

An interpreter - an Arduino Uno board;

A shield - a [CNC Arduino-compatible shield](https://www.amazon.it/AZDelivery-CNC-Shield-V3-Parent/dp/B07CZDC9TZ?th=1) ;

Drivers - Pololu A4988 driver;

The stepper motor itself - a Jameco NEMA 14 200 step stepper motor;

The servomotor SG90

A 12v power supply - for the motor;

The Arduino board, the CNC shield and the drivers are made to fit together, you put the shield on the top of the Arduino, you put the driver on the top of the shield and you wire the stepper on the pins of the shield next to the driver. Just be very careful with the drivers ‘cause you need to check for the correct direction (but, easily, one of the pin is named EN_ENABLE_and you can find the same indication on the surface of the CNC Shield). Furthermore, you wire up the 12v power supply in the proper slot of the CNC shield. The only thing to spend a little more care on is in the wiring of the stepper motor. Usually, stepper motors come in fashion of 4 or 6 colored leads used to operate the coils. Wire them up can be pretty confusing but, in my case, I noticed that the wires were already connected by pairs side by side, connecting them in one way or the other just changed the direction of the stepper rotation. Wathever, you can find diagrams on-line to check what you’re doing.

A separate topic are servomotors. The CNC shield board does not have PMW pins dedicated to the control of the servomotors but, looking at the indication of the local instructor and following the dedicated forums, I saw that there was a modified version of the GRBL sketch (explanation below) that I would have used to control the steppers , version that transforms a pin (D11) into a PMW to which I could attach a servomotor (which in my case would have served to open and close the hook of the Candy Grabber we were designing).

GRBL & G-code

What about the software? The Arduino will play as an interpreter and this is possible by flashing onto it a g-code parser and CNC controller called Grbl. Grbl simply receives g-code instructions via the serial port and translate them on the Arduino designated pins for the drivers to be read. Beyond that, Grbl allows you to set up many technical parameters regarding the performance of the stepper motors and give you feedback on the status of the machine, with the help of a commands enabled with the $ character that are thoroughly exposed in the official repository.

Here you can find all the information needed to burn grbl on your Arduino Uno board

But now? How can we make Arduino communicate with CNC Shield? We use the G-code system? Whay’s a g-code? Essentially is a language that communicates straightforward commands for your machine to be exectued. This is done in the form of commands made of a letter and a number whose combination corresponds to a precise, finite behaviour.

For example, the commands:

G91 F200 X10 Y-10 Z70

tells to move relatively to its position to x=10, y=-10 and Z=70 to a feedrate of 200.

Instead the commands:

G90 X4 Y30 Z40

tells to move in absolute coordinates at the top of its speed to x=4, y=30 and Z=40.

For learning g-code, I found it really useful to read fully the tutorial that you can find on the Simplify 3D site, It’s about 3D printing but the commands are quite similar. Alternatively this article is more CNC centered.

I fired the Arduino IDE and opened the serial monitor to communicate with the grbl-enabled Arduino.

Before even starting, two very important things need to be set up. Grbl simply won’t work if the baudrate and end character aren’t set respectively to 115200 and carriage return. By doing so you’ll get an easy to recognize message from the board ans you can start sending commands.

Precision is something trivially essential when dealing with machines, and Grbl won’t simply accept any command that isn’t written properly either as Grbl command or g-code . Fortunately, Grbl interface provides clear error messages in case of mistake that can be reviewed in the official repository.

immagine messaggio errore

For example, in the above gif I received the following errors (which are ones among the most common):

specificare gli errori e le spiegzioni

If you send a properly written command, Grbl will parse and reply a reassuring feedback.

immagine messaggio ok

Now you can test your stepper!

video stepper funzionanti ok

GRBL for servomotor

As I said before, the purpouse in using CNC Shield was to control 3 stepper motor and one servo motor to open/close the claw of the candy grabber machine. But the standard version of GRBL cannot control the servo, just the stepper. We check for a different one release and we found this one that let use use the command line M that control the spindle of the servomotor.

Using the command line M03 Sxxx (where xxx can be substitued by a value from 0 to 255 that control the rotation of the servomotor from 0° to 180°) we can move the mechanism of the claw (see next chapter) to obtain the two position that we need:

0 ---> OPEN

255 ---> CLOSE

Arduino UNO + Servo Motor: the claw Since we wanted to obtain a more “luna park” experience and we didn’t want to mess with the gcode in the serial monitor of Arduino, we decided to control the servo motor of the claw (that open and close is arms transmitting the circular movement of the servo to through some joints) using two buttons, making a simple circuits with an Arduino Uno and a breadboard and writing a simple sketch.

video claw funzionanti ok

inserire sketch.ino

inserire immagine circuito tinkercad

I’m a firestarter, twisted firestarter

While I was playing with CNC Shield and the stepper motors…something happend! I cannot really explain and, I’m sorry, there’s no documentation about it but…one of the driver for the stepper took fire after 30 minutes I was working on it.

There’s no an explanation. Maybe cheap components, maybe something went wrong with the connections. Maybe the stepper weren’t at the right voltage (microstepping) in summary I have burned the driver, the Arduino board and the CNC Shield…

While I was waiting the delivery man with the new shield I started playing with a different shield for the stepper controls. I found one in the Fablab that can be used with an Arduino Mega, so I downloaded from the repository the GRBL for Arduino Mega and started once again with my test.

The very next day the CNC shield arrived at my home but, this time, I decided to burn onto Arduino Uno the GRBL image that can also controls the servo and…nothing worked! After some trials and research, Antonio found that having in the same library differets version of GRBL can have a result that some of the functions could not work properly (reference here)

After having canceled the standard one and the Arduino Mega one, the GRBL+servo Version started work in the correct way!

GRBL Controller 3.6.1

At this time of the Fabacademy we don’t have any clue about how to control an interface for a machine so the only way to control all the movement of the stepper was to use the serial monitor that you can find in your Arduino IDE.

But, let’s be honest, write all the commands by yourself isn’t easy like to push a button…

I’m not the only one that think in this way. People more skilled than me asked themselves that same question and…found a solution! And now we can easily control GRBL with this program called GRBL Controller (there’s also an app that you can install on your mobile and uses the bluetooth connection to control the program on your pc. I didn’t use it…yet). The interface is very simple, just open the right port where your Arduino is connected and pushing the arrows on the right panel you can move the axis. Only problem is that you cannot move two or more axis at the same time. Maybe is used most off the time to find the zero position before starting a job.

But to fake (see the next video to know why I said FAKE…) a movement was enough!

Final result

In the end everything was assembled and ready to function… But It’s better if you check the final result on the group assignment page

immagine candy grabber machine