br g5

Dependencies:   mbed QEI HIDScope Motor biquadFilter MODSERIAL FastPWM

Committer:
boydmartherus
Date:
Fri Sep 20 12:51:20 2019 +0000
Revision:
11:5171ac607099
Parent:
10:9101c7a4f219
Child:
12:597f6b8224e5
motor+pulse+flip

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 11:5171ac607099 5 #include "Motor.h" ;
boydmartherus 7:d5e07647dfea 6
boydmartherus 7:d5e07647dfea 7 Serial pc(USBTX,USBRX);
boydmartherus 7:d5e07647dfea 8
Mortimerz 3:ea5f67f11825 9 AnalogIn pot(PTB2);
boydmartherus 11:5171ac607099 10 InterruptIn button(PTB3);
boydmartherus 6:c2608dedfd70 11
boydmartherus 6:c2608dedfd70 12 FastPWM motor(D5);
boydmartherus 9:cdcf30051100 13 FastPWM led(PTA1);
boydmartherus 10:9101c7a4f219 14
boydmartherus 10:9101c7a4f219 15 int pulses = 131;
boydmartherus 10:9101c7a4f219 16 QEI wheel (D13,D12,NC,pulses);
MarliesWeggemans 4:3e9a8f5d9a1a 17
boydmartherus 11:5171ac607099 18 int pin;
boydmartherus 11:5171ac607099 19
boydmartherus 11:5171ac607099 20 void flip()
boydmartherus 11:5171ac607099 21 {
boydmartherus 11:5171ac607099 22 pin=!pin;
boydmartherus 11:5171ac607099 23 }
boydmartherus 11:5171ac607099 24
boydmartherus 11:5171ac607099 25
boydmartherus 10:9101c7a4f219 26 int main()
boydmartherus 10:9101c7a4f219 27 {
boydmartherus 11:5171ac607099 28 printf("Control with dial\n");
boydmartherus 11:5171ac607099 29 button.rise(&flip);
boydmartherus 11:5171ac607099 30 while(true)
boydmartherus 11:5171ac607099 31 {
boydmartherus 11:5171ac607099 32 if (pin == 1)
boydmartherus 11:5171ac607099 33 {
boydmartherus 10:9101c7a4f219 34 led.write(pot);
boydmartherus 10:9101c7a4f219 35 motor.write(pot);
boydmartherus 11:5171ac607099 36 printf("motor speeed is (%f)\n\r",pot.read());
boydmartherus 10:9101c7a4f219 37 printf("pulse number is (%i)\n\r",wheel.getPulses());
boydmartherus 11:5171ac607099 38 }
boydmartherus 11:5171ac607099 39 else
boydmartherus 11:5171ac607099 40 {
boydmartherus 11:5171ac607099 41 led.write(pot);
boydmartherus 11:5171ac607099 42 motor.write(-pot);
boydmartherus 11:5171ac607099 43 printf("motor speeed is (%f)\n\r",pot.read());
boydmartherus 11:5171ac607099 44 printf("pulse number is (%i)\n\r",wheel.getPulses());
boydmartherus 11:5171ac607099 45 }
boydmartherus 11:5171ac607099 46 }
boydmartherus 10:9101c7a4f219 47 }