Opzetje

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM

Committer:
boydmartherus
Date:
Mon Sep 23 09:48:32 2019 +0000
Revision:
5:9f097dde857f
Parent:
4:86872b89b21c
23/9 11:48

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RobertoO 0:67c50348f842 1 #include "mbed.h"
boydmartherus 5:9f097dde857f 2 #include "MODSERIAL.h"
boydmartherus 5:9f097dde857f 3 #include "FastPWM.h"
boydmartherus 5:9f097dde857f 4 #include "QEI.h"
Mortimerz 3:ea5f67f11825 5
boydmartherus 4:86872b89b21c 6 Serial pc(USBTX,USBRX);
boydmartherus 4:86872b89b21c 7
Mortimerz 3:ea5f67f11825 8 InterruptIn button1(PTC2);
Mortimerz 3:ea5f67f11825 9 InterruptIn button2(PTC3);
boydmartherus 5:9f097dde857f 10
boydmartherus 5:9f097dde857f 11 //motorcontrol
boydmartherus 5:9f097dde857f 12 AnalogIn pot(PTB2);
boydmartherus 5:9f097dde857f 13 FastPWM motor(D5);
boydmartherus 5:9f097dde857f 14 DigitalOut direction(D4);
Mortimerz 3:ea5f67f11825 15
boydmartherus 5:9f097dde857f 16 int p_rev = 4200;
boydmartherus 5:9f097dde857f 17 QEI encoder(D13,D12,NC,p_rev);
boydmartherus 4:86872b89b21c 18
boydmartherus 5:9f097dde857f 19 int void() // set direction
boydmartherus 5:9f097dde857f 20 {
boydmartherus 5:9f097dde857f 21 direction.write(0);
boydmartherus 5:9f097dde857f 22 }
Mortimerz 3:ea5f67f11825 23
boydmartherus 5:9f097dde857f 24 int main()
boydmartherus 5:9f097dde857f 25 {
boydmartherus 5:9f097dde857f 26 printf("Control with dial\n");
boydmartherus 5:9f097dde857f 27 wait(3.0);
boydmartherus 5:9f097dde857f 28 while(true)
boydmartherus 5:9f097dde857f 29 {
boydmartherus 5:9f097dde857f 30 wait(0.6);
boydmartherus 5:9f097dde857f 31 printf("motor speed is (%f)\n\r",pot.read());
boydmartherus 4:86872b89b21c 32 wait(0.1);
boydmartherus 5:9f097dde857f 33 printf("aantal revoluties (%f)\n\r",encoder.getRevolutions());
boydmartherus 5:9f097dde857f 34 printf("aantal pulses (%f)\n\r",encoder.getPulses());
boydmartherus 5:9f097dde857f 35 wait(0.01);
boydmartherus 4:86872b89b21c 36 motor.write(pot);
boydmartherus 5:9f097dde857f 37 }
RobertoO 0:67c50348f842 38 }