Fernon Eijkhoudt
/
ROBOBIRDS_FINAL
EMG driven robot which shoots elastic bands
Fork of RoboBirdV1 by
main.cpp@1:bb11e38dda43, 2015-09-23 (annotated)
- Committer:
- Fernon
- Date:
- Wed Sep 23 12:19:33 2015 +0000
- Revision:
- 1:bb11e38dda43
- Parent:
- 0:5a5f417fa1b2
- Child:
- 2:f0e9ffc5df09
Working Encoder and motor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Fernon | 0:5a5f417fa1b2 | 1 | #include "mbed.h" |
Fernon | 0:5a5f417fa1b2 | 2 | #include "QEI.h" |
Fernon | 0:5a5f417fa1b2 | 3 | |
Fernon | 1:bb11e38dda43 | 4 | DigitalOut Direction(D4); //1 = CCW - 0 = CW |
Fernon | 1:bb11e38dda43 | 5 | PwmOut PowerMotor(D5); //van 0 tot 1 |
Fernon | 1:bb11e38dda43 | 6 | AnalogIn PotMeter(A1); |
Fernon | 1:bb11e38dda43 | 7 | QEI Encoder(D13,D12,NC,32,QEI::X2_ENCODING); //Encoder |
Fernon | 1:bb11e38dda43 | 8 | Serial pc(USBTX, USBRX); |
Fernon | 0:5a5f417fa1b2 | 9 | |
Fernon | 1:bb11e38dda43 | 10 | double P; |
Fernon | 1:bb11e38dda43 | 11 | const double pi = 3.14159265359; |
Fernon | 1:bb11e38dda43 | 12 | int Pulses; |
Fernon | 0:5a5f417fa1b2 | 13 | |
Fernon | 0:5a5f417fa1b2 | 14 | int main() |
Fernon | 0:5a5f417fa1b2 | 15 | { |
Fernon | 0:5a5f417fa1b2 | 16 | while (true) { |
Fernon | 1:bb11e38dda43 | 17 | pc.baud(115200); |
Fernon | 0:5a5f417fa1b2 | 18 | for (int n = 0; n < 2; n++) { |
Fernon | 1:bb11e38dda43 | 19 | //P = PotMeter.read(); |
Fernon | 1:bb11e38dda43 | 20 | //pc.printf('P = %f/n', P); |
Fernon | 1:bb11e38dda43 | 21 | Pulses = Encoder.getPulses(); |
Fernon | 1:bb11e38dda43 | 22 | pc.printf ("Pulses = %i", Pulses); |
Fernon | 1:bb11e38dda43 | 23 | // pc.printf ("K = %i \n", K); |
Fernon | 0:5a5f417fa1b2 | 24 | Direction.write(0); |
Fernon | 0:5a5f417fa1b2 | 25 | PowerMotor.write(0.5); |
Fernon | 0:5a5f417fa1b2 | 26 | wait (1); |
Fernon | 0:5a5f417fa1b2 | 27 | Direction.write(1); |
Fernon | 0:5a5f417fa1b2 | 28 | wait (1); |
Fernon | 0:5a5f417fa1b2 | 29 | } |
Fernon | 0:5a5f417fa1b2 | 30 | PowerMotor.write(0); |
Fernon | 0:5a5f417fa1b2 | 31 | return (0); |
Fernon | 0:5a5f417fa1b2 | 32 | } |
Fernon | 0:5a5f417fa1b2 | 33 | } |