Saleae Logic Analyzer Alpha 2 and how software is eating the instrument world

 

The other day I came across a Google Photos memory that took me back to my travels to a beautiful beautiful country called Chile almost 7 years ago. I had a rare chance to visit one of the largest instruments on earth in the middle of the Atacama Desert called the Paranal Observatory, the big ground-based telescope. Astrophysicists, cosmologists, and scientists all around the world use these telescopes to probe the skies and beyond in the universe.

 

Now after visiting the insides of these large telescopes, the tour ended with a visit to the control room that looked a lot like this photo, where the operators used computers to control these telescopes and download the data collected. Increasingly, software that is run external to the instrument is being used to not only control the instrument but also collect the data and process the findings from the data. And that kind of brings me to the famous article that Marc Andresson once wrote in 2011 titled “Software is eating the world”.

 

He pointed out many industries such as video services, and music companies that are software companies. This kind of makes me think about the daily instruments that I typically use in a hardware lab such as say the vernier calipers, the multimeter, or even a logic analyzer. The first obvious way in which the software is changing the world of instruments is via the user interface. And that is residing typically on an external laptop or mobile.

 

Now conventionally, instruments have an embedded display with some knobs, buttons, and even screens to interact with it. For example, an oscilloscope is a very very common hardware lab instrument. But look at the Saleae Logic Analyser hardware! It is tiny and simple with no complicated buttons or interfaces to deal with. But I’m more excited about Logic 2, which is currently still in the Alpha version. I believe this version of Logic 2 is made with web technologies. And the team is always updating.

 

So when you first open up Logic 2, this is what it looks like. Very crisp and clean design. And currently, I am using version 2.3.5, which is up-to-date as of August 2020. So, after I clear up the interface a little bit on the left-hand side you see all the channels. Now because I am using Logic 4, it has 4 channels. But of course, if you are using Logic 8 or Logic 16 you will have that number of channels. I have 4 digital channels. and of course, channel 0 is also available as analog. The cool thing about this interface is that I can drag around the channels in any way I like. I can even rename them. Let’s say Channel 0 is Data, Channel 1 is Clock. I can even resize them.

 

Let’s say I resize the digital clock channel. And I can match all other digital channels to this height. I can also hide certain channels. Let’s say channel 3. Also, let me hide it. And maybe the analog channel I can make it a little bit wider. On the right-hand side, we will see some buttons here. The very first one is to trigger or start the capture of the signal. The second one is the capture settings. So here you see I have the chosen channels here. The rest 2 are hidden or disabled. We can also choose the speed at which we want to capture it. The analog channel or the digital channel. The speeds are different. You can capture them. And also how you want to trigger the capture. For me, maybe I’ll put it to just “Timer”. And let’s say we will put it to just 5 seconds. You can also do it via “Trigger”, which can come in very handy either by a rising edge, falling edge, high pulse, or low pulse. So I’ll set it to “Timer”.

 

So the capture setting is simple. The next is the type of analyzers. Of course, these 3, the SPI, the I2C, and the Async serial are the common ones. But here we can also add more such analyzers. So after the analyzers, we have the next one which is measurements or annotations. This is where we can kind of do something analysis of the captured signal. We will explore this a little bit later. And I am very very excited about the last one, which is extensions. So here we can install other extensions written by the community members. Now, these people can be part of the Saleae team as well as engineers like you and me, who can create these extensions and share them with the wider community. So now that we are familiar with the interface and the layout of the software, the next crucial thing is obviously to control and capture the required data. So in our case, we will use a couple of temperature sensors. We will connect it to the logic analyzer via our laptop and capture the signals. The first sensor measures the temperature and humidity.

 

And it is based on the Si7021 temperature sensor. We will use this dev board from Adafruit. And connect it to Arduino UNO and get its temperature roughly every 2 seconds via the I2C protocol. Also, keep its datasheet handy to decode the temperature after capturing the signals. So this is what the entire setup looks like. And we have 3 things. The temperature sensor on the breadboard is connected to the microcontroller. And the logic analyzer hooked up to the laptop. Now it might seem like a lot of wires. So let’s look at the schematic to simplify things. Here you see the Arduino UNO microcontroller.

 

And the only thing that we have connected to, of course, other than the power and the ground, are the couple of pins for I2C. The SDA and SCL. They are connected directly to the sensor. And of course, these are the 2 lines that we will be probing via the logic analyzer channel 0 and channel 1. So let’s take a peek at the code as well. This is really like a “hello world” code for Si7021. In the setup() function, we are setting up the serial monitor and just doing a quick check to see if the sensor is available. And after that inside the loop(), we are blinking the LED just to denote that we are reading the temperature sensor, which means that we are reading the sensor every 2 seconds. So I am going to go ahead and upload this firmware onto Arduino UNO, the microcontroller. So I’m here on my serial monitor. Let me re-scan the ports. And yep! The port is chosen. The Baud Rate is chosen. So let’s connect it and also see what the serial monitor says. Alright! Started! The temperature is Celsius.

 

It’s about 26 degrees Celsius. So here let’s first arrange the channels. So I’m gonna put the Data Channel right at the top. And now we can also rename it. So let’s rename it as SDA. And the Clock is SCL. And this is the analog one. So I’m just gonna widen the channels a little bit and say “Match Digital Channels to current height”. As for the analyzer I can choose I2C. Yep! Channel 0 is SDA and Channel 1 is a clock. Save. So now that everything is good, let me click the start button to capture the signals. And there is another signal. So looks like we have captured 2 signals. Two temperature signals are about 2 seconds apart, which is exactly what we wrote in the code.

 

So why don’t we zoom into one of the I2C signals captured? And there you see! This is what it will look like. So from here, we will have to decode the temperature later on when we write our extension. So next let’s move on to the second temperature and humidity sensor, which is based on DHT11, a through-hole component. Now the DHT11 is available as a non-standard one-wire protocol. So there are a few datasheets on the Internet, but we got to find the one that explains the signals because we will be decoding them, especially how the data bits 0 and 1 formats are. So we will also connect this temperature sensor DHT11 to Arduino UNO and then get its temperature roughly at about 2 seconds. And because it has only one data line, the logic analyzer needs to probe only that line. This is the microcontroller here of course connected to the 5V and the GND.

 

We have only connected one wire from the D7 pin of Arduino to the data pin of DHT11. And of course, the logic analyzer channel 0 will be probing this data line, and the ground of the logic analyzer is also connected to the common ground. Let’s look at the code once again which is simple. We will define some pins at the start. And in the setup(), it’s similar. We will begin the sensor. And in the loop(), every 2 seconds we will read the temperature, and in between, we will blink the LED to denote that temperature is being read. So looks like all the wiring and everything is connected. So why don’t we upload this firmware? And yep! It is uploaded.

 

To check that it is uploaded, let’s visit the serial monitor. It is giving a temperature of 26.00. It consistently gives 00 because of the temperature sensor itself and its accuracy of it. And this time we will create a new session in the logic analyzer software. Channel 1. We will only need channel 1. Channel 0. So it’s just the data channel. In terms of capture, yup! It is only digital 0 and analog 0. I will capture it for a pre-defined duration of 5 seconds. As for the analyzer, I will remove it because it is a non-standard one-wire protocol. And I think that’s about it. Let me clear the screen. And I will start the capture. Alright! Seems like it has been captured. So let me zoom out and see what has happened. Alright! So it has captured 3 signals, which are 2 seconds apart. So why don’t we zoom into one of the temperatures captured?

 

It’s a one-wire non-standard protocol. So obviously we will need to read the datasheet to figure out what the temperature is. So conventionally I feed instruments typically stop at this stage. They allow you to control and capture the data. And that’s about it. When you start a new measurement, the old data might not be available. And this is where I think having software that can capture and export the measured or captured data is very valuable. In Saleae, we can export the data in 2 ways.

 

So the first way is the Saleae file format itself. So we will go to File and then “Save Capture…”. And here we can save it on the Desktop as a *.sal file. So let me name it Si7021 for the first one. And I will go to the next session and also save the capture. And let me name it dht11 on the Desktop as well.

 

And now if we visit the files on the Desktop, we will see a couple of files that are in the Saleae file format. Now the cool thing is I can simply double-click the file and it will come to the Logic Analyzer software and it will open up the exact captured data. Of course, it will say that it is read-only data, and nothing you can do about it. The second way how we can export is simply by exporting the data. And this is cool in the sense that we can export it in the CSV file format. And now we can use this CSV file format to ingest it via any programming language or even a spreadsheet application. Now typically, I like to only capture the digital channels because capturing the analog channel will take up a lot of data. But of course, you can do that as well.

 

