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 7:6f5cb6377bd4, committed 2017-05-05
- Comitter:
- sahilmgandhi
- Date:
- Fri May 05 00:08:59 2017 +0000
- Parent:
- 6:3d68fedd6fd9
- Child:
- 8:a0760acdc59e
- Commit message:
- Added some stuff for motor + encoders
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/QEI.lib Fri May 05 00:08:59 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/aberk/code/QEI/#5c2ad81551aa
--- a/main.cpp Thu May 04 21:38:20 2017 +0000
+++ b/main.cpp Fri May 05 00:08:59 2017 +0000
@@ -6,6 +6,7 @@
#include <stdlib.h>
#include "ITG3200.h"
+#include "QEI.h"
// PID
#define P_CONSTANT 0.0025
@@ -15,12 +16,14 @@
int main()
{
+ enableMotors();
//Set highest bandwidth.
gyro.setLpBandwidth(LPFBW_42HZ);
serial.baud(9600);
-
+ serial.printf("The gyro's address is %s", gyro.getWhoAmI());
+
wait (0.1);
-
+
// IR_1.write(1);
// IR_2.write(1);
// IR_3.write(1);
@@ -30,11 +33,14 @@
greenLed.write(0);
blueLed.write(1);
+ rightWheelForward(0.1);
+ leftWheelForward(0.1);
+
while (1) {
-
- wait(0.1);
+
+ wait(0.1);
serial.printf("%i, %i, %i\n", gyro.getGyroX(), gyro.getGyroY(), gyro.getGyroZ());
-
+
//reading = Rec_4.read();
// serial.printf("reading: %f\n", reading);
// redLed.write(0);
--- a/main.h Thu May 04 21:38:20 2017 +0000 +++ b/main.h Fri May 05 00:08:59 2017 +0000 @@ -10,14 +10,15 @@ PwmOut right1(PA_10); PwmOut right2(PA_11); +DigitalOut enableLeftMotor(PB_4); +DigitalOut enableRightMotor(PB_5); + // RGB LED DigitalOut redLed(PC_0); DigitalOut blueLed(PC_1); DigitalOut greenLed(PC_2); // IRs - -/* DigitalOut IR_1(PB_1); DigitalOut IR_2(PB_13); DigitalOut IR_3(PB_0); @@ -28,7 +29,7 @@ AnalogIn Rec_2(PC_4); AnalogIn Rec_3(PA_6); AnalogIn Rec_4(PA_7); -*/ + // Doing DEBUGGING #define DEBUGGING 1
--- a/motor.h Thu May 04 21:38:20 2017 +0000
+++ b/motor.h Fri May 05 00:08:59 2017 +0000
@@ -4,6 +4,8 @@
#include "mbed.h"
#include "main.h"
+#include "QEI.h"
+
#define BRAKE_VOLTAGE 0.2
extern PwmOut left1;
@@ -11,12 +13,22 @@
extern PwmOut right1;
extern PwmOut right2;
-inline void rightWheelForward(double voltage) {
+extern DigitalOut enableLeftMotor;
+extern DigitalOut enableRightMotor;
+
+//QEI leftWheel(
+
+inline void enableMotors(){
+ enableLeftMotor.write(1);
+ enableRightMotor.write(1);
+}
+
+inline void rightWheelBackward(double voltage) {
right1.write(voltage);
right2.write(0);
}
-inline void rightWheelBackward(double voltage) {
+inline void rightWheelForward(double voltage) {
right1.write(0);
right2.write(voltage);
}