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. Development
  3. Use FreeRTOS?

Use FreeRTOS?

Scheduled Pinned Locked Moved Development
12 Posts 6 Posters 142 Views 6 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.
  • electrikE Offline
    electrikE Offline
    electrik
    wrote on last edited by
    #3

    Even with the regular bootloader you can use the pin change interrupts to wake up the avr. Some special tricks are needed when waking up though but these are easy to implement.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jenspr
      wrote on last edited by
      #4

      The mysensor-library s building some kind of own operating system ;-) It hijacks a lot of things If you want to use them, you need to know how. For example save&read from EEPROM.
      Of course it is possible to handle everything.

      FreeRTOS would set the system on a standard base.
      Mysensor could "use" the functionality of FreeRTOS including different platforms and focus on the software for radio communication, security, etc..

      But FreeRTOS is also not very easy to understand and there are some tricky things to consider. In the end is it also complicated to understand everything as soon you need to go in detail. i am pretty sure that you would have had this or other questions if mysensors would set up on FreeRTOS.

      In the end a normal mysensor node just wants to send some collected data over the air and is not doing a lot of other things in parallel.
      So I dont know if it would make it more easy or more complicated.

      Maybe it is worse a thought if somebody starts to think about mysensor 3.0?

      C 1 Reply Last reply
      0
      • skywatchS skywatch

        @cvdenzen said in Use FreeRTOS?:

        Re: The "new" Arduino Pro IDE

        Sleeping can be done on only two interrupts. I am using an Arduino ATMega 328.

        You don't define what your goal is but sleeping can be done on either of the interrupts or timer or both. If you simply need more interrupts then look at the diode matrix solution. With minicore you can then have 9 'interrupts' on digital pins and more using the analog pins if you so choose.

        C Offline
        C Offline
        cvdenzen
        wrote on last edited by
        #5

        @skywatch I would like to see the "diode matrix solution", but I cannot find it. Is it in Arduino or in MySensors?

        skywatchS 1 Reply Last reply
        0
        • J jenspr

          The mysensor-library s building some kind of own operating system ;-) It hijacks a lot of things If you want to use them, you need to know how. For example save&read from EEPROM.
          Of course it is possible to handle everything.

          FreeRTOS would set the system on a standard base.
          Mysensor could "use" the functionality of FreeRTOS including different platforms and focus on the software for radio communication, security, etc..

          But FreeRTOS is also not very easy to understand and there are some tricky things to consider. In the end is it also complicated to understand everything as soon you need to go in detail. i am pretty sure that you would have had this or other questions if mysensors would set up on FreeRTOS.

          In the end a normal mysensor node just wants to send some collected data over the air and is not doing a lot of other things in parallel.
          So I dont know if it would make it more easy or more complicated.

          Maybe it is worse a thought if somebody starts to think about mysensor 3.0?

          C Offline
          C Offline
          cvdenzen
          wrote on last edited by
          #6

          @jenspr said in Use FreeRTOS?:

          The mysensor-library s building some kind of own operating system ;-) It hijacks a lot of things If you want to use them, you need to know how. For example save&read from EEPROM.
          Of course it is possible to handle everything.

          FreeRTOS would set the system on a standard base.
          Mysensor could "use" the functionality of FreeRTOS including different platforms and focus on the software for radio communication, security, etc..

          But FreeRTOS is also not very easy to understand and there are some tricky things to consider. In the end is it also complicated to understand everything as soon you need to go in detail. i am pretty sure that you would have had this or other questions if mysensors would set up on FreeRTOS.

          In the end a normal mysensor node just wants to send some collected data over the air and is not doing a lot of other things in parallel.
          So I dont know if it would make it more easy or more complicated.

          Maybe it is worse a thought if somebody starts to think about mysensor 3.0?

          Yes, I totally agree with you. The "problem" is, that I am a big fan of real time solutions, it was the subject of my final project at school. Things won't be easier, mistakes are easily made in concurrent programming.
          I see these advantages of using a real time OS:

          • better hardware support (more interrupts)
          • nice features to support elegant real-time concurrent programming (queues, semaphores etc.)
            The disadvantages I see:
          • extra software, more complexity (download, documentation to read)
          • concurrent programming is error-prone

          I am going to spend a few hours trying FreeRTOS with MySensors for my application, it looks like there are not many people who have tried it.

          Carl

          1 Reply Last reply
          0
          • C cvdenzen

            @skywatch I would like to see the "diode matrix solution", but I cannot find it. Is it in Arduino or in MySensors?

            skywatchS Offline
            skywatchS Offline
            skywatch
            wrote on last edited by
            #7

            @cvdenzen Essentially you normally take a 'trigger' signal to an int and that's it. Fine.

            But what you can do is take a lot of signals and send each one to a different input AND use a doide from that input to the int pin. Then any signal can trigger an int and the first thing you do in your int routine is check the inputs to see which one triggered it.

            I think a RTOS would drain batteries farily quickly, wouldn't it?

            C 1 Reply Last reply
            0
            • skywatchS skywatch

              @cvdenzen Essentially you normally take a 'trigger' signal to an int and that's it. Fine.

              But what you can do is take a lot of signals and send each one to a different input AND use a doide from that input to the int pin. Then any signal can trigger an int and the first thing you do in your int routine is check the inputs to see which one triggered it.

              I think a RTOS would drain batteries farily quickly, wouldn't it?

              C Offline
              C Offline
              cvdenzen
              wrote on last edited by
              #8

              @skywatch There should be no reason why a RTOS would drain batteries quickly, one could even expect the opposite. In a RTOS there is no need to loop, it can simply wait for any interrupt to arrive. That is theory. But I suspect FreeRTOS not doing a low-power sleep, and instead simply looping the cpu. There might be possibilities to do a low-power sleep (in the loop() method).
              Connecting diodes to other pins is not very simple in my situation. I have this easypirmultisensorbox (https://github.com/EasySensors/easyPIRmultisensorsBox2) and soldering will not be easy:-).
              The PIR sensor in this thing is connected to pin 7. In the MySensors sleep method only pins 2 and 3 can be used for interrupts.
              This Arduino forum post https://forum.arduino.cc/index.php?topic=704977.0 didn't give me much hope. It is bare Arduino that already is problematic with FreeRTOS, and I guess that MySensors will make things even more complicated.
              So maybe I will take a look at dirtier solutions, like writing my own sleep method. If I don't find a solution within a few months, I might even resort to one of the worst, dirtiest and appalling software mechanism ever: polling.

              1 Reply Last reply
              0
              • Nca78N Offline
                Nca78N Offline
                Nca78
                Hardware Contributor
                wrote on last edited by
                #9

                MySensors runs on ESP32 which is based on a modified FreeRTOS. So technically you can have MySensors and FreeRTOS at the same time right now, just not on an atmega.

                https://www.youtube.com/watch?v=F321087yYy4&list=PLEBQazB0HUyQ4hAPU1cJED6t3DU0h34bz

                1 Reply Last reply
                1
                • electrikE Offline
                  electrikE Offline
                  electrik
                  wrote on last edited by
                  #10

                  I am using the Pinchange interrupts to wake up from sleeping.
                  Maybe this helps?
                  See code snippets below.

                  #include <PinChangeInt.h>  //include PinChange lib from MySensors utilities
                  

                  in setup()

                    attachPinChangeInterrupt(BotLeft_PIN, BotLeft_ISR, CHANGE);
                  

                  and in the ISR

                  void BotLeft_ISR() {
                  _wokeUpByInterrupt = 0xFE; // work-around to force MS lib to handle this interrupt
                   // more code here
                  }
                  1 Reply Last reply
                  2
                  • E Offline
                    E Offline
                    ejlane
                    wrote on last edited by
                    #11

                    Yeah, the pin change interrupt really gets you the benefit of the diode plan that was talked about, but without using the extra pin. You still have to check which pin has changed, if you have multiple pins enabled for the interrupt, but that's still the same level of work as checking all the pins under the diode plan.

                    Saves all that extra hardware/soldering as well. You just need to hook up to the input as you normally would. Though with the board you're using, maybe things are already connected, and you just need to enable things and then check the input?

                    It sounds like you're making this more complicated than it has to be. What you're asking for is already supported and is pretty easy to do. It's just part of the microcontroller and is straightforwardly part of Arduino, and therefore mysensors.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      cvdenzen
                      wrote on last edited by
                      #12

                      Yes, the pin change intgerrupt gives me what I want. The sleep call also wakes up on this interrupt, I thought it would only wake up in INT0 or INT1.

                      So for now my experiments with FreeRTOS end.

                      @electrik thanks for the hint!

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


                      19

                      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