Go Down

Topic: Arduino vs Raspberry pi. Programming language and capability? (Read 1 time) previous topic - next topic

Awaqa909

I'm confused if the Arduino uses C C# C+ C++?  Looking though the FAQ quickly, is it just functions from so and so of these languages or is there more?

Will the language I learn carry over to the PI?
I should learn to program with a Arduino first?
How much more capable of a machine is the PI over Arduino?

I would like to make some sort of cnc machine or buy a manual mill/lathe and convert it to cnc.  Or make some kind of complicated rc car/truck. (wifi)  After taking baby steps that is.

Thanks,
    Awaqa909

Fuzzyzilla

The Pi is a computer.
Arduino is a microcontroller.

There is no competition - the Pi is the more capable machine. However if you're looking to make a CNC machine, I'd suggest arduino.

This is because of simplicity -- you don't need a full powered computer for that -- It just makes things more complex.


Robin2

The RPi is a PC in a very small package an it (uusually) uses the Linux operating system. For many purposes having an operating system is very useful - especially as it allows the appearance that several complex programs can run simultaneously and it manages access to the complex peripherals such as keyboards and disk drives and screens. But because it does that it is not possible to guarantee precise timing - it might be checking for a keyboard when you would prefer it to be doing something else.

An Arduino has no operating system so it gives all of its resources to running your program. That is the reason they are used for jobs where precise timing matters - for example driving 3D printers or CNC machines or detecting the speed of a rotating shaft. The downside with an Arduino is that its clock speed is only 16MHz and an Uno has only 2000 bytes of SRAM.

Using an Arduino in conjunction with a PC or an RPI can give you the best of both worlds. I have added stepper motors to my small lathe. Most of my software is written in Python and runs on my laptop. The Arduino is only used to control the stepper motors to implement the moves calculated by the PC program.

I confess that I have not yet managed to convince myself that it would be worth buying an RPi as I can do all the "PC" programming that I need on one of my laptops which come with a screen and keyboard and an uninterruptible power supply.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

sterretje

I'm confused if the Arduino uses C C# C+ C++?  Looking though the FAQ quickly, is it just functions from so and so of these languages or is there more?
It's C/C++; you can write plain C if you want although some stuff that you normally will use is C++. E.g. Serial.print is pure C++ because the print method is overridden depending on what you print. From a 'user' perspective you use it to print a text, a number etc. In pure C, you would have a function to print a text (e.g. printText and printNumber). In pure C, you would have a function to print a text (e.g. printText) and to print a number (e.g. printNumber).


Will the language I learn carry over to the PI?
No experience with the Pi but it being Linux based it can be programmed in C++. So if you learn C++, you can use it on both systems. I however suspect that a lot of people program the Pi in Python. I can not vow for the correctness of http://www.dummies.com/computers/raspberry-pi/top-10-programming-languages-ported-to-the-raspberry-pi/ but it can give you an idea. If you learn e.g. Python or Java on the Pi, it can not be used on the Arduino.

There are a number of classes, methods and functions that are specific to the Arduino; the serial class and its methods, functions like digitalRead and digitalWrite and so on. On the Pi they will more than likely be non-existing; I found e.g. Introduction to accessing the Raspberry Pi's GPIO in C++ (sysfs) (a library might exist though)

I should learn to program with a Arduino first?
Learn the basics of C/C++ first. Whether you learn that on the Arduino or on the Pi (or even a PC) is irrelevant. Next you can concentrate on the specifics of the platform.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Robin2

Will the language I learn carry over to the PI?
Just realized I forgot to refer to this in my Reply #2

Once you grasp the concept of writing computer programs you won't find it difficult to use different programming languages.

Python is probably the most common language for RPi programming but as it is an interpreted language it could not work in the small memory for an Arduino.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

RayLivingston

The RPi is a PC in a very small package an it (uusually) uses the Linux operating system. For many purposes having an operating system is very useful - especially as it allows the appearance that several complex programs can run simultaneously and it manages access to the complex peripherals such as keyboards and disk drives and screens. But because it does that it is not possible to guarantee precise timing - it might be checking for a keyboard when you would prefer it to be doing something else.

An Arduino has no operating system so it gives all of its resources to running your program. That is the reason they are used for jobs where precise timing matters - for example driving 3D printers or CNC machines or detecting the speed of a rotating shaft. The downside with an Arduino is that its clock speed is only 16MHz and an Uno has only 2000 bytes of SRAM.

Using an Arduino in conjunction with a PC or an RPI can give you the best of both worlds. I have added stepper motors to my small lathe. Most of my software is written in Python and runs on my laptop. The Arduino is only used to control the stepper motors to implement the moves calculated by the PC program.

I confess that I have not yet managed to convince myself that it would be worth buying an RPi as I can do all the "PC" programming that I need on one of my laptops which come with a screen and keyboard and an uninterruptible power supply.

...R
A Raspberry-Pi is MORE than capable of handling the real-time aspects of CNC control - FAR more so than an Arduino.  There are plenty of Raspberry-Pi-based CNC controllers out there, including LinuxCNC, which is undoubtedly the best open-source CNC controller in existence.  The Beaglebone-Black is also widely supported.  With ~100X more computing power, and memory, there is littel the Arduino can do that an R-Pi cannot do just as well, and usually better.  And, of course, with am R-Pi and Linux, you'd be able to use an actual debugger, and numerous other very useful tools, not least of which would be true pre-emptive multi-tasking, that Arduino users can only dream of.

Regards,
Ray L.

Robin2

A Raspberry-Pi is MORE than capable of handling the real-time aspects of CNC control - FAR more so than an Arduino.
Interesting. I am certainly not going to contradict you - I am not really surprised to hear it.

However it is not a message that is widely available on this Forum - perhaps we are too short-sighted.

Its a pity I can't do the same stuff as the RPi on my laptop.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

HermannSW

Python is probably the most common language for RPi programming but as it is an interpreted language it could not work in the small memory for an Arduino.
Depends on what Arduino you look.

You can run MicroPython on Arduino Due:
https://create.arduino.cc/projecthub/AdiK/arduino-due-micropython-enabled-717dd9?f=1
https://forum.arduino.cc/index.php?topic=424405.0

Although I did do much with my DUEs, I did not try to run Micropython on Due yet.

But I do use Micropython as debug shell after eg. soldering on ESP32 module I do use with Arduino IDE normally:
https://www.esp32.com/viewtopic.php?f=2&t=3476#p16515



Last, but not least, on "Arduino vs Raspberry pi" in title of this thread. I prefer to use both, especially the Pi Zero with its v1 camera as high horse power video capturing&processing coprocessor for Arduino Due (sitting on back of caterpillar robot) doing PID motor control based on data provided by Pi Zero:
https://forum.arduino.cc/index.php?topic=412642.msg3512160#msg3512160
https://forum.arduino.cc/index.php?topic=462107.msg3236016#msg3236016
http://stamm-wilbrandt.de/en/Raspberry_camera.html

Go Up