Ten Projects for Simplicity

While waiting for the PICDEM Curiosity board  (DM164137) to become more “available”, I kept at testing various new click boards with the “Simplicity board” aka PICKIT3 Low Pin Count demo board (DM164130-9).

Simplicity

 

Note the two SIL connectors added to the top of the prototyping area. That’s all it takes!

You will find about ten (adding as I go) Simplicity projects posted on GitHub to stimulate your curiosity (pun intended). They all follow the path set in my latest book “This is (not) Rocket Science“. Taking advantage of the Core Independent Peripherals (CIP) and extensive use of the MPLAB Code Configurator to avoid all the tedious work and keep only the fun part: experimenting!

Please fork, improve, extend, expand at will…

Posted in PIC16, Tips and Tricks, Tools | Tagged , , | 1 Comment

Stuck in Kindergarten!

Mom

There is only one thing that annoys me more than the hype and abuse of “IoT” and that is the hype surrounding the term “Hack”!

I do understand the need to excite a generation of young minds to take more STEM and at an earlier age.  I do get the importance of quick learning cycles and fast product development truly centred around the user needs and experience hence pr(e/o)totyping, Agile, etc…

But sooner or later somebody has got to do the homework!

If all we teach and prize aspiring engineers and entrepreneurs for is quick hacks and playful inventiveness without teaching them where the hard work has to be done to turn ‘it’ into a maintainable,  sustainable and reliable product, we are heading for very interesting times!

It’s feels like Kindergarten, where all kids’ doodles are applauded as master pieces and their incredible potential is only bound by the pride of the parents.

Posted in Tips and Tricks | Comments Off on Stuck in Kindergarten!

A Tale of Two (USB) Bootloaders

USB Low Pin Count demo board (DM164127-2)

USB Low Pin Count demo board (DM164127-2)

I have been looking with great interest at boot loaders design in recent months. It all started with the “Graphics, Touch, Sound and USB”  book I published last year, where I used  Mikromedia boards as my primary hardware platform to illustrate how easy it was to adapt the Microchip Library of Applications (MLA) to fit a custom design.  Those boards all come pre-loaded with a clever USB boot loader (based on the USB HID class). The fact that MikroElektronika provided a Windows-only  application, motivated me to learn more about it and write a platform agnostic version of the Loader application (using Python) for all my Linux and Mac readers!

Later came a new 8-bit project. An Intelligent Power Supply module featuring the PIC16F178x family. Half way through the design of a basic firmware framework, I realised that without an I2C boot loader this project would have been very user unfriendly, so I set off to write one. In the process, I learned a lot about writing boot loaders using the XC8 compiler (more on this in a future post). Most importantly, I learned a lot about the challenge to make a boot loader fit in the smallest code-protection unit (512 words) available on a PIC16F micro controller.

Writing an I2C boot loader (in C) that uses less than 512 instructions is relatively hard. But if you know a little about USB, you might assume that writing a USB boot loader that fits in the same space is simply impossible.

Continue reading

Posted in I2C, PIC16, Python, Tips and Tricks | Tagged , , | Comments Off on A Tale of Two (USB) Bootloaders

eXtreme USB with PIC16F145x

eXtremeUSB

Believe it or not, this is the USB temperature data-logger project recently (June 15, 2015) posted on Hackaday.io by Michael Mogenson.  Now the temperature sensing aspect of the project is relatively interesting to me, what is absolutely unique is the ingenuity applied to the mechanical construction of the device (see figure above!). This design is so radical that it might just work.

In fact I find it could be easily the most vivid representation of the unique capabilities of the PIC16F145x series, featuring a Crystal-less Full Speed USB device interface! Not only there is no crystal, but there are not caps as well. In fact all pins of the device have been filed away! Even the choice of the PDIP package is adding a somewhat nostalgic note to the whole (most designers today would choose one of the minuscule UQFN packages) and nicely highlights the ideal placement of the power supply and D+/D- pins on the device.

Vote it for the 2015 Hackaday Prize!

