Dependencies:   mbed Motor

main.cpp

Committer:
CCastrop1012
Date:
2021-09-03
Revision:
0:9b57ccb09755

File content as of revision 0:9b57ccb09755:

#include "mbed.h"
#include "Motor.h"

Serial PC(PA_2, PA_3);


TraccionD M1(PC_14, PE_6, PE_4, PE_2, 200, 3.3, 7.5);



DigitalOut LED(PD_14);

int main() {
        
        long SOH1;

        
        PC.printf("Hello World...\n");
        M1.StepFreq(20); 
        M1.Giro(270, true); 
        
        //M1.Run(2.5); 
        
        while(1)
        {
            SOH1 = M1.getStepOnHold();
            PC.printf("StepOnHold M1 = %d ;\n" , SOH1); 
            if(SOH1 < 10){ M1.StopT(); break; }
            wait(0.3);
        }
        
        wait(0.3);
        M1.StepFreq(20); 
        M1.Giro(270, false); 
        //M1.Run(2.5); 
        
        while(1)
        {
            SOH1 = M1.getStepOnHold();
            PC.printf("StepOnHold M1 = %d ;\n" , SOH1); 
            if(SOH1 < 10){ M1.StopT(); break; }
            wait(0.3);
        }
        
        
        
            long cont;
    while(1) {
        
        PC.printf("run %d...\n", cont++);
        
        //////// Giro sentido 1
        LED = 1;
        wait(2);
        
        SOH1 = M1.getStepOnHold();
        PC.printf("StepOnHold M1 = %d ;\n" , SOH1);
        
        wait(0.5);
        
        //////// Giro sentido contrario
        LED = 0;
        wait(2);
        
        SOH1 = M1.getStepOnHold();
        PC.printf("StepOnHold M1 = %d ;\n" , SOH1);
        
        wait(0.5);
        
    }
}