Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed QEI HIDScope MODSERIAL FXOS8700Q FastPWM
Revision 0:fc28ef7f69c1, committed 2019-10-30
- Comitter:
- AnaisChaumeil
- Date:
- Wed Oct 30 09:31:01 2019 +0000
- Commit message:
- determine the model of the motor
Changed in this revision
diff -r 000000000000 -r fc28ef7f69c1 FXOS8700Q.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FXOS8700Q.lib Wed Oct 30 09:31:01 2019 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/Freescale/code/FXOS8700Q/#aee7dea904e2
diff -r 000000000000 -r fc28ef7f69c1 FastPWM.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FastPWM.lib Wed Oct 30 09:31:01 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/Sissors/code/FastPWM/#c0b2265cff9c
diff -r 000000000000 -r fc28ef7f69c1 HIDScope.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HIDScope.lib Wed Oct 30 09:31:01 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/tomlankhorst/code/HIDScope/#d23c6edecc49
diff -r 000000000000 -r fc28ef7f69c1 MODSERIAL.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MODSERIAL.lib Wed Oct 30 09:31:01 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/Sissors/code/MODSERIAL/#d2a5e26fd658
diff -r 000000000000 -r fc28ef7f69c1 QEI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QEI.lib Wed Oct 30 09:31:01 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/aberk/code/QEI/#5c2ad81551aa
diff -r 000000000000 -r fc28ef7f69c1 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Oct 30 09:31:01 2019 +0000 @@ -0,0 +1,68 @@ +#include "mbed.h" +#include "MODSERIAL.h" +#include "FastPWM.h" +#include "QEI.h" +#include "HIDScope.h" +#include "math.h" + + +/* We want to feed the motor with a sinus VELOCITY input and get the angular POSITION thanks to the encoder*/ + +Ticker signal; // helps us to define the signal +DigitalOut motor1DirectionPin(D7); //Boolean, determines direction +FastPWM motor1MagnitudePin(D6); //PWM ranges from 0 to 1, determines velocity of the motor + +double MotorValue; +Serial pc(USBTX,USBRX); +double MeasuredPosition=0; //Measured position in rad +QEI Encoder(D1,D0,NC,32); +int ReferencePosition=3150; // reference position +double ReferenceVelocity; + +int f; // frequency of the sinus +double pi=3.14; + +double abs_time=0; //absolute time : where we are right now in the time signal +//CHECK IF RIGHT TO PASS ABS_TIME BY REFERENCE (we want it changed) + +double GetReferenceVelocity(double &t) // computes the reference velocity we will feed the motor with +{ + double refval; // input reference velocity + refval=sin(2*pi*t*f); + t=t+0.01; // sinus valuescomputed every 0.01 seconds + return refval; +} + + +void setMotor1(double b){ // b is refval + if (b>=0) + { + motor1DirectionPin=1; + } + else + { + motor1DirectionPin=0; + } + motor1MagnitudePin=fabs(b); +} + + +void control() +{ + ReferenceVelocity=GetReferenceVelocity(abs_time); + MeasuredPosition=Encoder.getPulses(); + printf("Reference Velocity: %d\r\n", ReferenceVelocity); + printf("MeasuredPosition: %d\r\n",MeasuredPosition); + setMotor1(ReferenceVelocity); +} + +int main(void) +{ + pc.baud(112500); + signal.attach(control, 0.01); + while(abs_time<10) + { + } + +} + \ No newline at end of file
diff -r 000000000000 -r fc28ef7f69c1 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Oct 30 09:31:01 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file