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: mbed
Diff: main.cpp
- Revision:
- 0:9c49bdc7e402
- Child:
- 6:688449345fff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Nov 22 02:18:07 2017 +0000
@@ -0,0 +1,68 @@
+#include "mbed.h"
+#include "PID.h"
+#include "controls.h"
+#include "globals.h"
+
+AnalogIn LL_t (PC_0);
+AnalogIn L_t (PC_1);
+AnalogIn R_t (PA_4);
+AnalogIn RR_t (PA_0);
+
+DigitalOut LL_e (PB_7);
+DigitalOut L_e (PB_0);
+DigitalOut R_e (PC_11);
+DigitalOut RR_e (PC_10);
+
+InterruptIn cM1_1(PB_3); //interrupt from encoders
+InterruptIn cM1_2(PA_15);
+InterruptIn cM2_1(PA_1);
+InterruptIn cM2_2(PC_4);
+
+DigitalOut M1F(PC_7); //motor direction and speed control
+DigitalOut M2B(PA_7);
+DigitalOut M1B(PB_10);
+DigitalOut M2F(PB_6);
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+volatile unsigned long counterM1 = 1; // counter for hall sensors
+volatile unsigned long counterM2 = 1;
+
+void incrementM1()
+{
+ ++counterM1;
+}
+void incrementM2()
+{
+ ++counterM2;
+}
+
+int main()
+{
+
+ M1B.write(0);
+ M2B.write(0);
+ M1F.write(0);
+ M2F.write(0);
+
+ LL_e=1;
+ RR_e=1;
+
+ cM1_1.rise(&incrementM1);
+ cM1_1.fall(&incrementM1);
+ cM1_2.rise(&incrementM1);
+ cM1_2.fall(&incrementM1);
+
+ cM2_1.rise(&incrementM2);
+ cM2_1.fall(&incrementM2);
+ cM2_2.rise(&incrementM2);
+ cM2_2.fall(&incrementM2);
+
+ move(.05, 1000000, forward, forward, &PID_e );
+
+}
+
+
+
+
+
+