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.
Revision 28:21773a6fb6df, committed 2013-11-24
- Comitter:
- calamaridudeman
- Date:
- Sun Nov 24 19:04:01 2013 +0000
- Parent:
- 27:4db137d6ea6e
- Child:
- 29:33c5c61f1068
- Child:
- 35:a4e89e78d034
- Commit message:
- Motor class is wrong, but motor encoders work so far
Changed in this revision
--- a/Master.cpp Sun Nov 24 06:02:47 2013 +0000
+++ b/Master.cpp Sun Nov 24 19:04:01 2013 +0000
@@ -10,15 +10,16 @@
Motor m1(p15,p17,p18,p21,mEnc1);//hip
Motor m2(p16,p19,p20,p22,mEnc2);//knee
-QEI bEnc1(p25, p26, p27, 1200, QEI::X4_ENCODING);//change pins!!!!!!!!!!!!!!!!!!!!!!!
+QEI bEnc1(p27, p28, p29, 1200, QEI::X4_ENCODING);//change pins!!!!!!!!!!!!!!!!!!!!!!!
QEI bEnc2(p8, p9, p10, 1200, QEI::X4_ENCODING);//these too
-Kangaroo kankan(m1,m2,bEnc1,bEnc2);
+//Kangaroo kankan(m1,m2,bEnc1,bEnc2);
int main() {
while(1){
- kankan.testEncoders(pc);
- wait(2);
+ //kankan.testEncoders(pc);
+ pc.printf("m1: %i, enc1: %i\n",m1.getPos(), mEnc1.getPulses());
+ wait(.5);
}
}
--- a/QEI.lib Sun Nov 24 06:02:47 2013 +0000 +++ b/QEI.lib Sun Nov 24 19:04:01 2013 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/teams/Pinocchio/code/QEI/#865d5b989ec4 +http://mbed.org/users/calamaridudeman/code/QEI/#865d5b989ec4
--- a/include/dynamics.hpp Sun Nov 24 06:02:47 2013 +0000
+++ b/include/dynamics.hpp Sun Nov 24 19:04:01 2013 +0000
@@ -14,13 +14,13 @@
class Kangaroo {
public:
- Kangaroo(Motor M1, Motor M2, QEI e1, QEI e2);
+ Kangaroo(Motor &M1, Motor &M2, QEI &e1, QEI &e2);
void zero();
void start();
void run();
void stop();
void updatePose();
- void testEncoders(Serial pc);
+ void testEncoders(Serial &pc);
private:
QEI enc1;
--- a/include/motor.hpp Sun Nov 24 06:02:47 2013 +0000
+++ b/include/motor.hpp Sun Nov 24 19:04:01 2013 +0000
@@ -7,13 +7,13 @@
class Motor {
public:
- Motor(PinName aPin, PinName fPin, PinName bPin, PinName pwmPin, QEI enc);
+ Motor(PinName aPin, PinName fPin, PinName bPin, PinName pwmPin, QEI &enc);
void start();
void stop();
void setTorque(float t);
void Control();
- float getMotorPos();
+ int getPos();
float getCurrent();
static float filterLowPass(float old, float currentIn, float alphar);
void setPos(float pos);
--- a/src/dynamics.cpp Sun Nov 24 06:02:47 2013 +0000
+++ b/src/dynamics.cpp Sun Nov 24 19:04:01 2013 +0000
@@ -2,7 +2,7 @@
#include "include/dynamics.hpp"
#include "include/motor.hpp"
-Kangaroo::Kangaroo(Motor M1, Motor M2, QEI e1, QEI e2):enc1(e1),enc2(e2),m1(M1),m2(M2){
+Kangaroo::Kangaroo(Motor &M1, Motor &M2, QEI &e1, QEI &e2):enc1(e1),enc2(e2),m1(M1),m2(M2){
}
@@ -24,11 +24,12 @@
}
-void Kangaroo::testEncoders(Serial pc){
- pc.printf("hello world\n");
- /*
- pc.printf("clix: %i, rots: %i\n",enc1.getPulses(), enc1.getRevolutions());
- */
+void Kangaroo::testEncoders(Serial &pc){
+ //pc.printf("hello world\n");
- //pc.printf("clix: %i, rots: %i\n",enc2.getPulses(), enc2.getRevolutions());
+ pc.printf("motor1: %i\n",m1.getPos());
+ pc.printf("clix1: %i, rots1: %i\n",enc1.getPulses(), enc1.getRevolutions());
+
+ pc.printf("motor2: %i\n",m2.getPos());
+ pc.printf("clix2: %i, rots2: %i\n",enc2.getPulses(), enc2.getRevolutions());
}
\ No newline at end of file
--- a/src/motor.cpp Sun Nov 24 06:02:47 2013 +0000
+++ b/src/motor.cpp Sun Nov 24 19:04:01 2013 +0000
@@ -1,9 +1,9 @@
#include "mbed.h"
#include "include/motor.hpp"
-Motor::Motor(PinName aPin, PinName fPin, PinName bPin, PinName pwmPin, QEI enc):aIn(aPin),Forward(fPin),Backward(bPin),pwmOut(pwmPin),encoder(enc){
+Motor::Motor(PinName aPin, PinName fPin, PinName bPin, PinName pwmPin, QEI* enc):aIn(aPin),Forward(fPin),Backward(bPin),pwmOut(pwmPin){//,encoder(enc){
//15,17,18,21,qei25,26 and 16,19,20,22,qei23,24
-
+ encoder = enc
freq =.001;
voltage = 12.0;
mode=0;
@@ -70,7 +70,7 @@
return (1/.140)*3.3 * aIn;
}
-float Motor::getMotorPos()
+int Motor::getPos()
{
return encoder.getPulses();
}
