Fernon Eijkhoudt
/
ROBOBIRDS_FINAL
EMG driven robot which shoots elastic bands
Fork of RoboBirdV1 by
main.cpp@3:af3f0ed8c99e, 2015-09-28 (annotated)
- Committer:
- Fernon
- Date:
- Mon Sep 28 10:12:57 2015 +0000
- Revision:
- 3:af3f0ed8c99e
- Parent:
- 2:f0e9ffc5df09
- Child:
- 4:de94e1135968
Ticker leest de waarde van de Potmeter niet uit.
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 | 2:f0e9ffc5df09 | 9 | Ticker Pot; |
Fernon | 0:5a5f417fa1b2 | 10 | |
Fernon | 1:bb11e38dda43 | 11 | const double pi = 3.14159265359; |
Fernon | 2:f0e9ffc5df09 | 12 | int Pulses; |
Fernon | 2:f0e9ffc5df09 | 13 | double Rotatie; |
Fernon | 3:af3f0ed8c99e | 14 | double z; |
Fernon | 2:f0e9ffc5df09 | 15 | |
Fernon | 3:af3f0ed8c99e | 16 | |
Fernon | 3:af3f0ed8c99e | 17 | void readpot () |
Fernon | 2:f0e9ffc5df09 | 18 | { |
Fernon | 2:f0e9ffc5df09 | 19 | z = PotMeter.read(); |
Fernon | 2:f0e9ffc5df09 | 20 | } |
Fernon | 0:5a5f417fa1b2 | 21 | |
Fernon | 0:5a5f417fa1b2 | 22 | int main() |
Fernon | 0:5a5f417fa1b2 | 23 | { |
Fernon | 2:f0e9ffc5df09 | 24 | pc.baud(115200); |
Fernon | 2:f0e9ffc5df09 | 25 | PowerMotor.write(0); |
Fernon | 3:af3f0ed8c99e | 26 | Pot.attach(&readpot,0.1); // Deze ticker moet de waarde uitlezen van de PotMeter 10 keer per seconde |
Fernon | 0:5a5f417fa1b2 | 27 | while (true) { |
Fernon | 3:af3f0ed8c99e | 28 | // Pulses = Encoder.getPulses(); |
Fernon | 3:af3f0ed8c99e | 29 | // Rotatie = (Pulses*2*pi)/4192; // Omrekenen van pulses met een x2 encoder naar rotatie eenheden |
Fernon | 3:af3f0ed8c99e | 30 | // pc.printf ("Potmeter = %f\n", z); // het weergeven van de waarde waar z (PotMeter) op dat moment is |
Fernon | 3:af3f0ed8c99e | 31 | //// pc.printf ("Rotatie = %f [radialen] \n", Rotatie); // De hoek wordt uitgerekend om te weten hoeveel het motortje gedraaid is |
Fernon | 3:af3f0ed8c99e | 32 | |
Fernon | 0:5a5f417fa1b2 | 33 | } |
Fernon | 2:f0e9ffc5df09 | 34 | } |
Fernon | 3:af3f0ed8c99e | 35 |