Connect with us

Generic RasPi talk

Discussion in 'General Electronics Discussion' started by Gryd3, Oct 31, 2014.

Scroll to continue with content
  1. Gryd3


    Jun 25, 2014

    Unlike a microcontroller, the PI is not 'flashed' or programmed in a typical sense.
    The Pi boots from an SD card, and will run the binaries provided.
    The RasPi in easy-mode is downloading and installing a pre-made OS to the SD card and starting up the PI.
    Once booted, you can use the PI like a conventional computer with a monitor, keyboard, and mouse. You can also configure it to allow remote access via a computer using ssh.
    The vast majority of OS images for the Pi are linux based, and as such, there is a huge collection of open-source resources that can be exploited to get your Pi to do whatever you want. Programming a Pi in easy-mode is much like making a computer program, with the exception of being able to directly manipulate physical IO pins on the Pi. This is typically done with reading and writing values to special files within the OS. There are some major limitations on the Pi when used in easy-mode though... although you have access to the physical pins, you must do so through the OS... so timing specific applications can be impossible/very difficult to implement in a 'bit-baning' sense. The OSes supplied do typically come with support for various serial communication methods, so this will only rarely be a problem. (For example... communicating directly with ws2812 addressable LEDs.
    Aside from this limitation, the 'program' on your pi can be a compiled binary, or a script that the OS interprets. Language support is vast, and can be done in pretty much any language you are already comfortable with. If using a script or binary, the OS needs to be configured to run the 'program' when the device boots, and optionally watch the process to handle any errors, glitches or crashes by resetting itself or the malfunctioning 'program'.
    If you have problems finding a Pi specific solution to your programming needs, you can look at generic solutions for other Linux distributions. (Remember, the various linux distros are 'families'. Ubuntu and Mint for example are 'Debian' based, and almost all Debian solutions will work.)
    We could easily end the easy-mode programming methods here, but there is an even easier method...
    There are many graphically based programming environments that the Pi can run and use... This is more attuned to the 'robot' kits from Lego and K'nex.
    Such a programming solution is NodeRed, which is more thinking and drawing than actual coding... Of course, the further removed you are from the final code, the less control over the very very fine details you have.
  2. hevans1944

    hevans1944 Hop - AC8NS

    Jun 21, 2012
    The lack of deterministic behavior is just one of the things you give up when programs are loaded by a multi-tasking OS like Linux or Windows. The OS also has to manage the I/O to prevent conflicts among other programs executing in other threads. A real-time OS is a solution to the problem.

    In the late 1980s I was asked to design a real-time system based on the Intel 80386 family on so-called PC-AT machines. There were a lot of PC clones by then. The sponsor thought we would use the current version of Windows (which IIRC was Win 3.x), not understanding that Windows is not deterministic or even preemptive, that being a necessary but insufficient requirement for real-time operation. So my software partner and I looked around and found a real-time kernel for Unix... or it may have been a flavor of Linux. To replace the Windows GUI we selected the open-source X-Windows package. A little fine tuning of the interrupt service routines and appropriate prioritization of interrupts yielded a workable system with perhaps a dozen or so threads executing "simultaneously" in a real-time OS. It took us almost a year to get the hardware and software working to our satisfaction, but in the end it was worth it. X-Windows took some getting used to if you were coming from a Windows environment, but it turned out to work just fine. I am sure the Linux GUI has been much improved since then. All the application code was written in C with perhaps a few calls to some assembly routines, but I really don't know because I tried not to get too involved in that part of the system design and programming.

    If we had been tasked with that job even a few years earlier, it would have been implemented on a PDP-11 minicomputer, perhaps running RSX-11M but probably RT-11. I had an opportunity to study the assembly source code for RT-11, and from that I gained an understanding of how tasks are prioritized, scheduled and executed. At the time it seemed amazing to me that the computer would have any time left over to perform useful computations, but then I didn't really appreciate just how fast the little buggers executed instructions.

    Interfacing hardware to a PDP-11 running RSX-11M (our in-house choice for the OS) was a difficult because you had to modify DEC drivers for DEC I/O hardware using assembly language and OS calls. We didn't even think about building our own DEC Unibus I/O cards. I don't think we could have done it if DEC hadn't supplied software driver source assembly code for their hardware.

    With RSX-11M, it definitely was not real-time, although if you hooked some interrupts and set priority correctly it was very fast. We were mostly interfacing Aydin Controls custom video cards with on-board bit-mapping RAM to the DR-11 family of parallel I/O boards. This later turned out to be almost a complete waste of time because within a few years a PC video card could do the same things we were doing with the Aydin custom video boards.

    My thoughts on this promising future for the PC fell mostly on deaf ears at the DEC-only shop that paid my salary. I plowed ahead anyway using high-end PC video cards and PC-AT computers for hyperspectral image display and processing. It's a good thing the hardware kept pace because such applications can bring a computer to its knees. Meanwhile, many of our customers (mostly at Wright-Patterson AFB) had embraced the PC revolution, ditching minicomputers and dumb terminals for Zenith PCs. There was still a strong cadre that insisted on wiring everyone up to a central server, complete with user names and passwords, no matter how smart the end-user's terminal happened to be. This continues to this day and led to the concept of cloud computing when sufficient bandwidth became available.

    Somewhere along the way I encountered Unix and later Linux, but also became enamored with Windows. Back then you had to use a command-line interface and I hated this from my early experience with MS-DOS and RSX-11M. The software wizards loved it of course because you can write scripts that do all sorts of wonderful things from the command line. Unfortunately, I am not a software wizard. But I do have a copy of Ubuntu that I used to troubleshoot my PC-AT clone a few years ago. There is some really good code out there, freely available to download, as your two links suggest. So, I will load up an SD card with a bootable Ubuntu distro and give that Pi a try.

    I will let the Forum know when I have something to say along those lines.
    Gryd3 and KrisBlueNZ like this.
  3. Gryd3


    Jun 25, 2014
    Usually when I see long posts like this, I skim it a little or pass it by.
    I'm glad you joined this forum, as along with Yourself, and Kris, there are not many that I take the time to sit down to read a lengthy text.

    I'm sure you will enjoy what your little Pi has to offer, and if the GUI options don't work out too well for you there are other options ;)
    You can load up 'winscp' and copy/paste text files from your windows machine to the Pi securely over ssh.
    Just make sure you don't use a standard windows editor, as linux bash and shell scripts do not like the carriage-return/new-line combo whitespace characters on the end of each line.
    Grab yourself something like notepad++ or 'programmers notepad' for this and you'll be fine.

    Keep us posted on what you do! I look forward to seeing what kind of tricks you can figure out.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day