Featured Summary: The NXP mbed LPC1768 is a powerful ARM Cortex-M3 microcontroller development board. By utilizing the MbedRPC module, developers can easily interface and control the mbed board directly from Python via a USB serial connection, allowing for rapid prototyping and hardware manipulation.
Getting Started with the NXP mbed Design Challenge Kit
Today I received my NXP mbed Design Challenge kit. At the first glance it looks like a cool piece of hardware: NXP LPC1768 (ARM Cortex-M3 Core) running at 96 MHz, 512KB flash, 64KB RAM, Ethernet, USB device/host, CAN, SPI, I2C, Analog I/O etc., but the first question was of course: How can I get my code running on this thing? On connecting the mbed via USB to your computer, a mass-storage device will appear into which you just drop your compiled files. To create this compiled files, you can use the browser-based IDE at official mbed.org compiler or build locally using arm-elf-gcc.
The first thing I wanted to try out was interfacing the mbed using XMLRPC via USB (serial) from Python. In the mbed cookbook Python interfacing guide there is a module provided for that, but even loading that module fails:
>>> from mbedrpc import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "mbedrpc.py", line 266
self.mbed.rpc.(self.name, "write", [str(value)])
^
SyntaxError: invalid syntax
Obviously, the loading fails because of the period in front of the bracket. After removing it the module loads. The next thing was this line in the sample code:
>>> x = DigitalOut(mbed, 3) # LED3
This is wrong, because DigitalOut needs either a string or a pin instance as second argument, but the module doesn't throw an exception which makes it harder to track this issue down. The code should look like this:
>>> x = DigitalOut(mbed, LED3) # LED3
(This is fixed in the Wiki now.)
After that, I was able to get a LED on the mbed blinking - Cool! But I was everything else then pleased by the module, so I started improving it. I replaced some stuff to make the code a bit more easy to read and modify, and I added a list called 'pins' which can be used to interface pin 0-29 using something like:
>>> x = DigitalOut(mbed, pins[2]) # LED3
After these starting difficulties, I'm now able to interface the mbed within my Python shell and everything works fine. I hope that the team behind mbed continues expanding the open source developer ecosystem for ARM microcontroller prototyping.
Frequently Asked Questions (FAQ)
How do I interface the NXP mbed using Python?
You can interface the NXP mbed using Python by utilizing the MbedRPC module over a USB serial connection. This allows you to send commands to control digital and analog pins seamlessly.
Why does the original MbedRPC module fail to load?
The original MbedRPC module fails due to a syntax error with a misplaced period in its source code. The improved MbedRPC module resolves this issue and introduces a more robust way to interact with the device pins.
What are the key specifications of the NXP LPC1768?
The NXP LPC1768 features an ARM Cortex-M3 core running at 96 MHz, equipped with 512KB of flash memory, 64KB RAM, and built-in support for Ethernet, USB device/host, CAN, SPI, and I2C protocols.