But I will just uncheck it. This is the DHT11 where I only used just channel 0. So I’m gonna do that. And let’s try just the visible screen. So I’m only gonna capture the signal from here onwards. So let me export it. And there you see! It will export it to a folder on the Desktop. And now when I come to the Desktop, I’ll see a couple more folders here. Let’s check them out. DHT11 is a CSV file. And when we open up, of course, we will see only 2 columns. You see the time is starting from about 2.8 seconds because we are only capturing the visible screen and here’s the data in digital format, 0 or 1.

 

 

So having a user interface and then being able to control it or even exporting the data, I believe is becoming much much more common. But the next 2 points, the next couple of points, are what I think are the game changers in terms of having a software control and interface with a hardware instrument. And these game-changers are the ability to create extensions or plugins and then distribute them via the community. Now in a previous video, which I kind of linked up here, I have used the datasheet to manually decode the temperature sensor.

 

But for today’s video, we are gonna write some extensions and use some community extensions from the marketplace to analyze the signals instead of doing it manually. So for the first temperature sensor which is based on the I2C protocol, I’ll be using something called the “High-Level Analyzer Extensions” that I’ll be writing on top of the I2C protocol. So the first step to creating an extension for Salease Logic Analyzer is to click this button called “Extensions”. So I’m gonna click “Create Extension”. And I’m gonna chose the High-Level Analyzer based out of I2C. And let’s give it a title. And let me save that on the Desktop. So once we do that, notice in the extension that there will be something called local.

 

And then, of course, we can publish it. But I won’t publish it yet. So now when I open the folder, it will have 3 files that are the boilerplate file. The second one is the Python file. This is where we will be writing our extension. So for the Python file, let me simplify the file a lot by just removing the comments.

 

And for this initialization, I’ll simply say just pass. So now you see my Python file, which is the crux of our extension is simple. I’m gonna simply, for the sake of simplicity, just call it found, which means I found the stuff I’m looking for. Inside the format, I’ll simply say “data”. And inside decode, why don’t we try to find the frame type called “data”? How do we know which frame type we are looking for? Well, yup! We are looking for the “data” frame type.

 

And once we find it, then only we will return and here we will refer to the object name once again, which is “found”. And, no. We have nothing inside. So this is as simple as it gets, like just a 15-line code. So what I need to do is go to the analyzer, sorry. And then I need to add on the analyzer. It is already available. Si7021 I2C. And yep, I will choose I2C. And let’s click finish.

 

And once we do that, looks like it has correctly identified the data frames. Now, of course, another type of frame is the address. So why don’t we replace the data with the address and see what it looks like? So I’m gonna come here and call it “Address”. And the frame type is sorry “address”. And yep! The return type will still refer to the found object as the first parameter. So if we want to reload the analyzer, all we need to do is right-click this local analyzer that we created. And then reload the source files. And immediately we will see that address is here. Now from the temperature sensor datasheet, we know that the temperature can be decoded from these 2 acknowledged data frames.

 

So we are gonna come here and then we are gonna add on say and the data frame is acknowledged. So it has to be data. So I’m gonna change back to data. And now when we come back to the analyzer, we can reload the source files. And yep! It says data here. So, once again I will refer to the datasheet for Si7021, the I2C section. And yep, here they will say that we will have the Most Significant Byte and the Least Significant Byte. And basically, we will have to combine them and use this equation to decode the temperature. So why don’t we transfer this equation to the Python code? So to do that, let’s start with the return object. Firstly, I will change this to an error-correcting or error-detecting frame. And then I will also create a new one called, High-Level Analyzer I2C.

 

And here the format will simply be dynamic, in this case. It will simply be data. the temperature that we will later on create. So now that the result types are done, we will have to go frame by frame. So for that, I will create a temporary frame that we can refer to as we go on to the next frames. Alright! So, let me delete everything in the decode function and start fresh. So the first thing that I’m gonna do is, if the current frame is None, then you just simply return it as an error. In the next bit, I will be checking for the start frame type. And if it is started, it will simply refer to the return type higher analyzer I2C. And then attach the data which is empty for now. I will also check for the frame type stop and then basically return the new frame. But we are not done yet.

 

