+ Post New Thread
Results 1 to 7 of 7
  1. #1
    Advanced Member level 2
    Points: 4,164, Level: 15
    Achievements:
    7 years registered

    Join Date
    Jun 2012
    Location
    Chennai
    Posts
    647
    Helped
    61 / 61
    Points
    4,164
    Level
    15

    interrupt or rtos in microcontroller

    I'm new to RTOS. I have experience in interrupts in microcontroller. I have used it in many of my projects.

    Let's say, I have a sensor where I will process and display the value on lcd or graphic lcd. I have keypad for the menu navigation to change the parameters values. output relays to be activated or deactivated based on the sensor value. Blinking action on led. I have used interrupt for blinking of LED.

    For the above process, interrupt is enough or RTOS is required. How RTOS varies from Interrupt. I'm interested to learn it. Can you guys please explain in detail for my application.

    •   AltAdvertisement

        
       

  2. #2
    Super Moderator
    Points: 77,053, Level: 67
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,611
    Helped
    3557 / 3557
    Points
    77,053
    Level
    67

    Re: interrupt or rtos in microcontroller

    Hi,

    I'd work with interrupts.
    RTOS takes more processing power overhead.
    (But your tasks don't seem to take much processing power, thus you are free to use RTOS)
    ****

    Most of your tasks I'd process in main loop, while the timing for the tasks is interrupt controlled.

    First consider the timing for the tasks: (example)
    Scanning keys: every 50ms with hardware debouncing (every 10ms with software debouncing).
    Display update: (with previous sensor readout and value calculation): every 300ms (up to 500 ms)
    Relay switching: maybe every 100ms (or 20ms if you need it fast)
    LED blink: every 500ms (or 200ms for fast blink)

    Then let only the fastest being processed in interrupt context (5ms, 10ms, 20ms tasks),
    for all the others just set the flags in the ISR, but process them in main loop.

    Don't use busy waits at all, if possible, (better use counters in the ISR).

    Klaus
    Please don´t contact me via PM, because there is no time to respond to them. No friend requests. Thank you.


    1 members found this post helpful.

  3. #3
    Junior Member level 2
    Points: 697, Level: 5
    Achievements:
    Created Blog entry

    Join Date
    Jan 2018
    Posts
    22
    Helped
    0 / 0
    Points
    697
    Level
    5
    Blog Entries
    1

    Re: interrupt or rtos in microcontroller

    I would say it is totally depends on requirements and cost of your project.
    Above things can be manageable with interrupt. And for that you can us controlller with limited flash and with cheap controller.

    If you want to try RTOS then first thing you will need is flash and better clock frequency, which is obvious links to cost.


    As @KlausST suggested, the way how you can manage your tasks with interrupt.



    •   AltAdvertisement

        
       

  4. #4
    Advanced Member level 4
    Points: 6,247, Level: 18
    kripacharya's Avatar
    Join Date
    Dec 2012
    Location
    New Delhi
    Posts
    1,209
    Helped
    182 / 182
    Points
    6,247
    Level
    18

    Re: interrupt or rtos in microcontroller

    Quote Originally Posted by hemnath View Post
    I'm new to RTOS. I have experience in interrupts in microcontroller. I have used it in many of my projects.

    Let's say, I have a sensor where I will process and display the value on lcd or graphic lcd. I have keypad for the menu navigation to change the parameters values. output relays to be activated or deactivated based on the sensor value. Blinking action on led. I have used interrupt for blinking of LED.

    For the above process, interrupt is enough or RTOS is required. How RTOS varies from Interrupt. I'm interested to learn it. Can you guys please explain in detail for my application.
    Rtos is useful when you have many complex realtime events occuring and the 'simultaneous' nature of processing is important.

    In your case you have just a very few realtime events and actions. You can easily implement direct code to manage this.

    Just make clever use of isr's and flags/ semaphores.



  5. #5
    Full Member level 5
    Points: 4,701, Level: 16

    Join Date
    Feb 2002
    Posts
    318
    Helped
    30 / 30
    Points
    4,701
    Level
    16

    Re: interrupt or rtos in microcontroller

    I find RTOS could give a more elegant solution by separating the tasks; keyboard, sensor, LCD and using mailboxes or message queues to pass data around. It depends on your resources on your microcontroller as each tasks will require memory. You could also designed using interrupts and depending on your timing requirements, you could use a state machine or create an event driven system similar to QP framework by Miro Samek. The one good thing about RTOS, you can set task priorities. You would have to implement it yourself if you take the interrupt route. At my previous work, we chose a RTOS for the LCD for handling the buttons and animation plus controlling the drum/motor of a washing machine.



    •   AltAdvertisement

        
       

  6. #6
    Advanced Member level 4
    Points: 6,247, Level: 18
    kripacharya's Avatar
    Join Date
    Dec 2012
    Location
    New Delhi
    Posts
    1,209
    Helped
    182 / 182
    Points
    6,247
    Level
    18

    Re: interrupt or rtos in microcontroller

    Quote Originally Posted by eziggurat View Post
    I find RTOS could give a more elegant solution by separating the tasks; keyboard, sensor, LCD and using mailboxes or message queues to pass data around. It depends on your resources on your microcontroller as each tasks will require memory. You could also designed using interrupts and depending on your timing requirements, you could use a state machine or create an event driven system similar to QP framework by Miro Samek. The one good thing about RTOS, you can set task priorities. You would have to implement it yourself if you take the interrupt route. At my previous work, we chose a RTOS for the LCD for handling the buttons and animation plus controlling the drum/motor of a washing machine.
    Rtos is obviously a huge overkill for the processing elements outlined by OP. OP is still at the stage of blinking lights using interrupts. Don't encourage this path. Let him learn more about REAL time processing before adding the confusion of rtos layer.

    I don't think he's ready yet.



  7. #7
    Full Member level 5
    Points: 4,701, Level: 16

    Join Date
    Feb 2002
    Posts
    318
    Helped
    30 / 30
    Points
    4,701
    Level
    16

    Re: interrupt or rtos in microcontroller

    Quote Originally Posted by kripacharya View Post
    Rtos is obviously a huge overkill for the processing elements outlined by OP. OP is still at the stage of blinking lights using interrupts. Don't encourage this path. Let him learn more about REAL time processing before adding the confusion of rtos layer.

    I don't think he's ready yet.
    He mentioned that he has writing an application to blink LEDs with interrupts but wants to design an application using graphical LCD and keyboard. It is no harm for someone to try out different things as this is not made into a product else how would you learn. You learn by tinkering. If it was a product of course you would have to look at the costings, the hardware requirements, time to market before deciding on your software architecture. Always plan before coding in my opinion either using UML or block diagrams etc ..



--[[ ]]--