TATARPRO
Posts: 3
Joined: Wed May 01, 2019 9:39 pm

How to write a software to control the pi board

Wed May 01, 2019 9:50 pm

I have a raspberry pi board which I want to use for a drone project. I will want to program something like a software or OS which will be installed on the SD card of the board. Things like the camera, motors, sensors, GSM module will be connected on the GPIO pins and other devices connected to its USB ports. I will want this software to take total control of the board and control the hardware devices attached to it. Is it that what I'm looking forward to create is an OS of its own? Or just a software to be installed on the Raspbian OS? Can someone just give me a guide on how to archive this? I have some experience in embedded systems programming and also C++, I think I may be on the right path.

B.Goode
Posts: 7748
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: How to write a software to control the pi board

Thu May 02, 2019 8:00 am

Welcome to the Raspberry Pi forums.


Maybe start with a tutorial from the Raspberry Pi Foundation, like this one: https://projects.raspberrypi.org/en/pro ... -computing

Is it that what I'm looking forward to create is an OS of its own?
Very unlikely. And to some extent the fact that you ask the question probably means you don't (currently) have the skills/knowledge/ability to do it. (But that could be a reason to gain those skills if that is the way you want to tackle the project.)

I have some experience in embedded systems programming
It may be more productive to think of an RPi running an Operating System as being a full-fledged multi-user time-shared general purpose computer, rather than a 'board' that needs to be loaded with an embedded system. Although you can choose to exploit an RPi board in that latter mode if you decide to do so..

boyoh
Posts: 1272
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: How to write a software to control the pi board

Thu May 02, 2019 1:28 pm

First you must understand the Raspberry Pi is not PLUG & PLAY
To interface all your Drone sensors with the Pi, you will need
A understanding of basic electronics. This will then give you a
Better understanding of how to connect the sensors to the
PI GPIOs, there are different voltage and current levels to be
Considered, The forum will point you in the right direction
But not do the research for you, So do the research on how
The Raspberry will intake and control the sensors

Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

TATARPRO
Posts: 3
Joined: Wed May 01, 2019 9:39 pm

Re: How to write a software to control the pi board

Fri May 03, 2019 3:42 am

Ok thanks for your reply. Which means I have to install Raspbian or Linux then write all the controls there?

W. H. Heydt
Posts: 10009
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: How to write a software to control the pi board

Fri May 03, 2019 5:17 am

TATARPRO wrote:
Fri May 03, 2019 3:42 am
Ok thanks for your reply. Which means I have to install Raspbian or Linux then write all the controls there?
That's one way. You could also take a look at the Bare Metal forum to see how people write programs for the Pi without using an existing OS. On the whole, though, it's probably much less work to run Raspbian (or some other OS of your choice) and have that run your software. Now...all of that said, if--as is moderately likely--you have analog inputs and outputs or need "real time" response, you may want to look at attaching the actual sensors and actuators to a microcontroller--such as an Arduino--and then let the Pi do the decision making and issue commands the the MCU(s) as needed.

And--just FYI--the Pi has a camera connector (CSI) so you don't need to eat up GPIO pins for that.

User avatar
rpdom
Posts: 14135
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: How to write a software to control the pi board

Fri May 03, 2019 5:26 am

TATARPRO wrote:
Fri May 03, 2019 3:42 am
Ok thanks for your reply. Which means I have to install Raspbian or Linux then write all the controls there?
Well, Raspbian is Linux.

For running the drone I'd use Raspbian Stretch Lite which doesn't have a GUI installed. After all, what use is a desktop going to be when it is flying around?

But you would probably want a desktop environment with text editors and stuff for the development, so it would be better to either have two micro SD cards, one with desktop for development and testing, and one without desktop for actual running, or install the desktop and disable it when running the drone. The configuration program will let you chose whether to start the desktop or not when the system boots.
Signature is on holiday.

Icosagon
Posts: 26
Joined: Sat Apr 13, 2019 12:32 pm

Re: How to write a software to control the pi board

Fri May 03, 2019 5:58 am

Hello TatarPro

What drone are you making ? NVM :D . I have a similar project but its a rover. Python is easy but if you know c++ that will be better.

You'll need wifi(router or connect pi to a wifi) to do this

I am planning to use python sockets for controlling. And you could easily make a GUI in a program called sharp develop. You could design the gui visually using winforms and ironpython or anyother language like c++. its easy( i cant figure out how to install libraries). and You could stream the camera visuals using mjpeg streamer to a website hosted by apache.

And if you couldn't do sockets. Try ssh and curses(python library) to show sensor values and control it. There is c++ version of curses called ncurses and you could control the drone using a program like putty(ssh client program). You need to know threading to do get sensor values real time. If you want to do in c++ you could use qt creator to do this(i dont know c++ and qt so I just quit on it :lol: )

That's all Have a nice day and best of luck.

boyoh
Posts: 1272
Joined: Fri Nov 23, 2012 3:30 pm
Location: Selby. North Yorkshire .UK

Re: How to write a software to control the pi board

Fri May 03, 2019 10:09 am

You are getting a lot of advice on the soft ware side of the
Project, This you seem to understand but programs “script”
is only usfull if it as hardware to control
All the hardware you want to fit on the Drone will add weight
To It, have you taken this into consideration,

Regards BoyOh
BoyOh ( Selby, North Yorkshire.UK)
Some Times Right Some Times Wrong

TATARPRO
Posts: 3
Joined: Wed May 01, 2019 9:39 pm

Re: How to write a software to control the pi board

Sat May 18, 2019 10:22 am

Seems as if my question is not well understood. Assuming I want to create something similar to the device in most cars which have GPS and a screen on the dashboard, a map usually displays on it when requested, you can also play music at will but the interface is not minimized like in Linux and windows. Usually when the car starts, the interface opens up probably which means that hats it OS. That's the kind of thing I'm referring to. Can someone give me a guide on how to?

B.Goode
Posts: 7748
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: How to write a software to control the pi board

Sat May 18, 2019 11:34 am

TATARPRO wrote:
Sat May 18, 2019 10:22 am
Seems as if my question is not well understood. Assuming I want to create something similar to the device in most cars which have GPS and a screen on the dashboard, a map usually displays on it when requested, you can also play music at will but the interface is not minimized like in Linux and windows. Usually when the car starts, the interface opens up probably which means that hats it OS. That's the kind of thing I'm referring to. Can someone give me a guide on how to?


You have a basic choice to make.


You can write an application that runs under the control of an Operating System such as Raspbian. Raspbian, a version of Linux, provides a lot of built-in tools for dealing with the interfacing of devices like screens, audio, gps...

Or you can write your own standalone executable application that runs as the sole program in control of the RPi hardware when it is booted. But in that case you will need to provide all the code that deals with screens, audio, gps...


Edit: to add, as an afterthought, that an application builder like Ultibo https://ultibo.org/ might be useful to you?

Return to “Beginners”