Dynamics ident of the system
Dependencies: FastPWM HIDScope MODSERIAL QEI mbed
Fork of Berekenen_motorhoek by
main.cpp
- Committer:
- TimDouma
- Date:
- 2016-10-13
- Revision:
- 2:bf1466ac4e6f
- Parent:
- 1:709a462b8373
- Child:
- 3:ac6f86c0db6e
File content as of revision 2:bf1466ac4e6f:
#include "mbed.h" #include "math.h" #define SERIAL_BAUD 115200 #include "iostream" Serial pc(USBTX,USBRX); Ticker TickerAfstandBerekenen; // in te voeren x en y waardes (de positie waar we heen willen) volatile float x = -30.0; volatile float y = 200.0; // waardes volatile const float a = 50.0; // de afstand van gekozen assenstelsel tot de armas (assenstelsel precies in het midden) volatile const float Bar = 200.0; // lengte van de armen //volatile float D1 = 9.0; // functie om D1 en D2 te berekenen float AfstandBerekenenLinks () { float BV1 = sqrt(pow((a+x),2) + pow(y,2)); // diagonaal (afstand van armas tot locatie) berekenen float D1 = pow(BV1,2)/(2*BV1); // berekenen van de afstand oorsprong tot diagonaal pc.baud(SERIAL_BAUD); pc.printf("D1 = %f\r\n", D1); return D1 ; } float AfstandBerekenenRechts() { float BV2 = sqrt(pow((x-a),2) + pow(y,2));// diagonaal (afstand van armas tot locatie) berekenen float D2 = pow(BV2,2)/(2*BV2); // berekenen van de afstand oorsprong tot diagonaal pc.baud(SERIAL_BAUD); pc.printf("D2 = %f\r\n", D2); return D2 ; } void Blij() { pc.baud(SERIAL_BAUD); pc.printf("het werkt wel met een void functie\r\n"); } /* void MotorhoekBerekenen (){ if (x > -a){ float MotorHoek1 = 180 - atan(y/(x+a)) - acos( */ int main() { float D1 = AfstandBerekenenLinks(); float D2 = AfstandBerekenenRechts(); TickerAfstandBerekenen.attach(&AfstandBerekenenLinks,1); pc.baud(SERIAL_BAUD); pc.printf("D1 = %f en D2 = %f\r\n", D1, D2); while (true) { } }