Python -> Nimrod

Nimrod

After several years using Python as my favourite scripting language I have developed a great appreciation for its conciseness and clarity. This experience though is so different and dissonant with my daily work in embedded control, where I use almost exclusively C nowadays.
Using Python in embedded control is tempting and I did play quite a bit with this concept, starting from the Pymite project, but I had eventually to surrender. I reached the conclusion that “dynamic typing” as in the Python interpretation of the term, is truly a luxury we cannot afford yet in embedded control. So is the interpreted nature of the language and any attempt to constraint it to fit in a (ahead of time) compiled image does completely disrupt the very nature of the language (see Micro Python).
The arrival of Swift showed me that it was possible to design a modern language with many of the Python characteristics that I love and at the same time think about performance and keep your feet firmly on the ground. But even Swift does not go low enough for my taste and it comes with the whole Apple “baggage” which makes it a very un-likely candidate for my kind of targets.
With help from the excellent site: “Learn X in Y minutes” (a true treasure trove) I had a chance to savour a couple dozen more languages in less than a week and find perhaps what I was looking for or the closest approximation: Nimrod.

Nimrod feels strangely familiar to me, perhaps because some of its structure is somewhat reminiscent of good old Pascal/Modula with clearly outlined Var and Type sections before a “PROC” (get that?) not a function, a procedure!!!
But the syntax is clean and void of semicolons and curly brackets or other strange symbol combinations so many other language (designers) seem to enjoy so much. Nimrod compiles to C language(!) and from there it is possible to cross compile to any target using any decent C compiler.

I am curious to see how far I can push Nimrod down to my favorite targets (PIC24/PIC32) and, why not, 8-bit microcontrollers too… Stay tuned!

 

 

Posted in Languages, PIC24, PIC32, Python | Comments Off on Python -> Nimrod

Source Code updates (v.1.4) Posted

I have committed several small improvements to the repository containing the Source Code for the book “Graphics, Touch, Sound and USB”.

These include some aesthetic enhancements to the Touch Grid project, the Touch Menu and in the 15-Tiles game.

Numerous patches also to the Sound chapter examples which I have streamlined as much as possible.

A new ZIP file (v1.4) has been finally added to the Downloads.

(Edited: my apologies, I originally mistakenly titled the post  v1.5 while it was still only 1.4!)

Posted in Graphics, PIC24 | Tagged , | Comments Off on Source Code updates (v.1.4) Posted

Supporting New Mikromedia boards with GDD_X

While I am not sure if the GDD_X tool will continue to be supported or if it will be added to the ‘new’ MLA (it is currently NOT planned), readers of the “Graphics, Touch, Sound and USB” book that have purchased a recent version of the Mikromedia boards (featuring the new Qt2 type TFT displays) might find some extra difficulty in running the last two projects in chapter 7.

We can blame the rapid evolution of the display market, its crazy (high volume consumer driven) dynamics, but the fact remains that we have to learn to live with it. Adding the new IL9341 controller support to the MLA graphics library is simple enough (I did include the new driver source files IL9341.c and IL9341.h in the book project repositories and I managed to add a few notes in each chapter just before going to print) but adding support to the GDD_X tool might seem a little more convoluted. Not to worry, here you will find a few notes that will help you ‘fix’ it at least as long as you stick to the ‘legacy’ MLA:

1- Start by browsing inside the /Microchip folder. If you followed the book first chapter instructions, that should have been copied in its entirety from the MLA installation directory (June-2013) into your working directory (/Mikromedia)

2- Open the /Graphics folder and proceed further inside the /GDD folder. Here you will find a Default_Template.xml file and a Default_Template folder.

3- Open the xml file with a text editor (MPLAB X editor?) and add the IL9341 drivers to the list enclosed by the <Drivers> tags.

<Drivers>
...
<list>Microchip\Graphcis\Drivers\IL9341.c</list>
<list>Microchip\Include\Graphics\IL9341.h</list>
...
</Drivers>

4- Save the file and proceed to opening the templates folder now. Inside of it you will find a /Configs folder. Once more, using your editor of choice, open the HWP_MIKRO_8PMP.h file. This is where the hardware configuration of the PIC24Mikromedia is defined.

5- You can customise it to your heart’s content, perhaps removing a lot of boilerplate stuff that has nothing to do with the Mikromedias, but to reduce risk and get to the point proceed to search for word ‘HX8347’. You will find it in four instances, where you will apply the following edits:

a) Where you find:

#define GFX_USE_DISPLAY_CONTROLLER_HX8347D

Proceed to comment the line and/or edit as:

#define GFX_USE_DISPLAY_CONTROLLER_IL9341

b) Where you find:

// Using HX8347D Display Controller
#if defined(GFX_USE_DISPLAY_CONTROLLER_HX8347D)
#define DISP_ORIENTATION 90
#define DISP_HOR_RESOLUTION 240
#define DISP_VER_RESOLUTION 320
#endif

Edit as :

#if defined(GFX_USE_DISPLAY_CONTROLLER_HX8347D) || defined(GFX_USE_DISPLAY_CONTROLLER_IL9341)
...

c) Where you’ll find:

#elif defined (GFX_USE_DISPLAY_CONTROLLER_HX8347D)
#define PMP_DATA_SETUP_TIME (18)
#define PMP_DATA_WAIT_TIME (82) // See HX8347 data sheet for details
#define PMP_DATA_HOLD_TIME (0)