Posted in PIC16, Tips and Tricks | Tagged , | Comments Off on eXtreme USB with PIC16F145x

Microcontroller Core Simulation Strategies

pic16f54

There are several reasons why you might want to write a simulator for a micro controller: education, debugging, legacy/preservation, or just fun.

Over the years I have felt the need for a bit of all of the above and I have published some of the results of such investigations. For example, in the category fun but also definitely legacy, I have written a simulator for the glorious Z80 microprocessor and the entire ZX Spectrum home computer (to run old “original” video games on a brand new PIC32 Mikromedia).

A simulator like that can be quite complex to “read”, the Z80 was not exactly a RISC machine with its 750+ individual instructions. For educational purposes I developed instead a PIC16 (baseline) simulator. Now that is RISC and it is quite simple code to follow, once more it is all C language for a PIC32. Several interesting things came out of that project: I discovered that although not optimised for speed the simulator could run two PIC16 in parallel (@4MHz) on a single PIC32 (@80MHz) proving once and for all that PIC16+PIC16 = PIC32!

But both the Z80 and the PIC16 simulator where written so to simulate code execution with the granularity of the instruction cycle (Tcy), without any regard for the actual way the microcontroller/processor instruction decoding and inner workings were actually implemented in silicon. More recent investigations of the Core Independent Peripherals design methodology (see the new Rocket Science book) drew my attention to the need to obtain a more accurate type of simulator. One that is capable of reproducing the behaviour of a (PIC16) microcontroller on a  cycle by cycle basis, reproducing each of the four Q cycles used by the core to execute each instruction.

So I set off to write a new simulator but this time I chose Python as the host language to add a little challenge to the project and to achieve a bit more portability across desktop platforms. Using solely the device data sheet as a source for hints of the internal architecture and silicon implementation details, the new cycle by cycle PIC16 (baseline) simulator turned out to be surprisingly compact and efficient.

Python is known to be quite expressive, but at the same time it is certainly not famous for its ability to describe the low level detail of a micro controller core.

By mimicking (or at least trying to stay closer to) the device internal architecture, the resulting application got reduced to half the number of lines of code while at the same time gaining in accuracy. With this new design it should be possible to add peripherals (core independent ones of course) and simulate very accurately the timing of the CLC macro blocks, the HLT and SMT timers and many more…

 

Posted in PIC16, Python | Tagged , , , | Comments Off on Microcontroller Core Simulation Strategies

Volare

IMG_0504

It’s been a while since I posted a flying picture …

This is where you can find me this week!

 

 

Posted in Flying | Comments Off on Volare

Waiting for Curiosity -> Simplicity

While preparing the code examples for the “Rocket Science” book, I had an opportunity to play with a prototype of a soon to be released new 8-bit board called “Curiosity” featuring a built in PICkit3 programmer/debugger (a la PIC24/PIC32 Starter Kit) and, for the first time, a mikroBUS© connector.

This was quite some fun, but I soon got addicted. I could play with the (Mikroe) Click© boards all day long… but what to do while waiting for Curiosity to be released to production?

DM164130-9

Simple, hack one of the good old 8-bit Low Pin Count demo boards (DM164130-9) to turn it into a brand new… Simplicity board!

All it takes is an old LPC board (or one of the PCBs included in the kit) and two strips of single-in-line (female) 100mils connectors, wire-wrap, a soldering iron and a little patience.  A PICkit3 will do the job and will power the board as well…

A free sample of PIC16F1509 or PIC16F1709 will ensure hours of fun assembling new creative uses for the Core Independent peripherals (CIP) to control the many Click boards and quick prototyping using the MPLAB Code Configurator and the MPLAB XC8 compiler.

 

 

Posted in PIC16, Tips and Tricks, Tools | Tagged , | Comments Off on Waiting for Curiosity -> Simplicity

8-bit is Easier! This is (not) Rocket Science – new Book on Lulu!

