Merging two working sketches into one??
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- brandtz
- Posts: 27
- Joined: Fri Aug 17, 2012 4:49 am
Re: Merging two working sketches into one??
But how then to explain the problem I am having with the sketch?
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Merging two working sketches into one??
Those symptoms are consistent with a stack-crash. It sounds like you still have a memory problem.So I added "lcd.print (GPS.speed);" Then the "creation of log files loops and creates one after the other until the SD card has reached logfile 99, after which I have to manually empty the card of course. If I then comment "// lcd.print (GPS.speed);" it logs the speed on the SD card just fine...
- brandtz
- Posts: 27
- Joined: Fri Aug 17, 2012 4:49 am
Re: Merging two working sketches into one??
OK, so back trying to shrink code...Since I am not too into these things I want to explore another avenue...Which "high end" Arduino could I step into compatibile with the UNO? Should I move into a DUE or a MEGA?
I have still much more sensors and things to integrate into my project, and if I am alrady contantly hitting the memory constraints I need to do something now....
I have still much more sensors and things to integrate into my project, and if I am alrady contantly hitting the memory constraints I need to do something now....
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Merging two working sketches into one??
The Leonardo has a little more SRAM headroom (2.5K vs 2K for the UNO). The Mega has 4x the space at 8K. The Due goes all the way to 96K. The main issue with the Due is compatibility. It runs at 3.3v and has a different processor architecture from the Atmega-based Arduinos. If you will be adding a lot of different sensors and such, the Mega is a safer bet.
- brandtz
- Posts: 27
- Joined: Fri Aug 17, 2012 4:49 am
Re: Merging two working sketches into one??
OK, seems the Duo is the best option...But then...have to restart with the sensors, shields and also afraid to changing "platform" again...
How about using the GPS Ultimate Shield with SD looging from Adafruit, and your LCD Shield (the one with I2C), are THOSE compatible at least!?
How about using the GPS Ultimate Shield with SD looging from Adafruit, and your LCD Shield (the one with I2C), are THOSE compatible at least!?
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Merging two working sketches into one??
Yes. Both of those shields work with the Due.
- brandtz
- Posts: 27
- Joined: Fri Aug 17, 2012 4:49 am
Re: Merging two working sketches into one??
Hi, did not get hold of a Due instead of the Uno I started with...Bought a MEGA instead...Changed the chipselect to 53 and uploaded the attached sketch...Now I get in Serial monitor "Ultimate GPSlogger Shield Card init. failed!"
- Attachments
-
- SD and LCD and GPS now with MEGA.txt
- (6.35 KiB) Downloaded 179 times
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Merging two working sketches into one??
the problem is here:
If you are using anything but an UNO, you need to use software SPI and specify all the pins.
Code: Select all
// see if the card is present and can be initialized:
if // (!SD.begin(chipSelect, 11, 12, 13)) {
(!SD.begin(chipSelect)) {
// (!SD.begin(chipSelect)) { // if you're using an UNO, you can use this line instead
- brandtz
- Posts: 27
- Joined: Fri Aug 17, 2012 4:49 am
Re: Merging two working sketches into one??
Hi, I found in forums that you would just change chipselect to 53...
Can you point to example/explanation of how to use "software SPI and define all pins" ?
I did find something and added this: "#define MEGA_SOFT_SPI 0" and also tried "#define MEGA_SOFT_SPI 1"
I tried also using "if (!SD.begin(chipSelect, 11, 12, 13)) {", but sketch compiler gives a hole lot of errors like: "no matching function for call to 'SDClass::begin(int, int, int, int)'"
Tried searching on Google and found almost same sort of project...and he writes: "Assuming you are using a Mega, cut the tracks to pins 7, 8 and 10 as shown in the sketch. Use a sharp scalpel and cut carefully. Check before you cut!"
I am in deeeep water now....Any help anyone...
Can you point to example/explanation of how to use "software SPI and define all pins" ?
I did find something and added this: "#define MEGA_SOFT_SPI 0" and also tried "#define MEGA_SOFT_SPI 1"
I tried also using "if (!SD.begin(chipSelect, 11, 12, 13)) {", but sketch compiler gives a hole lot of errors like: "no matching function for call to 'SDClass::begin(int, int, int, int)'"
Tried searching on Google and found almost same sort of project...and he writes: "Assuming you are using a Mega, cut the tracks to pins 7, 8 and 10 as shown in the sketch. Use a sharp scalpel and cut carefully. Check before you cut!"
I am in deeeep water now....Any help anyone...
- brandtz
- Posts: 27
- Joined: Fri Aug 17, 2012 4:49 am
Re: Merging two working sketches into one??
I now also changed to Adafruit SD library.....restarted the programmer and sketch and now it sticks at compiling...doesn't advance to download to the board..
- Franklin97355
- Posts: 23912
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Merging two working sketches into one??
Does it give you any output? In the IDE go to file > preferences and check the two boxes for "Show verbose output during" then run the compile again.and now it sticks at compiling...
- brandtz
- Posts: 27
- Joined: Fri Aug 17, 2012 4:49 am
Re: Merging two working sketches into one??
Step by step.....but still not close to goal.....
I reinstalled the IDE and all Adafruit libraries, SD, LCG and GPS...
Then started with a clean "example" file for the SD log test...(attached), changed chipselect to 53, still get "Card init. failed!"
I reinstalled the IDE and all Adafruit libraries, SD, LCG and GPS...
Then started with a clean "example" file for the SD log test...(attached), changed chipselect to 53, still get "Card init. failed!"
- Attachments
-
- GPS and SD log after reinstall.txt
- (5.55 KiB) Downloaded 196 times
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Merging two working sketches into one??
Code: Select all
changed chipselect to 53,
There are instructions for the Mega in the tutorial:
https://learn.adafruit.com/adafruit-dat ... d-leonardo
- brandtz
- Posts: 27
- Joined: Fri Aug 17, 2012 4:49 am
Re: Merging two working sketches into one??
Ok will try that later....
I am also in parallell with your good suggestion looking around and read the adafruit part of fixing the mega commuication with this: "Edit the file utility/Sd2Card.h in the default Arduino SD library, changing line 42 to read "#define MEGA_SOFT_SPI 1" (default is 0)." Did that and saved the file...
Then compiler says all this....: "Arduino:1.6.4 (Windows 7), Kort:"Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Program Files (x86)\Arduino\libraries\SD\utility\Sd2Card.cpp: In member function 'uint8_t Sd2Card::setSckRate(uint8_t)':
C:\Program Files (x86)\Arduino\libraries\SD\utility\Sd2Card.cpp:585:3: error: 'SPI' was not declared in this scope
SPI.setClockDivider(v);
^
Fel vid kompilering.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
"
Do you you need the "verbose" version....
Yeeeeezz is this more complicated than I thought.... :-)
I am also in parallell with your good suggestion looking around and read the adafruit part of fixing the mega commuication with this: "Edit the file utility/Sd2Card.h in the default Arduino SD library, changing line 42 to read "#define MEGA_SOFT_SPI 1" (default is 0)." Did that and saved the file...
Then compiler says all this....: "Arduino:1.6.4 (Windows 7), Kort:"Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
C:\Program Files (x86)\Arduino\libraries\SD\utility\Sd2Card.cpp: In member function 'uint8_t Sd2Card::setSckRate(uint8_t)':
C:\Program Files (x86)\Arduino\libraries\SD\utility\Sd2Card.cpp:585:3: error: 'SPI' was not declared in this scope
SPI.setClockDivider(v);
^
Fel vid kompilering.
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
"
Do you you need the "verbose" version....
Yeeeeezz is this more complicated than I thought.... :-)
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: Merging two working sketches into one??
If you are using the library linked in the tutorial, you should not need to edit any of the library files.
Please be positive and constructive with your questions and comments.