Go Down

Topic: GPS Neo-M6 with Adafruit or NEO GPS library (Read 585 times) previous topic - next topic

Sareno

I've got NeoGPS working, after a lot of reading and googling.

I know that the author is a member of this forum and being a starter, I reaaally would like to ask him some questions. A lot of text that is quite stiff for a beginner, I wish I could delete 99% of it (and yes, that should be possible).

Bit afraid I messed up IDE by now by installing al those new libs.

BTW, is SDFat better than the standard SD support?

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Sareno

Yes, SDFat is better.
Might be true but certainly not right out of the box.

I do learn a lot from this but neither NEO or SD fat work out of the box.

UKHeliBob

Quote
neither NEO or SD fat work out of the box.
What do you mean by that ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Sareno

What do you mean by that ?
NEOGPS required a lot of reading to do some configurations in the config files. You have to manually enable/disable certain software serial ports etc. On the other hand, in the examples he uses quite a bit of advanced coding and since there are no tutorials to be found, it is hard.

SDFat is also hard to get. I am used to set my on Chipselect pin. It took me a while to find out that SDFat requires pin 10 to be CS. I cannot find where to change that.




Sareno

Also, with an Uno or Nano, Do I have software SPI?

"#error ENABLE_SOFTWARE_SPI_CLASS must be set non-zero in SdFat/SdFatConfig.h"

In fact, with pin 13,12,11 and 10 I do not. Normal SPI works.

Sareno

To be honest, SDFat is kinda fun. But the coding in the examples is a bit above my pay grade.

Sareno

Just for example:

cout
SysCall

I will start digging the lib but I cant find anything about these 2 functions.

srnet

I do learn a lot from this but neither NEO or SD fat work out of the box.
SdFat works out of the box for me.


Quote
It took me a while to find out that SDFat requires pin 10 to be CS. I cannot find where to change that.
And neither does pin 10 have to be the SD_CS.

However, pin 10 must remain an output when your using SPI.

I setup SdFat like this;

SD.begin(SD_CS)



http://www.50dollarsat.info/
http://www.loratracker.uk/

Sareno

SdFat works out of the box for me.

 

And neither does pin 10 have to be the SD_CS.

However, pin 10 must remain an output when your using SPI.

I setup SdFat like this;

SD.begin(SD_CS)




Then again, CS@pin10 works.

And I know that pin10 needs to remain an output when using SPI.


That is why I would like to learn more about this. Let me give you a bit of a code later on, I hope you can/will explain it to me.

Sareno

Just an example that now works:

This is the pinout that I use. Not that this is not code, just how I pin it. The sketch works but why? Let's say I want CS @ 5... What do I do?


Quote
ChipSelect=10
MISO=12
SCK=13
Mosi=11
Code: [Select]

// This stress test will create and write files until the SD is full.
#include <SPI.h>
#include <SdFat.h>

// SD chip select pin.
const uint8_t SD_CS_PIN = SS;

// Set write buffer size.
#ifdef __arm__
#ifndef CORE_TEENSY
// Due
const size_t BUF_SIZE = 32768;
#else  // CORE_TEENSY
// Teensy 3.0
const size_t BUF_SIZE = 8192;
#endif  // CORE_TEENSY
#elif defined(RAMEND) && RAMEND > 5000
// AVR with more than 4 KB RAM
const size_t BUF_SIZE = 4096;
#else  // __arm__
// other
const size_t BUF_SIZE = 512;
#endif  // __arm__

const size_t FILE_SIZE_KB = 10240;
const uint16_t BUFS_PER_FILE = (1024L*FILE_SIZE_KB/BUF_SIZE);

SdFat sd;

SdFile file;

uint8_t buf[BUF_SIZE];
char name[13];
//------------------------------------------------------------------------------
void setup() {
  Serial.begin(9600);
  Serial.print("BUF_SIZE ");
  Serial.println(BUF_SIZE);
  Serial.println("Type any character to start");
  while (Serial.read() < 0) {}
 
  if (!sd.begin(SD_CS_PIN))sd.errorHalt("sd.begin");
 
  // Fill buf with known value.
  for (size_t i = 0; i < BUF_SIZE; i++) buf[i] = i;
 
  // Wait to begin.
  do {delay(10);} while (Serial.read() >= 0);
  Serial.println("Type any character to stop after next file");
}
//------------------------------------------------------------------------------
void loop() {
  // Free KB on SD.
  uint32_t freeKB = sd.vol()->freeClusterCount()*sd.vol()->blocksPerCluster()/2;

  Serial.print("Free KB: ");
  Serial.println(freeKB);
  if (freeKB < 2*FILE_SIZE_KB) {
    Serial.println(" Done!");
    while(1);
  }
  sprintf(name, "%lu.DAT", freeKB);
  if (!file.open(name, O_WRITE | O_CREAT | O_TRUNC)) {
    sd.errorHalt("Open error!");
  }
  for (uint16_t i = 0; i < BUFS_PER_FILE; i++) {
    if (file.write(buf, BUF_SIZE) != BUF_SIZE) {
      sd.errorHalt("Write error!");
    }
  }
  file.close();
  if (Serial.available()) {
    Serial.println("Stopped!");
    while(1);
  }
}

Sareno

But, with SDFat, how can I change the CS pin?

srnet

http://www.50dollarsat.info/
http://www.loratracker.uk/

Sareno

SdFat works out of the box for me.

 

And neither does pin 10 have to be the SD_CS.

However, pin 10 must remain an output when your using SPI.

I setup SdFat like this;

SD.begin(SD_CS)
Sorry but I dont get that. In the SDFAT doc it is clearly statet that Pin 10 is configured as sstandard CS. I do know that Pin10 has to be output all the time with SPI.

BUT, where can I change it to pin 5 (CS, not the outputted pin 10).

At this point SDFATwill only work when I connect CS to 10.

I find SDFAT very hard to understand because of the lack of information. Where does COUT or syscall come from.,

All tutorials I find are based on SD lib. With clear examples... just open a file, write it, close it. done.


Sareno

See attached.

It is about software SPI, should I use that?

I have a UNO and Nano. Hardware SPI would be faster right?

Go Up