Dependencies:   ESP8266Interface MPU6050 PID StepperMotor WebSocketClient mbed

Fork of irys by Kamil Foryszewski

Files at this revision

API Documentation at this revision

Comitter:
kfforex
Date:
Thu Nov 03 17:17:32 2016 +0000
Child:
1:ac613232f130
Commit message:
before publish

Changed in this revision

ESP8266Interface.lib Show annotated file Show diff for this revision Revisions of this file
MPU6050.lib Show annotated file Show diff for this revision Revisions of this file
PID.lib Show annotated file Show diff for this revision Revisions of this file
StepperMotor.lib Show annotated file Show diff for this revision Revisions of this file
WebSocketClient.lib Show annotated file Show diff for this revision Revisions of this file
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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ESP8266Interface.lib	Thu Nov 03 17:17:32 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/ESP8266/code/ESP8266Interface/#03fd9333670d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MPU6050.lib	Thu Nov 03 17:17:32 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/kfforex/code/MPU6050/#e4e02c9c1381
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PID.lib	Thu Nov 03 17:17:32 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/kfforex/code/PID/#0ffb635770b3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/StepperMotor.lib	Thu Nov 03 17:17:32 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/kfforex/code/StepperMotor/#6fbe104c6f37
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebSocketClient.lib	Thu Nov 03 17:17:32 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/samux/code/WebSocketClient/#4567996414a5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Nov 03 17:17:32 2016 +0000
@@ -0,0 +1,120 @@
+#include "mbed.h"
+#include "math.h"
+#include "Stepper.h"
+#include "MPU6050.h"
+#include "PID.h"
+#include "ESP8266Interface.h"
+#include "TCPSocketConnection.h"
+#include "TCPSocketServer.h"
+#include "Websocket.h"
+
+//------------------------------------
+// Terminal configuration
+// 9600 bauds, 8-bit data, no parity
+//------------------------------------
+//      PINOUT DESCRIPTION
+// MOTORS OUTPUT 
+// LEFT: EN-A1 STEP-A0 DIR-D13
+// RIGHT: EN-D12 STEP-D11 DIR-D10
+//
+// IMU MPU MPU6050
+// SDA-D4 SCL-D5
+//
+// DISTANCE SENSORS
+// D6, D3
+// D6 - temporary ESP8266 RESET
+//
+// ESP8266 WIFI MODULE
+// TX-D1 RX-D2 EN-D7
+//
+// WS2812B LED 
+// D2 - digital output
+// -----------------------------------
+
+//To Do
+//2 REGULATORS 
+
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+stepper left(A1,A0,D13); 
+stepper right(D12,D11,D10); 
+DigitalOut led1(LED1);
+DigitalOut wifiEnable(D7,1);
+AnalogIn shfront(D3); 
+MPU6050 imu; 
+Ticker loop;
+PID controll(120.0,0.004,0.0007,0.01);
+ESP8266Interface wifi(D1,D0,D6,"WLAN_Staszic","st@szicwifi5",115200);
+
+int i; 
+float pitch;
+float roll;
+float frontdistance; 
+double speed; 
+char str[10];
+
+
+void pid_thread() {
+    
+        imu.complementaryFilter(&pitch, &roll);
+        controll.setProcessValue(pitch); 
+        speed = controll.compute(); 
+        left.step(speed); 
+        right.step(-speed);
+}
+
+
+int main() {
+
+    left.disable(); 
+    right.disable();
+
+    imu.init();   
+    imu.calibrate(&pitch,&roll);
+    
+    //wifi.init(); //Reset
+    //wifi.connect(); //Use DHCP
+    
+    //Websocket ws("ws://192.168.0.103:1234/ws");
+    
+    //Check for successful socket connection
+    //if(!ws.connect())ws.close();
+    //else{
+        
+    left.enable(); 
+    right.enable(); //wstawaine
+    
+    //left.step(3000); 
+    //right.step(-3000);
+    wait(1);
+    wait(1); 
+    wait(1);  
+    left.step(-3000); 
+    right.step(3000);
+    wait(0.7); 
+
+    loop.attach_us(pid_thread,10000); 
+    controll.setSetPoint(-14.1);
+        
+        while(1) {
+            // string with a message
+            //sprintf(str,"%f",pitch);
+            //ws.send(str);
+        
+            //memset(str,0,10);
+            //wait(0.5);
+            //if (ws.read(str)) {
+            //    printf("rcv'd: %s\n\r", str);
+            //}
+        }
+        
+    //}
+    //ws.close();
+
+}
+
+    
+
+
+
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 03 17:17:32 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/f141b2784e32
\ No newline at end of file