![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Putty working, giving: Potmeter value, reference velocity and Motorvalue=0! Motor only works on 2.
Dependencies: MODSERIAL mbed HIDScope QEI
Fork of prog_pract3 by
Diff: main.cpp
- Revision:
- 6:84a01494d836
- Parent:
- 5:1b8032a15afe
--- 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();