delay() function stops recordings

Hi,

I'm doing impedance measurements channel after channel and then want to wait 15 minutes and then repeat the impedance measurement cycle again and so on.
I've tried to use delay(num of msec) or with millis() but in both cases the delay got the Cyton to get stuck and it never got back to measuring impedance anymore. Do you know the reason for that? How can I introduce a stop of 15 min. in the measurement in order to save power without causing the Cyton to stop?
Thanks a lot,
Gilad

Comments

  • Hi,

    I'm using a Cyton board for long measurement using AA batteries and can't use Lithium cells.
    I'm only writing data to the SD card and I don't need to use the RFduino to send data to the computer. I wonder how much current does the RFduino consume and how can I turn it completely off and only use the SD card to save power?
    Thank you very much,
    Gilad

  • wjcroftwjcroft Mount Shasta, CA

    Gilad, hi.

    The Cyton firmware, is designed as a 'looping' Arduino-style 'operating system'. This means that for all aspects that need attending to (such as checking for input, communications, storage, etc.) -- are handled by this 'main loop', which cycles through all that must be done. When you call the Arduino delay() function, for a very long period of time, you are stopping this looping action of the firmware, thus freezing the Cyton 'operating system'.

    https://www.arduino.cc/reference/en/language/functions/time/delay/
    https://www.arduino.cc/reference/en/language/functions/time/delaymicroseconds/

    Another possible approach you could consider, is to count the number of samples in the period desired. With the 8 channel Cyton there are 250 samples per second.

    @gilad said: ...
    How can I introduce a stop of 15 min. in the measurement in order to save power without causing the Cyton to stop?

    Why do you need to 'save power'? I think I posted on your other thread regarding using arbitrarily large Lithium cells, to handle any length of time you would need.

    https://openbci.com/forum/index.php?p=/discussion/3220/cyton-long-measurement-with-batteries#latest

    Regards, William

  • wjcroftwjcroft Mount Shasta, CA

    @gilad said:
    Hi,

    I'm using a Cyton board for long measurement using AA batteries and can't use Lithium cells.
    I'm only writing data to the SD card and I don't need to use the RFduino to send data to the computer. I wonder how much current does the RFduino consume and how can I turn it completely off and only use the SD card to save power?
    Thank you very much,
    Gilad

    @gilad, hi. I also merged your separate thread asking about turning off the RFduino to save power, into this same thread. See previous comment. I don't understand why Lithium cells are not an option. They are commonly used for example when the Cyton is configured for Ultracortex headset. Regardless of what battery type you use, batteries can always be paralleled to increase milliampHours (mAh). See link above for Cyton power consumption.

  • Hi William,
    Thank you for your reply. I can't use Lithium cell since we use it for a clinical use and as much as I understand they don't have the safety regulations for that although people say they are safe.
    So is there a way to turn off the RFduino?
    I will try your suggestion for the delay.
    Thanks a lot.

  • wjcroftwjcroft Mount Shasta, CA

    Did you see my other comment regarding mAh? Why not use 3 or 4 'C' size cells? That would give you huge mAh. 3 alkaline cells is 4.5V, 4 cells is 6V. The power regulator on the board only needs 3.3V to power the processors and ADC.

    Even with the 4 AA cell configuration, (cells in series), that would typically be 2000 or 2500 mAh. 2500 / 50 (Cyton current consumption) = 50 hours =~ 2 days.

    Alkaline C cells are typically 8000 mAh.

  • wjcroftwjcroft Mount Shasta, CA

    RFduino cannot be 'turned off'. With battery figures above you have very large runtimes.

  • Hi William,
    you wrote "Another possible approach you could consider, is to count the number of samples in the period desired. With the 8 channel Cyton there are 250 samples per second."
    I tried to do it but couldn't make the arduino wait the time I wanted. Can you suggest a sample code that count the number of samples and wait 10 sec, for example, and then write to SD card again. i.e. I need a way to stop the SD card writing for a specified amount of time.
    Thanks,

  • wjcroftwjcroft Mount Shasta, CA

    Just create your own variable, say totalsamples, that is incremented each time the main loop collects a sample. Then also add a test in the main loop for when this variable reaches your target. Additionally create a flag stopSDcard, when this is true the section of code that writes to the SD is temporarily disabled.

Sign In or Register to comment.