element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Twist, Turn and Move Design Challenge with TE Robotics
  • Challenges & Projects
  • Design Challenges
  • Twist, Turn and Move Design Challenge with TE Robotics
  • More
  • Cancel
Twist, Turn and Move Design Challenge with TE Robotics
Blog Blog #4
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Leaderboard
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: GustavoMorales
  • Date Created: 12 Sep 2022 3:56 AM Date Created
  • Views 384 views
  • Likes 6 likes
  • Comments 0 comments
Related
Recommended

Blog #4

GustavoMorales
GustavoMorales
12 Sep 2022

It has been a long journey, filled with knowledge. At this point, my RARM is almost done.

I would like to tell you a little bit of what was my path to building the robot. 

Let's get started

  • In the beginning, when I started blogging I used some servo motors to learn more about mechanical parts how they should move and how axis interact with each other avoiding blocking stages. That leads me to make a mixture between servo motors and steppers. Servos can be easy to control but sometimes they are not as stable as a servo can be in stressful situations.

  • Modeling, I am not a mechanical engineer so I had a really stressful time making pars at the end my design was not as efficient as others so I want to recognize the job made by JjRobots which design was taken from and to How to Mechatronics, without their orientation this could not be done, they knew more about movement and mechanisms, They have lots of information about libraries and how to use other drivers in order to make this type of robot more reliable. In the end, I took their ideas but wanted to improve or make them easy to understand and make more robots like mine for students so they can also get inspired in continuing with these activities. 

  • Once I had a clear idea time for assembling was coming I'll talk about some problems I had in my last blog with my final presentation. 
  • Coding, as I said in previous blogs, I was almost using a library but someone in the community advised me about using libraries that could not be as easy to troubleshoot as my own code should be. So taking that In mind I used my own code to create movement, and in my first blog I used a Joystick to control the prototype as a final result, I kept with the idea of using joysticks because it is a friendly way of controlling and if anyone wants to move it they can easily control it with any sophisticated interfaces.

Now here is my code 

image

In the first stage, I just defined variables that will be used in the rest of it, nothing out of this world simple integers and some constants that will be used in the routines I created to be part of the movement. 

At the main loop I just called a function called "joystick" this was made in order to keep a clean loop and make my routines. 

image

Here we can see the main structure of the robot, this is a routine that Ill call it as the main movement. I made 2 conditions to map the position of the joystick depending on the axis, then as a parameter for moving the steppers since I used some Drivers we just have to send 2 main parameters which are the direction and the steps, 

As extra parameters I send speed in microseconds son in order to have faster movements I have to place a small value in a constant defined at the very beginning, I am Just showing this part of the code because it is almost the same for each stepper (3 steppers) they follow the same structure to that we can keep simple stuff. At the end of this blog, I am attaching the code as plain text. Tomorrow I am uploading the final results and showing the ARM done.  There are some phrases in Spanish but they are just to understand me as my main language important stuff is English. 

Any doubt or advice is a pleasure to read you. 

#include <Servo.h> // Librería para controlar el servomotor
Servo pinza; // variable que tomará el valor de la posición del servomotor

// Stepper Motor X
const int stepPin = 2; //X.STEP
const int dirPin = 5; // X.DIR

// Stepper Motor Extremo
const int stepPinEx = 3; //Y.STEP
const int dirPinEx = 6; // Y.DIR

// Stepper Motor Altura
const int stepPinZ = 4; //Y.STEP
const int dirPinZ = 7; // Y.DIR

// joystick1
int vrx1 = A0;
int vry1 = A1;
int vrx_Joy1 = 0;
int vry_Joy1 = 0;

// joystick2
int vrx2 = A2;
int vry2 = A3;
int vrx_Joy2 = 0;
int vry_Joy2 = 0;

int x = 0;
int y = 0;
int z = 0;
int SMSpeed = 800; // Stepper Motor Speed


void setup() {
// Sets the two pins as Outputs
Serial.begin(9600);
//Contro steppers
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(stepPinEx,OUTPUT);
pinMode(dirPinEx,OUTPUT);
pinMode(stepPinZ,OUTPUT);
pinMode(dirPinZ,OUTPUT);

//stepers
pinza.attach(9); // Se coloca el servo en el pin 2


//control Joystick
pinMode(vrx1 , INPUT);
pinMode(vry1, INPUT);
pinMode(vrx2 , INPUT);
pinMode(vry2, INPUT);
}


void loop()
{
joystick();

}

void joystick()
{
//********************************************************************************** MOVIMIENTO MOTOR X**********************************************
vrx_Joy1 = analogRead(vrx1);

// to stop the stepper motor
if ( (vrx_Joy1 > 490) && (vrx_Joy1 < 510) )
{;}

//AVANZAR MOTOR
if ( vrx_Joy1 > 700)
{
digitalWrite(dirPin,HIGH);
x = x + 1;
digitalWrite(stepPin,HIGH);
delayMicroseconds(SMSpeed);
digitalWrite(stepPin,LOW);
delayMicroseconds(SMSpeed);
}


//REGRESAR EL MOTOR

if ( vrx_Joy1 < 300)
{
digitalWrite(dirPin,LOW);
x = x - 1;
digitalWrite(stepPin,HIGH);
delayMicroseconds(SMSpeed);
digitalWrite(stepPin,LOW);
delayMicroseconds(SMSpeed);
}


//********************************************************************************** MOVIMIENTO MOTOR BRAZO**********************************************
vry_Joy1 = analogRead(vry1);

// to stop the stepper motor
if ( (vry_Joy1 > 490) && (vry_Joy1 < 510) )
{;}

//AVANZAR MOTOR
if ( vry_Joy1 > 700)
{
digitalWrite(dirPinEx,HIGH);
y = y + 1;
digitalWrite(stepPinEx,HIGH);
delayMicroseconds(SMSpeed);
digitalWrite(stepPinEx,LOW);
delayMicroseconds(SMSpeed);
}


//REGRESAR EL MOTOR

if ( vry_Joy1 < 300)
{
digitalWrite(dirPinEx,LOW);
y = y - 1;
digitalWrite(stepPinEx,HIGH);
delayMicroseconds(SMSpeed);
digitalWrite(stepPinEx,LOW);
delayMicroseconds(SMSpeed);
}


//********************************************************************************** MOVIMIENTO MOTOR ALTURA**********************************************
vrx_Joy2 = analogRead(vry1);

// to stop the stepper motor
if ( (vrx_Joy2 > 490) && (vrx_Joy2 < 510) )
{;}

//AVANZAR MOTOR
if ( vry_Joy1 > 700)
{
digitalWrite(dirPinZ,HIGH);
z = z + 1;
digitalWrite(stepPinZ,HIGH);
delayMicroseconds(SMSpeed);
digitalWrite(stepPinZ,LOW);
delayMicroseconds(SMSpeed);
}


//REGRESAR EL MOTOR

if ( vrx_Joy2 < 300)
{
digitalWrite(dirPinZ,LOW);
z = z - 1;
digitalWrite(stepPinZ,HIGH);
delayMicroseconds(SMSpeed);
digitalWrite(stepPinZ,LOW);
delayMicroseconds(SMSpeed);
}

}

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube