Still Alive

Yes, I’m still here.  Unfortunately, I haven’t been showing this site the love it deserves.

I have, however, updated some of the flash memory benchmarks with some new devices that have been recently purchased.  Interested, check them out here…
Micro SD, SD, Compact Flash and USB

A New Toy. :)

I enjoy designing and building custom items.  After buying a cheap CNC mill off eBay, I had the ability to make some pretty nice PCBs.  I then thought “Wouldn’t it be nice if I could make custom enclosures for my projects.”  After reading some reviews on the ‘Net and watching some YouTube videos, I decided on the Monoprice Select Mini. ($200 on Monoprice.com)

Stay tuned for more…

A “Smarter” Watch

casio-ca-53w-calculator-watch

For over 20 years I have been carrying my beloved Casio calculator watch on my wrist.  Alas, time and abuse have taken their toll and my beloved watch ceased operation.  Originally I was going to replace it with a Casio Databank watch, but their evolution of functionality seemed to have stagnated for the last 10 years.  I also looked into smart watches but their price and dependency on being linked to a cell phone was a major drawback for me.  So I replaced my trusty Casio CA-53W calculator watch with another one.  (Thankfully Casio still makes them…and their relatively inexpensive.)

However,

This fueled my inner engineer to see if it is possible to make a “smarter” watch.  I am looking at designing something that has greater functionality than my calculator watch and even the databank watches, yet maintains independence from requiring a smart phone.  (Although I might give it the ability to link with a phone, it just wouldn’t require it.)

You can find project details here.

 

Now Appearing: VHDL Coded Modules

As I sit here working on my FPGA projects, it occurs to me that some of the work I am doing may be of interest to viewers of this site.  So, I will break down some of my projects into more basic blocks/modules and upload them for others to use or learn from.  I will attempt to annotate my code in a meaningful way so that everyone can understand what and how I am doing what I am doing in my code.

You can find an index of the VHDL modules in the link below.
VHDL Modules

How Fast is the Arduino Uno?

This was a question that popped into my mind lately.  Or rather, how efficiently does the Arduino Uno execute its C code?

I had read lots of articles of people switching to 32-bit chips on the Arduino platform in order to get better performance.  At first, I did not think much of this, but then started pondering why.  I mean, the 8-bit Uno can effectively execute one instruction per clock cycle giving it about 16 million instruction-per-second throughput.  Personally I think that is damn quick.  That beats my old Commodore Amiga computer by about four times (and that computer could play games, browse the Internet and run office productivity software.)  I started wondering if the Uno wasn’t actually attain its theoretical level of performance.  Does the C code compile so poorly that you lose a majority of the processing power?  To answer that question, I devised a little benchmark to see how efficiently the Arduino Uno can execute the mundane tasks associated with microcontrollers.

Here is the code.  The results are sent to the serial console.  (9600 baud)

// ---------------------------------
// Simple 'C' Benchmark for Arduino.
// ---------------------------------
// Date:  Aug. 3, 2016
// By: Brian Chhristian

// Clear the instruction counter.
unsigned long count = 0;

void setup()
{
    // There is nothing to initially setup.
}

void loop()
{
    count = 0;    // Clear the instruction counter
    int b = 0;    // Initialize result variable.
    
    // Get start time.
    unsigned long start_time = micros();

    // DO SOME STUFF.
    // I tried picking some commonly used functions to simulate
    // what might be used in the real world.  I did not use any
    // crazy mathematics as they are probably no indicative of
    // what the average user may incorporate.

    count++;                                // Increment instruction counter for each line of code.
    for (unsigned int x=0; x<1000; x++)     // Do something 1,000 times.
    {
        count++;
        b = DoSomething(1);                  // Jump to a subroutine.
    }

    // Get completion time.
    count++;
    unsigned long end_time = micros();

    // Calculate elapsed time and IPS performance.
    unsigned long calc_time = end_time - start_time;
    unsigned long ips = count / (calc_time * 1E-6);

    // Send result via serial console and wait.
    Serial.begin(9600);
    Serial.print("Expected result (1): ");
    Serial.println(b);
    Serial.print("Lines of code executed: ");
    Serial.println(count);
    Serial.print("Execution Time (us): ");
    Serial.println(calc_time);
    Serial.print("MIPS: ");
    Serial.println(ips / 1E6);
    Serial.println("");
    Serial.end();

    // Wait before running again.
    delay(5000);
}

// Do some stuff in a subroutine.
int DoSomething(int y)
{
    count++;
    int b = 0;

    count++;
    for (int z=0; z<16; z++)   // Do something 16 times.
    {
        count++;
        int a = a + 1;

        count++;
        if (a > 8)             // Lets do a compare.
        {
            count++;
            b = b + 10;        // How about some math.
        }
    }

    // Some more simple math and bit operations.
    count++;
    b = b / 2;

    count++;
    b = b & 8;

    count++;
    b = b << 3;
    
    count++;
    b = b - 63;
    
    count++;
    return b;          // Let's return.
}

There really isn’t anything scientific about this benchmark.  I just did a number of loops with compares, bit operations and some simple math.  This is somewhat representative of the kind of code I generally use.  Hardly ever do I use complex math in my controller projects, so I left that kind of stuff out.

What I have found with this experiment is that, as a baseline, you can assume the Uno can execute around 2.5 million lines of code per second.  Definitely the kind of code you write can make a big difference, but I feel this gives me a good starting benchmark when determining whether or not something is feasible on the Uno.  (Now if only the “digitalWrite” routine was as quick…)

A New FPGA Toy

I just purchased a Lattice iCEstick Development Board.  I have wanted to try these chips for a while now to see if they meet my needs for my smaller/simpler projects.

The iCE40 FPGA chips are a small form factor, inexpensive and minimalist series of programmable logic.  They are very low power device and have specs that range from 384 to 7680 logic cells and are available with up to 128Kbit of RAM and 210 I/Os.  That is still plenty of horsepower to do some pretty great things.

I have put some basic specs and data sheets up for the ICEstick board and its on-board peripherals.  Also, I have written a tutorial on how use the basic functions of Lattice’s iCEcube2 development software and programmer with a good ol’  blinking LED example.  If you are interested, you can check them out below.

Lattice iCEstick Development Board
“Blinky” Example

New USB Flash Drive Benchmarks

I just purchased two new USB Flash drives:  Lexar P20 64GB ($34) and Lexar S75 32GB ($11).  You can see their benchmarks here.

I am happy with the Lexar S75 32GB drive as it fits the bill for a larger capacity removable drive for cheap.  It’s not the fastest, but for $11 it gets the job done.

I also purchased the Lexar P20 64GB drive as a high-speed drive for quickly moving larger files around.  Wow, what a massive disappointment.  The specifications on Lexar’s website states 400MB/s read and 270MB/s write speeds.  I don’t get anything near that.  The measured read speed is fine at 341MB/s, but the write speed is paltry 39MB/s, way off the advertised 270MB/s numbers.  And if you send a collection of smaller files, be prepared for intolerable write speeds of 4.1MB/s.  (Yes that is four-point-one megabytes per second.)  This is unacceptable for a $34 drive, especially one advertised as being “faster with premium performance.”