loading

Can't the Raspberry Pi Multi-task?

I've seen a lot of tutorials showing how to do this or that cool thing with your Raspberry Pi, but I haven't seen any tutorials showing how to do several things at once with the device. For instance, is it even possible to control a stepper motor and servo motor all on one Pi?

sort by: active | newest | oldest
By definition Linux is multitasking, Simple as double clicking on one program and the double clicing on the next.
Command line.
with bg and fg you can send programs to the background whil they do their thing and then use fg when you want need that process back.
This should work also.
$ command @

But what I think your asking if you can multitask within a program. You can if you set up a loop to service all you want to control in sort of a round robin so that cpu services sending the stepper motor a command then go service the servo motor. with a command then repeat everything again. sort of simulated multitasking. You have to plan it out real well.
gmoon4 years ago
It's possible to "do several things at once," even with a simple microcontroller (and no OS at all). Schedule the CPU time yourself--either within loops, or use interrupts...
BradysoBOT (author) 4 years ago
Thank you for your replies! Ok so it's possible, but it seems as though that most of these projects end up using most of the Pi's available ports. Is that true? and if so, what do you do in that case?
Expand the I/O ports ! The Pi provides an SPI interface, with twin chip selects - that's basically extendable infinitely. There's also an I2C interface and 8 GPIO lines, you could a whole chemical plant on the thing.
...and a UART
BradysoBOT (author)  steveastrouk4 years ago
Wow there is a lot to learn about this. Thank you for your help. :-)
Of course its possible. Its running all the hardware with an operating system. What you perceive as a single task is actually only one of dozens happening "simultaneously". You have to understand though, that unless a chip offers multiple cores, its actually only doing one thing at a time, and switching what its doing hundreds of times a second.
kelseymh4 years ago
It runs Linux, so it can do multiprocess operations, where the processes are automatically swapped in memory by the operating system, or are activated by interrupt. You should certainly be able to launch tasks to control multiple devices, provide each device is connected to a separate I/O port.