post

Calculators and numerical differentiation

It happens that I quite like scientific calculators, and lately I’ve been adding a few to my collection. Several calculators are CAS (“Computer Algebra System”)-capable, meaning they are powerful enough to do symbolic / algebraic processing, and thus are able to understand and manipulate algebraic expressions containing any mix of unknowns, operators and numbers, and simplify, expand, and solve those in a general form. They normally can also do symbolic differentiation and integration, computing the general derivative/integral “function” from a expression first, before you can evaluate them at given points, if desired.

But I’ve always found quite fascinating that some less advanced calculators still offer the possibility of doing numerical integration and differentiation. They don’t know for instance that the derivative function of 3⋅x² is 6⋅x, but they can still tell you that when x = 2 the derivative is 12.

Before you ask; I got into this rabbit hole because numerical differentiation and integration are kinda standard features nowadays of any decent calculator. It doesn’t need to be a high end or an expensive calc. In fact, I noticed that even my fx-570MS “entry level” scientific calculator I purchased like 10 years ago can do both operations, while three of my “high end” vintage programmable Casio calculators can’t. As they were “programmable” I think Casio kinda expected users to write their own programs for whatever “advanced” feature they needed. So I started wondering what is the method/algorithm used by current scientific calculators to compute these functions, so I could add the same functionality to my these calcs.

Now, I’ll focus on differentiation here because it’s way easier to deconstruct and understand how that works. A post about integration may follow, if this doesn’t turn out to be a massive borefest.

The concept of derivative

So if you go back to the formal definition of a derivative;

You’ll see that it basically attempts to find the “slope” of the function f(x) at a point x by evaluating the expression at x and (x+h) (as you would do with a straight line), and trying to reduce the difference in the X-axis between those two points (h) to a tiny fraction. In fact, it uses the concept of limit to find out where that expression converges when h approaches 0 (It never really gets there though, because the whole expression goes to hell at that point). Read More

ZEPPP : Zero External Parts PIC Programmer

A couple of months ago I was asked if I could prepare a sort of workshop on one of my favorite topics: ASM Programming for PIC microcontrollers, which I of course accepted on the spot.  Now, I wanted to include a couple of “hands-on” lab sessions in this workshop, and because of this, I needed a way for all attendants to actually work with real PICs that hopefully did not involve purchasing PIC-programming hardware in bulk for what is probably going to be a one-shot activity.

The Quest

Simple DIY programming circuits exists, and in fact, my first PIC programmer was a home-built “Enhanced” NOPPP (No-Parts PIC Programmer); a fully functional device that required only a couple of components (Not really “No-parts” but pretty close to it). The problem is that it used the PC parallel port (R.I.P), and required an external power supply. And this goes for pretty much every “classic” DIY PIC programming circuit; they all either require extra hardware or can no longer be used on current computers.
Read More

Making a dedicated Logic Analyzer, Part 2

It took me a really long time to do this second part of my Pi-based Logic Analyzer project, mostly because of two things; the first one being that at one point (after I had pretty much all the case design, extra hardware and software tweaking done for my RPi1) I decided to switch to a Raspberry Pi 3, which of course meant discarding a lot of work and starting again but with the RPi3 in mind.

Why? Because I figured that my device was getting needlessly bulky (the case required extra room for a small fan (for the overclocking), extra width for the full-size SD card, and extra thickness due to the back-facing P5 connector, etc), and it would have been almost impossible for others to replicate this project (because I was using the old Pi1 Rev.B board, which is discontinued) so using a more modern Pi made sense. The physical layout of the Pi has stayed the same since the latest revision of Pi1 I believe, and -sans the position of the status LED- both the Pi2 and Pi3 are identical and completely interchangeable for the purposes of this project.

The second reason for the delay was that in an spectacular display of stupidity, I managed to fry my Waveshare TFT screen when I was done with the whole setup and designs for the Pi3, so I had to order another one online, and wait until it arrived, which took a long time. Read More

0-30V 3A Linear Power Supply Kit

It has become pretty common for me to have one or two unfinished projects on my bench or the shelf, because “I just can’t find the time” to complete them, or because I’m “waiting for something the project needs”. And both things happened in one way or another with a Linear Power Supply kit that I bought after watching a review/build by VoltLog.

I ordered the kit online, and before it arrived I went and purchased a 24V 3A transformer from a local electronics store, eager to build and test the kit as soon as I got my hands on it. By the end of July I received and soldered the kit. The enclosure arrived later I think.

Looks fun, right?

The beginning of the delays

Read More

Installing Apache and PHP on an Intel Edison with Yocto Poky 3.5