add:

#elif defined (GFX_USE_DISPLAY_CONTROLLER_IL9341)
#define PMP_DATA_SETUP_TIME (0)
#define PMP_DATA_WAIT_TIME (0) // See IL9341 data sheet for details
#define PMP_DATA_HOLD_TIME (1)

And you are all set!

 

 

Posted in Graphics, PIC24, Tips and Tricks, Tools | Tagged , | Comments Off on Supporting New Mikromedia boards with GDD_X

A Cross Platform Mikromedia HID Bootloader

mikrobootloader logo

I love the bootloader that comes with all MikroElektronika products, and in particular the Mikromedia boards (and can be used with the ‘Graphics, Touch, Sound and USB’ book), but for one thing… it does NOT run on my platform of choice: OS X!

In fact it does work only on Windows, so I suspect that Linux users feel equally left out. To be honest things had never been this good for PIC developers as only in the last few years the MCHP toolchain has expanded to include OS X and Linux with MPLAB X and recently all the XC compilers…

The specs of the mikroBootloader are “kind of open” … in other words, if you ask, the nice guys at Mikroe will give you everything you need (and some). So I did (ask) and they did give me bits and pieces of source code, some comments, and a lot of encouragement and I quickly concocted my own version of the boot loader application for Mac and, since I used Python: Tkinter libs for the GUI and the HID-API libs for easy USB access, this should work right out of the box on most Linux distros as well (your mileage might vary, please report of your experiences).

Please feel free to download the script from this shared Github  repository and use, improve, share…

Continue reading

Posted in PIC24, Python, Tips and Tricks, Tools | Tagged , , | Comments Off on A Cross Platform Mikromedia HID Bootloader

Flying to Trieste

IMG_3353 IMG_3355

Saturday morning, against all weather forecasts, I found the perfect conditions (CAVU) to attempt a flight as East as I had ever been before.

Well, I was born there and dreamed of seeing it from above for so long…

Seen from the air, it seemed as beautiful a place as it can be only in our own childhood memories!

Posted in Flying | Tagged | Comments Off on Flying to Trieste

Adding Support for the PIC32 Mikromedia

I have just finished the first complete port of all the “Graphics, Touch, Sound and USB” book projects to the PIC32 Mikromedia board series!

PIC32 Mikromedia

There were several lessons learned in the process, interested readers will find detailed notes (and a link to a shared Mercurial repository) in the dedicated PIC32 Mikromedia page of the book web site.

Over all it turned out to be a relatively painless experience, with the added reward of seeing a PIC32 performing at more than  8x the speed of the PIC24 Mikromedia boards…

 

Posted in PIC32, Tips and Tricks | Tagged , , , , , | Comments Off on Adding Support for the PIC32 Mikromedia

Adding support for the PIC24EP Mikromedia

I have just finished the first complete port of all the “Graphics, Touch, Sound and USB” book projects to the PIC24EP Mikromedia board series!

PIC24EP Mikromedia

There were several lessons learned in the process, interested users will find detailed notes (and a link to a shared Mercurial repository) in the dedicated PIC24EP page of the book web site.

Over all it turned out to be a relatively painless experience, with the added reward of seeing a PIC24 performing at up to 4x the speed of previous generations…

 

Posted in PIC24, Tips and Tricks | Tagged , , , , , , | Comments Off on Adding support for the PIC24EP Mikromedia

Weekend Reading Recommendations

Architects look at thousands of buildings during their training, and study critiques of those buildings written by masters. In contrast, most software developers only ever get to know a handful of large programs well—usually programs they wrote themselves—and never study the great programs of history. As a result, they repeat one another’s mistakes rather than building on one another’s successes.

Weekend reading recommendations (for the next weekend perhaps):

  • FreeRTOS, http://aosabook.org/en/freertos.html
  • PyPy: http://aosabook.org/en/pypy.html

And many more to choose from at: http://aosabook.org/en/index.html

 

Posted in Languages, Python, Tools | Tagged , , | Comments Off on Weekend Reading Recommendations

Python Most Popular Among Top U.S. Universities

Python is now the most popular introductory teaching language at top U.S. universities!

http://cacm.acm.org/blogs/blog-cacm/176450-python-is-now-the-most-popular-introductory-teaching-language-at-top-us-universities/fulltext

Posted in Python | Tagged | Comments Off on Python Most Popular Among Top U.S. Universities

Temboo and the IoT Babel Tower

temboo

I recently discovered Temboo, and after playing with it for a few minutes I was able to get a short Python script accessing a complex Google API I had never seen before running and delivering useful data to my .. application.
These days the number of services available online (such as google Maps, Flicker, Dropbox…) is growing exponentially. They make possible incredible things that enable our (Internet connected) applications to provide unprecedented utility. Unfortunately they all come from different companies and they all bring their own API and with it a more or less steep learning curve.
While hardware platforms (like Arduino) simplify access to basic embedded control hardware, this “Babel tower of APIs” works against it and fragments/slows down the adoption of the available software tools and services.
Temboo takes 100 + such APIs and unifies them, reducing them to a single set of recipes (or Choreos in Temboo lingo) which are then automagically presented to the user in a language/platform of choice among which: Python, Perl, Ruby, C#, Java, PHP, Arduino/wiring, but also IOS and Android.

Check it out!

Posted in PIC32, Python, Tools | Comments Off on Temboo and the IoT Babel Tower