Arduino Uno With Spindle and Pitch Motor

About: Do you like technology? Follow my channel on Youtube and my Blog. In them I put videos every week of microcontrollers, arduinos, networks, among other subjects. New tutorials on Tuesdays and Fridays.

Today we are going to talk about a very important subject in mechanics and mechatronics: the elements of machines. In this article, we will specifically address the spindles, featuring some interesting features and applications. Still, we will demonstrate some ways of calculating the movement caused by a spindle and presenting a test assembly.

I made the assembly below, therefore, which exposes the advance of a spindle of 2mm and another of 8mm. This TR8 spindles I am using are commonly used in small routers and 3D printers, especially on the Z axis. Remembering that by mastering some concepts that we will work on here, you will be able to design any type of machine.

Step 1: Resources Used

  • Trapezoidal spindle 8mm in diameter and 2mm pitch
  • Trapezoidal spindle 8mm in diameter and 8mm in pitch
  • 8x2 spindle flanged chestnut
  • 8x8 spindle flanged chestnut
  • Bearings for 8mm diameter spindles
  • Linear cylindrical guide 10mm in diameter
  • Cylindrical roller bearings for 10mm guides
  • Brackets for 10mm cylindrical guides
  • NEMA 17 Motors
  • Shaft couplings
  • Arduino Uno
  • Driver DRV8825
  • 4x4 matrix keyboard
  • Display Nokia 5110
  • Miscellaneous plastic parts
  • Bolts and nuts
  • Wood base
  • External 12V power supply

Step 2: About Spindles - What Are They?

Spindles are elements of machines, such as screws. That is, they are straight bars formed by threads of continuous steps. They are used in mechanisms that require linear movement and positioning. They can exert high tensile and compressive forces and transmit torque. They allow movement with automatic locking. They can be constructed of different materials, being the most common aluminum and steel.

As Chinese companies are manufacturing the trapezoidal spindles, I would suggest you get this type of product instead of the well-known nut bolt. This is due to the more attractive price and the drag, which I consider hideous.

In the photo I put the best spindle that has, in my opinion, that is the recirculating ball spindle. It is usually made of a very hard steel, and the balls revolve around it, inside the chestnut. Besides the precision that is great, I also highlight the durability, since this type of spindle can reproduce billions of movements without damaging the mechanism. A cheaper option, which is the one we use here, is the trapezoidal spindle.

Step 3: About Spindles - Single and Ball Threads

The ball spindles, in the photo to the left, have semicircular canals where the balls roll. They are relatively more expensive and have low friction compared to single screw spindles, leading to a much higher yield (rolling friction).

The single-threaded spindles on the right side of the image usually have trapezoidal profiles, since this geometry is more appropriate to apply forces in the axial direction and smooth transmission of motion. They are relatively inexpensive and have high friction compared to recirculating ball spindles, leading to a low yield, ie slip friction.

Step 4: About Spindles - Applications

Spindles can be applied to any mechanism where linear motion is required. They are widely used in the industry in machinery and processes.

Some applications include:

  • Cargo lifts
  • Presses
  • Strawberries and lathes
  • CNC Equipment
  • Wrapping Machines
  • 3D Printers
  • Laser Cutting & Cutting Equipment
  • Industrial processes
  • Positioning and linear motion systems

Step 5: About Spindles - Parameters

There are several characteristics of a spindle that must be taken into account when designing a mechanism. In addition to its diameter and pitch, it is necessary to recognize its compressive strength, its moment of inertia (resistance to change in its rotational state), constructive material, the speed of rotation to which it will be subjected, direction of operation (horizontal or vertical) , the applied load, among others.

But, based on already constructed mechanisms, we can intuit several of these parameters.

Let's recognize some common good. Let's start with STEP.

Step 6: About Spindles - Step (displacement and Speed)

Determines the length traveled by the nut at each revolution. This is usually in mm / revolution.

A 2 mm spindle per revolution will cause a displacement of 2 mm at each turn that the spindle performs. It will influence the linear velocity of the nut, since with the increase of the speed of rotation, the number of revolutions per unit of time will increase and consequently the distance traveled also.

If a 2mm spin per revolution spins at 60 RPM (one revolution per second), the nut will move at 2mm per second.

Step 7: Assembly

In our assembly, I have two motors and our keyboard with the display, which looked like a calculator, because I made a cover for them in the 3D printer. On the Nokia display we have the following options:

