David Salmon
/
ES_CW2_Starter_MDMA
ES2017 coursework 2
Fork of ES_CW2_Starter by
Diff: main.cpp
- Revision:
- 15:d9e50101a17e
- Parent:
- 14:155e9a9147d4
- Parent:
- 13:87ab3b008803
- Child:
- 16:372c720015ab
--- a/main.cpp Thu Mar 09 14:53:31 2017 +0000 +++ b/main.cpp Thu Mar 09 14:56:06 2017 +0000 @@ -201,6 +201,55 @@ } } +<<<<<<< local +======= +//void edgeRiseA() +//{ +// pos++; +// if(pos>=468) { +//// Direction=!Direction; +// pos=pos%468; +//// testpin=!testpin; +// } +// if(qB) DIR = 0; +// else DIR = 1; +//// clk=DIR; +////CLOCKWISE: A rises before B -> On A edge, B low -> DIR = 1 +////ANTICLOCKWISE: B rises before A -> On A edge, B high-> DIR = 0 +//} + +void sing(float singFreq) +{ + motor = driveTable[1]; + wait(1.0); + float singDelayus = 1000000/singFreq; + for(int count=0; count<singFreq; count++) { + motor = driveTable[2]; + wait_us(singDelayus); + motor = driveTable[1]; + } + singFreq = 15000; + singDelayus = 1000000/singFreq; + for(int count=0; count<singFreq; count++) { + motor = driveTable[2]; + wait_us(singDelayus); + motor = driveTable[1]; + } +} + +//void edgeIncr() +//{ +// pos++; +// if(pos>=468) { +//// Direction=!Direction; +// pos=pos%468; +//// testpin=!testpin; +// } +//} + +//#define WAIT 2 +//Main function +>>>>>>> other int main() { pc.printf("spin\n\r"); @@ -222,6 +271,14 @@ speedTimer.start(); I2.mode(PullNone); I2.fall(&rps); +<<<<<<< local +======= + +// qA.rise(&edgeRiseA); +// qB.rise(&edgeIncr); +// qA.fall(&edgeIncr); +// qB.fall(&edgeIncr); +>>>>>>> other VPIDthread.start(VPID); @@ -410,6 +467,9 @@ controller.setTunings(Kc, Ti, Td); // controller.setMode(1); break; + case 'l': + sing(10000); + break; default: //Set speed variables to zero to stop motor spinning //Print error message