Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. My Project
  3. nRF5 action!

nRF5 action!

Scheduled Pinned Locked Moved My Project
1.9k Posts 49 Posters 630.9k Views 44 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • rmtuckerR rmtucker

    @NeverDie
    No the nrf5 has a rtc.(Real time Counter)
    It can even keep time while sleeping.(just found this out myself!).
    That is a great leap forward on the arduino.

    rmtuckerR Offline
    rmtuckerR Offline
    rmtucker
    wrote on last edited by
    #756

    Try it just print the time out then put it to sleep for a minute then print the time out again.

    rmtuckerR 1 Reply Last reply
    0
    • rmtuckerR rmtucker

      Try it just print the time out then put it to sleep for a minute then print the time out again.

      rmtuckerR Offline
      rmtuckerR Offline
      rmtucker
      wrote on last edited by rmtucker
      #757

      The problem must be this line but i don't speak nrf5.:frowning:

      			// (1000/32768)<<12 == 125
      			MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2);```
      rmtuckerR 1 Reply Last reply
      0
      • rmtuckerR rmtucker

        The problem must be this line but i don't speak nrf5.:frowning:

        			// (1000/32768)<<12 == 125
        			MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2);```
        rmtuckerR Offline
        rmtuckerR Offline
        rmtucker
        wrote on last edited by rmtucker
        #758

        The only other thing it could be is the deletion of this line in the commit.

        
        nrf5_rtc_event_triggered = false 
        
        1 Reply Last reply
        0
        • d00616D d00616

          @NeverDie said in nRF5 Bluetooth action!:

          Thanks! I just now ordered one of your boards so that in the future we can share a common platform for comparing numbers.

          Ok. I have measured my Ebyte with the same sketch and in the µA range of my VC165 multimeter. Sleep current is 9.9µA with two ports in INPUT_PULLUP and one Port in OUTPUT_H0H1 mode. (b.t.w. this module costs actually 3,82€)

          @scalz said in nRF5 Bluetooth action!:

          in that case, you need to set it as a floating input i think, like it's generally at reset.
          In datasheet, section 20 (p111), is explained how works the GPIO. You have a Bit for disconnecting it. See the PIN_CNF[n] registers. For instance, p.140, you can see how it looks for the P0.10, and the Bit 1.
          This should do the job..

          Should I add a DISCONNECTED mode to hwPinMode()?

          rmtuckerR Offline
          rmtuckerR Offline
          rmtucker
          wrote on last edited by
          #759

          @d00616

          MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2);

          Should be:-

          MY_HW_RTC->CC[0] = max(((ms << 12) / 125), 2));

          rmtuckerR mfalkviddM d00616D 3 Replies Last reply
          1
          • rmtuckerR rmtucker

            @d00616

            MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2);

            Should be:-

            MY_HW_RTC->CC[0] = max(((ms << 12) / 125), 2));

            rmtuckerR Offline
            rmtuckerR Offline
            rmtucker
            wrote on last edited by
            #760

            @d00616

            Just checked and it now returns 10002 for a sleep(10000).
            Much better after the above alteration.

            1 Reply Last reply
            0
            • NeverDieN Offline
              NeverDieN Offline
              NeverDie
              Hero Member
              wrote on last edited by
              #761

              Epilog: I made the changes so that just prior to taking a measurement the sense pin is hwPinMode'd to an input pin, and then immediately after the measurement I disconnect it. Seems to be working, and without the usurious power drain I was experiencing previously. :)

              rmtuckerR 1 Reply Last reply
              0
              • NeverDieN NeverDie

                Epilog: I made the changes so that just prior to taking a measurement the sense pin is hwPinMode'd to an input pin, and then immediately after the measurement I disconnect it. Seems to be working, and without the usurious power drain I was experiencing previously. :)

                rmtuckerR Offline
                rmtuckerR Offline
                rmtucker
                wrote on last edited by
                #762

                @NeverDie said in nRF5 Bluetooth action!:

                Epilog: I made the changes so that just prior to taking a measurement the sense pin is hwPinMode'd to an input pin, and then immediately after the measurement I disconnect it. Seems to be working, and without the usurious power drain I was experiencing previously. :)

                Good news
                So what is the current usage now when sleeping?

                NeverDieN 1 Reply Last reply
                0
                • rmtuckerR rmtucker

                  @NeverDie said in nRF5 Bluetooth action!:

                  Epilog: I made the changes so that just prior to taking a measurement the sense pin is hwPinMode'd to an input pin, and then immediately after the measurement I disconnect it. Seems to be working, and without the usurious power drain I was experiencing previously. :)

                  Good news
                  So what is the current usage now when sleeping?

                  NeverDieN Offline
                  NeverDieN Offline
                  NeverDie
                  Hero Member
                  wrote on last edited by
                  #763

                  @rmtucker said in nRF5 Bluetooth action!:

                  @NeverDie said in nRF5 Bluetooth action!:

                  Epilog: I made the changes so that just prior to taking a measurement the sense pin is hwPinMode'd to an input pin, and then immediately after the measurement I disconnect it. Seems to be working, and without the usurious power drain I was experiencing previously. :)

                  Good news
                  So what is the current usage now when sleeping?

                  About 6ua on this particular Ebyte nRF52832. I'm pretty sure it would be higher on my other Ebyte nRF52832, though I haven't measured it again. Haven't tested any additional ones as of yet.

                  1 Reply Last reply
                  0
                  • rmtuckerR rmtucker

                    @d00616

                    MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2);

                    Should be:-

                    MY_HW_RTC->CC[0] = max(((ms << 12) / 125), 2));

                    mfalkviddM Offline
                    mfalkviddM Offline
                    mfalkvidd
                    Mod
                    wrote on last edited by
                    #764

                    @rmtucker very nice work, thanks for locating the problem.

                    It occurs because 12/125 will be evaluated before the bit shift. http://en.cppreference.com/w/c/language/operator_precedence for details.

                    1 Reply Last reply
                    1
                    • rmtuckerR rmtucker

                      @d00616

                      MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2);

                      Should be:-

                      MY_HW_RTC->CC[0] = max(((ms << 12) / 125), 2));

                      d00616D Offline
                      d00616D Offline
                      d00616
                      Contest Winner
                      wrote on last edited by
                      #765

                      @rmtucker said in nRF5 Bluetooth action!:

                      MY_HW_RTC->CC[0] = max((ms<<12 / 125), 2);
                      Should be:-
                      MY_HW_RTC->CC[0] = max(((ms << 12) / 125), 2));

                      Thank you. This was the result of merging some commits. I haven't seen I reversed that change. I had tested the code before merging some commits into one.

                      Actually I check the result of sleep(511999) and sleep(512001). When it's finished I fix that in MySensors.

                      1 Reply Last reply
                      0
                      • scalzS scalz

                        for unused pins, it should be floating, not pullup. set the pin register you need to 0x02.
                        Something like that
                        NRF_GPIO->PIN_CNF[ulPin] = 0x02;
                        that will put pin in same state like it's on reset. Everything disabled/default, floating, with disconnect bit set.
                        (see datasheet gpio).

                        @d00616 said in nRF5 Bluetooth action!:

                        Should I add a DISCONNECTED mode to hwPinMode()?

                        make sense to have it for input too.. i agree :simple_smile:

                        d00616D Offline
                        d00616D Offline
                        d00616
                        Contest Winner
                        wrote on last edited by
                        #766

                        @scalz said in nRF5 Bluetooth action!:

                        @d00616 said in nRF5 Bluetooth action!:

                        Should I add a DISCONNECTED mode to hwPinMode()?

                        make sense to have it for input too.. i agree

                        What's the best name for this mode? DISCONNECTED or INPUT_DISCONNECTED. I prefer the first variant.

                        I have to play a little bit with the port modes. Maybe it saves some current when the serial port pins are put into the disconnected mode while sleeping.

                        scalzS 1 Reply Last reply
                        0
                        • d00616D Offline
                          d00616D Offline
                          d00616
                          Contest Winner
                          wrote on last edited by
                          #767

                          @d00616 said in nRF5 Bluetooth action!:

                          Actually I check the result of sleep(511999) and sleep(512001). When it's finished I fix that in MySensors.

                          Is fixed in development branch.
                          https://github.com/mysensors/MySensors/pull/917

                          1 Reply Last reply
                          0
                          • d00616D d00616

                            @scalz said in nRF5 Bluetooth action!:

                            @d00616 said in nRF5 Bluetooth action!:

                            Should I add a DISCONNECTED mode to hwPinMode()?

                            make sense to have it for input too.. i agree

                            What's the best name for this mode? DISCONNECTED or INPUT_DISCONNECTED. I prefer the first variant.

                            I have to play a little bit with the port modes. Maybe it saves some current when the serial port pins are put into the disconnected mode while sleeping.

                            scalzS Offline
                            scalzS Offline
                            scalz
                            Hardware Contributor
                            wrote on last edited by scalz
                            #768

                            @d00616 said in nRF5 Bluetooth action!:

                            @scalz said in nRF5 Bluetooth action!:

                            @d00616 said in nRF5 Bluetooth action!:

                            Should I add a DISCONNECTED mode to hwPinMode()?

                            make sense to have it for input too.. i agree

                            What's the best name for this mode? DISCONNECTED or INPUT_DISCONNECTED. I prefer the first variant.

                            I have to play a little bit with the port modes. Maybe it saves some current when the serial port pins are put into the disconnected mode while sleeping.

                            agree too for the first one should be enough :simple_smile:
                            yes, for lower power consumption, better disconnect pins which are not needed.
                            it's the same for a simple 328p though (setting the right pin states).

                            1 Reply Last reply
                            0
                            • NeverDieN Offline
                              NeverDieN Offline
                              NeverDie
                              Hero Member
                              wrote on last edited by
                              #769

                              As a follow-up to rmtucker's line of inquiry, what is currently the shortest deep sleep that's supported? Is it one millisecond, or something else?

                              rmtuckerR d00616D 2 Replies Last reply
                              0
                              • NeverDieN NeverDie

                                As a follow-up to rmtucker's line of inquiry, what is currently the shortest deep sleep that's supported? Is it one millisecond, or something else?

                                rmtuckerR Offline
                                rmtuckerR Offline
                                rmtucker
                                wrote on last edited by rmtucker
                                #770

                                @NeverDie
                                Theoretically it is 2 clock ticks at 32768khz so 0.000061035secs i think.
                                But how long it takes to go into sleep mode and come out of sleep mode i am not sure.
                                But of course the sleep function only allows millis.

                                1 Reply Last reply
                                1
                                • NeverDieN NeverDie

                                  As a follow-up to rmtucker's line of inquiry, what is currently the shortest deep sleep that's supported? Is it one millisecond, or something else?

                                  d00616D Offline
                                  d00616D Offline
                                  d00616
                                  Contest Winner
                                  wrote on last edited by
                                  #771

                                  @NeverDie said in nRF5 Bluetooth action!:

                                  As a follow-up to rmtucker's line of inquiry, what is currently the shortest deep sleep that's supported? Is it one millisecond, or something else?

                                  Why do you need this type of short sleeps?

                                  Sleep is for battery powered devices. A device that wakes up more than 1000 times in the second might be hard to drive with a battery.

                                  @rmtucker said in nRF5 Bluetooth action!:

                                  @NeverDie
                                  Theoretically it is 2 clock ticks at 32768khz so 0.000061035secs i think.

                                  This is correct.

                                  But how long it takes to go into sleep mode and come out of sleep mode i am not sure.

                                  It's simple to evaluate with micros() before and after a sleep().

                                  1 Reply Last reply
                                  1
                                  • NeverDieN Offline
                                    NeverDieN Offline
                                    NeverDie
                                    Hero Member
                                    wrote on last edited by NeverDie
                                    #772

                                    I haven't yet upgraded to the current version, so maybe this is moot (?), but the following code in a loop:

                                      digitalWrite(TEST_PIN,HIGH);
                                      sleep(100); // Sleeps for 100ms
                                      digitalWrite(TEST_PIN,LOW);
                                      sleep(100); // Sleeps for 100ms 
                                    

                                    holds the TEST_PIN first HIGH for 250ms and then LOW for 250ms. That means 150ms of sleep overhead, which seems like a lot.

                                    I measured the length of time the TEST_PIN is HIGH or LOW using an oscilloscope. Ran it on an Ebyte nRF52832.

                                    NeverDieN 1 Reply Last reply
                                    0
                                    • NeverDieN NeverDie

                                      I haven't yet upgraded to the current version, so maybe this is moot (?), but the following code in a loop:

                                        digitalWrite(TEST_PIN,HIGH);
                                        sleep(100); // Sleeps for 100ms
                                        digitalWrite(TEST_PIN,LOW);
                                        sleep(100); // Sleeps for 100ms 
                                      

                                      holds the TEST_PIN first HIGH for 250ms and then LOW for 250ms. That means 150ms of sleep overhead, which seems like a lot.

                                      I measured the length of time the TEST_PIN is HIGH or LOW using an oscilloscope. Ran it on an Ebyte nRF52832.

                                      NeverDieN Offline
                                      NeverDieN Offline
                                      NeverDie
                                      Hero Member
                                      wrote on last edited by
                                      #773

                                      Nevermind. I just now upgraded to the current versions, and it seems to be fixed.

                                      1 Reply Last reply
                                      1
                                      • NeverDieN Offline
                                        NeverDieN Offline
                                        NeverDie
                                        Hero Member
                                        wrote on last edited by NeverDie
                                        #774

                                        So, with the current libraries and an Ebyte nRF52832 that's using its external crystal oscillator, I'm now measuring the sleep overhead as being 260us. I expect that may be even less if using the internal 32768Hz resonator.

                                        1 Reply Last reply
                                        0
                                        • NeverDieN Offline
                                          NeverDieN Offline
                                          NeverDie
                                          Hero Member
                                          wrote on last edited by NeverDie
                                          #775

                                          I tried measuring the sleep overhead with the Ebyte nRF52832 running on its internal resonator, and surprisingly it wasn't that much faster: it appears to be about 220us.

                                          Here's the test script:

                                          #include <MySensors.h>
                                          
                                          #define TEST_PIN 19  // (P0.19) 
                                          
                                          void setup() 
                                          {
                                            hwPinMode(TEST_PIN, OUTPUT_H0H1);  
                                            digitalWrite(TEST_PIN, LOW);  
                                          }
                                          
                                          void loop() {
                                            digitalWrite(TEST_PIN,HIGH);
                                            sleep(1); // Sleeps for 1ms
                                            digitalWrite(TEST_PIN,LOW);
                                            sleep(1); // Sleeps for 1ms  
                                          }
                                          

                                          Here's the scope capture:
                                          0_1504148461469_NewFile1.jpg

                                          Of course, this assumes (?) that the mcu sleeps for exactly 1ms, and during the extra 220us it is either ramping down or ramping up.

                                          BTW, I don't anticipate sleeping for a mere 1ms at a time. However, to get a good measurement of the overhead using the oscilliscope I had to set the sleep period that low.

                                          I can, however, well imagine having a use for sleep periods lasting 100ms.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          16

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • MySensors
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular