Replicating the simple idea of RTOS in a smartwatch for a project

I’ve been thinking about coming up with a decent project that involves RTOS (along with queues/messages, and synchornization techniques)…preferably based on a real-life example.

I feel I’m fascinated by the idea that revolves around a producer-consumer problem where the user requests something be it sensor data, and the system services the request.

One thing that came to mind is a smart watch which has multiple features including, say, an alarm clock, different sensors, real-time clock along with a display itself.

I wouldn’t be surprised if RTOS is being used for such a device; my understanding is at least from a high level (implementation-specific but that’s how I see it): there would be a separate task for each functionality be it:

  • for an LCD display that’s responsible for reading the desired data from different other tasks, and showing it in a nice way
  • for a sensor (assuming there’s one) that’s being constantly read
  • perhaps BLE that’s responsible for sending desired data over to an app over BLE
  • for a real-time clock for updating the time on a display
  • Perhaps a push-button that, say, wakes up the screen or maybe get an
    “average” of the sensor readings till the point the button was pressed. (If not an average, just the point at which the button was pressed so the sensor task would be blocked till the flag is set in a push-button ISR for instance)

Does the idea sound doable/good enough and a legit reason to use RTOS? Is there anything else I could add to it that you could think? (my main motivation is learning but also to put something on my resume).

Since I don’t have enough hardware, I’d probably just be replicate the functionality using a breadboard for connections.

Any ideas are greatly appreciated

A basic smart-watch could certainly be done with an RTOS, though I think you’ll find most of them on the market are actually running a stripped down version of Android or iOS. There’s nothing in particular that would prevent a simple RTOS from performing the basic tasks though. Even a small microcontroller could run the full FreeRTOS kernel, in fact. FreeRTOS has been implemented on some very low end hardware.

There is absolutely nothing wrong with you learning and using FreeRTOS - and by the sound of it the project you have would be an excellent starting point since it isnt either too small or too big. There is however a few things that I learned from my hands on experience by doing both RTOS and non-RTOS based projects that you may find very useful:

  • Because you will be dealing with an RTOS, it will add additional complexity to your project. That will mean that you may need more time to figure out where things went wrong since it will be more difficult to see if the problem arose from your own code, you trying to integrate your own code with the RTOS, or because of some internal quirk of the RTOS that you werent aware of.

  • An alternative way that I personally see for your project is the use of design patterns (Software design pattern - Wikipedia) for things like message passing, synchronisation, and so on and also finite state machines (Finite-state machine - Wikipedia, and also https://www.state-machine.com/). The books that I found the best as far as the design patterns for embedded systems are “Design Patterns for embedded systems i C” (it also contains actual code examples for each of the patterns the book desctribes) and also Real-Time Design Patterns: Robust Scalable Architecture for Real-Time Systems

What I would recommend you do is to make this project by two different approaches: this way you will learn the different tools that will do the job so that you can see the advantages and disadvantages of the different tools/approaches. That would help you in the future make decisions on what tool/approach is more appropriate in the context of whatever project you are working on

I hope my experience helps you

Ilya

In a nutshell, any project that keeps you motivated and get going is good and legit, so if you think it is a good idea, first of all it is.

That said - it would not be the kind of project I’d use to learn the guts of an RTOS. A smart watch is a consumer product with a strong focus on user interaction; you’ll “compete” against products that give you super sparkling fancy UIs, including full Web access capabilities and lots of other bells and whistles. You could probably realize that, but in order to do that, you need fairly powerful hardware for which OSs that already provide HMIs are better suited.

The domain of FreeRTOS is industrial controllers with limited resources, real time requirements and at most rudimentary HMIs. With something like a smart watch, your main focus will eventually be the HMI, and while doing so, you won’t spend a lot of time diving into the guts of what FreeRTOS is best at.

But again, pick a project that keeps you personally interested and motivated.

Spot on about doing something that keeps you going. Honestly, I’m at a stage where I’m taking in suggestions cause I want to have a concrete idea prior to digging into it, at least to a certain point where it’s functional enough, and later add I could add more stuff to it.

My point here is not to compete with anyone but to come up with something that I could add to my repertoire.

I see your point about how other full blown OSes are used in smart watches, but basically I’m looking for something along the lines of a producer-consumer problem, where the user requests something be it data which they get in a form of value displayed either on a BLE-based app or an LCD.

Thanks for the suggestions, and the links! I see one of them is design patterns for Embedded Systems while the other focused more on Real-time systems. Would you suggest both of them?

It’s just I’ve been wanting to get my hands dirtier in RTOS hence why I’d incline more towards it as my first approach at least.

Also, I plan on using C++ and I see the books will have examples in C, but I think there isn’t any amazing book focused on C++ for embedded in particular on an architecture level.

Any thoughts on the project with RTOS in general?

Right, but I only plan on making a really stripped-down version of it, and was curious if the idea sounds decent with RTOS in particular

Actually the title of the second book is a bit misleading in that the only difference with the first book I mention is that it doesnt have actual code examples on how to use the design patterns that the book deals with. So it will be more on you if you also want to see the actual code examples alongside the design patterns.

Whether you decide to go for C++ or C, I hope the examples in the book will still prove to be very valuable

Well the only generic comment I will make on this is that an RTOS is just a tool to do a certain job, so you will need to learn how to use the tool, what its strengths and weaknesses are and also what projects will actually benefit from its usage (because of the additional layer of complexity an RTOS adds and because of the additional debugging youll need), and what alternative solutions may exist apart from using an RTOS. Thats why in my original post I suggested that you do the project in 2 ways: purely as a way for you to see the different tools and also what strengths and weaknesses they have so that in future projects you can make the decision based on the merits of whatever tools/solutions rather than based on popularity of a particular tool/solution.

Hope it helps

Ilya