Last Monday, on Australia Day, I had a meeting with a company to discuss a project. I can’t say a lot about what was discussed but suffice to say that it is an automation project. The meeting went on for over 3 hours – what is required, what could be achieved, can I do it, what can I do, etc. We want to be able to see what switches are turned on and do something with this knowledge. It would be microcomputer based of course – what automation project is not about micro’s? Now, these things are already on the market, but is it really necessary to “reinvent.it“? Yes, if you want to put your name on it, and own the design – you should!
We decided to work with the Raspberry Pi (RPi) – which some of you will know, is a little credit card sized computer, with a System on Chip (SoC). There are a number of versions of this, but essentially, it is like a desktop computer without the desktop. It has memory, a SD card slot, network interface, hdmi output and a couple of USB ports. Oh, I have a Model B on hand, and it is low power, I use my phone charger to power it through the micro-usb port.
The RPi also has a number of general purpose input/output ports – which will come in handy since these are where the signals will come in. For a small number of inputs, we can just poll them – i.e. check each one to see if it is active, but for a larger number – this can be cumbersome especially if there are time constraints. I knew that I would be needing interrupts to handle the inputs. The RPi will also be running a version of Linux, which will also have the Python interpretive/scripting language installed, hence this would be a good choice.
Anyway, after discussions, I said that I would be able to come up with a PoC (Proof of Concept) in a week’s time. I would need a couple of days for research, i.e. google, then a few more days to do some circuit design and programming, not being familiar with Python. On Thursday I rang the company and made a few corrections on our initial assumptions, now armed by my research, and confirmed that I would be on track with a working concept by Monday.
So, now we are at Monday, I have a RPi connected to a breadboard with a number of dip switches, which will simulate our inputs. Yes, that is a tooth pick next to it for size comparison – and I use it to press the tiny switches. A fair bit of time was spent working out how to do things in Python – a very powerful language. Some more time was spent in coding so that we can put the parameters in lists to avoid hard coding. When communicating with the GPIO ports, we can use either pin numbers or port numbers. I chose to use pin numbers since that way I can confirm that I am connecting a particular switch to a particular pin. The software works out how to translate the pin number to the actual GPIO port, so all I have to do is to refer to the inputs as being 1, 2, 3, 4, etc. I don’t have to worry about 1 being actually 7, or 2 being 11, etc.
More software testing was done in order to determine its performance, how many inputs could be checked if polling the ports were done, etc. This is to get an indication of the maximum polling rate – we won’t use polling, though, but it is to get an idea, so we know how long things could take at worst if polling was used.
Also, the RPi doesn’t have a realtime clock – I will need to add one, but that won’t be necesary for this PoC – isn’t that great? The PoC is ready, and it’s running on a SoC. Just waiting until the company can come in and see it in action, so in the meantime, I can relax and think about more code enhancements.
[Note] I also had a look at Copyright’s and Intellectual Property rights – this is quite a complex area. But anyway, if I write the software, then I own the copyright – but if I am employed by a company, then the company owns the copyright, or if this done for the government, then the government owns the copyright. Whew! Did you know that a circuit board cannot really be copyrighted? We could claim the copyright on the artistic and literary works of the circuit board though, but it can be difficult to prove and doesn’t really stop anyone from making something similar – maybe that’s why some boards come with the important bits covered in epoxy. However, all is not lost because usually, the secret is in the way the program works, and this is copyrighted. Python is used for the PoC, but for production, this would be C++ most likely.