4 ms·
> How different is it from programming the GPIO on the Raspberry Pi? Conceptually they are they same (just flipping GPIO bits), but practically you can do thin
by cellularmitosis 8y ago
> How different is it from programming the GPIO on the Raspberry Pi?
Conceptually they are they same (just flipping GPIO bits), but practically you can do things with one which you can't do with the other.
There is no operating system on an Arduino, like there is on a Pi. This means you can do much more "real-time" things on an Arduino, like bit-bang a serial port. This is hard to do on a platform with an OS, because the OS process scheduler might pull your program off of the CPU for a few milliseconds. If you need to do something to those pins 1,000 times per second or more, you're out of luck.
If you've ever seen a large scrolling LED marquee sign which appeared to have an occasional "stutter" in the scrolling, that's most likely because it was being controlled by an operating system.
- holy_city 8y agoI kinda disagree with you here. You can do bare metal (no OS) and real time (on bare metal or with an RTOS) on a Pi no problem. The difference between the two has to do with resources, architecture, and peripherals. Arduino is a low power, low cost, low memory, low speed 8-16bit microcontroller. A raspberry pi is a complete 64 bit computing system with 1-2GB of RAM and the peripherals you'd expect on most desktops. Arduino use Atmega chips while Pis use ARM cores. You need to program in a language supported by gcc for Arduino, but RPis can use the LLVM infrastructure.
- tombert 8y agoYou have me curious; how do I do baremetal on the Raspberry Pi? Which RTOS do you use?
- holy_city 8y agoThey've got a whole stickied thread on the forums about it: https://www.raspberrypi.org/forums/viewtopic.php?f=72&t=72260&sid=abfe9cd3f47665852023ed5469169727 https://www.raspberrypi.org/forums/viewtopic.php?f=72&t=7226... And I think I was totally mistaken on RTOS's, I could have sworn there was a port of FreeRTOS for the RPi but it looks like that isn't really floating around.
- SAI_Peregrinus 7y agoRTAI &/or Xenomai are RTOSes based on Linux, both support ARM. Xenomai has support for the Pi Zero, Pi 2 model B, and Pi 3 Model B[1]. I've never used it, but it's probably easier than porting another OS from scratch. [1] https://gitlab.denx.de/Xenomai/xenomai/wikis/Supported_Hardware https://gitlab.denx.de/Xenomai/xenomai/wikis/Supported_Hardw...
- devwastaken 7y agoBut on a pi, how accurate is the CPU and gpio speed? On an Arduino mega it's guaranteed to be 68.5ns give or take a tiny amount because that's how long an instruction takes for gpio bitbanging registers. This makes it possible to interface with hardware that requires this precision timing. On a pi even if you're at 700mhz constant clock, caching supposedly will mess up your timings for gpio. On top of that I haven't seen much in what the lowest stable delay is for the pi gpio.