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 mbed HIDScope QEI
Fork of prog_pract3 by
Revision 6:84a01494d836, committed 2016-10-10
- 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 |
--- 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();
--- 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
