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: MODSERIAL QEI mbed HIDScope
Fork of prog_pract3 by
Diff: main.cpp
- Revision:
- 6:84a01494d836
- Parent:
- 5:1b8032a15afe
- Child:
- 7:9f4e35d977af
diff -r 1b8032a15afe -r 84a01494d836 main.cpp --- a/main.cpp Mon Oct 10 14:47:39 2016 +0000 +++ b/main.cpp Mon Oct 10 15:03:42 2016 +0000 @@ -31,6 +31,8 @@ // encoder in HIDScope setten void sample() { + QEI Encoder(D12, D13, NC, 32); + counts = Encoder.getPulses(); // gives position scope.set(0, counts); DerivativeCounts = (counts-countsPrev)/0.001; scope.set(1, DerivativeCounts); @@ -87,14 +89,14 @@ float referenceVelocity = GetReferenceVelocity(); float motorValue = FeedForwardControl(referenceVelocity); SetMotor1(motorValue); - pc.printf("MotorValue: %f rad/s \r\n", motorValue); + //pc.printf("MotorValue: %f rad/s \r\n", motorValue); } -void TimeTrackerF(){ - wait(1); - float Potmeter = potMeterIn.read(); - pc.printf("Reference velocity: %f rad/s \r\n", referenceVelocity); - pc.printf("Potmeter: %f rad/s \r\n", Potmeter); +//void TimeTrackerF(){ + //wait(1); + //float Potmeter = potMeterIn.read(); + //pc.printf("Reference velocity: %f rad/s \r\n", referenceVelocity); + //pc.printf("Potmeter: %f rad/s \r\n", Potmeter); } @@ -104,14 +106,14 @@ led1=0; led2=0; int counts; - float Potmeter = potMeterIn.read(); + //float Potmeter = potMeterIn.read(); MeasureTicker.attach(&MeasureTicker_act, 0.01f); TimeTracker.attach(&TimeTracker_act, 0.3f); pc.baud(115200); QEI Encoder(D12, D13, NC, 32); // turns on encoder sampleT.attach(&sampleT_act, 0.001f); - pc.printf("Reference velocity: %f rad/s \r\n", referenceVelocity); - pc.printf("Potmeter: %f rad/s \r\n", Potmeter); + //pc.printf("Reference velocity: %f rad/s \r\n", referenceVelocity); + //pc.printf("Potmeter: %f rad/s \r\n", Potmeter); while(1) { @@ -120,12 +122,12 @@ MeasureTicker_go=false; MeasureAndControl(); counts = Encoder.getPulses(); // gives position - pc.printf("Encoder counts: %i \r\n", counts); + //pc.printf("Encoder counts: %i \r\n", counts); } - if (TimeTracker_go){ + /*if (TimeTracker_go){ TimeTracker_go=false; TimeTrackerF(); - } + }*/ if (sampleT_go){ sampleT_go=false; sample();