Trying to log data from UM6 sensor with GPS receiver LS20031. I have two problems: - I can't log to file at a fast rate (<0.5s) without data values freezing to a fixed value. Print to pc screen it works fine. Ideally I would do this with an interrupt (e.g. ticker) so that the time of each reading is a fixed interval - I removed this as I thought this was causing the problem. - I want to record GPS lat and long. I have setup the GPS ground speed so I know the sensor are communicating. So I possibly havent set the config file to correctly interpet these two signals.

Dependencies:   MODSERIAL mbed

Fork of UM6_IMU_AHRS_2012 by lhiggs CSUM

main.cpp

Committer:
lhiggs
Date:
2012-09-28
Revision:
0:03c649c76388
Child:
1:20201cda90d0

File content as of revision 0:03c649c76388:

#include "mbed.h"          // MBED LIBRARY
#include "MODSERIAL.h"     // MBED BUFFERED SERIAL

#include "UM6_usart.h"     // UM6 USART HEADER
#include "UM6_config.h"    // UM6 CONFIG HEADER

/////////////////////////////////////////////////////////////////////////////////////////////
// SETUP (ASSIGN) SERIAL COMMUNICATION PINS ON MBED
/////////////////////////////////////////////////////////////////////////////////////////////
MODSERIAL pc(USBTX, USBRX);  // PC SERIAL OVER USB PORT ON MBED

////////////////////////////////////////////////////////////////////////////////////////////////
// SETUP (ASSIGN) MBED LED (1 thru 3) FOR VISUAL DEBUGGING ON MBED
////////////////////////////////////////////////////////////////////////////////////////////////
DigitalOut pc_activity(LED1);    // LED1 = PC SERIAL
DigitalOut uart_activity(LED2);  // LED2 = UM6 SERIAL


void rxCallback(MODSERIAL_IRQ_INFO *q) {
    if (um6_uart.rxBufferGetCount() >=  MAX_PACKET_DATA) {
        uart_activity = !uart_activity;  // Lights LED when uart RxBuff has > 40 bytes
        Process_um6_packet();
    }
}
 

int main() {

/////////////////////////////////////////////////////////////////////////////////////////////////////
//          SET SERIAL UART BAUD RATES
/////////////////////////////////////////////////////////////////////////////////////////////////////

    // set UM6 serial uart baud 9600
    um6_uart.baud(9600);
    pc.baud(9600);  // pc baud for UM6 to pc interface

    // attach interupt function to uart
    um6_uart.attach(&rxCallback, MODSERIAL::RxIrq);

    int Roll_Counter = 0;

    while (1) {
         Roll_Counter++;      
         if (Roll_Counter > 5000000) {
          pc.printf("Gyro_Proc_X %f deg/s, ",data.Gyro_Proc_X);
          pc.printf("Gyro_Proc_Y %f deg/s, ",data.Gyro_Proc_Y);
          pc.printf("Gyro_Proc_Z %f deg/s, ",data.Gyro_Proc_Z);
          pc.printf("Roll %f deg, ",data.Roll);
          pc.printf("Pitch %f deg, ",data.Pitch);
          pc.printf("Yaw %f deg \r\n",data.Yaw);
          pc_activity = !pc_activity;  // Lights LED when uart RxBuff has > 40 bytes
          Roll_Counter = 0;
         }
  
    }  // end while(1) loop

}  // end main()