Compatibility with arduino due

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Rockdamned
 
Posts: 2
Joined: Sun Mar 23, 2014 7:21 pm

Compatibility with arduino due

Post by Rockdamned »

Hello everyone!
I am about to buy the gps breakout, the 9dof imu and the bmp180, but I am concerned that they wouldn't be compatible with arduino due, in terms of code and power supply (I'm really a newbie to electronics, so I'm really scared to burn up something!

Besides, what is the current consumption? (Still need some current for four or five outputs...)

Thank you very much for your help
Grazie mille!
Edoardo

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Compatibility with arduino due

Post by adafruit_support_rick »

Well, I just ported the GPS library to the Due this afternoon.
The BMP and the 9DOF should also work.

Power all three breakouts from 3.3V.

NOTE: You must connect the GPS breakout to Due RX1 and TX1. It's hardcoded in the library for Serial1.

Rockdamned
 
Posts: 2
Joined: Sun Mar 23, 2014 7:21 pm

Re: Compatibility with arduino due

Post by Rockdamned »

adafruit_support_rick wrote:Well, I just ported the GPS library to the Due this afternoon.
The BMP and the 9DOF should also work.

Power all three breakouts from 3.3V.

NOTE: You must connect the GPS breakout to Due RX1 and TX1. It's hardcoded in the library for Serial1.
So lucky I am (just bought it)! Thank you!

Pippa
 
Posts: 19
Joined: Mon Apr 21, 2014 7:53 am

Re: Compatibility with arduino due

Post by Pippa »

Hi,
I'm sorry if I use this topic but the problem is quite the same.
I bought a Ultimate GPS logger shield and a 9DOF imu but I'm experiencing some problems with the SD card. There is something wrong because I get a bunch of errors that I can't explain but all seems to raise when I call some methods like SD.open(10) (I have an Arduino Uno) or when I try to write on my MicroSD.

I wrote a sketch that reads the raw accelerometer data (x and y) and write it on the card and on the serial. Everything was ok but when I added instructions for read also roll and pitch (I added a dof sensor objects) the shield have some errors in opening log file (the same happens when I try to add the code to manage GPS).
The strange thing is that in my setup() routine I can write on the card but in the routine where I read values I can't.

I'm pretty sure it isn't a matter of circuitry because loading some of the examples in the Adafruit library everything goes fine. I also checked my code about 1000 times and everithing is ok, I'm starting to think that here is something wrong in the included files (maybe some code that put together in the same sketch makes some errors):

Code: Select all

#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303_U.h>
#include <Adafruit_9DOF.h>
#include <SPI.h>
#include <SD.h>

Adafruit_9DOF                dof   = Adafruit_9DOF();
Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(30301);

File dataFile;
boolean continueReadingRequested = LOW;


/* Update this with the correct SLP for accurate altitude measurements */
const int chipSelect = 10;
int sensorsNumber = 5;
int timeBetweenReadings = 100;

//Variables containing last sensors values
String accelX, accelY, roll, pitch;


void initSystem()
{
  //******* Initialise Accelerometer
  if(!accel.begin())
  {
    /* There was a problem detecting the LSM303 ... check your connections */
    Serial.println(F("Ooops, no LSM303 detected ... Check your wiring!"));
    while(1);
  }
  Serial.println("Accelerometer initialised.");
  
   //******* Initialise SD
  pinMode(chipSelect, OUTPUT);
  Serial.println("CS set");
  if(!SD.begin(chipSelect)){
    //There was a problem with the SD!
    Serial.println("Ooops, a problem with the SD!");
    while(1);
  }
  Serial.println("SD card initialised.");
  
  //******* Initialise GPS
  /*GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  Serial.println("GPS Started.");*/
}

void InitLogFile(){
  //Controllo se c'è il file e se presente lo cancello...
  if (SD.exists("DATALOG.LOG")){
    Serial.println("Old log file found...");    
    SD.remove("DATALOG.LOG");
    Serial.println("Old log file erased..."); 
  }
  
  //Ri-creo un file con lo stesso nome e lo apro.
  dataFile = SD.open("DATALOG.LOG", FILE_WRITE);
  //Verifico se ci sono problemi
  if (dataFile){
    Serial.println("New log file created...");
    dataFile.println("Start");
    dataFile.println("*1-AccelX");
    dataFile.println("*2-AccelY");
    dataFile.println("*3-Chassis roll");
    dataFile.println("*4-Chassis pitch");
    dataFile.flush(); 
    Serial.println("New log file initialized...");
  } else {
    Serial.println("File log ERROR.");
  }
  
  
}

