David Pasztor / Mbed 2 deprecated Motor_control

Dependencies:   mbed-rtos mbed

main.cpp

Committer:
NKarandey
Date:
2017-03-24
Revision:
49:731c95cd5852
Parent:
48:02d5565b8fac
Child:
50:c0c299bf54a6

File content as of revision 49:731c95cd5852:

//#include "mbed.h"

#include "definitions.h"
#include "motorControl.h"
#include "photointerruptRoutines.h"
#include "commands.h"


//extern PinName I1Pin;
//DigitalOut myled(LED1);


int main() {
    LPins[0] = &L1L;                        //Define the pins for the pin array
    LPins[1] = &L1H;
    LPins[2] = &L2L;
    LPins[3] = &L2H;
    LPins[4] = &L3L;
    LPins[5] = &L3H;

    motorHome();
    
    I3.rise(&i3rise);
    dt_I3.start();

    CHA.rise(&CHA_rise);
    CHA.fall(&CHA_fall);
    CHB.rise(&CHB_rise);
    CHB.fall(&CHB_fall);

    controlTicker.attach(&control, dt);
    motorTicker.attach(&motorControl, dtMotor); //Call motor control periodicly

    precisionMotorOut(360-240);
    pwmPeriod.attach(&velocityPwmPeriod, velocityPeriod);

    while (true) {
        Thread::wait(1);
        motorOut((state-orState+lead+6)%6, velocityDuty);
//        print("Speed: %f, duty cycle: %f, currentRevs: %i, vErr %f, prevErr; %f, dErr %f, totalVErr: %f \n\r",w3, velocityDuty, count_i3, VKp*vErr,VKp*vPrevErr, dErr, VKi*totalVErr);
    }


    return 0;
}