String Theory ?

A shrunk down Leonardo-compatible board, thumb drive sized with native USB support. [Product info]
Post Reply
leo_stuck
Posts: 26
Joined: Sun Jun 16, 2013 11:57 pm

String Theory ?

Post by leo_stuck » Wed Mar 26, 2014 2:55 am

Firstly thanks for the advice on getting the SD card module working. Now for my next problem - I am trying to build a string from data collected from 2 sensors attached to Leo'. Everything was going according to plan until I tried to include two values which had decimal places, I got around the problem with one value by leaving it as milliseconds instead of converting it to seconds. But then some some really weird results followed. I tried a similar method with the temperature value but the best I get is a whole number ( some of the results encountered - sketch hanging after 100 seconds, cyclic restarts, strange characters being written to the card just before sketch hangs to name but a few) The only way to get it working properly again was to reload a saved 1st generation of the sketch!

The value in question (temperature) responds to Serial.print , I just can't add it to the string.
I've made a copy of the sketch (attached) but I have left out the several hundred definitions.
Hope you can point me in the right direction again as I would like to start soldering.
Attachments
Document.txt
(12.56 KiB) Downloaded 167 times

leo_stuck
Posts: 26
Joined: Sun Jun 16, 2013 11:57 pm

Re: String Theory ?

Post by leo_stuck » Fri Mar 28, 2014 1:10 am

Silence was the stern reply!

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: String Theory ?

Post by angusgr » Fri Mar 28, 2014 5:16 am

Hi Leo,

Sorry it's taken us a couple of days to get back to you.

It sounds like your sketch might be running low on resources, maybe RAM. My suggestion would be to remove as many "float" types as you can from the sketch, and store everything as type int (-32767 to 32767) or for bigger numbers long. You'll only be able to store whole numbers, but floating point manipulation (particularly formatting floating point) is computationally expensive so you may find the random crashing problems go away.

Good luck,

Angus

leo_stuck
Posts: 26
Joined: Sun Jun 16, 2013 11:57 pm

Re: String Theory ?

Post by leo_stuck » Mon Mar 31, 2014 12:46 am

Thanks Angus,
that was helpful as I was calculating & including some values in the string that i really didn't need, it's just that the sensors were capable of doing so , so i thought "why not?". Looks like I'll be doing a bit of editing.

funnypolynomial
Posts: 6
Joined: Sun Aug 12, 2012 5:03 am

Re: String Theory ?

Post by funnypolynomial » Mon Apr 14, 2014 1:13 am

Also, consider refactoring to use char*, strcpy() etc rather than the String class.

Post Reply