Running kubernetes on a 10 node Raspberry PI cluster

Introduction

In this article I designed and build a 10 node PI cluster. The specs of this cluster are not bad. The cluster consists of:

  • 5x Raspberry PI3B+ 4 cores 1.2Ghz (Broadcom BCM2837 Cortex-A53)
  • 5x Raspberry PI4 4G 4 cores 1.5Ghz (Broadcom BCM2711 Cortex-A72)

The specs of the cluster:

Total Storage (Gb)    : 320
Total RAM (Gb)        : 25
Total CPU Cores       : 40 
Total Cpu Ghz         : 13,5 
Max Power consumption : 130 Watt

In this article I’m going to describe what my plans are for this cluster. And while the title is a dead give away, I’m not going into technical depths. If this article is going to be to long I’ll split the article up in multiple articles.

What to do with all this power?

Having the cluster up and running, it’s time to do something with it. One of the goals I have to learn is CI/CD pipelines. I have a small personal Gitlab server running. The goal is to use CI/CD pipelines with Kubernetes. And now that I have a 10 node cluster, this should be possible.

Running Kubernetes on Raspberry PI

While it’s possible to run Kubernetes on Raspberry PI, there are a couple of things to consider. And that is that most of the development being done is for major platforms like AMD, Intel etc. This means that for ARMhf and ARM64 a lot of things won’t work out of the box.

Another things to consider is: Kubernetes itself is not designed to run on a low powered platform like the Raspberry PI. However there are some Kubernetes flavors which focus on lightweight Kubernetes, by reducing for example the memory footprints. More on this later on. The bottom line is: Yes it is possible to run Kubernetes on Raspberry PI. There are however some caveats.

What is this Kubernetes anyway?

To get a overview of what Kubernetes is and what is does take a look at: What is Kubernetes – an overview The gist of it is that Kubernetes can be seen as a framework which allows the deployment of applications in containers, and to manage these containers and providing scaling and fail-over for the application being deployed.  Also note that Kubernetes is also revered to as K8s, by stripping the 8 letters between K and S of Kubernetes. So don’t pronounce this as K eight, but pronounce it as: Kubernetes.

Starting with Kubernetes

Wanting to run Kubernetes on my Pi cluster is one thing. Actually getting to run it is quite a different story. So how to get Kubernetes running? Basically there are a couple of challenges hidden in this question. The first one is: Which flavor of Kubernetes to run, and the second one is: How to learn Kubernetes.

Which flavor of Kubernetes to run?

There are a couple of lightweight Kubernetes to choose from. Some of these allows you to run Kubernetes inside docker on your local machine for example K3d , Minicube. For the Raspberry Pi I investigated the following two:

    • Microk8s
    • K3s

Before installing Kubernetes onto a Raspberry PI notes to choose a 64bit OS. The reason for this is that most of the (docker) containers are for 64 bits OS’es. Therefore I used Ubuntu server (LTS) 64 bits for Raspberry PI. Normally I would use Rasbian, or Raspberry OS as it is called now, but since their 64bit version is still in beta during the time of writing I switched to Ubuntu server.

Let’s get started with MicroK8s

As the first candidate I installed MicroK8s. The reason for this is that the installation instruction sounds really simply. Install MicroK8s, and off you go. As it turns out, it was not that simple, and eventually I had to give up on MicroK8s, simply because I could not get is stable.

After I installed MicroK8s I noticed that after a couple of hours, the whole cluster was not responding to kubectl commands. All I get was timeout errors. Rebooting nodes was not helping. I did a lot of searching, and browsing through the issues on MicroK8s issues, and I did find that others where experience the same problems on Raspberry PI’s, but no solution.

So after two weeks of fighting I give up upon MicroK8s, and moved on to the next option

Installing K3S on Raspberry PI cluster

According to the documentation the name of K3s comes from:

We wanted an installation of Kubernetes that was half the size in terms of memory footprint. Kubernetes is a 10-letter word stylized as K8s. So something half as big as Kubernetes would be a 5-letter word stylized as K3s. There is no long form of K3s and no official pronunciation.

Installing K3s can be completely done by using k3s-Ansible. Which is perfect fit, since I do a lot with Ansible. After cloning the repository I Fowwloed the instruction (which basically tells you to change the host.ini file and hostvar file and to run the ansible playbook).

And right from the start I could tell that K3s was much more stable. I could  deploy applications, and could remove them, and even after a couple of days the cluster was stable. Since the default version installed is v1.17.5+k3s1 I decided to upgrade the cluster. Due to my inexperience with Kubernetes, K3s and how to upgrade I manged to completely destroy my beautiful working cluster. So I started over, flashing all my SD cards with Ubuntu server, ran my own Ansible playbook to install the basics, and installed the latest version of Rancher’s K3s. And to my relieve everything works perfect. The cluster runs stable.

So in conclusion: Microk8s sounds great, and I really wanted to use it, but couldn’t get it stable to run. Keep in mind that at this point I have no experience with Kubernetes, so your mileage may vary. Thanks to Ansible-k3s repository I could get K3s up and running quickly. At this point I’m not interested in the details on how to install and configure Kubernetes. In case of K3s it’s one binary anyway. At this point I’m mainly interested in getting Kubernetes up and running and start learning on how to use Kubernetes.

Learning Kubernetes

Now that Kubernetes is up and running where to start learning? I came across the Kubernetes 101 series done by Jeff Geerling. I highly recommend watching his  Kubernetes 101 YouTube video’s. I learned a lot watching these video’s and give me some basics to get me started.

In the next article I’m going to describe how I got Gitlab CI/CD pipelines working with my Kubernetes cluster.

An easy extensible Raspberry PI Cluster

Introduction

For quite some time I want to play around with a PI Cluster. Of course “cluster” can mean many things. A Cluster can be combining all the CPU power of the nodes, to get more processing power. A cluster can also mean having couple of nodes to build a scalable platform like OpenStack. In this case, the purpose of the cluster isn’t that important. The thing I’m mainly interested in is build a frame which can hold a couple of PI’s. And the frame should be easy to extend, so that when there is a need for more PI nodes in the cluster, the frame is can be easily extended. At the end I came up with a working frame. However this implementation might not be suitable for everyone… More on that later on.

How this all started

With a friend of my we started to build a 20 node PI cluster. The cluster was split into two: 10 Nodes lived in my home, and the other 10 nodes lived by my friends house. We used a VPN to connect the cluster nodes together. This worked great. However when we used PI3 nodes, we needed cooling. And the current frame didn’t provide that. After a attempt to alter the frame to add cooling FAN’s I realized that it might be better to start from scratch. The reason for that was during the cluster was operational, we discovered the current frame could be improved by adding some features.

Designing the ultimate cluster

Well the “ultimate” is maybe a bit strong.. but since I wanted to redesign a cluster from scratch I decided that at least the following features must be implemented:

    • The nodes must be easy to remove or easy to be inserted into the cluster
    • The frame itself should be 19 inch so it could fit in a standard network rack
    • The nodes should be powered from a own power supply, and should NOT rely on PoE
    • The frame must be easy to extend
    • Each node should have proper cooling
    • It would be nice that each node has some LED’s to display status (preferred RGB LED’s)

Tackling the power requirements

Powering each node from a power supply is the hardest part to implement. After thinking about it I came to the conclusion that I could do this by developing a back-plane. This back-plane is then used to distribute the power from one Power Supply (PSU) to all the other nodes. This sound like a great idea. However it introduces a new problem:

How can I make a easy extensible frame when there is a back-plane. The answer to that problem was quite easily actually: by splitting the back-plane up into smaller back-planes. This is how I came up with a back-plane design which can hold two PI nodes, and can be extended by adding more back-planes together. And as it turns out: splitting the back-plane up into smaller back-planes also makes the manufacturing of the PCB easier.

By using a back-plane design it’s easy to come up with a PCB for each node , which would provide the interconnect between the PI node and the back-plane. Which makes it possible to remove or insert a PI node.

Tackling the cooling

Next thing problem to tackle was: How to keep the PI node cool, so that the CPU won’t overheat and throttle. I soon came with the idea to develop a PI Cluster HAT. This Cluster HAT solves a couple of other problems:

  • The HAT can be used to hold a FAN to cool the CPU (PWM controlled)
  • The HAT can be used to distribute the 5V to the back-plane
  • The HAT can also be used for other features:
    • Hold the connections for 3 RGB LED’s so they can be controlled by GPIO pins
    • Break-out I2C
    • Break out serial RX and TX
    • Break out 3V

Developing the cluster frame

Within three months I had the first version of a 10 node cluster working. It would take me another six months to get it to a a workable version. The final design uses 3 PCB’s:

  • A back-plane PCB with can power 2 PI Nodes and which are extensible.
  • A PI Cluster HAT with a lot of features (EEProm, PWN controlled FAN, 3 RGB LEDS, I2C, 3V, 5V power lines)
  • A Power board which connects the power of the PI node to the back-plane
  • A LED Board which holds the 3 RGB LED, which connects to the PI Cluster HAT

The frame of the cluster has mainly two parts: The frame which holds the PI tray. And the PI tray which holds the PI, the PI Hat with FAN, the Power Board and Led Board. The whole design is modular.

The downside of this is: To build this cluster frame, a lot of parts are needed, and the PCB’s must be soldered. So that’s why this might not be for everyone. However…

OpenSource is the way to go

Did I mention this whole design is OpenSource? No?? Well it is. And it’s on github for everyone to download. All the 3D models, Gerber files , schematics, a full hardware assembly guide is available. You can find it here

Working on a older project – making a frequency counter

  Introduction

Since the Corona virus pandemic I got some more free time on my hands in the weekend and decided to blew off the dust from a project I was working on. This project involves designing and making a frequency counter. This project is more about learning on how to make a modular design.

The frequency counter modules

The frequency counter has the following modules:

      • A main board which holds all the modules, the counter itself and the display buffer
      • A Divider module. This modules controls the gate time (which can be set in three steps)
      • A Micro Controller (uC) module. This module controls the multiplexing of the display as well as other features such as handling the button pushes on the front panel. (there are two buttons)
      • A Display module. This module holds the 7 segment displays as well as  a max7219 which takes care of the multiplexing.
      • A power module which provides power to the frequency counter. This module is yet to be designed.

The things I wanted to improve

In the first versions the modules used wires to interconnect with the main-board. In this version I wanted the modules to interconnect to the main-board directly, without using wires.

Secondly I wanted to reroute the PCB’s. Since the start of the project I used auto router to route the traces. Since it was one of the first PCB I created. Since I learned a lot more about PCB design I decided to route all the trace manually.

And I wanted to learn more about SMD soldering so I decided to change some IC’s from a DIP package to a smd package. Which means I had to swap connections to other pins, since the pin numbers are not always the same.

And last I wanted to have the ability to mount the display on to the main-board.

 

Testing the changes made

Once the new PCB’s were in, I started to solder all the IC and other parts. Once completed I realized that I didn’t think about adding a ISP header on the uC board.

So I had to improvise:

First soldering the wires to the micro controller

And finally after connecting all the wires together I could hook up a Arduino UNO as a ISP programmer. And could flash the boot loader. After that I could use the program header to upload the firmware.

The end result

And this is how the end result looks like. I didn’t have cleaned the board, since I’m still testing, but to my surprise the counter was working the very first time. And the result looks like:

Fun with Ebay purchases

Introduction

A lot of the stuff in my lab comes from Ebay. Simply because this kind of equipment is hard or impossible to find in Europe. And if you find it, the seller is asking big money for it. Buying overseas is not cheap either, due to import taxes, and shipping costs.

And buying from Ebay has some risk to it. Of course, if you pay with Paypall, there is the “money back guarantee”. Most of the times this means shipping back the item

, and depending on the seller the shipments must be payed. If you buy stuff from Ebay you know all of this.

Most of the times however, it’s okay and there are no problems. And sometimes you find yourself in a situation which is just baffling.

What about a 54845A Infiniium Oscilloscope?

For some time I was looking for one of these. And I found a Ebay listing, made a best offer, which was accepted. For $1350,00 dollars the scope was mine. The scope was advertised as a working scope. So all in all it’s still on the high side. These scopes aren’t the best. But for what I have in mind it’s more then good enough.

And then the scope arrives

After a week and a couple of day waiting the scope was delivered. And well the package wasn’t that great. The scope could move around inside the box, which is bad. I wish that people sending equipment would learn to pack equipment so it can’t move around, with enough protection around all sides. In this case I feared the most. Luckily the scope itself was wrapped in a good amount of bubble wrap, and it didn’t destroyed the box it was in.

After unpacking and turning it on, the scope refused to boot. Due to a bad CMOS battery it want’s me to press F1 on the keyboard. And luckily a keyboard was included, so after hooking on the keyboard, and pressing F1, the scope booted into Windows, and started the scope application. The first impression was not that good. But if this was all.. I’m not complaining..

Self test time!

While the scope was booted I noticed some strange flickering and weird behavior while channel 1 was enabled. I disabled channel 1, and it looked good… for a while then some other glitches I could not explain. Hmm let’s do a self test.  And the self test failed on Video SRAM. And the second time  did a self test it failed on: “Tri State trig”. This points into the direction of a board called “A6”,which is a scope interface board.

It’s dirty… real dirty

So maybe the card has bad contacts, so I decided to remove the case, and take a look inside. And that is when I noticed a lot of dirt. I have seen dirt in machines, but this is really bad. I cleaned most of it. Cleaned the A6 board, and sprayed some Deoxit on the contacts. and reinstalled  the board. Unfortunately, the problem stayed.

Time to contact the seller

Now knowing that there is a problem with the scope I contacted the seller, which replied with: “I”ll see what I can do, and else send it back and you get a refund”.

After a good night of sleep I decided that sending the scope back in the original package, would be the end of the machine. The package would hold a second time. And I don’t have other packing materials. And it also means shipping costs, and the value of the dollar and euro.. so in the end it will cost me money, even if I get a refund. So I started to look online for a A6 board and could find one for 50 dollars. Which I bought. I let the seller know what I did to get the scope going. I also told about the state the scope is in, and that it’s not good. But that I went ahead and invested 50 dollar for a A6 card. The response I got was.. well i didn’t know if a should cry or laugh. the exact response was:

“All I can say is wow! That is amazing. Can’t thank you enough for doing that. I’m hoping it works out!”

Errr.. I don’t know how to respond to that.

Self calibration

I went ahead and tried to calibrate the scope by using the self calibration process. This is a straight forward process. It only takes some time to complete.

When I started the self calibration tool, it looks like the previous calibration seems to have failed on channel 2. Not a good sign. This is just the kind of problems I’m afraid of. These scopes have hybrid ADC’s. And it they fail, or there is some problem in the front-end.. it can be very hard to fix, and very costly.

And of course when I tried to calibrate the scope ,it failed. A lot of effort later by cleaning the hybrids the calibration process finally end successful. So now I only have to wait for the “A6” board, which is hopefully a working board, and I only have to swap the board, which is not very complicated.

In conclusion

When buying stuff on Ebay, there is always a risk that the item bought isn’t exactly what is advertised.And yes I could have shipped it back, and got a refund. However due to the state of the packaging I know for sure the scope wouldn’t make it in one piece. And spending 50 dollar seems the cheapest option. And the last thing I wanted was ending up in a discussion about a scope which was damaged during shipping.

To summarize: This scope was advertised as working, however:

      • Didn’t boot due to a dead CMOS battery (easy fix)
      • A6 board is defective (bad SRAM)
      • The machine wasn’t cleaned, and if I didn’t had to open it.. I would not know about the dirt inside.. which could easily destroyed the machine due to lack of cooling.
      • Calibration failed on channel 2. Luckily I could fix this. But this could have been a major problem.

This machine should have been listed as “untested for repair or parts”. If such a machine as this was advertised as such I wouldn’t even considering buying. It took a lot of time and to get it to a point of a good working scope. But I rather would have spend this time on the project I’m working on where I need the scope for in the first place.

Installing PyVisa on MacOS 10.14.6 (Mojave)

Installing PyVisa on MacOS 10.14.6 (Mojave)

In this article I had some trouble installing the NI-VISA library for py-visa. So this article is a quick update on that. This article describes what I did to test the NI-VISA library. And honestly I don’t know why it was not working.

First of all, when testing the installation of pyvisa with:

>>> import pyvisa
>>> rm = pyvisa.ResourceManager()
>>> rm.list_resources()

Make sure the equipment connected to the USB GPIB adapter is on. If the connected equipment is not on, you get a empty list of resources back.

Testing the NI-VISA library

The first thing I wanted to know was: When the NI-VISA library is not working, is that due to some configuration?

Testing can be a little annoying since when you reinstall the library, or de-install and (re)install you have to reboot your machine.  And I didn’t want to mess around to much, with the risk I wrecked some black magick library configuration. Which might be almost impossible to fix.

So I figured: Why not unpacking the installation package, and try the driver within the package directly ?

Unpacking a .pkg file under MacOS is really simply. First mount the Downloaded .dmg package. In my case: NI-VISA_20.0.0.dmg

Once it’s mounted, I changed to my home-dir, and created a test directory.

cd ~
mkdir test-nivisa
cd test-nivisa

Next I copied the installation package (NI-VISA_Full_20.0.0.pkg) to this test dir:

cp /Volumes/NI-VISA\ 20.0.0/NI-VISA_Full_20.0.0.pkg ./test-nivisa

Unpacking (or expanding) the install package is really easy:

pkgutil --expand nivisai.mpkg/.packages/NI-VISA_Full_20.0.0.pkg ./unpack

Note that the unpack dir is created during expanding the package. So don’t create the dir upfront! If you do the command fails with:

pkgutil --expand NI-VISA_Full_20.0.0.pkg ./unpack
Error encountered while creating ./unpack. Error 17: File exists

In the test dir where the package is unpacked, a lot of other packages can be found.  One of these packages contains the library which I’m after. However all the packages contains a file called “Payload” which is a gzipped tar file.

To unpack this file for each package, the find command is our friend:

cd unpack
find ./ -name 'Payload' -exec tar xzvf {} \;

This will unpack every Payload file in your current directory. Since the “v” flag is enabled (verbose) this outputs a lot of text (files which are untarred) There is a chance this will overwrite files, but this is not something I’m worried about, as long as I can use the NI-VISA library.

This library is called “VISA”, so a second find command is needed:

find ./ -name 'VISA'

Which gives the result:

.//VISA.framework/Versions/A/VISA
.//VISA.framework/VISA

Once I had the library I tested this with Pyvisa. This can easily be done in a virtual environment (not since I already tested this, the package pyvisa is already installed):

python3 -m venv env
pip install pyvisa
Requirement already satisfied: pyvisa in /Users/edwin/.pyenv/versions/3.7.3/lib/python3.7/

python3
Python 3.7.3 (default, Dec 4 2019, 15:11:28)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyvisa
>>> rm = pyvisa.ResourceManager('./VISA.framework/VISA')
>>> rm.list_resources()
('GPIB0::9::INSTR',)
>>>

As can be seen on the last line:

('GPIB0::9::INSTR',)

The NI-VISA library works just fine. The actual library lives in:

/Library/Frameworks/VISA.framework/VISA

So I created a file .pyvisarc in my home dir (notice the dot (.) in front of the file!

This files contains:

cat ~/.pyvisarc
[Paths]
VISA library: /Library/Frameworks/VISA.framework/VISA

So know when I use pyvisa-info (pyvisa-shell) it works as well. pyvisa-info gives:

pyvisa-info
Machine Details:
Platform ID: Darwin-18.7.0-x86_64-i386-64bit
Processor: i386

Python:
Implementation: CPython
Executable: /Users/edwin/.pyenv/versions/3.7.3/bin/python3.7
Version: 3.7.3
Compiler: Clang 10.0.1 (clang-1001.0.46.4)
Bits: 64bit
Build: Dec 4 2019 15:11:28 (#default)
Unicode: UCS4

PyVISA Version: 1.11.3

Backends:
ivi:
Version: 1.11.3 (bundled with PyVISA)
#1: /Library/Frameworks/VISA.framework/VISA:
found by: auto
bitness: 64
Vendor: National Instruments
Impl. Version: National Instruments
Spec. Version: National Instruments
py:
Version: 0.5.1
ASRL INSTR: Available via PySerial (3.4)
USB INSTR: Available via PyUSB (1.1.1). Backend: libusb1
USB RAW: Available via PyUSB (1.1.1). Backend: libusb1
TCPIP INSTR: Available
TCPIP SOCKET: Available
GPIB INSTR:
Please install linux-gpib (Linux) or gpib-ctypes (Windows, Linux) to use this resource type. Note that installing gpib-ctypes will give you access to a broader range of funcionality.
No module named 'gpib'

So I really don’t know why it was not working the first time, and why it almost a day of pulling my hear out. There are two things I can think of:

I switch with my usb adater between a windows 10 VM maybe I didn’t release the adapter properly from Windows 10?

Or the adapter was not plugged in correctly ?

I tried switching from MacOS to my  Windows 10 VM multiple times, noticing it worked in Windows 10 perfectly, but not under MacOS.

Anyways, it works now. And hopefully the steps above might be useful to someone.

Comparison between Prologix and National Instruments USB GPIB controller

Introduction

Almost every electronics lab equipment has the possibility to be controlled remotely. This is almost always done by using IEEE-488. Also known as ” HP-IB” As HP called it when HP developed this 8 bit parallel bus.   It’s also know as “GPIB”. (General Purpose Interface Bus).

In the old days a dedicated computer card was used as a controller, to perform remote operations on the lab equipment.

Nowadays we have LXI for example, making it possible to remotely control devices over Ethernet network by using the TCP/IP protocol. This doesn’t mean GPIB isn’t used anymore. Even modern equipment can have a IEEE-488 interfaces. For example my Rigol DM3608 has a IEEE-488 interfaces and can be configured to understand a specific command set.

Use an IEEE488(GPIB) communication -adapter

Nowadays it’s more common to use USB GPIB controllers to remotely control the (old) lab equipment.  There are a couple of choices:

  • Use Prologix GPIB-USB
  • Use an IEEE488(GPIB) communication -adapter (Keithley or National Instruments for example)
  • These adapters may also be available as Ethernet controllers which plug into a LAN network.

However there are mainly two difference between the “brand names” and the Prologix:

For example the National Instruments (NI) USB controller present itself as a GPIB device. Whereas the Prologix presents itself as a serial device.

Which one to choose ?

If you look at the known brand names one, presenting them self as a gpib device, you notices these devices are not cheap. A new adapters can cost you as much as $1300,00 and no.. this is not a typo. While the Prologix adapter cost around $150,00 dollars.. So what’s the catch ? (there is always a catch).

And as always: It’s depends. Say for instance that you want to use an application from a vendor which only works with a GPIB device. The Prologix in this case won’t work. At least not out of the box.

On the other hand: If you’re about to write your own data log / measure applications, the Prologix might be a perfect solution, since  it’s a serial device, and you don’t have the overkill of using the NI-VISA drivers (for example)

Then there is of course the price. Luckily the GPIB USB adapters can be found relatively cheap second hand. I did found a genuine NI  GPIB USB-HS new in box for a around $150,00 dollar. Which brings these adapter in the price range of the Prologix one.

Comparing a Prologix and a NI GPIB USB-HS adapter

Since I have both types, let’s compare them in practice. To compare the adapters i’m going to use them in the following scenarios:

  • Using the adapters with a existing application from a vendor (Rohde Schwarz WINIQSIM) which is a Windows application
  • Use both adapters to write a own application, testing Windows 10 operating system and MacOS (10.14.6)

 

Prologix adapter

The Prologix USB adapter can be programmed by sending commands through a serial terminal. The GPIB address of the device can be set by sending:

++addr #

So for example to set the GPIB address to ‘8’:

++addr 8

There several commands, which allows to configure the adapter to one needs. Also it’s possible to update the firmware.  To talk to the adapter FTDI device drivers are needed, which are available for Windows, Linux and MacOS.

 

The national Instruments (NI) GPIB-USB HS adapter

The NI adapter needs NI-VISA drivers to be installed. These drivers are available for Windows, Linux and MacOS.As far that I know there is no firmware available for these adapters. There is a lot of information about how to install NI-VISA drivers etc. The only thing I needed to was to install the NI-VISA software, and plug in the adapter.

Using existing application WinIQSIM

The application WinIQSIM works perfectly with the NI USB-GPIB-HS. The application has the benefit of using a GPIB device, or serial. However I could not get a serial device to work with my Rohde Schwarz AMIQ. I either received a timeout, or a communication error. At the end I tried to use a null modem cable, but this gives me problems also.

The main problem when using the Prologx in the case is the speed setting. The applications “sweeps” the baud-rate setting. The Prologix however, doesn’t care about serial baud setting. So the WinIQSIM application gets confused, when trying to determine the baud settings. I tried several options, even disabling the “sweep”, however the application kept trying to find the highest speed it could communicate on.

It might be possible to implement a driver in NI-VISA, I didn’t test this however.

In this case: The NI USB adapter wins.

Writing my own application

In this test I’m going to test the python script which I wrote to remotely control my HP 8175A. In this case I’m going to use Python since this makes testing under MacOS and Windows 10 very easy.

I’m going to use two modules:

    • PyVisa
    • PySerial

On both systems I’m using virtual environments.

Test under MacOS

And this test ended very quickly.. I tried to use PyVisa under MacOS, and couldn’t get PyVisa to work. The library isn’t listing my GPIB device. I tried installing several versions of NI-VISA library. I even tried different version of NI-488.2 drivers.

>>> import pyvisa >>> rm = pyvisa.ResourceManager() >>> rm.list_resources() ('ASRL/dev/cu.Bluetooth-Incoming-Port::INSTR', 'ASRL/dev/cu.EEsiPhone-WirelessiAPv2::INSTR') >>>

Update: I finally got the NI-VISA driver working under MacOS. I just reinstalled the drivers, and when I give the path to the library (I tried that before, which didn’t work) it works:

>>> import pyvisa
>>> rm = pyvisa.ResourceManager('/Library/Frameworks/VISA.framework/VISA')
>>> rm.list_resources()
('GPIB0::8::INSTR', 'GPIB0::9::INSTR')
>>>

When I use the NI-VISA tools, the adapter is recognized without problems.

Test under Windows 10

So I moved to windows, installed NI-VISA library, and PyVisa and it worked instantly. No problems what so ever.

Next I tried pySerial on both platforms, and both worked just fine. Of course I needed to adapt the device name (under MacOS this is:

ser = serial.Serial('/dev/cu.usbserial-PX4UALP2')

Under Windows this is:

ser = serial.Serial('COM4')

The whole python script:

import serial

cmd = ['RST','DM0;DUR0,1s;IFM(CLOCK),,,1111','DM1;CFM(CLOCK);TSA0;CHD0,(CLOCK),0000,0001,0010,0011,0100,0101,0110,0111,1000,1001;TSA9;CHD0,(END)','PM0;CD;(PROG1);CR7;CE;(END)','OM;POD 1','CM 0;CYM 1','UP;SA','LO']

ser = serial.Serial('/dev/cu.usbserial-PX4UALP2')

for c in cmd:
   send_cmd = c+'\n'
   ser.write(send_cmd.encode())

ser.close()

Conclusion

When using software which requires a GPIB device, then the easiest option is to chose for a USB controller which present itself as such a device. With some patience these devices can be bought relativity cheap. It might be possible to develop a own NI-VISA (or alike) driver for a Prologix USB adapter. Since I’m no expert in this, I didn’t do any research.

When using a NI USB GPIB controller (or alike) this will work under Windows. Under other Operating systems this might be problematic. With a lot of searching, and trying it might result in a working solution.  I couldn’t get the pyvisa to work under macOS the first time, after lot of trying and finally a reinstall, I could get it to work.

In my case the Prologix as the NI GPIB HS works on both platforms.

So the big question is: which wins ? Well if I only had Windows running as my Operating System, I definitely would go for the NI USB GPIB HS adapter, despite of the overkill of the whole NI-VISA environment.

And now that the NI adapter also works under macOS, I prefer the NI adapter over the Prologix adapter. Once the NI-VISA library works, it’s very easy to interact with the device. If however the NI-VISA lib doesn’t work.. or you simply don’t want the overhead the Prologix adapter might be the way to go, while keeping in mind when using vendor supplied software which relies on GPIB controller, the Prologix might not work..

Another thing to consider when using an adapter which relies on drivers like NI-VISA is when transferring software to other systems. For example when you write this awesome script in python for a specific device. When uploading this script to GitHub for others to use it, they need to install the (external) library. Which may be undesirable. In my case this is not really a concern.

However since I got both adapters.. I have the best of both worlds 🙂

Using a VFD IV-3A tube to build a simple counter – Part four

Introduction

In part three the rest of the counter is build, and the circuit is almost complete. The part which is missing, is the thing that makes it count. We  could simply add a 4 bits binary counter, but why not simulate a counter ?

The HP8175A

To simulate a simple 4 bits counter, I’m going to use my HP8175A. It’s big, it’s heavy, makes a lot of noise and eats a gazillion electrons per microseconds, and spits them out as heat. So what is not to love about this machine?

The interface of the HP8175A may take some time to get used at, but I loved it from the start. However to make it more interesting the HP8175A is programmed completely by IEEE-488. or GP-IB or a HP-IB  If you own a HP8175A and don’t have the possibility to remote control the machine, then study the user manual. It’s really not that difficult to program the HP8175A through the keyboard and knobs.

I used a National Instrument USB GPIB HS adapter to remote control the HP.

Remote control the HP8175A

To program the HP8175A a couple of steps must be taken. The HP8175A has so called “Module pages”. We need to:

    1. Setup on the Data Module the format: by setting up the POD and the duration.
    2. Setup on the Data Page the labels and bits which makes up the program
    3. Setup on the Program Page the program, the start end end labels, as well the times to run the program
    4. Setup the Clock page,
    5. And finally update all the settings and start the program

The IEEE-488 commands for the HP8175A is a bit cryptic, but this is the whole program:

RST
DM0;DUR0,1s;IFM(CLOCK),,,1111
DM1;CFM(CLOCK);TSA0;CHD0,(CLOCK),0000,0001,0010,0011,0100,0101,0110,0111,1000,1001;TSA9;CHD0,(END)
PM0;CD;(PROG1);CR7;CE;(END)
OM;POD 1
CM 0;CYM 1
UP;SA
LO

Explanation of the program

The commands and parameters are separated by a ‘;’. So for example the second line contains 3 commands: DM0 and DUR0 and IFM (Data Module, Duration Fixed, and Insert ForMat label)

    1. Reset HP8175A to defaults
    2. Go to page: Data Module FORMAT and set DUration to fixed 1 second and Insert ForMat label CLOCK and enable the first 4 POD lines (bits) of POD0
    3. Go to DATA page module and ChangeForMat label to CLOCK and Set
    4. ToStartAdress; CHangeData 0, CLOCK end set bits up to address 9 and change label to END ()
    5. Go to Program Module page and set the label PROG1, Move Cursor Right 7  positions, clear the field and change field so it contains the END label
    6.  Go to Output Module page and set all PODS enable
    7.  Goto Clock Module page and Set Clock to Auto Cycle
    8.  Update and start
    9.  Return to local (stop remote control, and enable front panel)

Line 3 might require some explanation:

DM1;CFM(CLOCK);TSA0;CHD0,(CLOCK),0000,0001,0010,0011,0100,0101,0110,0111,1000,1001;TSA9;CHD0,(END)

The part:

 TSA0;CHD0,(CLOCK),0000,0001,0010,0011,0100,0101,0110,0111,1000,1001

is quite clever. The engineers at the time by HP really know how to implement this kind of stuff. The command TSA needs a start address, which is the 0. Next command changes the format label to “CLOCK”. And then comes the clever part.

Since we enabled only for outputs on POD 0, we can have 4 bits on each address line. So by placing the 4 bits separated by comma’s, each bit pattern is placed on a address line. And therefore, this command places each 4 bits starting from address 0000 to 1001 (0 – 9).

So it works like:

                 4bits  4bits                                4bits
Set start addr   addr 0 addr 1                               addr 9
/|\               /|\   /|\                                   /|\
 |                 |     |                                     | 
TSA0;CHD0,(CLOCK),0000,0001,0010,0011,0100,0101,0110,0111,1000,1001

DECIMAL              0,   1,   2,   3,   4,   5,   6,   7,   8,   9

Let’s see the HP8175A in action

After sending the commands, the HP8175A is acting like a 4 bit binary counter:

Once I know the program is working I wrote a little pyton script using pyvisa:

import pyvisa
import time

# Small programm to remote control a HP8175A
# Using PyVisa with a NI USB GPIB-HS+

# Setup the resource manager
rm = pyvisa.ResourceManager()

#print(rm.list_resources())
# Open HP8175A
hp8175a = rm.open_resource('GPIB0::8::INSTR')

# Identify yourself!
print(hp8175a.query('IDN?'))
print(hp8175a.write('RST'))
time.sleep(5)

print(hp8175a.write('RST'))
print(hp8175a.write('DM0;DUR0,1s;IFM(CLOCK),,,1111'))
print(hp8175a.write('DM1;CFM(CLOCK);TSA0;CHD0,(CLOCK),0000,0001,0010,0011,0100,0101,0110,0111,1000,1001;TSA9;CHD0,(END)'))
print(hp8175a.write('PM0;CD;(PROG1);CR7;CE;(END)'))
print(hp8175a.write('OM;POD 1'))
print(hp8175a.write('CM 0;CYM 1'))
print(hp8175a.write('UP;SA'))
print(hp8175a.write('LO'))

Connecting a Rohde Schwarz AMIQ to a SMIQ04

Connecting a Rohde Schwarz AMIQ to a SMIQ04

The first article explains how to setup an R&S AMIQ and talk to it, and to get signals out of the I and Q outputs. In this article the AMIQ is connected to a SMIQ04. In this setup the AMIQ provides the IQ modulation, and the SMIQ is providing modulated signal on its RF output.

Prerequisites

To be able to use the SMIQ and AMIQ together, a vector modulator (IQMOD variant 4 or higher (var. 8) must be installed in the SMIQ.

Connecting the R&S AMIQ to R&S SMIQ

There are a couple of options on how to connect and control the R&S AMIQ. It’s possible to control the AMIQ from the SMIQ. Or control the AMIQ by a PC.In this setup I’m connecting the R&S SMIQ and R&S AMIQ together by the use of an IEEE-488 cable, so GPIB can be used to control the instruments.

One think to keep in mind is that when using the SMIQ to control the AMIQ, the SMIQ is acting as a controller. And there can only be one controller active on the bus at the same time.

The output “I” and”Q” of the R&S AMIQ must be connected to the “I” and “Q” inputs on tthe R&S SMIQ.

Generating signals

When using the SMIQ as a controller, the signals of the AMIQ can be used as follows:

In the menu Utilities/Install the option AMIQ control must be enabled. After enabling the SMIQ must be rebooted.

After reboot an extra menu option: IMQ CTRL is visible. In this menu the following options must be selected and set:

    • Start by setting carrier frequncy
    • Set the level of the output signal (for example 0 dBm)
    • Select the option: SELECT WAVEFORM
    • Next select: Drive and choose C:
    • Pick a waveform, or change to directory to select a waveform
    • Press return and select menu Mode.
    • In the Mode menu select AUTO
    • Press Return key, and select menu option Level
    • In the Level menu set the I and Q outputs to 0.5V/50 Ohm
    • Press return key, and go to Vector mod, and set state to “On”

The modulated signal should now be present on the RF output.

To demonstrate a modulated signal which is generated by the AMIQ I use a directional coupler.

 

 

I connected the directional couple’s input port the the RF output port of the SMIQ. The output port of the directional coupler is connected to a Tektronix 2225 scope. The CPL port is connected to a HP8591A.

Note that I connected the NOT I port, so I could create a interesting signal, which is a challenge to trigger on the Tek 2225.

 

Getting an Rohde Schwarz AMIQ up and running

Introduction

The Rohden Schwarz AMIQ is an IQ modulation generator. According to the documentation of Rohden Schwarz this device has:

 

 

    • 100 MHz sample rate
    • 16 M Samples memory depth
    • IF generation up to 25 MHz
    • Multiple carrier simulation

And the best part is.. these devices can be picked up for little money.  Even if one is not into IQ modulation and such, the device is able to put out some very nice looking sine waves. There is a catch however. (There is always a catch): The AMIQ can only be controlled remotely.

What to look for when buying an AMIQ

When buying an AMIQ, look at the options the unit has. The user manual which can be found online, list all the available hard-, and software options.

Secondly, the AMIQ has a built in hard disk. If this drive is damaged, you could be out of luck. I searched online, but could not find any firmware images. If you bought an AMIQ, then make a image of the internal hard disk.  The AMIQ boots OpenDos.

There is an easy way to determine if the AMIQ is in a working condition. And that is to listen to the beeps at startup. The device will give one beep when turned on, and a few moments later, a second beep is produced. It’s the AMIQ’s way of letting you know it’s past it’s error checking thing. This second beep,should be followed by a steady green LED on the front panel.

If none of the above is happening, the AMIQ is having a fault, or the AMIQ didn’t start in a sane state. There seems to be a service manual for the AMIQ, where you can troubleshoot. Unfortunately I could not find the service manual online.

So when buying an AMIQ, let the seller boot up the AMIQ, and let the seller describe to you the boot process.

Once you got physical access to the AMIQ, you could run the the command:

*TST?

This should return a 0 when no errors are found, or a 1 if a error is found. The user manual describes in detail how to hardware test the AMIQ. Also note that the above command doesn’t test the RAM memory.

The third thing you may be aware of, are the different models:

    • AMIQ02
    • AMIQ03
    • AMIQ04

I never encounter the AMIQ01, however the AMIQ03 and 04 are the newer models, with more memory, sample rates etc. The main difference between the AMIQ03 and 04 is greater memory: The 04 has up to 16 000 000 IQ values, compared to the 03: 4 000 000 I/Q values)

Only the models 03 and 04 can have the option “AMIQ-B3” fitted. So if you see an AMIQ listed with the option “AMIQ-B3” you know it has to be a 03 or 04 model.

Controlling the AMIQ

To let the AMIQ do something useful, like spitting out signals, the AMIQ needs remote control. And for this remote controlling there are several options:

    • Through serial connection
    • Through IEEE-488 (GP-IB or also called HP-IB)
    • Use an Rohde Schwarz SMIQ
    • Use software like WinIQSim (version 1.x)

Luckily I got all the options…

Talking to the AMIQ

The easiest way of getting the AMIQ up and running is to connect a null modem cable to the RS232 port. If someone has changed the default serial parameters (9600,8n1) an formatted floppy disk (MSDOS) is needed with the file: AUTOEXEC.IEC with the following line:

:SYST:COMM:SER:BAUD 9600

Insert the floppy disk into the AMIQ, turn the AMIQ off, and on again. Once the AMIQ is fully booted, the serial console should be accessible.

When you have the luxury of having IEEE-488 or you could reset the the default address 6 with similar procedure, the line in the AUTOEXEC.IEC must be:

:SYST:COMM:GPIB:ADDR 6

Once a working connection is established to the AMIQ, the following command should give you the directories on the hard drive C:

:MMEM:DIR?

To load an waveform, and put out the signals on the I and Q outputs, give the following commands:

*RST;*CLS;*WAI
:MMEM:CD 'C:\'
:MMEM:LOAD RAM, 'GSM_TSC1.WV,TRAC'
:TRIG:MODE CONT
:OUTPUT:I FIX
:OUTPUT:Q FIX

The commands on the first line resets the device. Next the directory is changed to the C: drive. On the third line a waveform called: “GSM_TSC1.WV” is loaded into RAM memory. By setting the trigger to continuous on the next line, the waveform is send to the outputs, which are enabled on the last two lines.

This produces the following signal:

In the next article I’m going to hook up the AMIQ to the Rohde and Schwarz SMIQ04 and generate some signals.

Using a VFD IV-3A tube to build a simple counter – Part three

Introduction

In part two an ULN2023 is used so we can connect the IV-3A segments to 20V, while driving the segment with 5V. In this part the IV-3A is connected to the ULN2803A, and a 74LS48 which is BCD to 7-Segment Decoder.  By using the 74LS48 we can use 4 bits to drive the 7 segments.

Connecting the IV-3A

To connect the IV-3A to the IV-3A follow the following table:

IV-3A connections

IV-3A ULN2308
5 8
6 7
10 6
1 5
2 4
3 3
4 2

The last connections to make are the grid and heater. The schematic looks like:

IV-3A connections
IV-3A connections

Connect the 74LS48

The datasheet for the 74LS48 can be found here. Before connecting up the 74LS48, we need to invert the signals. Since the ULN2308 is a NPN Darlington array, we  need to invert the signals, so that a segment is activate when the input signal is going HIGH, instead of LOW.

An easy solution is to use a HEX invert. Since a HEX invert, as the name implies has 6 inverters, so we need two of them. So 2x a 74LS04 is going to be used.

The schematic looks like:

Display Driver schematic
Display Driver schematic

When connecting the all the BCD (248) inputs( pins: 76,2,1) to GND, the IV-3A should show a “zero”.   Like wise, if we connect these pins to 5V, a 8 is shown. The table below show the BCD coding for the pins:

BCD (248) conversion table

A3 A2 A1 A0 Digit
0 0 0 0 0
0 0 0 1 1
0 0 1 0 2
0 0 1 1 3
0 1 0 0 4
0 1 0 1 5
0 1 1 0 6
0 1 1 1 7
1 0 0 0 8
1 0 0 1 9

In the next article the HP8175A is going to be used as a binary 4 bits counter.