Archive for PIC-on-The-Go

USB Side-Project

Sometimes I get a little bit inspired by things on the internet. The internet isn’t all bad.

 

Here are some projects, pictures, or schematics that I like:

http://old.bennahill.com/tsunami/

http://www.piclist.com/techref/io/usb/pcbmaleconn.htm

http://vonkonow.com/wordpress/2012/03/usbserial-pcb/

http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/PowerCell-v13.pdf

(That’s mostly a reference for me, for later)

 

 

Pretty regularly, I have need of a cheap microcontroller that does one thing only, like output a stepper motor’s step sequence. It would be nice to have a pile of these, and be able to leave them in place, price being insignificant.

 

 

A pretty obvious candidate is the PIC18F14K50. It’s an older PIC that costs about $1.50, has a very small package, and speaks USB. I had also planned to draw a USB card edge connector. The advantage of that is that it’s easy (no solder required!), cheap (minus the costs of a slightly longer PCB), and compact. The cons are that it requires an ENIG gold plated finish to prevent contact oxidization, and the FR4 thickness needs to be 2mm, which is not standard, although not super unusual, either.

 

I’ll probably still do that, eventually, but first I got distracted by opening up a USB flashdrive.

 

Then this happened:

 

So I sent it off. It’s a hair larger than the original flashdrive PCB because of the programming headers, but it fits.

USB Thing

I used the PIC18F14K50 because I have a pile of them, but if I were to go for an even smaller package, I could fit a flash memory chip on the other side, like the original. That’s a great pathway to a flashdrive that writes a rootkit on-the-fly to data as it gets stored, for example. Scary stuff, and it doesn’t even seem that hard.

A flash memory chip is even pretty bulky, for what it is. By replacing it with a microSD card, there is even more space for other junk. Like using an ESP8266EX for the microcontroller, and drawing a small wifi antenna on the PCB.

 

There are so many side channels for this project, I don’t even know where to start.

In the meantime, I’ve spun this off into it’s own repo, here.

There’s a quick LED-blink program, but the real fun is in the “HID” projects.

 

Note the pogo pins I jammed into my PicKit for programming. The slot quite nicely into the programming header, while the board is being powered over USB.

 

When you plug this in, it appears to be a dud flashdrive. Doesn’t do anything. Until you forget about it and leave it in for ten minutes. At that point, it emulates a HID keyboard, and starts typing commands.

As this is just a test, it types “Windows-R->Notepad->Hello world!”, but it’s a great demonstration of the terrifying stuff you can do with literally 15 hours or less of work.

 

Keep in mind, I have never worked with USB hardware before. This stuff is not rocket science.

 

Don’t plug in unknown USB drives, folks!

 

Travel-PIC

With the huge popularity of Arduino in the past few years, everything that can be advertised “Arduino-compatible” is being commoditized to such a huge degree that it can be hard to find price-competitive components that do not have that distinctive Arduino pin layout.

 

 

An example is this TFT touchscreen LCD. It’s like, 6 bucks, which is insane. This is definitely going to show up in some future projects of mine.

 

Having everything work as an Arduino shield is all well and great, but I’m generally against using them. My problem with that whole ecosystem has always been that:

A) It shields(get it?) you from what is really happening on the microcontroller

B) It follows that if the user is unfamiliar with the inner workings of their system, then they will be motivated to leave the entire Arduino in place in their project

Historically, that second point has meant that people will build a project and run it permanently using what amounts to a single $30 microcontroller.

With the above commoditization argument, this point is fast losing ground when you can now buy a Chinese Arduino clone for $3.

 

Those arguments don’t even make sense anymore! I guess what it boils down to now is that Arduino offends my inner perfectionist.

Microchip PICs are fantastic because they are easy to use, powerful, and extremely inexpensive.

I can find a 60 cent chip that has exactly the peripherals I need, with almost no bloat.

The problem is that I have to build it into a circuit every time, thus negating the cost benefits with a time penalty.

 

Anyway. I have a whole bunch of PIC18F4520 DIP packages kicking around, and some other similar ones (4431 I think?). I suspect that I will be forced to start using Arduino eventually, but at least with this method I can now do some of my simpler PIC development on-the-go with USB power.

For some reason the TSA doesn’t like it when I try and take a breadboard, wire, and wire strippers onto a plane.

So the result:

A PIC dev board in an Arduino form factor.

PIC-On-The-Go SchematicPIC-On-The-Go Bare BoardPIC-On-The-Go with fill

 

Powered by USB (no communication, though), switch-selectable 5V/3.3V power rail (don’t hit this while plugged in!), reset button, 3 LEDs, and I’ve tried to match most of the Arduino pins with the associated PIC functions (eg. SPI and analog pins are in the same location).

You still need an external programmer, but that’s okay. Programmers are pretty cheap and come in a sleek form factor. The programming header pins match the Pickit 3’s pinout, so it’s just plug-and-play with MPLAB.

 

When I get the board and give it a test ride, I’ll release the source files. Altium, though, so many people won’t be able to edit them.