BLDC main.cpp for BLDCmotorDriver

Dependencies:   BLDCmotorDriver RateLimiter mbed

main.cpp

Committer:
mslovic
Date:
2015-06-01
Revision:
1:aa6b6d379be4
Parent:
0:24b227524f2d

File content as of revision 1:aa6b6d379be4:

#include "mbed.h"
#include "RateLimiter.h"
#include "BLDCmotorDriver.h"

Serial pc(USBTX, USBRX);
float dc = 0.0;
BLDCmotorDriver M(p26, p24, p22, p25, p23, p21, p14, p17, p18, LED1);
DigitalOut EN(p8);
DigitalOut EN_BUCK(p28);

int main() {
  EN = 1;
    pc.printf("Press 'w' to speed up, 's' to speed down\n\r");
    while(true) { 

      char c = pc.getc();
        if((c == 'w') && (dc < 0.9)) {
            dc += 0.1;
        M.setDutyCycle(dc);
        }
        if((c == 's') && (dc > -0.9)) {
            dc -= 0.1;
        M.setDutyCycle(dc);
        } 
       
 pc.printf("Duty Cycle: %1.2f, Sector: %d\n\r",dc, M.getSector());
 
    }   
}