I felt the urge to write another book and this time I ‘ve focused on the new 8-bit PIC16F1 family and its Core Independent Peripherals:

Rocket Science Cover

ISBN: 978-1-312-90777-5

Lulu.com, 160 pages

Three Steps to embedded Control ZEN

  • Discover a whole new set of Core Independent Peripherals
  • Use MPLAB® Code Configurator to generate automatically all peripheral initializations for your applications
  • Follow the many (single page) examples to create fast and efficient solutions using exclusively MPLAB® XC8 C compiler

Who should read this book:

  • If you think you know 8-bit microcontrollers, think again. These are not your grandfather’s microcontrollers anymore!
  • If you knew and liked PIC microcontrollers, but have not looked at them in a while, you will get a kick out of this!
  • If you have been trying to use small 32-bit microcontrollers, but got put off by the rapidly escalating complexity and the excessive reliance on software when trying to realize even the simplest real time functions, you will get a refreshing new perspective!

Available directly at Lulu.com (for a limited time at 30% discount)

Also available (shortly) at Amazon and most other major distribution networks

Posted in PIC16 | Tagged , , , | Comments Off on 8-bit is Easier! This is (not) Rocket Science – new Book on Lulu!

Rebol to RED and RED/System with a detour by IO

My search for a better language to use in embedded control continued this month. I spent more time than I would like to admit on LearnXinYminutes.com. I find it irresistible, and what is worse,  once I start reading about a new language, and I google it to find out more, I tend to get sucked in a seemingly endless nest of cross links, down the rat hole.

So somehow, I truly don’t recall the exact mental process, I ended up exploring Rebol, an example of an homoiconic language. Think a language that uses the same syntax to represent data and its own code. Which means the two can become easily interchangeable and therefore , among other interesting things, it means that it is very easy to create new dialects of the language! Which is interesting if we think of how this could be used in vertical application in the embedded world.

From Rebol the step to RED is short, as the latter is an open source rewrite of sorts of the first and seems to be still actively developed,  while Rebol seems to have been abandoned by now…

RED developers are ambitious, and in the hope of bootstrapping the language, have started developing a dialect of the language (RED/System) that can cover the low level stuff and be compiled (rather than interpreted by a VM as most new languages nowadays). Now that is interesting again, RED/System could be close to what I am looking for…

(I had to play with it, so I used the online REPL…)

Now at this point I am really not sure how but while I was  looking at the concatenative family of languages (among which you might recognise FORTH…), I somehow got detoured to IO which is really a prototype based language of unique elegance.

I really like the absolute simplicity of IO’s grammar, the entire syntax of the language can be described in 5 lines:

exp        ::= { message | terminator }
message    ::= symbol [arguments]
arguments  ::= "(" [exp [ { "," exp } ]] ")"
symbol     ::= identifier | number | string
terminator ::= "\n" | ";"

Which translates in an incredible expressive power (also see the simplicity of the concurrency model offered) and with it “danger”…

(I had to play with it so I got the source and a brew for my Mac)

But IO virtues would be lost if we were to compile it and constrain it to the low level stuff as RED/System or RPython can/could.

Then somehow an article , linked from Reddit, brought me back to take a second look at Swift, ouch, short circuit!

Posted in Languages | Tagged , , , , , | Comments Off on Rebol to RED and RED/System with a detour by IO

New Book and Board Bundles

Mikromedia PIC24 Bundle

PIC24 Mikromedia Bundle

Mikromedia PIC32 Bundle

PIC32 Mikromedia Bundle

 

If you are looking for a perfect Christmas gift (to yourself), let me suggest the new Book & Board combos from MikroElektronika!

Seasonal and daily discounts will apply during the holidays! See  Mikroe online shop for pricing.

Or if you already got the book, know that you can now buy the Mikromedia PIC24 and PIC32  boards  from the Microchip Direct online shop and take advantage of special end of year discounts as well!

Happy Holidays!!

Posted in PIC24, PIC32, Tools | Tagged , , , | Comments Off on New Book and Board Bundles