![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Starter code for brushless motor controller
Diff: main.cpp
- Revision:
- 5:08f338b5e4d9
- Parent:
- 3:569b35e2a602
- Child:
- 10:a4b5723b6c9d
diff -r 569b35e2a602 -r 08f338b5e4d9 main.cpp --- a/main.cpp Thu Mar 01 09:41:46 2018 +0000 +++ b/main.cpp Tue Feb 19 09:22:17 2019 +0000 @@ -1,21 +1,25 @@ #include "mbed.h" //Photointerrupter input pins -#define I1pin D2 +#define I1pin D6 #define I2pin D11 #define I3pin D12 //Incremental encoder input pins -#define CHA D7 -#define CHB D8 +#define CHA D4 +#define CHB D5 //Motor Drive output pins //Mask in output byte -#define L1Lpin D4 //0x01 -#define L1Hpin D5 //0x02 -#define L2Lpin D3 //0x04 -#define L2Hpin D6 //0x08 -#define L3Lpin D9 //0x10 -#define L3Hpin D10 //0x20 +#define L1Lpin D9 //0x01 +#define L1Hpin D10 //0x02 +#define L2Lpin D1 //0x04 +#define L2Hpin D2 //0x08 +#define L3Lpin D0 //0x10 +#define L3Hpin D3 //0x20 + +//Motor current sense +#define MCSPpin A1 +#define MCSNpin A0 //Mapping from sequential drive states to motor phase outputs /* @@ -114,6 +118,7 @@ if (intState != intStateOld) { intStateOld = intState; motorOut((intState-orState+lead+6)%6); //+6 to make sure the remainder is positive + //pc.printf("%d\n\r",intState); } } }