Translate

C4 Labs Review

Zebra Black Ice Case For The Raspberry Pi

My latest open source efforts have been almost exclusively devoted to the Raspberry Pi. Over the years I have developed a strong affinity for this little powerhouse of a computer, but was never particularly pleased with the choices for housing the unit. 

I have gone from no housing at all, just letting it sit on my lab bench, to trying several of the inexpensive ABS cases available on the market.  I was never pleased with any of these choices. The "naked bench top" approach always left the computer exposed to mayhem, and the ABS cases never fit quite correctly, making installing and removing the SD cards difficult, not to mention removing the board from the cases, an exercise in frustration.

So I went on a quest for a quality case and found the C4 Labs family of products. I purchased a Zebra Black Ice case and was immediately impressed with both the physical design and the design aesthetics. You do have to assemble the case, which takes about 10 minutes, but it is well worth the effort. The case not only provides substantial protection for the RPi, but is truly a thing of beauty. Its rounded corners, and color accent make me smile each time I see or pick up the case. That is not something I had ever gotten from working with the RPi before.

The case comes with a set of heat sinks, as well as a set of soft feet. It allows access to GPIO pins, the DSI display connector and CSI camera connector. It provides for air flow on both the top and bottom, and has holes for screw mounting the case if desired.

If that wasn't enough, C4 Labs provides wonderful, personal,  customer service. I had some questions and not only were they answered and resolved quickly, but C4 Labs went over and beyond to make sure that I was satisfied. This is a rare thing these days.

I highly recommend this case for its protection, design integrity, quality construction, and aesthetics. If you too want to smile when you use your RPi, check out C4 Labs cases.

NOTE: I am not an employee of C4 Labs, nor have they solicited for this review, I am just one happy customer.


The Documentation For s2-pi has been updated and can be found here:


To install the demo code either type:

sudo pip3 install s2-pi


Or

The SmartiPi Touch

A Versatile, Five Star Solution For Mounting The Raspberry Pi Touch Display

Recently I purchased a Raspberry Pi touch display and quickly came to the realization that I needed a way to easily position and protect the display on my desk. Before checking out the various cases, I came up with the following list of must haves: 
  • Good design using highest quality components
  • Simple to assemble.
  • Be able to house my Raspberry Pi.
  • Does not require image positioning adjustment to fit the needs of the case.
After checking out all the cases available I found only one that checked all of the boxes, and that was the SmartiPi Touch case. It was breeze to assemble, holds my Raspberry Pi, is constructed of high quality materials and orients the screen in its natural position without having to diddle with rotating the image 180 degrees (some cases require you to do that!).

In addition, the SmartiPi case includes a Raspberry Pi camera case that mounts onto the main case using a Lego compatible bracket. Last week, I wanted to mount the camera on the case, only to realize that I did not have the appropriate bracket. I contacted SmartiPi to see what type of Lego bracket I needed to get.  They informed me that I should have received one in the kit of parts. and promptly sent one to me, free of charge.

With the quality of product and quality of customer service, SmartiPi is truly five star.

Python Banyan Has Been Released!


I am pleased to announce the initial release of the Python Banyan Framework. The Python Banyan User's Guide  explains how to create and run a Python Banyan application. Many of the examples operate in a standalone fashion, without the need of a Raspberry Pi or Arduino, but there are also examples demonstrating GPIO control, such as the  Raspberry Pi driven BCD Clock display, pictured above.

The framework is currently Python 3 compatible only, and will run on Windows, Linux and the Mac.

So What Is Python Banyan?

Python Banyan is a lightweight, reactive framework used to create flexible, non-blocking, event driven, asynchronous applications. It was designed primarily to implement physical computing applications for devices such as the Raspberry Pi and Arduino, but it is not limited to just that domain, and may be used to create application in any domain.
Most traditional physical computing libraries or frameworks use an object oriented model that results in a single, tightly coupled, monolithic executable image. Python Banyan uses an extension of the object oriented model, called the component based model. A component based application is comprised of a set of independent, loosely coupled modules. Functionality is easily added to a Python Banyan application, and in fact it may be added to a fully running system without the need to recompile or reboot.
Because each module is a self contained entity, applications can be created with a set of modules that use different versions of Python, and in fact, you can even add modules written in other computer languages.
In addition, the modules may be run on a single computer, or may be distributed across multiple computers running different operating systems, without having to change a single line of code.
Where Can You Find Python Banyan?

Python Banyan is located in its own Github repository and may be found here.

20 January 2017

What Have I Been Doing Lately?

My last posting was in October of 2016, and since then I have been working on moving the code and lessons I learned from the razmq project to a new project called Python Banyan. The code has been complete for some time now, but I have been struggling to get it documented. I am pleased to say that the documentation is well under way and hopefully will be complete in about 2 weeks time (hopefully shorter). You can view a draft of  the User's Guide here, but be mindful it is subject to change. 

