br g5

Dependencies:   mbed QEI HIDScope Motor biquadFilter MODSERIAL FastPWM

Committer:
boydmartherus
Date:
Fri Sep 20 12:07:59 2019 +0000
Revision:
10:9101c7a4f219
Parent:
9:cdcf30051100
Child:
11:5171ac607099
motor control + write motor + pulse write

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RobertoO 0:67c50348f842 1 #include "mbed.h"
Mortimerz 3:ea5f67f11825 2 #include "MODSERIAL.h";
Mortimerz 3:ea5f67f11825 3 #include "FastPWM.h" ;
boydmartherus 9:cdcf30051100 4 #include "QEI.h" ;
boydmartherus 7:d5e07647dfea 5
boydmartherus 7:d5e07647dfea 6 Serial pc(USBTX,USBRX);
boydmartherus 7:d5e07647dfea 7
boydmartherus 7:d5e07647dfea 8 InterruptIn button1(PTC2);
boydmartherus 7:d5e07647dfea 9 InterruptIn button2(PTC3);
boydmartherus 7:d5e07647dfea 10 InterruptIn button3(PTA4);
boydmartherus 7:d5e07647dfea 11 InterruptIn button4(PTC6);
Mortimerz 3:ea5f67f11825 12
Mortimerz 3:ea5f67f11825 13 AnalogIn pot(PTB2);
boydmartherus 6:c2608dedfd70 14
boydmartherus 6:c2608dedfd70 15 FastPWM motor(D5);
boydmartherus 9:cdcf30051100 16 FastPWM led(PTA1);
boydmartherus 10:9101c7a4f219 17 //DigitalOut richting(D4);
boydmartherus 9:cdcf30051100 18
boydmartherus 10:9101c7a4f219 19 //int direction = 0;
boydmartherus 10:9101c7a4f219 20 //void flip() {
boydmartherus 10:9101c7a4f219 21 // direction = !direction;
boydmartherus 10:9101c7a4f219 22 //}
boydmartherus 10:9101c7a4f219 23
boydmartherus 10:9101c7a4f219 24 //DigitalOut richting(D4);
boydmartherus 10:9101c7a4f219 25
boydmartherus 10:9101c7a4f219 26 int pulses = 131;
boydmartherus 10:9101c7a4f219 27 QEI wheel (D13,D12,NC,pulses);
MarliesWeggemans 4:3e9a8f5d9a1a 28
boydmartherus 10:9101c7a4f219 29 int main()
boydmartherus 10:9101c7a4f219 30 {
boydmartherus 10:9101c7a4f219 31 printf("Controll with dial\n");
boydmartherus 9:cdcf30051100 32 while(true)
boydmartherus 10:9101c7a4f219 33 {
boydmartherus 10:9101c7a4f219 34 wait(0.1);
boydmartherus 10:9101c7a4f219 35 printf("motor speeed is (%f)\n\r",pot.read());
boydmartherus 10:9101c7a4f219 36 wait(0.1);
boydmartherus 10:9101c7a4f219 37 led.write(pot);
boydmartherus 10:9101c7a4f219 38 motor.write(pot);
boydmartherus 10:9101c7a4f219 39 wait(0.1);
boydmartherus 10:9101c7a4f219 40 printf("pulse number is (%i)\n\r",wheel.getPulses());
boydmartherus 7:d5e07647dfea 41 }
boydmartherus 10:9101c7a4f219 42 }