I got the chance to play with an Intel Edison board a couple of months ago, and I just got my own board today, so I spent a bit of my afternoon settings things up, and playing with it.

One thing I noticed, is that most tutorials and guides for the Edison were written for the version of the system that was popular during the “golden age” of these boards (the “2015-05-25” image), which is no longer the latest version. Now that I’ve upgraded mine to the most recent image (2016-06-06) it was clear that a lot of packages were upgraded, removed or changed, which means that a lot of tutorials, guides and info online no longer apply (I actually experienced this first-hand when trying to find config files that were nowhere to be found, or disable services that no longer existed).

But among the differences, the worst offense (to me) is that Apache is missing (It was apparently replaced by nodeJS as their “web” technology of choice). A lot of fun things you can do with an Edison (and other linux boards) require Apache or PHP, so this might be a problem for a lof of you, not only myself.

But anyway, upgrading is usually good (as long as the new software runs well), so I decided to give the new version a chance.

Read More

Arduino’s broken Random()

If you are using your Arduino’s PRNG (Pseudo-Random Number Generator) for anything more serious than flashing random lights for your Christmas decorations, there’s a chance you might run into some unexpected issues, as the random() function in Arduino seems to be somewhat broken.

Why? Let me explain.

Background

Most basic random number generators in programming libraries and platforms are based on what is called a “Linear Congruential Generator” (LCG), and I have discussed them before here in my blog. As with any PRNG, the output of the algorithm ends up being a sequence of numbers “seemingly” selected at random, starting from a “seed”.

Given the basic structure of an LCG, after you have drawn X numbers from the generator, you’ll start getting the same sequence again. This is called the “period” of the LCG, and is one of the things you should know about the PRNG you are using (again, if you are serious about your random numbers, or you need a controlled, predictable and stable behavior).

Arguably, you should always know the weakness and strengths of the PRNG you are going to use, before even using it, as to avoid any potential pitfall and/or limitation (and that’s why it’s normally not a good idea to use the default implementation of a random generator in any language; For the most of it you don’t know what you are getting).

Read More

Enclosure for a D3806 Buck-Boost Switching Power Supply

I kinda like the end result.

Not long ago I purchased this neat and compact DC to DC Buck Boost converter that performs reasonably well. It has a maximum output of 38V, 6A and has more than enough flexibility and features to be a secondary power supply in my lab.  I recently found a review of this product by Julian Ilett on his channel (which I’ve been following for a while) and the way it works is quite clever. The problem for me, however, is that it was a bit messy to have the bare circuit board laying around unprotected on my bench. The top-mounted panel wasn’t too practical either, and it was becoming increasingly clear that it was meant as an adjustable power converter module rather than a supply. Read More

post

Making a dedicated Logic Analyzer, Part 1

For a few months now (and after successfully using a cheap USB analyzer with my Pocket C.H.I.P) I’ve wanted to make a sort of standalone Logic Analyzer  / mini linux machine that I could have on my bench. I originally wanted to use one of my C.H.I.P boards, but I soon stumbled upon a bit of a difficulty: It’s not that easy to use readily-available touch-screen / LCDs with the C.H.I.P.

Because of this I decided to switch to an old RaspberryPi1 Model B that I had laying around instead.  I don’t need anything faster than that, and finding TFT/LCD screens for Raspberry Pi is ridiculously easy. As a matter of fact, I already had a small 480×320 LCD that I tested before and worked really well. I may eventually switch to a small HDMI screen, but for the time being I’ll use this one:

*SPOILERS* The RPI with the LCD after everything was configured.

Read More

Developing on a Pocket CHIP with “Motor”, a Text-based IDE

Nothing like a Text-based UI

A recent discussion on the Pocket C.H.I.P forums made me dig up memories of my time with DJGPP (a wonderful DOS port of GCC), and its quite functional text-based IDE; RHIDE.

I thought that it would be great to have RHIDE running on my Pocket CHIP for doing simple C/C++ development on the go, as TUIs (Text-based User Interfaces) were pretty simple and could work in really low resolutions, but unfortunately CHIP’s ARM architecture was completely foreign to RHIDE’s build scripts, and it refused to compile.

I’m definitely no Linux guru, but I reckoned that adding the architecture to the build script wasn’t going to be easy, especially since it apparently had several architecture-dependent libraries, modules, etc, so I embarked on a quest to find another text-based IDE for Linux, and that’s how I found Motor.

Sure, the project is 12 years old (last “build” is 3.4.0 from February 2005, and still more recent than RHIDE), but I thought that perhaps it could still work on a relatively modern Linux distribution, and to my surprise, it did (with a few gotchas, though).

Read More