What we did are just some checking and finding the start and the stop of the frames. So just like we did before, we are first gonna check for the frame type if it is data and also acknowledged. Once we find that, we will then create a variable called data_byte and store that. And then we will do some checks to say that hey, if it is longer than zero, then we will start creating or appending the most significant byte and least significant byte. So MSB in this case will be the previous data, and LSB will be the current data. And we will have to format it as hexadecimal. And finally, because we are appending it, we will do a little hack and just shift it by 100. Now we saw the temperature sensor code here. And we will now start writing this code. So temperature will simply equal to… so for this, I will round up the temperature and put it as a String. And finally, use the temperature and append a degree C to it.

 

Of course, if it is lesser than zero, then the current data is, you are just kind of adding on. Hexadecimal to a data byte. Ok, so this is where we are adding the temperature. And we will have the temperature, the value that we calculated from the equation displayed right here. So let me reload the source file. And there you see! It is 26.12 degrees C.

 

And for the final part, now that we have written the extension, the next powerful thing to do is actually to be able to share this extension with the community at large. And I think this is pretty powerful because we might not need to duplicate something if it is already made by someone. So for this example, of showing how we can use extensions by the community, we will use back the signals captured by DHT11. And we will go to the marketplace and install some extensions. But here we will not the analyzer because it is not part of a standard protocol.

 

We. will instead use this thing called Measurements. Now from the datasheet, we know that we are supposed to receive about 40 data. And although we will not calculate it manually, let’s zoom in on this one. The zero-bit format is made up of a signal which is 50 plus say about 30 ms. And the 1-bit data format is made of the signal which is 50 plus 70 ms. I’m gonna choose from where the data should start. And somewhere around here. And once we do that, you will notice that they are gonna give you a number.

 

I’m not sure what this number is. But let’s go to the extensions. Install this extension called “Pulse Count”. Count the number of positive and negative pulses. When we click, it will give us more information. So basically, our measurements will have more attributes. np+ and np-. So let me go ahead and install it. And now when we come to the measurement, you see that it will be 40 or 41 thereabout. So we do note that the data is captured here. The temperature data is captured here as denoted by the datasheet the output 40 data.

 

As another example, let’s try to install this one, the average period. So I’m gonna do it. And I’m gonna add another measurement. And in this case, I’m gonna add the ones that we see with the shorter signals. And when I come to the T-average, it is actually around 80ms, which is similar to the. data bit 0, which is 50 + 30, which is 80ms. Why don’t we do the same with the 1-bit? So it should be 50 + 70, 120ms. So I’m gonna come and add another measurement. Let me choose the one with the wider signals. And yep, the T-average is around 120ms. So by analyzing using these measurements here, we can also probe into the signals. And of course, as I did manually you can go ahead and decode it 00. To be honest, for many software-related instruments, having a plugin and extension, an API, and sharing it with the community, along with you know, the tools such as controls and displaying the data are not uncommon.

 

For example, as a web developer, a browser dev tool is a typical software instrument. And Chrome and Firefox have extensive add-ons and plugins. Or even software tools such as Figma, which is a design tool, also have a rich network of community users who are contributing to creating plugins and extensions. But I’m especially about the real-world physical instruments such as telescopes, vernier calipers, and logic analyzers, that are integrating software not only to have a dynamic user interface but also the ability to create extensions and plugins that can be shared around the community worldwide. Do check out the open-source option such as the Sigrok project with PulseView as a graphical user interface for instruments like logic analyzers or oscilloscopes. But does this mean that software is more important than hardware? Well, not really! I feel it is quite the reverse.

 

As the saying goes by Alan Kay, “People who are serious about software should make their hardware”. So here’s to all the instrument engineers out there whether they are doing the hardware part of it, the software part of it, or even the material science and mechanical engineering part of it that makes our lives as application engineers or other areas of engineering much more delightful. So that we can continue to do our job, we can continue to debug, probe into data that we collected, or even explore the universe! So thank you for watching this video and I’ll see you in the next one.
.

As found on YouTube

Traffic Xtractor ᶜˡⁱᶜᵏ ᵗʰᵉ ˢⁿᵒʷᵐᵃⁿ ☃ Page 1 Of Google & YouTube In MINUTES! Software Gets As Much FREE Traffic As You Want With A FEW CLICKS OF YOUR MOUSE… NEW Features Include: Video Title & Description Curating & Optimization Google suggest keywords ⇝ Google related keywords ⇝ Bing suggest keyword ⇝ Bing related keywords

Leave a Reply

Your email address will not be published. Required fields are marked *