首页 > 解决方案 > Embedded system: How to identify required tasks/threads?

问题描述

I'm studying embedded programming, so I'm new in this field. Can someone explain how to identify tasks/threads from given system description. Also, how can I estimate timing constraints, execution times... I'm really stuck.

Here is system description I'm working on:

Implement a 2 degree of freedom servo motor system. A two-axis joystick is used for controlling servo motors. Additionally, enable recording and reproducing the user path of the joystick, so that identical movement could be replicated multiple times. It is necessary to support the recording of 3 motion profiles with a length of at least 5 minutes. The profile needs to be recorded to a non-volatile memory, and the recording/playback control via the joystick button. Provide appropriate signalling for the current selected profile and operating mode (recording / playback) using one LED for each profile. In the RT-Thread system realize the necessary drivers on the Raspberry Pi Pico platform as support for the devices used and the application itself that implements the described system with clear separated threads for each of the observed functionalities.

标签: cmultithreadingembeddedreal-time

解决方案


功能分区很诱人,但在实践中,您应该根据截止日期、确定性和更新率进行分区。对于简单的系统,这可能与功能分区相同。那个部分:

为每个观察到的功能清除分离的线程

可能会导致您进行不适当的分区。然而,这可能是您的导师所期望的分区,即使它不是最理想的。

可能没有单一的解决方案,但任务的明显候选者是:

  • 操纵杆阅读器,
  • 伺服控制器,
  • 录音机,
  • 重播器。

现在考虑这些候选,可以看出摇杆控制和回放控制是互斥的,并且回放本身是通过摇杆按钮选择的。因此,将其作为一项任务是有意义的。尤其是因为回放器将以与操纵杆相同的方式与伺服控制器通信。所以你可能有:

  • 操纵杆阅读器/播放器,
  • 伺服控制器,
  • 录音机。

记录器必须是一个单独的线程,因为访问 NV 内存可能更慢且不确定。您需要在足够长的消息队列中提供时间和 x/y 位置数据,以确保记录不会影响定时运动控制。

目前尚不清楚您使用的是哪种伺服之王,或者您的应用程序是否负责 PID 运动控制或只是将位置信号发送到伺服控制器。如果是后者,则可能没有理由将伺服控制与阅读器/重放器分开。在这种情况下,您将拥有:

  • 操纵杆阅读器/回放器/伺服控制器,
  • 录音机。

其他解决方案是可能的。例如,记录器可能会随时间记录伺服位置而不是操纵杆位置,并让伺服控制器处理回放。

  • 操纵杆阅读器,
  • 伺服控制器/回放器,
  • 录音机。

如果操纵杆轮询和伺服更新率不同,这是有道理的,因为您要重播伺服器所做的事情,而不是操纵杆所做的事情。


推荐阅读