el programa permite ingresar la posición en el eje X,Y,Z, haciendo que el Servo MG90S con sus movimientos de 180° trabaje en mm de 0 a 50.
Dependents: PICCOLO_CNC PICCOLO_CNC1
Diff: Servo_X.h
- Revision:
- 2:cc30b42ac66f
- Parent:
- 1:59dc95283a4d
- Child:
- 4:4b884116fbe6
--- a/Servo_X.h Tue Feb 20 13:00:47 2018 +0000 +++ b/Servo_X.h Mon Feb 26 19:38:14 2018 +0000 @@ -1,49 +1,34 @@ #include "mbed.h" -PwmOut mypwmX(PA_8); -PwmOut mypwmY(PB_10); -PwmOut mypwmZ(PB_4); -int Move_x,Move_y,Move_z; + + +#ifndef SERVO_X_H +#define SERVO_X_H +#define MINPULSE 620 +#define MAXPULSE 2450 +#define MAXPOS 50// poscisión max de la coordenasda en mm +#define DRAW 50 +#define NODRAW 0 + + + class Servo { private: int x,y,z; + int mm2pulse(int vmm); public: Servo(); ~Servo(); - void SetServo(int,int,int); + void SetServo(int,int); + void SetZ(int); int GetServoX(); int GetServoY(); int GetServoZ(); }; -Servo::Servo() -{ -} -Servo::~Servo(){ -} -void Servo::SetServo(int _x,int _y,int _z) -{ - x=_x; - y=_y; - z=_z; - Move_x=(x*20)+1000; - Move_y=(y*20)+1000; - Move_z=(z*20)+1000; - mypwmX.pulsewidth_us(Move_x); - mypwmY.pulsewidth_us(Move_y); - mypwmZ.pulsewidth_us(Move_z); -} -int Servo::GetServoX() -{ - return x; -} -int Servo::GetServoY() -{ - return y; -} -int Servo::GetServoZ() -{ - return y; -} +#endif + + +