void setup(void)
{
  Serial.begin(115200);
   
  /* Initialise the system */
  initSystem();
  /* Initialise the log file */
  InitLogFile();
  
 
  Serial.println("Ready...");
}

void loop(){
  if (continueReadingRequested){
    for (int i = 1; i = 4; i++){
      ReadValues(i);
      delay(timeBetweenReadings);
    }
    PlotData();
  }
  if (Serial.available()){
    char c = Serial.read();
    switch (c){
      case '1':
        ReadValues(1);
        break;
      case '2':
        ReadValues(2);
        break;
      case '3':
        ReadValues(3);
        break;
      case '4':
        ReadValues(4);
        break;
      case 'C':
        PrintSensors();
        break;
      case 'O':
        continueReadingRequested = !continueReadingRequested;
        Serial.print("Continuous reading: ");
        Serial.println(continueReadingRequested);
        break;
      case 'F':
        Serial.print("&"); Serial.print("Firmware000001.ino");
        Serial.println("-RC Datalogger 21/04/2014");
        break;
      case 'S':
        PrintStatus();
        break;
      default:
        break;   
    }
  }
}

boolean ReadValues(int sensorID){
  //questo vettore conterrà i caratteri per convertire i valori letti da float a string
  char rawData[10];
  sensors_event_t accel_event;
  sensors_vec_t   orientation;
  accel.getEvent(&accel_event);
  String rawDataString;
  
  if (sensorID==1){
    Serial.println("Selected 1");
      //viene richiesta l'accelerazione X
      dtostrf(accel_event.acceleration.x, 3, 2, rawData);
      rawDataString=rawData;
      accelX = "1-";
      accelX += rawDataString;
      Serial.println(rawDataString);
  } else if (sensorID==2){
    Serial.println("Selected 2");
     //viene richiesta l'accelerazione Y
      dtostrf(accel_event.acceleration.y, 3, 2, rawData);
      accelY = "2-" + String(rawData);
      Serial.println(accelY);
  } else if (sensorID==3){
    Serial.println("Selected 3");
      //viene richiesto il roll
      if (dof.accelGetOrientation(&accel_event, &orientation)){
        dtostrf(orientation.roll, 3, 2, rawData);
      }
      roll = "3-" + String(rawData);
      Serial.println(roll);     
  } else if (sensorID==4){
    Serial.println("Selected 4");
      //viene richiesto il pitch
      if (dof.accelGetOrientation(&accel_event, &orientation)){
        dtostrf(orientation.pitch, 3, 2, rawData);
      }
      pitch = "4-" + String(rawData);
      Serial.println(pitch);     
  }
  
  return HIGH;
}

void PlotData(){
  if (!dataFile){
    Serial.println("There was an error with the file, I was unable to log");
    return;
  }
  dataFile.println(accelX);
  dataFile.println(accelY);
  dataFile.println(roll);
  dataFile.println(pitch);
  dataFile.flush();
}

void PrintSensors(){
  Serial.println("*1-AccelX");
  Serial.println("*2-AccelY");
  Serial.println("*3-Chassis roll");
  Serial.println("*4-Chassis pitch");
}

void PrintStatus(){
  Serial.println("Routine da scrivere");
}





The code above stops after "Serial.println("SD card initialised.");" in "InitSystem()" routine.

Some suggestions?

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Compatibility with arduino due

Post by adafruit_support_rick »

I think you're probably running out of SRAM. Please see this tutorial for tips on resolving memory issues:
https://learn.adafruit.com/memories-of-an-arduino

Pippa
 
Posts: 19
Joined: Mon Apr 21, 2014 7:53 am

Re: Compatibility with arduino due

Post by Pippa »

I've got it!!!

Thank you very much!

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Compatibility with arduino due

Post by adafruit_support_rick »

Cool! :)

Pippa
 
Posts: 19
Joined: Mon Apr 21, 2014 7:53 am

Re: Compatibility with arduino due

Post by Pippa »

Rick, excuse me but I take the opportunity of your help.

Can you tell me why this code works correctly and outputs the right GPS speed:

Code: Select all

#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
#include <SPI.h>
#include <SD.h>

SoftwareSerial mySerial(8, 7);
Adafruit_GPS GPS(&mySerial);
int velocita;
String firmwareVersion = "test.ino";
File logFile;
const int chipSelect = 10;

