Alle functies van de motoren werken

Dependencies:   MODSERIAL QEI mbed

Fork of worknotjet by Timo de Vries

Committer:
Frostworks
Date:
Wed Oct 12 14:35:38 2016 +0000
Revision:
1:833c73834749
Parent:
0:2b420376e01d
Child:
2:4fb733fffd1f
all motors work yeah

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Frostworks 0:2b420376e01d 1 #include "mbed.h"
Frostworks 0:2b420376e01d 2 #include "MODSERIAL.h"
Frostworks 0:2b420376e01d 3
Frostworks 1:833c73834749 4 DigitalOut M1_rotate(D2); // voltage only base rotation
Frostworks 1:833c73834749 5 PwmOut M1_Speed(D3); // voltage only base rotation
Frostworks 1:833c73834749 6
Frostworks 1:833c73834749 7 DigitalOut M2_rotate(D4); // encoder side pot 2 translation
Frostworks 1:833c73834749 8 PwmOut M2_Speed(D5); // encoder side pot 2 translation
Frostworks 1:833c73834749 9
Frostworks 1:833c73834749 10 DigitalOut M3_rotate(D7); // encoder side pot 1 spatel rotation
Frostworks 1:833c73834749 11 PwmOut M3_Speed(D6); // encoder side pot 1 spatel rotation
Frostworks 0:2b420376e01d 12
Frostworks 0:2b420376e01d 13 //DigitalOut M2_rotate(D6);
Frostworks 0:2b420376e01d 14 //PwmOut M2_Speed(D7);
Frostworks 0:2b420376e01d 15
Frostworks 1:833c73834749 16 AnalogIn pot1(A4); // pot 1 motor 1
Frostworks 1:833c73834749 17 AnalogIn pot2(A3); // pot 2 motor 3
Frostworks 1:833c73834749 18
Frostworks 0:2b420376e01d 19 MODSERIAL pc(USBTX, USBRX);
Frostworks 0:2b420376e01d 20
Frostworks 1:833c73834749 21 DigitalIn sw2(SW2); // motor 2 off/on
Frostworks 1:833c73834749 22
Frostworks 0:2b420376e01d 23 int main()
Frostworks 0:2b420376e01d 24 {
Frostworks 0:2b420376e01d 25 pc.baud(115200);
Frostworks 0:2b420376e01d 26 pc.printf("hoi\n");
Frostworks 0:2b420376e01d 27 M1_rotate = 1;
Frostworks 1:833c73834749 28 M2_rotate = 1;
Frostworks 1:833c73834749 29 M3_rotate = 1;
Frostworks 1:833c73834749 30
Frostworks 0:2b420376e01d 31 while (true) {
Frostworks 0:2b420376e01d 32
Frostworks 1:833c73834749 33 if (sw2 == 1) {
Frostworks 1:833c73834749 34 M2_Speed = 1;
Frostworks 1:833c73834749 35 }
Frostworks 1:833c73834749 36 float M2 = M2_rotate.read();
Frostworks 1:833c73834749 37 float potje1 = pot1.read();
Frostworks 1:833c73834749 38 float potje2 = pot2.read();
Frostworks 1:833c73834749 39 M1_Speed.write(potje1);
Frostworks 1:833c73834749 40 M3_Speed.write(potje2);
Frostworks 0:2b420376e01d 41 wait(0.1);
Frostworks 1:833c73834749 42 pc.printf("motor 1 %f, motor 2 %f, motor 3 %f \n \r ", potje1, M2, potje2);
Frostworks 0:2b420376e01d 43 }
Frostworks 1:833c73834749 44 }