Home > ARM, Development boards, Reviews > mbed – Rapid Prototyping with Microcontrollers

mbed – Rapid Prototyping with Microcontrollers

Name: mbed
Distributor: Silica Avnet
Price: $60

Evaluation Type: Development Board
Application you used the part in: Easy embedded development with microprocessors
Was everything in the box required?: Yes
What were the biggest problems encountered?: Requires an internet connection for software development (compiling)

Scoring
Product Performed to Expectations: 10
Specifications were sufficient to design with: 9
Demo Software was of good quality: 8
Demo was easy to use: 10
Support materials were available: 8
The price to performance ratio was good: 9
TotalScore: 54

Prelude
Recently we got an mbed donated by Silica Avnet, so we have been testing this for a while.
The mbed is an easy to use microprocessor board with an LPC1768 ARM Cortex-M3 as its’ heart. The board have many different features, including USB Host, USB Client, Ethernet, SPI, I2C, PWM and much more – everything controlled by the LPC1768 microprocessor running at 96MHz.


Video review
To start with please take a look at the Video demonstration when I show the board itself and a breakout board we made, making it easy to get started using both USB and Ethernet.


The mbed board

The mbed board


As said in the prelude the mbed contains an LPC1768 microprocessor from NXP. This microprocessor has an ARM Cortex-M3 core running at 72MHz. It contains 512KB Flash and 64KB RAM. It has built in 10/100 Ethernet MAC and a USB 2.0 compliant Host/Device/OTG port. Besides of that it does also come with other standard microprocessor peripherals like USART, SPI, I2C, CAN, 12-bit ADC and a 10-bit DAC.
The chip itself is placed on a “breadboardable” board with 2x 20-pins thruhole male headers. The different peripherals is then brought out to these pins for an easy to use development solution.

The board also contains a USB port connected to the “mbed interface controllers” which takes care of the programming. By connecting the mbed to a computer, it will enumerate as a USB Flash Drive and to program the LPC1768 you simply drag the binary (.bin) file to the flash drive. The flash drive has a size around 2MB, and when the board is reset it automatically programs the most recent binary file into the LPC1768. Very easy and handsome programming!

The board also contains the necessary external Ethernet PHY circuitry – so when you want to add Ethernet to your next application, all you need is simply a MAGJACK ethernet connector. When you want to add USB Host or Client all you need is simply a USB connector. All required external hardware for the different peripherals is already on the board (though some resistors and capacitors are still required).

All this combined makes a great development tool for hobby or student use – well competitive with the well known Arduino.


mbed Peripheral board
To get you started even faster using one of the many peripherals on the mbed we decided to make a peripheral poard. This mbed Peripheral Board contains all the necessary connectors, so you will be able to use USB Host, USB Client, and Ethernet.

Our first prototype. USB B connector not yet soldered.


Again our prototype. Just from the side.

The mbed plugs directly into the female headers on the peripheral board, making the required connections to the external connectors, but on the same time also making the unused pins available on two other rows of female headers.
With a jumper you are able to switch the power supply mode, whether you want it to be powered from USB Client or from the Power Jack connector. With another jumper you can select whether you want to use USB Host or USB Client.

mbed Peripheral board schematic


We are currently doing the final revisions of the board and hope to be able to sell this inexpensive board as a kit, in the beginning of 2012. It will also include SD Card support.


The software
To start creating applications for the mbed, you don’t even have to install anything on your computer. When connecting the mbed to your computer you will find an HTML file on the flash drive. When opening that you will be taken directly to the mbed homepage to register your new mbed and an account for their online compiler.

Their online compiler is consists of their own online development IDE connected to different servers capable of compiling your code. This means that your code is written online, saved online, compiled online and then downloaded to your computer as a binary file, ready to be copied to your mbed.

The online compiler has a great number of libraries for all the peripherals. The API (functions) of the libraries are very similar to the one used in the Arduino world. Therefor it is very easy to get started developing, as you don’t have to think about many lines of code for initializing the different peripherals.

The only minus about the online compiler is of course that it requires an internet connection. So without an internet connection you won’t be able to make any applications for your mbed, without buying a compiler solution like KEIL uVision.


Test application – Random number voice
The project shown in the video above is a simple demonstration of using the Ethernet for wave-file downloading, saving the file to a USB Memory Stick, for later playback using the 10-bit DAC peripheral.
The project is made using already available libraries from the big online mbed community – why reinvent the wheel?

