Skip to content

Commit

Permalink
Actualizacion area de dibujo
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghigliazza committed Nov 2, 2024
1 parent 922bab2 commit 0b0829f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
10 changes: 4 additions & 6 deletions rtos/Proyecto_Plotter/arm_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@
#define _ARM_CONTROLLER_H_

// Controlador del brazo mecanico (controlador de movimiento)

#include "servo_controller.h"

//Valores maximos y minimos de coordenadas que puede alcanzar el lapiz
//Usados para abstraer los limites del area de dibujo
#define MIN_X 450
#define MAX_X 1350
#define MIN_Y -750
#define MAX_Y 750
#define MIN_X 375
#define MAX_X 1400
#define MIN_Y -725
#define MAX_Y 725
#define RANGE_Y (MAX_Y-MIN_Y)
#define RANGE_X (MAX_X-MIN_X)

// Coordenadas iniciales del brazo
#define STARTING_X RANGE_X-MIN_X
#define STARTING_Y RANGE_Y


// Ciclos del scheduler que espera el brazo a que se terminen de mover los servos
#define WAIT_CYCLES 2

Expand Down
19 changes: 10 additions & 9 deletions rtos/Proyecto_Plotter/servo_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,20 @@ void SERVO_calculate_range()
{
float R, theta, gamma, alpha, beta;

int pos_y = 90;
int pos_x = 90;
int pos_y = ARM_LENGTH_A;
int pos_x = ARM_LENGTH_B;
bool negative_found = false;

int min_x = 90;
int max_x = 90;
int min_x = ARM_LENGTH_B;
int max_x = ARM_LENGTH_B;
bool min_x_found, max_x_found;

for (int y = 90; y > -90; y--) // For each height
for (int y = ARM_LENGTH_A; y > -ARM_LENGTH_A; y--) // For each height
{
pos_y = y;
pos_x = 90; // Reset X position and min/max values
min_x = 90;
max_x = 90;
pos_x = ARM_LENGTH_B; // Reset X position and min/max values
min_x = ARM_LENGTH_B;
max_x = ARM_LENGTH_B;
min_x_found = false;
max_x_found = false;

Expand Down Expand Up @@ -176,7 +176,7 @@ void SERVO_calculate_range()
}

// Calculate max_x
pos_x = 90;
pos_x = ARM_LENGTH_B;
negative_found = false;
while (!negative_found)
{
Expand Down Expand Up @@ -207,4 +207,5 @@ void SERVO_calculate_range()
Serial.println("Altura (" + String((int)pos_y) + "): No valid range for X");
}
Serial.println("TEST FINALIZADO");
delay(5000);
}
8 changes: 4 additions & 4 deletions rtos/Proyecto_Plotter/servo_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

#include <ESP32Servo.h>

//Longitud de cada brazo
#define ARM_LENGTH_A 900 //Brazo conectado al servo alpha
#define ARM_LENGTH_B 900 //Brazo conectado al servo beta

//ESP32 PWM Pins: 0-19, 21-23, 25-27, 32-39
#define SERVO_ALPHA_PIN 18
#define SERVO_BETA_PIN 19
#define SERVO_VERTICAL_PIN 23

//Longitud de cada brazo
#define ARM_LENGTH_A 900 //Brazo conectado al servo alpha
#define ARM_LENGTH_B 900 //Brazo conectado al servo beta

void SERVO_init();
void SERVO_moveto(int x_coord, int y_coord); //Calcula los angulos alfa y beta para posicionar el extremo en (X,Y)
void SERVO_lift(bool lifted); //Eleva o desciende el servo vertical
Expand Down

0 comments on commit 0b0829f

Please sign in to comment.