Group 9 BioRobotics
/
motor_calibration
V0.1
Fork of motor_calibration by
Diff: main.cpp
- Revision:
- 2:ea985bb173f6
- Parent:
- 1:53bb5928adcf
- Child:
- 3:d519ec330c31
diff -r 53bb5928adcf -r ea985bb173f6 main.cpp --- a/main.cpp Fri Oct 26 07:36:28 2018 +0000 +++ b/main.cpp Fri Oct 26 07:51:43 2018 +0000 @@ -3,7 +3,9 @@ //initial allocations DigitalOut dirpin(D4); +DigitalOut dirpin2(D7); PwmOut pwmpin(D5); +PwmOut pwmpin2(D6); QEI Encoder(D12,D13,NC,64,QEI::X4_ENCODING); @@ -13,17 +15,23 @@ -//functions (4 functions not finished) +//functions (2 functions not finished) int counts(){ int counts=Encoder.getPulses(); //MAAK NOG AF MET PREVIOUS COUNTS ONTHOUDEN. return counts; int pos_store(a){} //store position in counts to know count location of the ends of bridge -void rotate_start(){} //start rotation of disk - +void translation_start(a,b); //start rail motor + dirpin.write(a); + pwmpin = b; +void translation_stop(); //stop rail motor + pwmpin = 0; +void rotate_start(a,b){} //start rotation of disk + dirpin2.write(a); + pwmpin2 = b; void rotate_stop(){} //stop rotation of disk - + pwmpin2 = 0; //main function @@ -38,8 +46,7 @@ //move towards end for (m=1;2;m++){ - dirpin.write(dir); - pwmpin = speed; + translation_start(dir,speed); //when motor counts do not change anymore, change direction int n=1; while(n=1){ @@ -48,9 +55,10 @@ n=0;} else {} wait(0.1);} + translation_stop(); int position=counts();} - dir=dir+1; - pos_store(position);} //stores position integer + dir=dir+1; + pos_store(position);} //stores position integer //Check if a full circle can be made without obstruction //Try adding a timer as well, you know how long it should take, how long does it actually take? Does that matter?