The code used in this project can be found below. Let me describe brifly what happens in the main() function.

To start with I set up the Ethernet controller, which makes it fetch an IP-adress by DHCP.
Afterwards I check if a USB memory stick is inserted and formatted by reading the root directory.
Next I go to webaddress (PHP-script) to generate an audio file (.wav) with a specific message, and in the following line I download this file to the USB memory stick by using the get_file() function from the top of the code.

Finally I go into a loop where it gets a random number from a PHP-script by using the get_string() function.
Afterwards it sends this number to the audio file generation script, which generates a wave-file with the number being said.
Then again it downloads this audio file, but this time it saves it as “numberXX.wav” to the USB memory stick.

To end all this it first plays the specific message (“The random number is”) and then it plays the recent downloaded number audio file. This continues to be done in a loop, again and again.

I have created a free Voice Generation service, that can be used in this project. The service is free though limited to a maximum of 100 voice generations per day.

You can create a user here: http://www.tkjweb.dk/?goto=Voice
After you have created a user you will receive a mail with more information on how to use the service.

#include "mbed.h"

#include "MSCFileSystem.h"
#include "EthernetNetIf.h"
#include "HTTPClient.h"
#include <wave_player.h>

// Network and USB filesystem
EthernetNetIf eth;
HTTPClient http;
MSCFileSystem usb("usb");
LocalFileSystem local("local");

// Audio Output
AnalogOut DACout(p18);
wave_player audio(&DACout);

DigitalOut myled(LED1);

// Simple HTTP helper functions
int get_file(char *url, char *file) {
    printf("Getting url to file [%s]...\n", url);
    HTTPFile f(file);
    HTTPResult r = http.get(url, &f);
    if (r != HTTP_OK) {
        printf("HTTPResult error %d\n", r);

        return 0;
    }
    return 1;
}

int get_string(char *url, char *str) {
    printf("Getting url [%s] to string...\n", url);
    HTTPText t;
    HTTPResult r = http.get(url, &t);
    if (r != HTTP_OK) {
        printf("HTTPResult error %d\n", r);
        str[0] = 0;
        return 0;
    }
    strcpy(str, t.gets());
    return 1;
}

FILE *wave_file;
void PlayWav(char *filename)
{
  wave_file=fopen(filename, "r");
  audio.play(wave_file);
  fclose(wave_file);
}




char receiveBuffer[100];
char randomNumber[5];
const char* genURL = "http://www.yourdomain.com/voice.php?msg=";
char urlBuffer[70];
char nameBuffer[20];
FILE *fp;

int main() {
    printf("Setup network...\n");
    EthernetErr ethErr = eth.setup();
    if(ethErr) {
        printf("Error %d in setup\n", ethErr);
    }

    /* Just make sure USB is initialized */
    DIR *d;
    struct dirent *p;
    d = opendir("/usb");
    printf("\nList of files on the flash drive:\n");
    if ( d != NULL )
    {
        while ( (p = readdir(d)) != NULL )
        {
            printf(" - %s\n", p->d_name);
        }
    }
    else
    {
        error("Could not open directory!\n");
    }
    printf("\n\n");


    printf("Getting overall-message\n");
    get_string("http://www.yourdomain.com/voice.php?msg=The+random+number+is", receiveBuffer);
    strcat(receiveBuffer, "\n");
    printf(receiveBuffer);

    get_file("http://www.yourdomain.com/voice.wav", "/usb/random.wav");


    printf("\nStarting Random-Number Generator cycle\n\n");
    while(1) {
        if (get_string("http://www.yourdomain.com/rand.php", receiveBuffer) == 0)
            continue;
        strcpy(randomNumber, receiveBuffer);

        strcpy(receiveBuffer, "The random number is ");
        strcat(receiveBuffer, randomNumber);
        strcat(receiveBuffer, "\n\n");
        printf(receiveBuffer); // Print the random number

        myled = 1;

        strcpy(nameBuffer, "/usb/number");
        strcat(nameBuffer, randomNumber);
        strcat(nameBuffer, ".wav");

        /* Check if the file exists already */
        fp = fopen(nameBuffer, "r");
        if ( fp == NULL )
        {
            /* If not, download the number */
            strcpy(urlBuffer, genURL);
            strcat(urlBuffer, randomNumber);

            get_string(urlBuffer, receiveBuffer);
            strcat(receiveBuffer, "\n\n");
            printf(receiveBuffer);

            get_file("www.yourdomain.com/voice.wav", nameBuffer);
        } else {
            fclose(fp);
        }

        PlayWav("/usb/random.wav");
        PlayWav(nameBuffer);


        myled = 0;
    }
}

