0
Offline
Edison Member
Karma: 28
Posts: 1079
Arduino rocks
|
 |
« Reply #15 on: January 25, 2013, 03:47:48 pm » |
It may be a problem with Serial.read(). nilFifoDataLogger is the only example with Serial.read(). I have tried many Arduino boards and two Windows 7 computers with no problem. Load the nilTemplate1 example and put the following at the beginning of loop() like this. void loop() { int c = Serial.read(); if (c < 0) return; Serial.print((char)c); return;
Run the example and type one or two characters into the serial monitor and see if they are echoed. Also run nilFifoDataLogger with no SD card and see if this prints: type any character to begin SD problem SD errorCode: 0X1,0X0
|
|
|
|
« Last Edit: January 25, 2013, 03:50:47 pm by fat16lib »
|
Logged
|
|
|
|
|
Rapa Nui
Offline
God Member
Karma: 17
Posts: 905
Pukao hats cleaning services
|
 |
« Reply #16 on: January 25, 2013, 04:05:15 pm » |
Also run nilFifoDataLogger with no SD card and see if this prints: Quote type any character to begin SD problem SD errorCode: 0X1,0X0
type any character to begin SD problem SD errorCode: 0X1,0X0
Yes they are echoed (after pushing Send): 33 54 pito Q
|
|
|
|
« Last Edit: January 25, 2013, 04:09:22 pm by pito »
|
Logged
|
|
|
|
|
Rapa Nui
Offline
God Member
Karma: 17
Posts: 905
Pukao hats cleaning services
|
 |
« Reply #17 on: January 25, 2013, 04:19:44 pm » |
 type any character to begin type any character to end Done Unused Stack: 141 342
** overrun errors **
with: // SD chip select pin. const uint8_t sdChipSelect = 10; //SS;
|
|
|
|
« Last Edit: January 25, 2013, 04:25:14 pm by pito »
|
Logged
|
|
|
|
|
0
Offline
Edison Member
Karma: 28
Posts: 1079
Arduino rocks
|
 |
« Reply #18 on: January 25, 2013, 04:59:17 pm » |
pito, Could you put a continue statement in thread 1 like this so no data is taken. while (1) { // Sleep until time for next data point nilThdSleep(intervalTicks); continue;
Let me know what happens.
|
|
|
|
|
Logged
|
|
|
|
|
Rapa Nui
Offline
God Member
Karma: 17
Posts: 905
Pukao hats cleaning services
|
 |
« Reply #19 on: January 25, 2013, 05:04:39 pm » |
type any character to begin type any character to end Done Unused Stack: 141 445
data.csv is 0kB No idea what is the issue, with "continue" it always works, with "//continue" it sometimes works, sometimes does not.
|
|
|
|
« Last Edit: January 25, 2013, 05:37:08 pm by pito »
|
Logged
|
|
|
|
|
0
Offline
Edison Member
Karma: 28
Posts: 1079
Arduino rocks
|
 |
« Reply #20 on: January 25, 2013, 05:13:53 pm » |
How was this run? Was any data recorded? type any character to begin type any character to end Done Unused Stack: 141 342
** overrun errors **
with: Code:
// SD chip select pin. const uint8_t sdChipSelect = 10; //SS;
The output is from the old example. It should look like this from today's pito.zip file. type any character to begin type any character to end Done Maximum SD write latency: 3748 usec Unused Stack: 57 407
|
|
|
|
« Last Edit: January 25, 2013, 05:19:21 pm by fat16lib »
|
Logged
|
|
|
|
|
Rapa Nui
Offline
God Member
Karma: 17
Posts: 905
Pukao hats cleaning services
|
 |
« Reply #21 on: January 25, 2013, 05:52:56 pm » |
Yes, when ran the old one I got csv data (100-200kB). I cannot get it working with the new version yet.. Still the same issue, with =10 or =SS.. It works with "continue;" only: type any character to begin type any character to end Done Maximum SD write latency: 0 usec Unused Stack: 57 480
No idea what to do in order to get it working..
|
|
|
|
|
Logged
|
|
|
|
|
Rapa Nui
Offline
God Member
Karma: 17
Posts: 905
Pukao hats cleaning services
|
 |
« Reply #22 on: January 25, 2013, 06:04:40 pm » |
With new one I get now this type any character to begin type any character to end Done Maximum SD write latency: 48548 usec Unused Stack: 141 372
with: // Read ADC data. p->value = 555; //analogRead(0);
Strange..
|
|
|
|
|
Logged
|
|
|
|
|
Rapa Nui
Offline
God Member
Karma: 17
Posts: 905
Pukao hats cleaning services
|
 |
« Reply #23 on: January 25, 2013, 06:11:15 pm » |
It seems this does the trick (the original example, 115k2) : void setup() {
Serial.begin(115200); analogReference(INTERNAL);  type any character to begin type any character to end Done Maximum SD write latency: 19736 usec Unused Stack: 57 456
NA 252 0 1024 41 0 1024 47 0 1024 48 0 1024 46 0 1024 45 0 1024 36 0 1024 33 0
|
|
|
|
« Last Edit: January 25, 2013, 06:25:53 pm by pito »
|
Logged
|
|
|
|
|
0
Offline
Edison Member
Karma: 28
Posts: 1079
Arduino rocks
|
 |
« Reply #24 on: January 25, 2013, 06:22:43 pm » |
I need to think about this. I don't touch the ADC stuff.
I must go out with my wife now.
|
|
|
|
|
Logged
|
|
|
|
|
Rapa Nui
Offline
God Member
Karma: 17
Posts: 905
Pukao hats cleaning services
|
 |
« Reply #25 on: January 25, 2013, 09:01:43 pm » |
Another issue I've found - I have to use: struct FifoItem_t { uint16_t usec; // Low 16-bit of time in usec. uint16_t value; // ADC value. uint8_t error; // Overrun count since last point. }; otherwise the adc value read is not correctly passed to p->value. It seems our compiler has got a problem with passing values to bitfields ..
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Edison Member
Karma: 28
Posts: 1079
Arduino rocks
|
 |
« Reply #26 on: January 25, 2013, 09:56:26 pm » |
I don't understand. I store this counter in thread 1 // p->value = analogRead(0); p->value = nr; nr = nr < 1023 ? nr + 1: 0;
and the correct result is written to the SD. The bit field works fine. I ran it for many cycles of 0 - 1023. Why can't I reproduce your results? Edit: I now can show that only 8-bit of the ADC value get stored even though the counter works. Edit: I got rid of the bit fields and now the ADC values in the file match a fixed voltage applied to pin A0.
|
|
|
|
« Last Edit: January 25, 2013, 10:55:51 pm by fat16lib »
|
Logged
|
|
|
|
|
Rapa Nui
Offline
God Member
Karma: 17
Posts: 905
Pukao hats cleaning services
|
 |
« Reply #27 on: January 26, 2013, 01:52:43 am » |
.. you may see for example (when p->value is a bitfield): p->value = 1023; //this works p->value = analogRead(0); //this does not work, only 8bits passed p->value = temp; //this does not work, only 8bits passed
PS: now it seems to me all above issues I saw here were caused by the bitfield issue..
|
|
|
|
« Last Edit: January 26, 2013, 05:51:38 am by pito »
|
Logged
|
|
|
|
|
0
Offline
Edison Member
Karma: 28
Posts: 1079
Arduino rocks
|
 |
« Reply #28 on: January 26, 2013, 07:42:03 am » |
pito, Do you still need the call to analogReference() after changing FifoItem_t? I really would like to get to the bottom of why you need the analogReference() call. All it does is set the global analog_reference. My experience has been that things like this are a symptom of a nasty bug. uint8_t analog_reference = DEFAULT;
void analogReference(uint8_t mode) { // can't actually set the register here because the default setting // will connect AVCC and the AREF pin, which would cause a short if // there's something connected to AREF. analog_reference = mode; }
I have more cases where bit fields work and a lot where they don't. Clearly they are to be avoided.
|
|
|
|
|
Logged
|
|
|
|
|
Rapa Nui
Offline
God Member
Karma: 17
Posts: 905
Pukao hats cleaning services
|
 |
« Reply #29 on: January 26, 2013, 08:29:01 am » |
I do not need analogreference when not using bitfields.
|
|
|
|
|
Logged
|
|
|
|
|
|