Stephen Smith's Blog

Musings on Machine Learning…

Predictions for 2018

with one comment

Introduction

As 2017 draws to a close, I see a lot of predictions articles for the new year. I’ve never done one before, so what the heck. Predictions articles are notorious for being completely wrong, so take this with a grain of salt. The main problem is that things tend to take much longer than people expect so sometimes predictions are correct, but take ten years instead of one. Then again some predictions are just completely wrong. Some predictions keep reappearing and never coming true, like Linux replacing Windows or Microsoft releasing a successful phone. I think most writers find they get a lot of readers on these articles and then no one bothers to check up on them a year later. I’ll assume this is the case and go ahead and make some predictions. Some of these will be more concrete and some will be continuing trends.

Blockchain/Bitcoin

I’m not going to make any predictions on the value of Bitcoin. The more interesting part is the blockchain algorithm behind it. This algorithm allows a method to ensure reliable transfers of money in a distributed manner. The real disruption will come when services like credit or debit cards start to be supplanted via blockchain transactions that don’t require any centralized authority. Several big companies like IBM are investing heavily in the infrastructure to support this. Right now credit and debit cards charge very high fees and many businesses are highly motivated to find an alternate solution. Blockchain offers a ray of hope to remove the transaction charge/tax that exists today on every transaction. I doubt that credit and debit cards will disappear this year, but I do predict that blockchain will start to appear in a number of business to business financial exchanges perhaps something like Walmart and their suppliers. This will be the start of a long decline for the existing credit and debit card companies unless they innovate and reduce their costs. Right now they are going the route of lobbying governments to make blockchain illegal, but like with the music industry protecting CDs they are fighting an ultimately losing battle.

AI

What we are calling Artificial Intelligence will continue to evolve and become more and more useful. We won’t reach true strong AI this year and the singularity is still a ways off, but the advances are coming quickly both on the algorithms side and the hardware to run them on. Will this be the year of the self driving car? Perhaps in small numbers. We are already seeing self driving taxis in Singapore and Phoenix. I think we are primed for this to take off big time. Some of the big cost savings will come from self driving buses, taxis and trucks. However governments still need to figure out how to alleviate the disruption to the work force this will cause. We will see more and more AI solutions rolled out in sales, inventory replenishment and scientific research. Speech, translation and handwriting recognition systems will continue to get better and better. Predictive systems that suggest movies to watch and music to listen to will get better and better. Products like Alexis and Google Home will become more widespread and their perceived intelligence will improve daily.

Privacy and Security

2017 was a very bad year for data breaches, ransomware attacks, government interference and a general trend to imposing restrictions on the Internet. 2018 will be worse. We have national security agencies like the Russians operating with immunity. We have rogue nations like North Korea launching ransomware attacks. We have the removal of Net Neutrality in the USA allowing ISPs and the government to spy on everything you do. Due to the amounts of money involved and a general lack of oversight or prosecution from governments, 2018 will set new records for data breaches, stealing of personal information, botnets and ransomware attacks.

DIY

In the early days of personal computers the Apple II and IBM PC were quite open hardware architectures with slots for expansion boards and all sorts of interface capabilities. Software was also open, interfaces were documented (either by the manufacturer or reverse engineers) and you could run any software you liked. Now hardware is all closed with no interface slots and you are often lucky to get a USB port. With many modern devices you can’t even replace the battery.

With the introduction of the $35 Raspberry Pi, suddenly DIY and home hardware projects have had a resurgence. Since the Raspberry Pi runs Linux, you can run any software you like on it (ie no regulated App store).

The Raspberry Pi won’t have a refresh until 2019, but in the meantime many companies seeing an opportunity are offering similar board with more memory and other enhancements. Int 2018 we’ll see the continuing explosion of Raspberry Pi sales and an explosion of add-ons and DIY projects. All the similar and clone products should also do well and fill some niches that the Pi has ignored.

Low Cost Computers

The Raspberry Pi showed you can make a fully useful computer for $35. Others have noticed and Microsoft has produced and ARM version of Windows. Now we are seeing small complete computers based on ARM processors being released. Right now they are a bit expensive for what you get, but for 2018 I predict we are going to start seeing fully usable computers for around $200. These will be more functional than the existing x86 based Chromebooks and Netbooks and allow you to run a choice of OS’s, including Linux, Android and Windows. I think part of what will make these more successful is that emulation software has gotten much better so you can you x86 programs on these devices now. Expect to see more RAM than a Pi and SSD drives installed. For laptops expect quite long battery life.

AR/VR

Augmented Reality and Virtual Reality have received a lot of attention recently, but I think the headsets are still too clunky and these will remain a small niche device through 2018. Popular perhaps in the odd game, not really mainstream yet.

Cloud Migration

People’s cloud migrations will continue. But due to the complexity of hybrid clouds and Infrastructure as a Service (IaaS), many are going to reconsider. Companies will rethink managing their own software installations, and just adopt Software as a Service (SaaS). Many companies will move their data centers to the cloud whether Amazon, Google, Microsoft or another. But they will find this quite complex and quite expensive over time. This will cause them to consider migrating from their purchased, installed applications to true SaaS offerings. Then they don’t have to worry about infrastructure at all. Although IaaS will continue to grow in 2018, SaaS will grow faster. Similarly at some point in a few years IaaS will reach a maximum and start to slowly decline. The exception will be specialty infrastures like those with specialized AI processors or GPUs that can perform specific high intensity jobs, but don’t require a continuous subscription.

Summary

Those are my predictions for 2018. Blockchain starting to blossom, security and privacy under greater attack, AI appearing everywhere (and not just marketing material), DIY gaining strength, dramatically lower cost computers, not much in AR/VR and cloud cycling through local data centers to IaaS to SaaS. I guess we can check back next year to see how we did.

 

Merry Christmas and Happy New Year.

 

Advertisements

Written by smist08

December 21, 2017 at 9:55 pm

On Net Neutrality

leave a comment »

Introduction

With Ajit Pai and the Republican led FCC removing net neutrality regulations in the USA, there is a lot of debate about what this all means and how it will affect our Internet. Another question will be whether other jurisdictions like here in Canada follow suite. The Net Neutrality regulations in the USA were introduced by Barack Obama in 2015 to combat some bad practices by Internet Service Providers (ISPs) that were also cable companies. Namely they were trying to kill off streaming services like NetFlix to preserve their monopoly on TV content via their pay by channel model. Net Neutrality put a stop to that by requiring all data over the Internet’s pipes be treated equally. Under net neutrality streaming services blossomed and thrived. Are they now too big to fail? Can new companies have any chance to succeed? Will we all be paying more for basic Internet? Let’s look at the desires of the various players and see what hope we have for the Internet.

Evil Cable Companies

The cable companies want to maintain their cable TV channel business model where they charge TV channels to be part of their packages and then charge the consumers for getting them (plus the consumer has to pay by watching commercials). With the Internet people are going around the cable companies with various streaming services. The cable company charges a flat (high) monthly charge for Internet access usually based on maximum allowable bandwidth. What the cable companies don’t like is that people are switching in droves to streaming services like NetFlix, Amazon Prime or Crave. Like the music companies fighting to save CD sales, they are fighting a losing battle, just pissing off their customers and probably accelerating their decline.

So what do the Cable companies want? They want a number of things. One is to have a mechanism to stifle new technologies and protect their existing business models. This means monitoring what people are doing and then blocking or throttling things they don’t like. Another is to try to make up revenue on the ISP side as cable subscription revenue declines. For this they want more of an App market where you buy or subscribe to bundles of apps to get your Internet access. They see what the cell phone manufacturers are doing and want a piece of that action.

The cable companies know that most people have very limited choices and that if the few big remaining cable and phone companies implement these models then consumers will have no choice but to comply.

Evil Cell Phone Companies

Like the cable companies, the phone companies want to protect their existing business models. To some degree the world has already changed on them and they no longer make all their money charging for long distance phone calls. Instead they charge rather exorbitant fees for cell phone Internet access. Often due to mergers the phone and cable companies are one and the same. So the phone companies often have the same Interests as the cable companies. Similarly to the cable companies without net neutrality, the phone companies can start to throttle services they feel compete with their own services like Skype and Facetime. They also want the power to kill any future technologies that threaten them.

Evil Internet Companies

The big Internet companies like Google and Facebook claim they promote net neutrality. But their track record isn’t great. Apple invented the App market which Google happily embraced for Android. Many feel the App market is as big a threat to the Internet as the loss of Net Neutrality. Instead of using a general Internet browser, the expectation is that you use a collection of Apps on your phone. This adds to the cost of startups since they need to produce a website and then  both a iOS and Android App for their service. Apps are heavily controlled by the Apple and Google App stores. Apps that Apple or Google don’t like are removed. This way Apple and Google have very strong control on stifling new innovative companies that they feel threatened by. Similarly companies like Facebook or Netflix that have the resources to create lots of Apps for all sorts of platforms, so they aren’t really fighting for Net Neutrality so much as ensuring their apps run on all sorts of TV set top boxes and other device platforms. They don’t mind so much paying extra fees as this all raises the cost of entry for future competitors.

Evil Government

Why is the government so keen to eliminate Net Neutrality? The main thing is control. Right now the Internet is like the wild west and they are scared they don’t have sufficient control of it. They want to promote the technologies like deep packet inspection that the ISPs are working on. They would like to be able to be a man in the middle in secure communications and monitor everything. They would love to be able to remove sites from the Internet. I think many western governments are looking jealousy at what China does with their Great Firewall and would love the same control. In the early days of the telephone the dangers of government abuse were recognized and that is why they put in laws that required search warrants from judges to tap or trace phone calls. Now the government has fought hard to not require the same oversight on Internet monitoring. They see the removal of Net Neutrality as their opening to working with a few large ISPs to gain much better monitoring and control of the Internet.

The mandate of the government is to provide some corporate oversight to avoid monopolistic abuses of power. They have failed in this by allowing such a large consolidation of ISPs to very few companies and then refusing to regulate or provide any checks and balances over this new monopoly. As long as the government is scared of the Internet and considers it in its best interest to restrict it, things don’t look good.

Pirates and Open Source to the Rescue

So far that looks like a lot of power working to control and regulate the Internet. What are some ways to combat that? Especially if there is very little competition in ISPs due to all the mergers that have taken place. Let’s look at a few alternatives.

Competition

Where there is competition, take the time to read reviews and shop around. Often you will get better service with a smaller provider. Even if it costs a bit more, factor in whether you get better privacy and more freedom in your Internet access. Really just money controls these decisions and a consumer revolt can be very powerful. Also beware of multi-year contracts that make it hard to change providers (assuming you actually have a choice).

VPN

in many countries VPNs are already illegal. That could happen in North America. But if it does it will greatly restrict people’s ability to work at home. As long as you can use a VPN you have some freedom and privacy. However note that most VPNs don’t have the bandwidth to use streaming video services and would likely be throttled if they did.

The Dark Net

Another option is the darknet and setting up Tor nodes and using the Onion browser. The problem here is that it’s too technical for most people and mostly used for criminal enterprises. But if things start to get really bad due to the loss of Net Neutrality, more development will go into these technologies and they could become more widespread.

Peer to Peer

BitTorrent has shown that a completely distributed peer to peer network is extremely hard to disrupt. Governments and major corporations have spent huge amounts of time and money trying to take down BitTorrent sites used to share movies and other digital content. Yet they have failed. It could be that the loss of Net Neutrality will drive more development into these technologies and force a lot of services to abandon the centralized server model of Internet development. After all if your service comes from millions of IP addresses all over the world then how does an ISP throttle that?

Use Browsers not Apps

If you access web sites more from Browsers than Apps then you are helping promote an open and free Internet. If there isn’t an app store involved it can help keep services available. The good thing is that the core technologies in the Mozilla and WebKit browsers is open source so creating and maintaining Browsers isn’t under the control of a small group of companies. Chromium and Firefox are both really good open source browsers that run on many operating systems and devices.

Summary

Will the loss of Net Neutrality in the USA destroy the Internet? Only time will tell. But I think we will start to see a lot of news stories (if they aren’t censored) over the coming years as the large ISPs start to flex their muscles. We saw the start of this with the throttling of streaming services that caused Net Neutrality to be enacted and we’ll see those abuses restored fairly quickly.

At least in the western world these sorts of bad government decision making can be overridden by elections, but it takes a lot of activism to make changes given the huge amounts of money the cable and phone companies donate to both political parties.

Written by smist08

December 19, 2017 at 7:22 pm

Fortran Lives

with 3 comments

Introduction

I was looking at a programming IDE called Code::Blocks that seems popular on the Raspberry Pi. Much lighter weight than Eclipse or Visual Studio, but it has a great deal of the same functionality including debugging, project templates, code highlighting and auto-complete. One thing that caught my interest was that Code::Blocks has direct support for Fortran programming. Back when I took first year Computer Science at UVic, all the programming labs were done in WATFIV (Waterloo Fortran IV) and then one of my Co-op work terms was at the the Institute of Ocean Sciences analysing experimental data from the Arctic, writing in Fortran using the extensive Fortran scientific and visualization libraries that were state of the art for the time (on a Univac mainframe).

One thing I noticed when playing with Machine Learning and Python programming was that if I installed something that didn’t have a binary for the particular flavour of Linux I was using then it would download the source code and compile that. What surprised me was the number of Fortran source files it would compile. Part of the reason for this is the giant library of efficient and well tested numerical libraries written in Fortran that have either been donated to the public domain or originated that way from various University research projects. It turns out that many of the popular array, numerical and algorithm libraries for Python are all written in Fortran and a large part of the popularity of Python is the easy access to all these libraries (like LAPACK).

GCC

Many people think of GCC just as the Gnu C compiler for Linux. However officially GCC stands for the Gnu Compiler Collection and supports C, C++, Objective-C, Objective-C++, Fortran, Java, Ada, Go and OpenMP. This then provides a great free cross platform compiler for Fortran that supports most of the things in the latest standard. As a result you can do Fortran programming easily anywhere including the Raspberry Pi. GCC is the compiler that the Code::Blocks IDE runs to compile your Fortran programs.

Fortran isn’t pre-installed on the Raspberry Pi, so to compile a Fortran program you need to add Fortran support to GCC which you do from a terminal window by:

sudo apt-get install gfortran

GPIO

I thought as an experiment I would port my simple flashing light program that I showed in Python and Scratch in my previous blog posting on breadboarding over to Fortran. So Python and Scratch come with GPIO libraries pre-installed and was really easy. For Fortran I didn’t see any such library, but fortunately for Unix/Linux you can usually access any hardware devices via the file metaphor. Basically you control the hardware by opening a file (usually in /dev) and then cause things to happen by writing various things to these special files. Similarly you read these files to get input or status. A good description of how to control the GPIO lines via files is given here. For instance if we want to turn on our LED we wired to pin 17, we would send 17 to the file /sys/class/gpio/export. We can do this from a terminal command line via:

echo 17 > /sys/class/gpio/export

This causes a number of files under /sys/class/gpio/glio17 to be created that we can now access. First we setup pin 17 for output via:

echo out > /sys/class/gpio/gpio17/direction

Then we turn pin 17 on via

echo 1 > /sys/class/gpio/gpio17/value

And turn it off via:

echo 0 > /sys/class/gpio/gpio17/value

Since most programming languages have file I/O libraries, under Linux this then makes most devices accessible.

Fortran Code

Creating the program was quite easy. I found a library on the Web that provides the GPIO access via the files which I’ll list later. The only problem was that the Fortran sleep function takes its parameters only in seconds so you can’t do a sub-second sleep which means the LEDs flash very slowly. Fortunately it turns out that you can call C runtime routines from Fortran fairly easily, so I include the interface to the C usleep (sleep in microseconds) function so we can use the same 0.2 second time between flashes that we used before. Below is the Fortran source code:

 

! Flash the GPIO lights
program main
  use gpio
  implicit none
  interface
     subroutine usleep(useconds) bind(C)
      use iso_c_binding
      implicit none
      integer(c_int32_t), value :: useconds
     end subroutine
  end interface
  integer i, sleepTime

  call gpioSetOut(17)
  call gpioSetOut(27)
  call gpioSetOut(22)

  sleepTime = 200000

  do i = 1, 10
    call gpioOutput(17, 1)
    call usleep(sleepTime)
    call gpioOutput(17, 0)
    call gpioOutput(27, 1)
    call usleep(sleepTime)
    call gpioOutput(27, 0)
    call gpioOutput(22, 1)
    call usleep(sleepTime)
    call gpioOutput(22, 0)
  end do
end


Fortran has evolved a bit since my University days. There are full structured programming constructs, so you don’t need to use labels. Notice the DO loop has a DO END rather than specifying a label on a CONTINUE statement as we used to do. Fortran has added good support for modules and even object oriented programming while maintaining compatibility for all those scientific libraries everyone loves so much.

Now the GPIO module which I found here. This shows how to create a nice Fortran module. It also shows some Fortran string processing. The module didn’t work for me directly, I had to add a sleep statement after allocating the GPIO pin to allow time for the files to be created or I got file access errors. Here is the code:

 

module gpio
    implicit none
    contains
    subroutine gpioSetOut(pin)
        integer, intent(in) :: pin
        character (len=35) :: unexportChar
        character (len=33) :: exportChar
        character (len=45) :: directionChar
        write (unexportChar, '("echo ", I0, " > /sys/class/gpio/unexport")') pin
        write (exportChar, '("echo ", I0, " > /sys/class/gpio/export")') pin
        call execute_command_line(unexportChar)
        call execute_command_line(exportChar)
        call sleep(1)

        write (directionChar, '("echo out > /sys/class/gpio/gpio", I0, "/direction")') pin
        call execute_command_line(directionChar)
    end subroutine gpioSetOut

    subroutine gpioSetIn(pin)
        integer, intent(in) :: pin
        character (len=35) :: unexportChar
        character (len=33) :: exportChar
        character (len=45) :: directionChar
        write (unexportChar, '("echo ", I0, " > /sys/class/gpio/unexport")') pin
        write (exportChar, '("echo ", I0, " > /sys/class/gpio/export")') pin
        call execute_command_line(unexportChar)
        call execute_command_line(exportChar)
        call sleep(1)

        write (directionChar, '("echo in > /sys/class/gpio/gpio", I0, "/direction")') pin
        call execute_command_line(directionChar)
    end subroutine gpioSetIn

    subroutine gpioOutput(pin, value)
        integer, intent(in) :: pin, value
        character (len=45) :: valueChar

        write (valueChar, '("echo ", I1, " > /sys/class/gpio/gpio", I0, "/value")') value, pin
        call execute_command_line(valueChar)
    end subroutine gpioOutput

    subroutine gpioRead(pin, value)
        integer, intent(in) :: pin
        integer, intent(out) :: value
        character (len=28) :: valueChar

        write (valueChar, '("/sys/class/gpio/gpio", I0, "/value")') pin

        open (unit=1, file=valueChar)
        read (1,*) value
        close (1)
    end subroutine gpioRead

end module gpio


One other thing, I needed to add -lgfortran as a linker option in Code::Blocks, since for some reason a freshly created Fortran application project didn’t include the link for the Fortran runtime.

Fortran Evolution

The latest standard for Fortran came was Fortran 2008 which came out in 2010. The next version will be Fortran 2018 and we’ll see if it shows up next year. GCC supports most things in Fortran 08 plus a few other enhancements. The next 2018 release is includes quite a few things including more advanced parallel processing capabilities and easier interoperability with C. Certainly Fortran has made great strides since my University days with structured, modular and object oriented programming support along with variable length string processing. Fortran really excels at parallel processing support since it is still the goto language on most supercomputers and used for all those advanced climate, astronomical and other scientific models.

Summary

I think I’ll stick to Python as my current goto language. But playing with Fortran was fun and it’s amazing to see how much usage it still gets. If you are doing serious high performance numerical processing then you are probably going to have to get your hands dirty with Fortran. Certainly the Raspberry Pi is a good place to learn Fortran with high quality free tools like Code::Blocks and GCC Fortran.

 

Written by smist08

December 2, 2017 at 4:39 pm

Retro-Spreadsheeting

leave a comment »

Introduction

I’ve been using my Raspberry Pi for retro-gaming, but I was thinking that if my Pi can run old video games for the Apple II and IBM PC then can it also run old business programs? The answer turns out to be yes, with a few notes. The developers of the emulator programs clearly claim their goal is to support gaming, but that of course most other programs will also work. But the emphasis is on user input, general processing and graphics. What is left out or secondary are more business things like printing or networking. The networking aspect would be important if you were trying to run a database server program or a multi-user program that used file locking to control concurrent access.

Anyway it turns out that many older business programs have been provided by the publisher or current own to the Internet Archive for historical preservation. So these are actually available for legal download and playing with. The Internet Archive even links to browser based emulators that can run these in a browser. In this article I’m going to be looking a bit at the history of spreadsheets and the fun fact that you can still run these and have some fun.

VisiCalc

VisiCalc is often cited as the first electronic spreadsheet program. It was originally developed and released for the Apple II in 1979 and propelled the Apple II from being a hobbyist computer into a useful business tool. VisiCalc was written in 6502 assembler and was very fast and compact. VisiCalc was ported to the IBM PC when it came out in 1981, written in 8088 assembler, it was only 27K in size. However VisiCalc was a straight port of the Apple version (including bugs) and never utilized the greater hardware capabilities of the newer PC. After Lotus supplanted VisiCalc they purchased what was left in 1985 and eventually donated VisiCalc to the Internet Archives for historical preservation. So let’s give it a try on the Raspberry Pi, running under the various Retro Pie emulation libraries. First with the Apple II. I couldn’t get it to work in 80 column mode or with lower case letters, but otherwise seemed to be working fine. I couldn’t figure out the emulator’s screen capture function so I just took a photo of my monitor.

Using VisiCalc reminded me how bad the original Apple keyboard was. It didn’t have many keys so VisiCalc used escape for backspace, and there were only horizontal arrow keys so you had to toggle between moving vertically or horizontally using the space bar.

Now let’s try it in a DOSBox to emulate an original IBM PC. Here upper/lower case work, its 80 columns and there are all 4 direction keys, so moving around is much more natural.

The PC version of VisiCalc isn’t that bad. It’s just too bad the developers spent all their time porting to different platforms and didn’t develop the feature set or recognize where the spreadsheet world was heading.

Dan Bricklin, one of the founders of VisiCalc is still around and a frequent writer and blogger. He has quite a bit to say on technology evolution and the history of VisiCalc and Lotus. You can check out his web site here. One thing he points out is that because VisiCalc was so popular, that anyone entering the market had to be compatible so Lotus 123 had to read VisiCalc files seamlessly and it ended up copying VisiCalc’s expression language and structure pretty closely. As a result no VisiCalc customers were orphaned or abandoned since they could easily and seamlessly move to Lotus 123 and then Excel and now Google Sheets. If you do play with VisiCalc, it’s worth having a look at the reference cards that Dan posted here.

Lotus 123

With the advent of the original IBM PC with better hardware (mostly more memory for programs to run, but with the original 640k limit), the stage was set for someone to supplant VisiCalc who just did a straight port. Enter Lotus 123 in 1983 which claimed to be a spreadsheet, graphics and database program (hence the 123). The database claim was rather dubious but the graphics claim of producing business charts and graphs from your spreadsheet data was groundbreaking for the time. The first couple of versions of 123 were written in 8088 assembler and went around the BIOS and DOS to access the hardware directly. This made the program blazingly fast. Eventually 123 was supplanted by Excel and Lotus was bought by IBM in 1995 for a whopping 3.5Billion. IBM donated some early versions of 123 to the Internet Archives. I tried downloading and running 1.0a. This was a good version to play with since I didn’t have to install anything, I could just run it directly from the original floppy disk image. Below is a photo of my screen running Lotus 123 1.0a on my Raspberry Pi under the RetroPie MS-DOS emulator.

Trying to view graphs didn’t work in the emulator, I suspect this oldest version of 123 expects a graphics mode that the emulator hasn’t spent much time on (ie pre-VGA and probably pre-EGA).

Lotus 123 lost the battle when the world went to GUIs and Microsoft’s Excel became the new defacto spreadsheet program. IBM shutdown 123 development in 2014 and put this program to bed for good. Of course migration from 123 to Excel is painless so no one was left in a lurch due to this.

What’s Next?

A common question is: As 123 supplanted VisiCalc and as Excel supplanted 123, what’s next? I think one thing to be aware of is that Lotus 123 was dominant for a long time and its decline was slow. I think the seeds of replacing Excel are already sown. Now Microsoft isn’t just a one product company so it can keep Excel (and Office) going for a long time, but the contribution of Office to the bottom line is going down and Microsoft is looking to other areas for proper growth (like Azure). It might not be that there is just one replacement, since spreadsheets are used for many things, at different groups of users may take different paths. Some of the alternatives are:

  • Cloud based like Google Sheets. These offer much better collaboration and your data is kept safe in the cloud. You can run these on all your devices from your phone to your workstation. Many would argue that Microsoft is doing well here with Office 365, but I think Office Online is an also ran to Google Sheets just as Lotus 123 for Windows was an also ran to Excel.
  • Free software. LibreOffice is now really good and does most things people need. Why would anyone pay for Office when LibreOffice is there. Note that LibreOffice is also pre-installed on the Raspberry Pi.
  • Per device specialist. For instance Apple has Numbers which is freely available for all their devices as an app or for other platforms as a web app. This is very tailored to Apple devices and many will use this since it is usually pre-installed.
  • Specialty apps. People don’t seem to be going in for big giant programs anymore. The in thing are small task specific apps that typically run on a mobile device. For many tasks rather than use a spreadsheet, people just install a specialty app from their app store to get the job done.
  • Accounting apps. Many accounting companies like Xero, Sage or Intuit have extremely easy to use entry level products. Much of the use of spreadsheets is to keep simple general ledgers. People perceived using proper accounting apps as too difficult or too expensive, but this is no longer the case. Similarly most banks have really good web interfaces that give you most of what you need.
  • Machine learning and advanced analytics. This field has also moved away from spreadsheets and into more sophisticated tools and often more pure code  solutions. Much advanced analytics is now performed in R or Python since the quantity of data has overflowed spreadsheet usage.
  • Digital assistants, perhaps you don’t need to calculate with a spreadsheet anymore. Now you can just ask your digital assistant a question and get an answer. Digital assistants can have access to your accounting data and other data to give an answer without you needing to know formulas or type in any data. You can even type questions or formulas into Google directly and often just get a good answer. Its really good at metric conversions and other common tasks.

Summary

Playing with retro-business apps is almost as much fun as playing with retro-games. It’s certainly fun to be able to run all these older programs under emulation on my Raspberry Pi. It is also amazing how performant they seem and what a good job the open source communities that work on these emulators have done.

There are many other spreadsheet programs that you can play with, but I chose these two since I actually used them and they were industry leaders in their time. Some of the other abandoned spreadsheets include SuperCalc, Multiplan, T/Maker, Symphony, Jazz, Improv and Quattro Pro. But there is only so much time and this is already quite a long article.

Written by smist08

December 1, 2017 at 12:13 am

Playing Music by Writing Code

leave a comment »

Introduction

The standard Raspbian Linux for the Raspberry Pi comes with an interesting program called Sonic Pi. This program lets you create music by writing code, the goal is that the coding is easy enough that anyone can learn it, and that you can code fast enough to play a live performance by writing the code as you go along, including jamming with other musicians. From my coding experience there is always a lot of pressure to write code faster, but here you need to write the next bit of code and stay on beat.

I was interested in this, primarily to use as a drum machine to accompany by very beginner guitar playing. Basically something a bit more interesting than a metronome. Sonic Pi will run on Windows, MacOS and Linux, but one of the goals of the program was to be as accessible as possible, so hopefully even low income school districts or third world countries can afford a Raspberry Pi or two.

Learning to Code

Like many programs on the Raspberry Pi, Sonic Pi is a backdoor way to try and get kids to learn how to code. Writing code to create music has been around since electronic synthesizers became digital, but how to do this was quite technical and required a lot of (then) expensive equipment. Sonic Pi comes with a lot sampled sounds so you can go quite far without a good sampler.

The programming language is based on Ruby and can do some quite powerful things. The emphasis in Sonic Pi tends to be on fairly straight forward functional programming and it recommended that you only use what is documented for Sonic Pi, but people have discovered hidden Ruby features that work if you try them.

The Sonic Pi language is described as a strongly timed language (a play on other strong typed languages) since music is all about timing and Sonic Pi is brilliant in how it keeps everything in time.

The language keeps things simply, so hopefully if a student can think musically then they can transfer that skill into programming via the Sonic Pi language. The hope being that this is a more interesting entry point to programming than say learning sorting algorithms.

The program is designed to be interactive, have lots of help and typical IDE type features like auto-complete. There is a vibrant online community and tons of examples. Additionally there is a free book available here.

Live Performances

People actually use their Raspberry Pi running Sonic Pi as a musical instrument. This isn’t just running a program they wrote previously for people to listen to. This is actually writing the code as people listen. It isn’t always a solo performance either, it could include jamming with other musicians either playing Sonic Pi or playing regular musical instruments.

The key part of the language to support this is the live loop, where you have a loop playing the music (or code) and it allows you to update the code and have the new code seamlessly take effect whenever you like without causing a break in the music.

This usage is often called live coding and there are actual clubs that have events where this happens called algoraves.

It’s hard to explain this, but if you check out some of the YouTube videos of such performances it’s easy to get the idea. A good introduction is Sam Aaron’s presentation at OSCON on how to start coding and playing Sonic Pi. Here is a Sonic Pi performance covering Daft Punk. Here is a jam session with a guitarist. And another example.

Some Code

At the most basic level you can get some noise out of Sonic Pi just by running the one line program:

play 100

This just plays a beep which decays to nothing. You can add another note with:

play 100
play 75

This actually plays the two notes at the same time, since the program doesn’t stop and wait for the first note to finish. To play the two notes one after the other we would do something like:

play 100
sleep 1
play 75

The notes are actual midi numbers from 0 to 254. The following diagram shows how they relate to the notes from a piano keyboard.

Beeps are all well and good, but you can get much more interesting notes by playing the built in samples. For instance:

sample :bd_haus
sleep 1
sample :ambi_choir

We aren’t very musical yet, but if we put it in a live_loop then it will play over and over.

live_loop :mySong do
    sample :bd_haus
    sample :ambi_choir
    sleep 1
end

Now we’re playing music and with the live_loop we can modify the code and when we hit run it seamlessly starts playing the new code allowing us to perform live by writing code.

Rather than including a lot of source code in this article, for more examples I’ll just provide a couple of links. Note that if you Google around, there are a lot of Sonic Pi samples that you can have a look at. A good little drum machine bit of code is this one. Since Sonic Pi is based on Ruby you can use Ruby string processing to convert ascii drum tabs into music as done here.

Summary

Sonic Pi is a pretty cool program. Basically you get a fairly sophisticated music synthesizer with your inexpensive Raspberry Pi. It’s fun to play with, and perhaps will motivate a few more kids to pick up coding. After all if you do learn how to program in Ruby with this, then you are well on your way to being a highly employable Ruby on Rails web developer. Combined with Scratch, the Raspberry Pi really offers some innovative ways to teach coding to students.

Written by smist08

November 25, 2017 at 9:25 pm

Retro-Gaming on the Raspberry Pi

with one comment

Introduction

Retro-gaming is really popular right now as exemplified by how hot the Nintendo SNES classic gaming systems are which outsold both the PS4 and XBox One last month. However you can put together a similar gaming system with a Raspberry Pi, some game controllers and a bit of software. This isn’t as easy as just buying an SNES Classic, but you get access to way more games, and games on way more platforms. In this article we’ll start to look at the retro-gaming world on a Raspberry Pi system.

RetroPie

RetroPie is a bit of glue that combines many open source gaming projects into one system that is easy to install and get running. It includes dozens of emulators for many older gaming system from Nintendo, Sega, Atari, Colecovision and Sony. It also includes dozens of emulators for older computer systems including Apple II, Atari ST, Commodore 64 and Amiga, Radio Shack TRS-80, MS-DOS, Apple Macintosh, Amstrad, ZX Spectrum and the TI-99. Its really amazing how many of these old systems have active communities creating and maintaining these emulators. Many are configurations of some overarching all in one emulators, but nevertheless it’s amazing what you can run.

You can configure the system to give you a menu of games to run, or to just autorun one particular game on startup. The system also prefers getting all input from the game controller (which could be a keyboard). Combined these allow people to build their own arcade game boxes.

There is quite a community of DIYers building these themselves from scratch, along with all sorts of kits being available. The other nice thing is that nearly everything in the Raspberry Pi marketplaces is quite affordable.

Controllers

Although you can use a keyboard to do most things it isn’t ideal. You will probably want a proper game controller fairly quickly. Fortunately these are readily available and quite cheap. Note that out of all the systems that are emulated, most had different controllers, so you probably want a controller close to your favorite system, or you might like to buy a collection of  controllers.

Another reason to use a game controller is that if you use the keyboard, then some game controllers require mapping a lot of keys to buttons and this can then interfere with keyboard usage if it is used as well (more for computer emulations like an Apple II or Commodore Amiga).

Games

So what games can you play? The easiest games to play with Retropie are the games that can be installed from the Retropie package manager. These are all open source games that have been ported to the Raspberry Pi (ie they are natively compiled for the ARM processor). You might think yuck, open source games aren’t good. But you would be wrong, because several software publishers have open sourced their old games as an act of goodwill to their fans. These include games by ID Software including Doom, Quake and Castle Wolfenstein. I found all these games work exceedingly well and I enjoy playing them again.

Next if you install the SNES emulator from the package manager, it is now installed but has no games and there aren’t any games for this in the package manager. This then leads us into the murky world of abandonware. Basically there are websites that contain games from companies that no longer exist. After all how many Atari ST or Commodore Amiga game publishers are still in business? These sites have downloads for many games that you can copy to the Raspberry Pi and run. I say murky because copyright law in different countries have different views on the legality of copyrighted materials, when the copyright holder is no longer around. Anyway you can make your own judgement. If you do have an old SNES system for instance and play games you own then many people consider this ok too. Anyway this topic is up to you. But pretty well every old game you can think of is available this way.

Computers

With the computer emulations, you can just run games like the console games, but these tend to be a bit more problematic, since you need to deal with multiple floppy disks (usually hard disks don’t work for games), and many games have copy protections or non-standard disk drivers that can mess up the emulation, so results will vary. I found you can get quite a bit working but it tends to take a bit of fiddling with settings to make things work.

The other cool thing you can do with the computer emulators is just run the old computer software. For instance I used to have an Apple II+ computer that I bought with the money from my first University coop work term. It’s fun to just run Applesoft in the emulator and play with good old Applesoft Basic again. One interesting thing is that by default the emulator is configured to run at ¼ speed. This is so the games play about the same as on an original Apple IIe. This shows how good the emulator is that is can emulate an Apple running 4 times the speed of the original on a little $35 piece of kit.

Summary

Retro-gaming is a lot of fun and you can certainly waste a lot of time. They don’t have the high resolution realistic graphics that you can get out of a modern computer with a graphics coprocessor, but a lot of these games were groundbreaking and a lot of the actual gaming elements haven’t changed. If you have an inkling to play old arcade games like Space Invaders, Dig Dug or Ms. PacMan then this is a great way to play around. A lot of these emulators will run on regular PCs or Macs, but there is something fun about doing it on a little 35 dollar Raspberry Pi.

 

Written by smist08

November 22, 2017 at 4:23 pm

Breadboarding with my Raspberry Pi

with 5 comments

Introduction

One of the cool things about the Raspberry Pi is that it has a set of general purpose input/output (GPIO) pins. Many Raspberry Pi starter kits (including my Canakit) come with a breadboard and few simple electronic components you can play with. In this article I’ll talk about connecting up some LED lights and controlling them from both Python and Scratch. Below is a bit of a hazy picture of my Raspberry Pi hooked up to the breadboard and a Scratch program running.

Here is a closer look at the breadboard with a few LEDs and resistors connected.

You don’t need to do this for many standard tasks, after all the Pi has four USB ports, Wifi, Bluetooth, HDMI, sound/composite video and ethernet ports. But the GPIO port is great for electronic enthusiasts, hobbyists and educators to get their hands dirty playing with electronic components.

Hooking up an LED

Each GPIO pin can be individually controlled and will provide 3.3V when activated. It is then specified to keep the current under 16mA or you can damage the circuits. My kit came with a number of 220 Ohm resistors and by Ohm’s law these would case the current to be 3.3V/220Ω = 15mA, so just right. You need to have a resistor in series with the LED since the LED’s resistance is quite low (typically around 13 Ohms and variable). I connected 3 LEDs and for each LED you connect a wire from a GPIO pin (in this case I used 17, 27 and 22) to the positive lead of the LED then you connect the negative side to a resistor and the other side of the resistor to the -3.3V line on the breadboard. Really quite simple.

Python

It’s quite simple to control the GPIO pins via a Python package. You just need to import RPi.GPIO and you can get going. This package came pre-installed so all I had to do was write some lines of code and away it went. Basically I just need to set the mode for since the package supports a few different boards and chipsets, then configure the pins I’m using for output. Then I just need to turn the LEDs on and off. You need to add some sleep statements or the whole thing executes faster than you can see.

Scratch

Scratch is a very simple and visual programming language/environment developed by the MIT Education Department. It is used to teach programming to students as young as in kindergarten. It is really amazing the animations and games that kids can produce with this system. It comes pre-installed on the Raspberry Pi and you can also control the GPIO pins with it, just like you can in Python. You have to run the GPIO server from the edit menu and then you use the broadcast statement to control the GPIO functions. Here is the Scratch version of the simple Python program displayed above.

More on the GPIO

The GPIO has 26 pins, two are +3.3V, two are +5V, 5 are ground and then that leaves 17 as general GPIO pins.

In the same way we configured the pins for output to control LEDs you can configure them for input and then for instance read the setting of a switch.

However this isn’t all there is to GPIO, besides the functions we’ve talked about so far, which are rather limited, a number of the pins have “alternate” functions that you can select programatically. For instance pins 3 and 5 can support the I2C standard that allows two microchips to talk to eachother. There are pins that can support two serial ports which are handy for connecting to radios or printers. There are pins that can support PWM and PPM which are handy for controlling electical motors.

Summary

The Raspberry Pi 3 is a very versatile device. It runs a most Linux software and has a very flexible architecture allowing it to interface to a great many devices. It has four USB ports, Wifi, Internet and Bluetooth. Plus there is the general purpose GPIO bus that allows a great deal of flexibility to interface the Pi to almost anything. That is why you see Raspberry Pi’s built as the brains of drones, robots, home security systems, information kiosks and so much more.

 

Written by smist08

November 15, 2017 at 9:14 pm

Posted in raspberry pi

Tagged with , ,