void setup(){
  Serial.begin(9600);
  Serial.println("Ok");
  GPS.begin(9600);
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_5HZ);
  pinMode(SS, OUTPUT);
  SD.begin(chipSelect);
  logFile = SD.open("logFile.log", FILE_WRITE);
  logFile.println("Start");
  logFile.println("*1-GPS Speed");
  logFile.close();
  
  
}

void loop(){
  
    char c = GPS.read();
    //Serial.println(GPS.speed);
    if(GPS.newNMEAreceived()){
    if (!GPS.parse(GPS.lastNMEA())){
      return;
    }
    Serial.println(GPS.speed);
    velocita = GPS.speed * 1.852;
     
    }
    if (Serial.available()){
    char t = Serial.read();
    switch(t){
      case '1':
        Serial.print("1-");
        Serial.println(velocita);
        logFile = SD.open("logFile.log", FILE_WRITE);
        logFile.print("1-");
        logFile.println(velocita);
        logFile.close();
        break;
      case 'F':
        PrintFirmware();
        break;
      case 'C':
        PrintSensors();
        break;
      default:
        break;
    }
}
}

void PrintSensors(){
  Serial.println("*1-GPS Speed");
}

void PrintFirmware(){
  Serial.print("&"); Serial.print(firmwareVersion); Serial.println("-Prova accelerometro");
}
But this tell me "No new nmea" continuously:

Code: Select all

#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>

SoftwareSerial mySerial(8, 7);
Adafruit_GPS GPS(&mySerial);

boolean continueReadingRequested = HIGH;
char f;
void initSystem()
{
  //******* Initialise Accelerometer
 
  //******* Initialise GPS

  //GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  //GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ); 
  
}

void setup(void)
{
 
  /*
  accelX.reserve(7);
  accelY.reserve(7);
  roll.reserve(7);
  pitch.reserve(7);
  GPSSpeed.reserve(7);*/
  
 
   
  /* Initialise the system */
  //initSystem();
 
 
   Serial.begin(9600);
     
   GPS.begin(9600);
   GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCONLY);
   GPS.sendCommand(PMTK_SET_NMEA_UPDATE_5HZ);
   
   Serial.println(F("Ready..."));
}


void loop(){
  f = GPS.read();
  if (continueReadingRequested){
    
      ReadValues();
      //delay(timeBetweenReadings);
      //PlotData();
    }
    //if (Serial.available()){
    char c[1];
    c[0] = Serial.read();
    switch (c[0]){
      case '1':
        ReadValues();
        //PlotData(); //Questa si potrebbe togliere per disabilitare la scrittura SD durante la lettura gestita dal pc.
        //delay(timeBetweenReadings);
        break;
      /*case 'C':
        PrintSensors();
        break;*/
      case 'O':
        continueReadingRequested = !continueReadingRequested;
        Serial.print(F("Continuous reading: "));
        Serial.println(continueReadingRequested);
        break;
      default:
        break;   
   // }
  }
}

void ReadValues(){
  /************* QUI SI POTREBBE RISPARMIARE MOLTO SPAZIO AD ESEMPIO METTENDO INSIEME PITCH E ROLL E LE DUE
  ACCELERAZIONI (VIENE UN CICLO DI VERIFICA IN MENO) ****************** */
  //questo vettore conterrà i caratteri per convertire i valori letti da float a string
  int velocita;
  char rawData[10];
 
  String rawDataString;
  String outputString;
  

 
  //Velocità GPS 
  
  
  if (GPS.newNMEAreceived()){
     //Serial.println(F("newnmea"));
     if (!GPS.parse(GPS.lastNMEA())){
       //Serial.println(F("parseerror"));
       return;
     }
     Serial.println(GPS.speed);
  velocita = GPS.speed * 1.852;
  //Serial.println(velocita);
  outputString = "5-" + velocita;
  Serial.println(outputString);
  //Serial.println(GPSSpeed);
  
  } else {
    Serial.println(F("No new nmea"));
  }
}
Be patient if there are some commented statements but is a try sketch!
Last edited by adafruit_support_rick on Wed Apr 23, 2014 9:54 am, edited 1 time in total.
Reason: please use Code tags when posting code (</> button)

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Compatibility with arduino due

Post by adafruit_support_rick »

The problem is here:

Code: Select all

  else {
    Serial.println(F("No new nmea"));
  }
You are saturating the processor with printing "No new nmea". It is so busy doing this that it is not able to read properly from the GPS.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”