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 Gerhard Berman

Files at this revision

API Documentation at this revision

Comitter:
Marieke
Date:
Mon Oct 10 15:03:42 2016 +0000
Parent:
5:1b8032a15afe
Commit message:
Motor working, HIDScope showing encoder and derivative encoder not working!

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
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();
diff -r 1b8032a15afe -r 84a01494d836 mbed.bld
--- a/mbed.bld	Mon Oct 10 14:47:39 2016 +0000
+++ b/mbed.bld	Mon Oct 10 15:03:42 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/aae6fcc7d9bb
\ No newline at end of file