Please feel free to write a comment with any questions regarding the mbed, this project and the source code.


Pros and Cons
Pros:

  • Easy online programming enviromnment (IDE)
  • Programming language and libraries similar to the Arduino

Cons:

  • Online compiler – not possible to program offline without buying a compiler


Conclusion
It has been a pleasure using the mbed for embedded development. The mbed makes microprocessor development very easy, like the Arduino, but with the processing power and peripherals as an ARM device.
The mbed boards makes a great fit for the hobbyist who has grown out his Arduino and would like to make even bigger projects – maybe using the extra speed or one of the many peripherals.

I would definitely recommend the mbed to any microprocessor enthusiasts, especially if they are currently using the Arduino and knows how to use their pretty straight forward language. The mbed might not be a good choice for a commercial application though, as the online compiler makes a bad fit for a company that requires the code to be very close and confidential.

In the future you will definitely see more projects from us using the mbed!

Categories: ARM, Development boards, Reviews Tags:
  1. Asad
    October 28th, 2011 at 22:58 | #1

    can i copy same code in my mbed ,, will it work? or it need some changes?

  2. assad
    October 28th, 2011 at 23:16 | #2

    sir could i copy past same program and library in my compiler? or it needs some changes? kindly give me basic idea to download file as you done in your coding….

  3. Asad
    October 29th, 2011 at 20:11 | #3

    sir kindly help me….

  4. October 29th, 2011 at 23:11 | #4

    @assad
    Dear Assad.
    Of course I will try to help you, but please have in mind that our response may take a while.

    The code you see in this review is the code I used in the project. You have to add your own generation URL and Wave file download URL to get it working.
    I will soon post the PHP- and .NET-code which is used to generate the Voice wave file.

    If you are just looking for a way to download files to your mbed and a USB memory stick you should have a look at the “int get_file(char *url, char *file)” function. This functions saves the content of a file on the internet (url) to a local file (file). The location of the local file can be all the places the mbed supports: /usb, /sd and /local.

    Best Regards
    Thomas Jespersen

  5. Asad
    October 29th, 2011 at 23:42 | #5

    oh thanks, i hope you will done more with mbed, it will be helpful for new users of arm such as me

  6. October 30th, 2011 at 11:06 | #6

    @Asad
    I surely will 🙂

  7. Asad
    November 3rd, 2011 at 21:58 | #7

    sir could you create mbed library of any tft lcd easily available in china, such as ILI9325

  8. November 3rd, 2011 at 22:04 | #8

    @Asad
    Dear Asad.
    Yes I can. I have made a working ILI9325 library for the STM32, and it would be easily portable for the mbed!

    Thomas

  9. Asad
    November 3rd, 2011 at 22:55 | #9

    could you give me library?

  10. Asad
    November 3rd, 2011 at 22:56 | #10

    or will you convert this library in mbed format?

  11. Asad
    November 3rd, 2011 at 23:24 | #11

    Sir
    If you have some extra time then pls done this i shell be thankful to you.

    M.Asad

  12. November 7th, 2011 at 13:07 | #12

    @Asad
    Dear Asad.
    Unfortunately I don’t have any time for this currently.
    Please write us an email and we can give you a couple of hints.

    Thomas

  13. JZ-system
    March 8th, 2012 at 23:57 | #13

    It is possibile to but that pcb??

  14. March 10th, 2012 at 12:43 | #14

    @JZ-system
    Yes it is. You can buy the board as a kit from our Webshop: http://shop.tkjelectronics.dk/product_info.php?products_id=30

  15. December 23rd, 2012 at 20:14 | #15

    Kindly send the one mbed board and one peripheral board for evaluation at our Department of Electronics, RTM Nagpur University, Nagpur – 4400333 (India)
    Our research team shall be glad to have one and send the feedback

  1. No trackbacks yet.