TVZ Mechatronics Team / Mbed 2 deprecated BLDC_mainProgram

Dependencies:   BLDCmotorDriver RateLimiter mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "RateLimiter.h"
00003 #include "BLDCmotorDriver.h"
00004 
00005 Serial pc(USBTX, USBRX);
00006 float dc = 0.0;
00007 BLDCmotorDriver M(p26, p24, p22, p25, p23, p21, p14, p17, p18, LED1);
00008 DigitalOut EN(p8);
00009 DigitalOut EN_BUCK(p28);
00010 
00011 int main() {
00012   EN = 1;
00013     pc.printf("Press 'w' to speed up, 's' to speed down\n\r");
00014     while(true) { 
00015 
00016       char c = pc.getc();
00017         if((c == 'w') && (dc < 0.9)) {
00018             dc += 0.1;
00019         M.setDutyCycle(dc);
00020         }
00021         if((c == 's') && (dc > -0.9)) {
00022             dc -= 0.1;
00023         M.setDutyCycle(dc);
00024         } 
00025        
00026  pc.printf("Duty Cycle: %1.2f, Sector: %d\n\r",dc, M.getSector());
00027  
00028     }   
00029 }
00030