You are here

Microchip PIC on Arduino with Jaluino Cuckoo

Baby Cuckoo


Cuckoo birds are brood parasites, they use other birds' nests to grow their hatchlings. Mother Cuckoo carefully selects existing nests and puts an egg, only one egg per nest. When Baby Cuckoo hatches, most of the time before other eggs, it just pushes them out the nest. This is its very first instinct, probably not the most rewarding one... Adoptive parents are now only focused on Baby Cuckoo and feed it graciously, with profusion.

This gave me an idea for a new Jaluino family board...


What about mimicing  Baby Cuckoo and pushing ATMega chip out of Arduino ? Then plug a tiny board with a Microchip PIC. This is a fast way, even if not the most rewarding one, to get an Arduino clone, isn't it ? And a nice way to take advantage of existing boards and features.

So, Jaluino Cuckoo is very small board aimed to be plugged instead of original ATMega168, on an Arduino board. Does it exist ? No, not yet, but this post is about designing this board to match as close as possible Arduino features. Because, like Mother Cuckoo, we first need to carefully observe our nest in order to lay down our egg and make sure it'll hatch with success.

Overview of Arduino features

Arduino Duemilanove or Diecimila will be the victims, the "cuckooed" boards. Both are using Atmel ATmega168 chip (or ATmega328, pin compatible, more memory) with a 16MHz crystal. Both are offering a wide range of features:

  • 14 digital inputs and outputs. Amongst them, some can carry special functions:
    • 2 TX/RX pins for serial communications
    • 2 pins for external interrupts
    • 6 pins carrying PWM outputs
    • 4 pins for SPI protocol
    • 1 pin connected to a LED
  • 6 analog inputs. 2 pins, out of these six, can also be used for I²C protocol.
  • another pin can be used as a voltage reference,
  • and a final one is used to reset.
One pin can sometimes carry more than one feature. Features are distributed as followed:


Arduino features


While matching pins, it's important to keep in mind this distribution. For instance, PICs can bring at most two PWM channels. At first sight, these two precious channels shouldn't match an Arduino pin with more than one feature. They could be mapped against PD5, PD6 and PB1. But, maybe, the most used one remains PWM0 on pin PD3 (just because this is the first PWM channel), which is also used as external interrupt. Should we use this pin and potentially miss an interrupt ?

ATmega168 pins are dispatched by port (PB, PC and PD). When looking at an Arduino board, pins go like this:

ATmega168 distribution

Which Microchip PIC ?

Now that we had a brief overview of the nest, let's choose our Cuckoo ! We can specify the following requirements:

  • 28 pins, PDIP (easy to solder)
  • self-writable (for bootloaders)
  • 5V operational voltage
  • runs as fast as possible with a 16MHz Xtal
  • at least 6 ADC channels, independent (ANSEL-like ADC channel selection)
  • 2 PWM channels
  • SPI
  • I²C

Microchip product matrix tool found few candidates, amongst them, PIC18F25K22 (big brother 18F26K22 is a big fat one, with 64KB memory, but not in production yet).

18F25K22 is an interesting chip, with a lot of features. It provides 32KB memory, 1.5KB RAM, 256B EEPROM. It has a 4xPLL module and can run up to 64MHz (16MIPS, just like ATmega168). This means its max speed is reached using a 64/4 = 16 MHz xtal, the same one that can be found in Arduino! It also has 19 analog inputs, independent, this will help while dispatching and matching Arduino pins. It also has two CCP modules (two PWM channels, seem to be multiplexed over 4 different pins), two MSSP modules to run SPI and I²C at the same time, two USART modules, three 8-bits timers and one 16-bits timer. An interesting chip...

How would Jaluino Cuckoo look like ?

Jaluino Cuckoo can't be as small as a simple 28-pins chip, because some pins must be mapped, a PCB is needed. But there could be enough space to put a "clever" PCB, plugged instead of Atmel chip, yet having enough space to use a shield. As suggestions received from this jallib thread

  • if a PCB is needed, it could also be used as a standalone board (when Baby Cuckoo leaves the nest ?). 
  • it could have its own external crystal, with jumper selection (Arduino's or Cuckoo's). This would allow to plug a 20MHz xtal, instead of just 16MHz. But, 18F25K22 can also run at 16MHz or 64MHz using its internal clock + 4xPLL, so does it worth it ?
  • it could have an ICSP connector, to easily program Cuckoo. I don't know if Arduino's ICSP could be used though
  • it could also use SMD components, 64-pins, etc... but maybe for a future version to cuckoo Arduino Mega...

How would it plug onto Arduino ? Maybe something like this ?

Cuckoo preview

Cuckoo PCB will have to be cut so it won't be in contact with ICSP connector (or it could plug on it to actually use it ?). Pin headers could be used in place of ATmega chip. PIC18F25K22 certainly won't be able to be plugged on these headers as it would be too thick when using a shield. But it can be moved away and hopefully this would leave enough space to put required components.

Now it's time to draw the schematic and decide how to concretely map pins between Arduino and Jaluino Cuckoo. In a major and critical step, we will have to ensure there's no physical constraints related to plugging shields with a cuckooed Arduino (btw, where's the reset button ?...). Finally, we will have to justify why creating such a useless board.

Feel free to react, either on this jallib thread or by commenting this page.



Sébastien Lelong


Poor Mother Cuckoo...

Which is Baby Cuckoo ?...