For the final draft of this blog, a numerical control will be made by the computer capable of integrating stepper motors with an aluminum module for the respective movements in three dimensions (in this case 2 X and Y).
The information received by the Arduino will be transmitted through an interface graphical user made in processing, which has the functionality of an automatic mode to sweep through space.
The graphical interface has an automatic mode, which measures the object functions by introducing scanning on the three movements X, Y, and Z.
The communication between the PC and the Arduino is serial; the Arduino contains a firmware which receives the information on a function, which receives the communication frame that reflects the value that corresponds to each of the motors for the respective movement.
The materials used for the final project are:
The communication between the PC and the Arduino is serial; the Arduino contains a firmware which receives the information on a function, which receives the communication frame that reflects the value that corresponds to each of the motors for the respective movement.
MATERIALS:
The materials used for the final project are:
- 2 --- Stepper Motors 1.8 ° / 200 steps
- 2 --- Driver L293D
- 1 --- Source Computer
- 4 --- Transistors BC547
- 4 --- 10k Resistors
- 4 --- resistors 1k
- 1 --- Arduino Uno R3 platform
- aluminum
- borneras
- Cable (connections)
PATTERNS:
Breadboard:
Breadboard:
1.Arduino Code
- #include <Stepper.h>
- int led=12;
- int led1=11;
- int led2=10;
- // Motores Paso a Paso
- const int motorX = 140; //(M8=>Paso:1,43mm; 360/1,43=>1mm=252º; 252ºpormm/0,9ºpor paso=280 Pasos por 1mm
- const int motorY = 140; //(M8=>Paso:1,43mm; 360/1,43=>1mm=252º; 252ºpormm/1.8ºpor paso=140 Pasos por 1mm
- const int motorZ = 140; //(M8=>Paso:1,43mm; 360/1,43=>1mm=252º; 252ºpormm/1.8ºpor paso=140 Pasos por 1mm
- // initialize the stepper library on pins 8 through 11:
- Stepper mymotorX(motorX, 2,3);
- Stepper mymotorY(motorY, 4,5);
- Stepper mymotorZ(motorZ, 6,7);
- // ARREGLO Y VARIABLES LECTURA DE PROCESSING PARA SERVOS
- int MOTORX=0, MOTORY=0, MOTORZ=0;
- int motor[3] = {MOTORX, MOTORY, MOTORZ};
- //int antbase=90, anthombro=86, antcodo=150, antmuneca=45, antgiro=157, antgripper=175;
- // byte lector
- int inByte, x, m, b, h, j, z;
- int k=0;
- void setup() {
- pinMode(led,OUTPUT);
- pinMode(led1,OUTPUT);
- pinMode(led2,OUTPUT);
- // set the speed at 60 rpm:
- mymotorX.setSpeed(150);
- mymotorY.setSpeed(150);
- mymotorZ.setSpeed(100);
- // initialize the serial port:
- Serial.begin(9600);
- }
- void loop() {
- }
- void serialEvent(){
- if (Serial.available() > 0){
- inByte = Serial.read();
- if(inByte == 'M')
- modo_manual();
- }
- }
2.Arduino Code
- // FUNCION LEER TRAMA
- void modo_manual(){
- while(inByte != 'F'){
- if (Serial.available() > 0){
- inByte = Serial.read();
- motor[x] = inByte;
- x++;
- }
- }
- if(inByte == 'F'){
- x=0;
- //lcd.clear();
- MOTORX = motor[0];
- MOTORY = motor[1];
- MOTORZ = motor[2];
- }
- movpaso(MOTORX,MOTORY,MOTORZ);
- }
- void MOV Paso(int MOTORX, int MOTORY, int MOTORZ){
- m=motorX*MOTORX;
- b=motorY*MOTORY;
- h=motorZ*MOTORZ;
- //numero de vueltas en X y Y para hacer el recorrido del objeto
- for (int j=1; j<=((MOTORX/10)+1); j++){
- if ((j%2)==1)
- {
- for (int i=0; i <=(1.1*MOTORY); i++){
- mymotorY.step(140);
- }
- }
- else {
- for (int i=0; i <=(1.1*MOTORY); i++){
- mymotorY.step(-140)
- }
- }
- if(j<=(MOTORX/10)){
- for(int n=0;n<11;n++){
- mymotorX.step(140);
- }
- }
- }
- }
Code Processing
- // LIBRERIAS
- import controlP5.*;
- import processing.serial.*;
- // CREACION DE OBJETOS
- ControlP5 cp5;
- Serial serial;
- Textlabel texto1, texto2, texto3, texto4, texto5, texto6; // definir las variables
- // TAMAÑO TITULOS
- PFont f;
- boolean on_off = false;
- //BOTONESl
- Button envio;
- Toggle actauto;
- // SLIDERS
- Slider movx, movy, movz;
- // CAJAS INGRESO DE VALORES
- Textfield textb, texth, textc;
- // ARREGLO PARA MOTORES PASO A PASO
- int MOTORX=0, MOTORY=1, MOTORZ=2;
- int[] motor = new int[3];
- int var=0;
- void setup() {
- size(450, 370);
- background(40);
- smooth();
- // TITULOS
- f = createFont("Arial", 12, true);
- cp5 = new ControlP5(this);
- serial = new Serial(this, Serial.list()[0], 9600);
- // VALORES PREDETERMINADOS PARA LOS MOTORES
- motor[MOTORX]=0;
- motor[MOTORY]=0;
- motor[MOTORZ]=0;
- //BOTON ENVIAR AUTO
- envio = cp5.addButton("envio", 1, 310, 125, 50, 20);
- //TOGGLES PARA ACTIVAR MANDOS
- actauto = cp5.addToggle("on_off", false, 53, 100, 26, 10);
- // INPUT TEXTBOX BASE
- textb = cp5.addTextfield("ejeX", 100, 125, 50, 20);
- textb.setFocus(true);
- // INPUT TEXTBOX HOMBRO
- texth = cp5.addTextfield("ejeY", 170, 125, 50, 20);
- texth.setFocus(true);
- // INPUT TEXTBOX CODO
- textc = cp5.addTextfield("ejeZ", 240, 125, 50, 20);
- textc.setFocus(true);
- // crear texto
- texto1 = cp5.addTextlabel("label")
- .setText("INTERFAZ CNC ANDI")
- .setPosition(60, 30)
- .setColorValue(0xffffffFF)
- .setFont(createFont("Broadway", 30))
- ;
- texto2 = cp5.addTextlabel("label1")
- .setText("Introduzca las coordenadas en mm")
- .setPosition(120, 170)
- .setColorValue(0xffffffFF)
- .setFont(createFont("arial", 12))
- ;
- texto3 = cp5.addTextlabel("label2")
- .setText("Encender el boton ON/OFF para inicializar el modulo")
- .setPosition(80, 190)
- .setColorValue(0xffffffFF)
- .setFont(createFont("arial", 12))
- ;
- // otra forma de crear texto
- texto4 = new Textlabel(cp5, "Estudiante: Andres Felipe Sinisterra", 40, 280, 600, 200);
- texto4.setFont(createFont("MV Boli", 15));
- texto5 = new Textlabel(cp5, "Ingenieria Electronica", 40, 295, 600, 200);
- texto5.setFont(createFont("MV Boli", 15));
- texto6 = new Textlabel(cp5, "Decimo semestre", 40, 310, 600, 200);
- texto6.setFont(createFont("MV Boli", 15));
- }
- //----------------------------------------------------------------------------------------------
- void draw() {
- background(20, 100, 200); // color de fondo de la ventana
- texto4.draw(this); // introduce el texto en la ventana
- texto5.draw(this);
- texto6.draw(this);
- textFont(f, 12);
- fill(255);
- text(" ---------------- MANDO AUTOMATICO -------------------------", 50,105);
- }
- //-------------------FIN DEL LOOP---------------------------
- // FUNCION DE EVENTOS
- void controlEvent(ControlEvent theEvent) {
- //if (theEvent.isController()) {
- if ( on_off == true ) {
- //while (var < 1) {
- motor[0] = (int(textb.getText()));
- motor[1] = (int(texth.getText()));
- motor[2] = (int(textc.getText()));
- if(theEvent.controller().name()=="envio") {
- serial.write('M' + ":" + motor[0] + ":" + motor[1] + ":" + motor[2]); // envia por el puerto serial el nombre y el valor
- println('M' + ":" + motor[0] + ":" + motor[1] + ":" + motor[2]); // imprime por pantalla el nombre y el valor
- //var++;
- }
- }
- // var=0;
- // delay(100);
- }
Post a Comment