Blue Pill Test MPU6050 Test LCD

Dependencies:   mbed mbed-STM32F103C8T6 MPU6050 TextLCD

Files at this revision

API Documentation at this revision

Comitter:
Javierdf
Date:
Sun Nov 17 17:34:50 2019 +0000
Commit message:
Blue Pill MPU6050 test LCD

Changed in this revision

MPU6050.lib Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
TextLCD.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-STM32F103C8T6.lib Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib 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/MPU6050.lib	Sun Nov 17 17:34:50 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Javierdf/code/MPU6050/#de35b2c863c0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Sun Nov 17 17:34:50 2019 +0000
@@ -0,0 +1,57 @@
+# Getting started with Blinky on mbed OS
+
+This guide reviews the steps required to get Blinky working on an mbed OS platform.
+
+Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
+
+## Import the example application
+
+From the command-line, import the example:
+
+```
+mbed import mbed-os-example-blinky
+cd mbed-os-example-blinky
+```
+
+### Now compile
+
+Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5:
+
+```
+mbed compile -m K64F -t ARM
+```
+
+Your PC may take a few minutes to compile your code. At the end, you see the following result:
+
+```
+[snip]
++----------------------------+-------+-------+------+
+| Module                     | .text | .data | .bss |
++----------------------------+-------+-------+------+
+| Misc                       | 13939 |    24 | 1372 |
+| core/hal                   | 16993 |    96 |  296 |
+| core/rtos                  |  7384 |    92 | 4204 |
+| features/FEATURE_IPV4      |    80 |     0 |  176 |
+| frameworks/greentea-client |  1830 |    60 |   44 |
+| frameworks/utest           |  2392 |   512 |  292 |
+| Subtotals                  | 42618 |   784 | 6384 |
++----------------------------+-------+-------+------+
+Allocated Heap: unknown
+Allocated Stack: unknown
+Total Static RAM memory (data + bss): 7168 bytes
+Total RAM memory (data + bss + heap + stack): 7168 bytes
+Total Flash memory (text + data + misc): 43402 bytes
+Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin
+```
+
+### Program your board
+
+1. Connect your mbed device to the computer over USB.
+1. Copy the binary file to the mbed device.
+1. Press the reset button to start the program.
+
+The LED on your platform turns on and off.
+
+## Troubleshooting
+
+If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Sun Nov 17 17:34:50 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/wim/code/TextLCD/#ce348c002929
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Nov 17 17:34:50 2019 +0000
@@ -0,0 +1,96 @@
+#include "stm32f103c8t6.h"
+#include "mbed.h"
+#include "MPU6050.h"
+#include "TextLCD.h"
+
+ 
+SPI spi_lcd(PB_15, NC, PB_13);
+MPU6050 mpu(PB_7, PB_6); // SDA, SCL pines de la comunicacion I2C 
+TextLCD_SPI lcd(&spi_lcd, PB_12, TextLCD::LCD16x2,TextLCD::HD44780); // SPI bus, CS pin, LCD Type ok
+DigitalOut ledr(PB_5);   //Led de conexion fallida 
+DigitalOut ledg(PB_4);   //Led de conexion OK
+DigitalOut ledb(PB_3);   //Led de envio de datos serial
+
+float AX,AY,AZ;  // variables para la conversion a aceleracion en m/s^2
+int estado=1; // variable que hacer repetir el ciclo de conexion con el MPU hasta que haya una conexion I2C satisfactoria
+int ax,ay,az; /// variables a imprimir
+int contador=0;
+
+int main() {
+    lcd.cls();
+    wait(0.50);
+    //Posicionar al LCD en el espacio 0,0  ORIGEN
+    lcd.locate(0,0);
+    lcd.printf("Start PowerTip");
+    wait(1.0);
+    lcd.cls();
+    
+    ledr=0; //inicializacion de led (conexion fallida) off
+    ledg=0; //inicializacion de led (conexion OK) off
+    ledb=0; //inicializacion de led (envio de datos) off
+ 
+    int accdata[3];  //se aparta el arreglo para la adquisiscion de datos de la aceleración
+    int gyrodata[3]; //se aparta el arreglo para la adquisicion de datos del giroscopio 
+    
+    while(estado){ // inicia bucle para reconocimiento del estado 
+    wait_ms(100);     // retardo para el inicio de las variables 
+    if (mpu.testConnection()){ // lectura del estado de conexion del MPU 6050 
+        lcd.printf("MPU connection succeeded\n\r"); //imprime en patalla que la conexion fue OK 
+        
+        //lcd.cls();
+        estado=0; // cambio de estado de la variable se sale del ciclo una vez que la conexion esta OK
+        ledg=1; // si la (conexion OK) led green enciende
+        
+        }
+    else{
+        lcd.printf("MPU connection failed\n\r");// Imprime en pantalla que la conexión fue fallida 
+        //lcd.cls();
+        estado=1; //Estado permanence en uno repitiendo el ciclo while(estado)
+        ledr=1;  ///si la (conexion fallida) led rojo enciende
+         
+        }
+        // retardo para preguntar sobre la conexion del MPU
+        wait_ms(1000); /// Se hace cada segundo si es que la conexion fue fallida
+        }
+        ledr=0; // Se apaga led red una vez que la conexion fue OK 
+    while(1) {
+        contador++;
+        //MPU6050_ACCEL_XOUT_H_REG se piden los datos de esta direcion
+        // definición de los registros para pedir datos de acelerometro
+        //MPU6050_ACCEL_XOUT_H_REG   0x3B
+        //MPU6050_ACCEL_YOUT_H_REG   0x3D
+        //MPU6050_ACCEL_ZOUT_H_REG   0x3F
+        
+        mpu.getAcceleroRaw(accdata); //Funcion para mandar llamar los datos del acelerometro
+        
+        mpu.getGyroRaw(gyrodata);  // funcion para mandar llamar los datos del giroscopio
+        
+        ax=(accdata[0])+(4175);  ///compenzación del offset del sensor
+        ay=(accdata[1])-(12759); ///compenzación del offset del sensor
+        az=(accdata[2])-(14029); ///compenzación del offset del sensor
+        
+        ///impresion de pantalla de lo datos puros de aceleracion 
+        //pc.printf("Accelero data: X: %d - Y: %d - Z: %d\n\r", accdata[0], accdata[1], accdata[2]); 
+       
+        lcd.printf("X");       //Identificador para el software LABVIEW
+        lcd.printf("%d ",ax); //Imprime los datos de aceleracion en 'X'
+        lcd.printf("Y");       //Identificador para el software LABVIEW
+        lcd.printf("%d ",ay); //Imprime los datos de aceleracion en 'Y'
+        lcd.printf("Z");       //Identificador para el software LABVIEW
+        lcd.printf("%d ",az); //Imprime los datos de aceleracion en 'Z'
+       // lcd.cls();
+        /// Impresion de panatalla de los datos del giroscopio
+        /// pc.printf("Gyro data: X: %d - Y: %d - Z: %d\n\r\n\r", gyrodata[0], gyrodata[1], gyrodata[2]);
+        if(contador==10)
+        {
+           ledb=!ledb;  //Cambio de estado del led blue (da un tono azul) al encender blue con green
+        //indica un envio de datos serial correcto 
+         contador=0;
+            }
+        
+        
+        wait_ms(100); // Retardo sincronizado con la interfaz grafica para el envio de datos
+    }
+        
+        
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-STM32F103C8T6.lib	Sun Nov 17 17:34:50 2019 +0000
@@ -0,0 +1,1 @@
+http://os.mbed.com/users/hudakz/code/mbed-STM32F103C8T6/#727468adfd1d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Sun Nov 17 17:34:50 2019 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#addec7ba10054be03849eff58a1d17f157391e7d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Nov 17 17:34:50 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file