F1: Crescent - Fuso goes from the current position to the position I determine

F2: Descending - Turn

F3: Speed - Can I change the pulse width

F4: ESC

Step 8: Mounting - Materials

A - 10mm Linear Guides

B - Trapezoidal spindles of steps 2 and 8mm

C - Drilling Base

D - Bearings for spindles

E - Guide holders

F - Chestnuts

G - Bearings

H - Couplings

I - Engines

J - Various plastic parts (cursors, engine brackets, wedges, keyboard support and display

Step 9: Assembly - Step 01

Following the drilling of the base (C), we assemble the two motors (I). To fasten them, we use brackets made in the 3D printer (J). Do not tighten any of the screws in this positioning step. This will allow for the necessary adjustments in the alignment step.

Step 10: Assembly - Step 02

Still following the drilling of the base (C), position the guide rails (E) and the bearings (D). Detail for the plastic shim (J) used to adjust the heights of the bearings.

Step 11: Mounting - Step 03

We create a cursor using a printed part to connect the bearing (G) to the nut (F). We used two cursors, one right another left. Its function is to indicate the position on a scale whenever we want to determine the displacement caused by the spindle.

Step 12: Assembly - Step 04

Insert the guide (A) and the spindle (B) in their respective bearing (D) and support (E), opposite the motor, then insert the guide and the spindle in the bearing (G) and chestnut (F) and at the tip of the spindle we also insert the coupler (H). We take them both until they reach their final points (opposite support and motor).

Lightly tighten the screws to allow a later adjustment. Repeat the procedure using the remaining guide and spindle. With all the components positioned, we perform the alignment of the parts, finishing the mechanical assembly stage.

Step 13: Mounting - Electronics

Using a printed plastic holder, we secured the Nokia 5110 display and a 4x4 matrix keypad. In the lower space of the stand will reside the Arduino Uno, the driver DRV8825.

Using the available drilling in the base, we fasten the assembly.

Step 14: Electric Scheme

The wiring diagram is simple. We have the DRV8825 and the same two 17 mirrors, that is, the same step we send to one goes to another. What changes is that in one of the engines I have an 8mm spindle and in the other a 2mm spindle. Obvious, then, that the first, with 8mm spindle, goes faster. Still in the diagram are the display and the 4x4 keyboard, which has to be matrix.

Step 15: Source Code

Inclusion of libraries and creation of objects

We have here a Lib that I did, which is StepDriver.h. It is prepared for the 8825, 4988 and also the TB6600 drivers. I create in this step the object DRV8825, the d1.

//Biblioteca responsável por capturar a tecla que foi pressionada no teclado
#include <Keypad.h> //Biblioteca responsável pelos graficos do display #include <Adafruit_GFX.h> //Biblioteca responsável pela comunicacao do display #include <Adafruit_PCD8544.h> //Configuracao de pinos do Display // pin 6 - Serial clock out (SCLK) // pin 5 - Serial data out (DIN) // pin 4 - Data/Command select (D/C) // pin 3 - LCD chip select (CS/CE) // pin 2 - LCD reset (RST) Adafruit_PCD8544 display = Adafruit_PCD8544(6, 5, 4, 3, 2); //Biblioteca de motor de passo #include //Instancia o driver DRV8825 DRV8825 d1;

Constants and global variables

In this part of the code I treat the matrix, which I taught in another video lesson (LINK KEYBOARD). Still, I'm talking about the Keypad object, besides distance and speed.

const byte LINHAS = 4; //número de linhas do teclado
const byte COLUNAS = 4; //número de colunas do teclado //define uma matriz com os símbolos que deseja ser lido do teclado char SIMBOLOS[LINHAS][COLUNAS] = { {'A', '1', '2', '3'}, {'B', '4', '5', '6'}, {'C', '7', '8', '9'}, {'D', 'c', '0', 'e'} }; byte PINOS_LINHA[LINHAS] = {A2, A3, A4, A5}; //pinos que indicam as linhas do teclado byte PINOS_COLUNA[COLUNAS] = {0, 1, A0, A1}; //pinos que indicam as colunas do teclado //instancia de Keypad, responsável por capturar a tecla pressionada Keypad customKeypad = Keypad( makeKeymap(SIMBOLOS), PINOS_LINHA, PINOS_COLUNA, LINHAS, COLUNAS); //variáveis resposnsáveis por armazenar o valor digitado char customKey; unsigned long distancia = 0; unsigned long velocidade = 2000;

Keyboard reading function

In this step we have the code referring to the display, which works the increasing and decreasing printing.

//Funcao responsavel por ler o valor do usuario pelo teclado-----------------------------------------
unsigned long lerValor() { //Escreve o submenu que coleta os valores no display display.clearDisplay(); display.fillRect(0, 0, 84, 11, 2); display.setCursor(27, 2); display.setTextColor(WHITE); display.print("VALOR"); display.setTextColor(BLACK); display.fillRect(0, 24, 21, 11, 2); display.setCursor(2, 26); display.setTextColor(WHITE); display.print("CLR"); display.setTextColor(BLACK); display.setCursor(23, 26); display.print("LIMPAR"); display.fillRect(0, 36, 21, 11, 2); display.setCursor(5, 38); display.setTextColor(WHITE); display.print("F4"); display.setTextColor(BLACK); display.setCursor(23, 38); display.print("VOLTAR"); display.setCursor(2, 14); display.display(); String valor = ""; char tecla = false;

looping waiting for the key pressed

Here we explain Loop programming, that is, where you enter the values.

//Loop infinito enquanto nao chamar o return
while (1) { tecla = customKeypad.getKey(); if (tecla) { switch (tecla) { //Se teclas de 0 a 9 forem pressionadas case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0': valor += tecla; display.print(tecla); display.display(); break; //Se tecla CLR foi pressionada case 'c': //Limpa a string valor valor = ""; //Apaga o valor do display display.fillRect(2, 14, 84, 8, 0); display.setCursor(2, 14); display.display(); break; //Se tecla ENT foi pressionada case 'e': //Retorna o valor return valor.toInt(); break; //Se tecla F4 (ESC) foi pressionada case 'D': return -1; default: break; } } //Limpa o char tecla tecla = false; } }

Motor drive function

The "move" function is worked on in this step. I get the number of pulses and the direction and then I make a "for".

//Funcao responsavel por mover o motor--------------------------------------
void mover(unsigned long pulsos, bool direcao) { for (unsigned long i = 0; i < pulsos; i++) { d1.motorMove(direcao); } }

setup ()

Now I move the display and the driver configuration, and I even put the pinning inside the source code to make it easier. I initialize certain values and deal with the methods that generate the settings.

void setup() {
//Configuracao do display ------------------------------------------------ display.begin(); display.setContrast(50); display.clearDisplay(); display.setTextSize(1); display.setTextColor(BLACK); //Configuração do Driver DRV8825 ----------------------------------------- // pin GND - Enable (ENA) // pin 13 - M0 // pin 12 - M1 // pin 11 - M2 // pin 10 - Reset (RST) // pin 9 - Sleep (SLP) // pin 8 - Step (STP) // pin 7 - Direction (DIR) d1.pinConfig(99, 13, 12, 11, 10, 9, 8, 7); d1.sleep(LOW); d1.reset(); d1.stepPerMm(100); d1.stepPerRound(200); d1.stepConfig(1); d1.motionConfig(50, velocidade, 5000); }

loop () - 1st part - Drawing menu

void loop() {
//Escreve o Menu do Programa no display ----------------------------------- display.clearDisplay(); display.fillRect(0, 0, 15, 11, 2); display.setCursor(2, 2); display.setTextColor(WHITE); display.print("F1"); display.setTextColor(BLACK); display.setCursor(17, 2); display.print("CRESCENTE"); display.fillRect(0, 12, 15, 11, 2); display.setCursor(2, 14); display.setTextColor(WHITE); display.print("F2"); display.setTextColor(BLACK); display.setCursor(17, 14); display.print("DECRESCENTE"); display.fillRect(0, 24, 15, 11, 2); display.setCursor(2, 26); display.setTextColor(WHITE); display.print("F3"); display.setTextColor(BLACK); display.setCursor(17, 26); display.print("VELOCIDADE");

loop () - Part 2 - Drawing menu

display.fillRect(0, 36, 15, 11, 2);
display.setCursor(2, 38); display.setTextColor(WHITE); display.print("F4"); display.setTextColor(BLACK); display.setCursor(17, 38); display.print("ESC"); display.display(); bool esc = false;

loop () - Part 3 - Running

//Loop enquanto a tecla F4 (ESC) nao for pressionada
while (!esc) { //captura a tecla pressionada do teclado customKey = customKeypad.getKey(); //caso alguma tecla foi pressionada if (customKey) { //Trata a tecla apertada switch (customKey) { //Se tecla F1 foi pressionada case 'A': distancia = lerValor(); //Se tecla ESC foi pressionada if (distancia == -1) { esc = true; } else { //Escreve a tela "Movendo" no display display.clearDisplay(); display.fillRect(0, 0, 84, 11, 2); display.setCursor(21, 2); display.setTextColor(WHITE); display.print("MOVENDO"); display.setTextColor(BLACK); display.setCursor(2, 14); display.print(distancia); display.print(" Passos"); display.display();

loop () - Part 4 - Running

//Move o motor
mover(distancia, LOW); //Volta ao menu esc = true; } break; //Se tecla F2 foi pressionada case 'B': distancia = lerValor(); //Se tecla ESC foi pressionada if (distancia == -1) { esc = true; } else { //Escreve a tela "Movendo" no display display.clearDisplay(); display.fillRect(0, 0, 84, 11, 2); display.setCursor(21, 2); display.setTextColor(WHITE); display.print("MOVENDO"); display.setTextColor(BLACK); display.setCursor(2, 14); display.print(distancia); display.print(" Passos"); display.display();

loop () - Part 5 - Running

//Move o motor
mover(distancia, HIGH); //Volta ao menu esc = true; } break; //Se tecla F3 foi pressionada case 'C': velocidade = lerValor(); if (velocidade == -1) { esc = true; } else { //Escreve a tela "Velocidade" no display display.clearDisplay(); display.fillRect(0, 0, 84, 11, 2); display.setCursor(12, 2); display.setTextColor(WHITE); display.print("VELOCIDADE"); display.setTextColor(BLACK); display.setCursor(2, 14); display.print(velocidade); display.print(char(229)); display.print("s");

loop () - Part 6 - Running

display.fillRect(31, 24, 21, 11, 2);
display.setCursor(33, 26); display.setTextColor(WHITE); display.println("OK!"); display.setTextColor(BLACK); display.display(); //Configura nova velocidade ao motor d1.motionConfig(50, velocidade, 5000); delay(2000); //Volta ao menu esc = true; } break; //Se tecla F4 (ESC) foi pressionada case 'D': //Se tecla CLR foi pressionada case 'c': //Se tecla ENT foi pressionada case 'e': //Volta ao menu esc = true; default: break; } } //Limpa o char customKey customKey = false; } }

Step 16: About Spindles - Machine Configurations

In CNC machines such as 3D printers and routers for example, the program responsible for positioning control needs to know how the movements will occur as a function of the number of pulses given to the stepper motor.

If the step motor driver allows the application of micro-steps, this configuration must be taken into account in the calculation of the displacement produced.

For example, if a 200-step motor per revolution is connected to a driver set to 1/16, then 16 x 200 pulses will be required for a single revolution of the spindle, that is, 3200 pulses for each revolution. If this spindle has a pitch of 2mm per revolution, it will take 3200 pulses in the driver for the nut to move 2mm.

In fact, software controllers often use a reason to specify this ratio, the "number of pulses per millimeter" or "steps / mm".

Step 17: Marlin

In Marlin, for example, we see in the section @section motion:

/ **

* Default Axis Steps Per Unit (steps / mm)

* Override with M92

* X, Y, Z, E0 [, E1 [, E2 [, E3 [, E4]]]

* /

#define DEFAULT_AXIS_STEPS_PER_UNIT {80, 80, 3200, 100}

In this example, we can conclude that the X and Y axes have an accuracy of 80 pulses to move 1mm, while the Z needs 3200 pulses and the extruder E0 needs 100.

Step 18: GRBL

Below we see the GRBL configuration commands. With the $ 100 command, we can adjust the number of pulses required to cause a one-millimeter offset on the X-axis.

In the example below we can see that the current value is 250 pulses per mm.

The Y and Z axes can be set respectively $ 101 and $ 102.

Step 19: See More of My Work:

Share

    Recommendations

    • Plastics Contest

      Plastics Contest
    • Optics Contest

      Optics Contest
    • Make it Glow Contest 2018

      Make it Glow Contest 2018

    Discussions