WHAT IS PYTHON BANYAN?

Python Banyan is a lightweight, reactive framework used to create flexible, non-blocking, event driven, asynchronous applications. It was designed primarily to implement physical computing applications for devices such as the Raspberry Pi and Arduino, but it is not limited to just that domain, and may be used to create application in any domain.
Most traditional physical computing libraries or frameworks use an object oriented model that results in a single, tightly coupled, monolithic executable image. Python Banyan uses an extension of the object oriented model, called the component based model. A component based application is comprised of a set of independent, loosely coupled modules. Functionality is easily added to a Python Banyan application, and in fact it may be added to a fully running system without the need to recompile or reboot.
Because each module is a self contained entity, applications can be created with a set of modules that use different versions of Python, and in fact, you can even add modules written in other computer languages.
In addition, the modules may be run on a single computer, or may be distributed across multiple  computers running different operating systems, without having to change a single line of code.

A Little More Detail

The Python Banyan Framework consists of a single, simple base class. All Banyan compatible components inherit from this class. When a Banyan component is first invoked, it automatically connects to a common shared software backplane. All of the complexity of managing connections is hidden within and handled by the base class. All Banyan modules exchange information with each another by sending or publishing user defined protocol messages via the backplane. All routing and message buffering is automatically handled by the Framework. Each Banyan component can "publish" messages, "subscribe" to receive specific messages or both publish and subscribe messages. A Banyan component is not limited as to how many types of messages it may subscribe to.
Because Banyan messages are not computer language specific, components written in other computer Languages, such as JavaScript, can be used within a Python Banyan application. A simple JavaScript demo is provided in the examples section below.
Python Banyan takes full advantage of the ZeroMQ networking library that not only provides connectivity, but in addition acts as a concurrency framework. All of this is handled transparently by the Python Banyan base class. If your application requires additional concurrency support, you are free to choose whatever works best for your application, such as a multi-threading or a Python asyncio approach. User defined messages are prepared for transport across the network by wrapping them in theMessage Pack format.
The complexities of MessagePack are handled transparently by the base class, both for transmitting and receiving messages.

A User's Guide Is Provided. Here is what the guide covers:

Chapter 1 is an introduction to developing with Python Banyan. An application tailored specifically for this purpose will be presented in detail.
In chapter 2, a demonstration of, and a discussion about creating physical computing components with Python Banyan.
To demonstrate Python Banyan's flexibility, applications will be built from Python 2 components, Python 3 components and even a JavaScript component, all cooperating and communicating with each other within a single Python Banyan application.
Python Banyan applications may be distributed across multiple computers, all without changing a single line of code. Using the components created in this guide, all of the components will first be launched to run on a Raspberry Pi, and then then the components will be re-distributed across a Linux Unbuntu PC, a Windows PC and the Raspberry Pi without having to change a single line of code.
In Chapter 3, we will add components to control an 8x8 bicolor LED matrix connected to a Raspberry Pi. A demonstration of using Python Banyan to control an i2c device will be presented.
If you need to control multiple i2c devices sharing the same i2c pins, Python Banyan provides the concurrency support for you to do so.
Chapter 4 will discuss how to use Python's setup tools to convert a Banyan component into an executable file and have it automatically installed on the execution path.


2 October 2016

Writing The Software To Control The Raspberry RedBot 

Part 2

I have completed the bulk of the coding for razmq and the results are in!

I wanted to share this information now. The code will be published in a short while, after some cleanup and additional testing.

The following screen shots were taken on a Raspberry Pi 3 running the latest Raspbian image, Raspbian Jessie with Pixel

The first is "quiescent" mode. The pigpio daemon, pigpiod,  the xrdp  daemon and htop  are running.



CPU utilization is at 4.2% and Memory utilization is 129 of 925 MB. CPU utilization varies and can go as high as 6.1% for this scenario.

Starting all the processes that monitor and control the Raspberry RedBot we see the following:


CPU utilization rises to 6.4% and Memory utilization is 294 of 925 MB. CPU utilization varies from about 4.5 to 6.5%.

The Accelerometer (ADXL345) and the  3 Line Followers (PCF8591) are continuously streaming data via i2c in this scenario.

Finally, we run the motors at full speed. This causes the encoders to add their streaming information into the mix. The motors at full speed run at 140 RPM. Each encoder sensor generates 192 "ticks" with each wheel revolution. Since this level of resolution was not necessary for the purposes of this project, the number of ticks was throttled  by a factor of 6. So now each wheel revolution is limted to generating 32 "tick" notifications per wheel (but 192 are still being generated). This yields a 1/8 inch or 3.175 mm distance resolution that is reported on the GUI screen. Here are the results when the motors are running full speed and all other sensors and actuators are active:


CPU utilization varies from about 16% to 26% and there is no additional memory utilization while the motors are running.

Here is a screen shot of the Kivy based GUI running on my Ubuntu based desktop PC.


Let's summarize what is running when the "motor run" numbers were captured:

  1. Data is continuously being streamed by the accelerometer, 3 line followers and 2 wheel encoders.
  2. All other actuators (LED, Buzzer) and sensors (Push Button Switch, two mechanical bumpers) are ready to be activated or provide reports in a non-blocking fashion.
  3. There are currently 12 separate processes running to monitor and control the Raspberry RedBot.

Some Important Facts About The Framework Used to Create razmq

  1. Everything is written using Python 3.4.2, the version that comes with the Raspberry Pi image.
  2. All processes are activated using the lunch process launcher - simplifies the start up process.
  3. Processes may be started, stopped, added and removed at will, with no system crashes. Effectively providing a software backplane with hot swapping capabilities.
  4. Most of the processes were built using a base class that encapsulates and hides the complexities (and there really are very little) of ZeroMQ and MessagePack.
  5. For the purposes of this article, all processes, with the exception of the GUI, were run on a single Raspberyy Pi 3. However, during development some processes were run on a Pycharm IDE in Ubuntu on my desktop.  The pigpio dependent processes were remotely debugged using the same PyCharm session. 
  6. Without any coding changes, any process may be run on any computer residing on  a single LAN.
  7. Module interfaces are defined as language independent protocol messages. The messages are asynchronously published to the network and may be subscribed to by any other process. This is done by transporting the MessageQueue messages using ZeroMQ.  The result of using this mechanism is a simplified, non-blocking IPC (inter process communication) scheme with no data needed to be protected or locked. A lot more about this will also follow in a future article.
  8. The system is totally non-blocking without the need of mechanisms like the Python asyncio or threading or multiprocessing modules.
  9. Testing new modules is easy to do. Their published protocol messages may be observed in real-time using a simple monitor process. Building drivers for these modules is also quick and easy as a result of using the encapsulation base class (more on this will follow in future articles as well).
  10. All modules use a consistent and common coding pattern.

So What Does This All Mean?

The razmq project was built for a specific set of hardware actuators and sensors. However, the framework is easily adaptable to be used for other projects. New features can easily be added to existing projects and enabled on an already executing system. New projects can be created using a simple and consistent coding pattern.

The next several articles will explain in detail how razmq works and how you can use its framework in your own projects. 

Stay tuned!


Writing The Software To Control The Raspberry RedBot



18 September 2016


Now that the hardware has been completed and is in place, it is time to start writing the software. When working on a new project I like to take a "Mise en place" approach - that is getting everything organized and in place and ready to go. First I create a Github page for the project and update the Wiki pages as the project progresses. For this project, I created a Github repository called razmq

Next, I identify any additional software packages I might need and install them. The additional software requirements for razmq are identified here

After that, I  write a set of routines to exercise the hardware.- a hardware baseline so to speak. In this way, I am able to verify hardware functionality at any time.

An Experimental Software Architectural Approach

As I have done in several of my previous projects, Python 3 will be used. I believe it is better to look towards the future of the language rather than have to worry about maintaining the legacy of Python 2. 

I will still maintain an asynchronous event driven design approach, however, I would like to simplify things and provide concurrency without the use of either the Python asyncio module or the threading module. To do this, I will be dividing support for a given hardware functionality into 2 separate processes. The first process will present a "user" view of the hardware. For example, for motor control, this process will describe motor motion in abstractions such as direction and speed. These abstractions will be translated into MessagePack messages and then "published" using the ZeroMQ publisher/subscriber pattern. Another process will be created and it will be a subscriber for these messages. It will translate the abstractions into pigpio calls to directly control a motor controller device. In this way, I can maintain an abstract view of the world and swap in specific hardware at any time to implement that abstraction.

To simplify the networking connections between all of these processes, a ZeroMQ forwarder will be used. The forwarder uses a "well-known" IP address/port for all publishers to publish their messages, and another "well-known" IP address/port for subscribers to subscribe to receive messages. There are no configuration files to maintain and each process uses a consistent methodology to both publish and subscribe to messages. To make the coding easier, a base class will be provided to encapsulate many of the ZeroMQ and MessagePack details. This base class can be inherited by the classes that provide either the user or hardware view of the system. 

The experimental part of this exercise is to determine if the memory and CPU utilization is viable while having multiple concurrent processes running.

If this all seems a little abstract, in my next posting I will be describing the details of supporting a simple hardware device, the LED, using these methods. Hopefully that will demystify the described approach. It really is simpler than it sounds and provides a very flexible development environment.

Until next time ....