br g5

Dependencies:   mbed QEI HIDScope biquadFilter MODSERIAL FastPWM

Committer:
boydmartherus
Date:
Mon Sep 23 12:36:08 2019 +0000
Revision:
17:3751c2c685ca
Parent:
16:0ff43ed4d259
Child:
18:3de4412d8b63
POGING 2: ticker etcetc

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RobertoO 0:67c50348f842 1 #include "mbed.h"
boydmartherus 16:0ff43ed4d259 2 #include "MODSERIAL.h"
boydmartherus 17:3751c2c685ca 3 #include "FastPWM.h"
boydmartherus 17:3751c2c685ca 4 #include "QEI.h"
boydmartherus 7:d5e07647dfea 5
boydmartherus 7:d5e07647dfea 6 Serial pc(USBTX,USBRX);
boydmartherus 7:d5e07647dfea 7
boydmartherus 17:3751c2c685ca 8 // functies aan PINs toevoegen
boydmartherus 9:cdcf30051100 9 FastPWM led(PTA1);
boydmartherus 16:0ff43ed4d259 10 FastPWM motor(D5);
boydmartherus 17:3751c2c685ca 11 AnalogIn pot(PTB2);
boydmartherus 17:3751c2c685ca 12 InterruptIn button(PTB3);
boydmartherus 9:cdcf30051100 13
boydmartherus 17:3751c2c685ca 14 // timer opzetten = ticker
boydmartherus 17:3751c2c685ca 15 Ticker ticker;
boydmartherus 17:3751c2c685ca 16
boydmartherus 17:3751c2c685ca 17 // opzetten van hoekbepaling
boydmartherus 16:0ff43ed4d259 18 int pulses = 4200;
boydmartherus 10:9101c7a4f219 19 QEI wheel (D13,D12,NC,pulses);
MarliesWeggemans 4:3e9a8f5d9a1a 20
boydmartherus 17:3751c2c685ca 21 // aparte functies
boydmartherus 17:3751c2c685ca 22 // functie hoekbepaling
boydmartherus 17:3751c2c685ca 23 void hoek_bepaling()
boydmartherus 17:3751c2c685ca 24 {
boydmartherus 17:3751c2c685ca 25 wheel.getPulses();
boydmartherus 17:3751c2c685ca 26 }
boydmartherus 17:3751c2c685ca 27
boydmartherus 17:3751c2c685ca 28 //functie motor aansturen met pot
boydmartherus 17:3751c2c685ca 29 void motor_running()
boydmartherus 17:3751c2c685ca 30 {
boydmartherus 17:3751c2c685ca 31 motor.write(pot);
boydmartherus 17:3751c2c685ca 32 led.write(pot);
boydmartherus 17:3751c2c685ca 33 }
boydmartherus 17:3751c2c685ca 34
boydmartherus 17:3751c2c685ca 35 // functie print output
boydmartherus 17:3751c2c685ca 36
boydmartherus 17:3751c2c685ca 37 void main_loop()
boydmartherus 17:3751c2c685ca 38 {
boydmartherus 17:3751c2c685ca 39 hoek_bepaling();
boydmartherus 17:3751c2c685ca 40 motor_running();
boydmartherus 17:3751c2c685ca 41 }
boydmartherus 10:9101c7a4f219 42 int main()
boydmartherus 10:9101c7a4f219 43 {
boydmartherus 17:3751c2c685ca 44 ticker.attach(&mainloop, 0.001f);
boydmartherus 17:3751c2c685ca 45 while(true){};
boydmartherus 10:9101c7a4f219 46 }