Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:ef18c260ce02, committed 2017-09-18
- Comitter:
- waspSalander
- Date:
- Mon Sep 18 13:05:47 2017 +0000
- Parent:
- 0:7cedfb720712
- Commit message:
- Step controller
Changed in this revision
--- a/EixoController.cpp Wed Jun 07 13:31:02 2017 +0000
+++ b/EixoController.cpp Mon Sep 18 13:05:47 2017 +0000
@@ -12,11 +12,12 @@
bool EixoController:: goToOrigem(DigitalIn swOrigem, int dirOrigem){
- if(swOrigem == 1){ // já está na origem ?
+ if(swOrigem == 1){ // já está na origem ?
return true;
}
else{ // vá para a origem
- return motor->findLimits(50000, dirOrigem, swOrigem);
+ return motor->findLimits(30000, dirOrigem, swOrigem);
+
}
}
@@ -49,8 +50,7 @@
void EixoController:: goToPosition(int posCm, int dir){
- int pulses = conversao(posCm);
- motor->step(pulses, dir);
-
+ int pulses = conversao(posCm);
+ motor->step(pulses, dir);
}
--- a/EixoMonitoring.cpp Wed Jun 07 13:31:02 2017 +0000
+++ b/EixoMonitoring.cpp Mon Sep 18 13:05:47 2017 +0000
@@ -1,6 +1,6 @@
#include "EixoMonitoring.h"
-bool EixoMonitoring::stopAll = false;
+bool EixoMonitoring::stopAll = false;
bool EixoMonitoring::isCalibrated = false;
@@ -8,7 +8,7 @@
this->stopMoviment = false;
this->stopMonitoring = false;
- this->delayTimer = 700;
+ this->delayTimer = 700;
PinName pin_End = pinEnd;
PinName pin_Origin = pinOrigin;
--- a/EixoMonitoring.h Wed Jun 07 13:31:02 2017 +0000
+++ b/EixoMonitoring.h Mon Sep 18 13:05:47 2017 +0000
@@ -11,8 +11,8 @@
class EixoMonitoring {
public:
- int delayTimer;
- int hitSensor;
+ int delayTimer;
+ int hitSensor;
Debug* debug;
--- a/Stepp.cpp Wed Jun 07 13:31:02 2017 +0000
+++ b/Stepp.cpp Mon Sep 18 13:05:47 2017 +0000
@@ -46,28 +46,30 @@
_en = 0; // habilita move
_dir = direction;
- while(sensor.read() == 0 && EixoMonitoring::stopAll == false){ // n chegou na origem
-
- if(this->acell){ //linear acceleration
- if(i < START_STOP_SPEED) if (--accelspeed == this->speed) accelspeed ++;
- if(i > (n_steps-START_STOP_SPEED)) if(++accelspeed == START_STOP_SPEED) accelspeed--;
- }
-
- _clk = 1;
- wait_us(1);
- _clk = 0;
- wait_us(1);
- wait_us(accelspeed);
-
- i++;
+ while(sensor.read() == 0 && EixoMonitoring::stopAll == false){ // n chegou na origem
+
+ if(this->acell){ //linear acceleration
+ if(i < START_STOP_SPEED) if (--accelspeed == this->speed) accelspeed ++;
+ if(i > (n_steps-START_STOP_SPEED)) if(++accelspeed == START_STOP_SPEED) accelspeed--;
+ }
+
+ _clk = 1;
+ wait_us(1);
+ _clk = 0;
+ wait_us(1);
+ wait_us(accelspeed);
+
+ i++;
}
_en = 1;
- if(sensor.read() == 0){
- return 0;
- }
- else return 1;
+ if(sensor.read() == 0){
+ return 0;
+ }
+ else{
+ return 1;
+ }
}
--- a/main.cpp Wed Jun 07 13:31:02 2017 +0000
+++ b/main.cpp Mon Sep 18 13:05:47 2017 +0000
@@ -4,8 +4,8 @@
#include "EixoController.h"
#include "EixoMonitoring.h"
-#define LEFT 0
-#define RIGHT 1
+#define LEFT 1
+#define RIGHT 0
#define FRONT 1
#define BACK 0
@@ -14,78 +14,51 @@
PinName dirPinX = p19;
PinName enPinX = p18;
-PinName clkPinZ = p17;
-PinName dirPinZ = p16;
-PinName enPinZ = p15;
-
-PinName swOrignX = p5;
+PinName swOrignX = p11;
PinName swEndX = p6;
-PinName swOrignZ = p7;
-PinName swEndZ = p8;
+
+//PinName clkPinZ = p17;
+//PinName dirPinZ = p16;
+//PinName enPinZ = p15;
+
+//PinName swOrignZ = p7;
+//PinName swEndZ = p8;
// ============================================
-
// =============== Pinos Swtches ===============
-DigitalIn swLeft(p5); //X0 --> origem
-DigitalIn swRight(p6); //X0 --> origem
-DigitalIn swBack(p7); //X0 --> origem
-DigitalIn swFront(p8); //X0 --> origem
-//DigitalIn swRight(p6);//Xf --> final
+DigitalIn swLeft(p11); //X0 --> origem
+DigitalIn swRight(p6); //Xf --> fim
+//DigitalIn swBack(p7); //Z0 --> origem
+//DigitalIn swFront(p8); //Zf --> fim
// ============================================
-DigitalIn leituraOlimex(p21);
-Debug *debug = new Debug();
+Debug *debug = new Debug();
Stepp* motorX = new Stepp(clkPinX, dirPinX, enPinX);
-Stepp* motorZ = new Stepp(clkPinZ, dirPinZ, enPinZ);
-
-EixoController* eixoX = new EixoController( 49000, 38.10, motorX, swOrignX, swEndX);
-//EixoController* eixoZ = new EixoController( 14000, 9.00, motorZ,swOrignZ, swEndZ);//40.55
-EixoMonitoring* eixoMonitoring = new EixoMonitoring( swOrignX, swEndX) ;
+EixoController* eixoX = new EixoController( 55000, 14, motorX, swOrignX, swEndX);
+EixoMonitoring* eixoMonitoring = new EixoMonitoring( swOrignX, swEndX) ;
// 0 - esquerda 1 - direita ---> Eixo X
// 1 - frente 0 - trás ---> Eixo Z
// 1 - pressionado 0 - solto ---> Switches
-
int main() {
+
bool teste = false;
- bool start = true; // mudar p/false com o uso do olimex
-
- if(start == true){
-
- teste = eixoX->goToOrigem(swLeft , LEFT);
-
- EixoMonitoring::isCalibrated = false;
- eixoMonitoring->startThreads();
-
- if(teste == 1){// se está na origem
- eixoX->calibragem(RIGHT);
- EixoMonitoring::isCalibrated = true;
- eixoMonitoring->hitSensor = 0;
- eixoMonitoring->stopAll = false;
-
+ teste = eixoX->goToOrigem(swLeft , LEFT);
+
+ /*EixoMonitoring::isCalibrated = false;
+ eixoMonitoring->startThreads();
+
+ if(teste == 1){// se está na origem
+ eixoX->calibragem(RIGHT);
+ EixoMonitoring::isCalibrated = true;
+ eixoMonitoring->hitSensor = 0;
+ eixoMonitoring->stopAll = false;
+ eixoX->goToPosition(5,RIGHT);
+ }
- eixoX->goToPosition(17,RIGHT);
-
- }
- }
-
- eixoMonitoring->stopThreads();
-
-
- /*
- wait(0.5);
- start = true;
- if(start == true){
- teste = eixoZ->goToOrigem(swBack, FRONT);
- if(teste == true){// se está na origem
- eixoZ->calibragem(FRONT);
- eixoZ->goToPosition(3,FRONT);
- }
- }
- */
-}
-
+ eixoMonitoring->stopThreads(); */
+}
\ No newline at end of file