How to use a Pro Micro as a cheap controller/converter

User avatar
scottc

21 Jul 2014, 00:13

In this tutorial, I'm going to show you how to make a cheap controller or converter using a Pro Micro. This tutorial will specifically talk about using it for Pro Micro for an AT-style 180-degree DIN5 so that I can remap keys on my Model F, but it should be applicable for other uses.

Why?
  • - They're cheap - you can get them for less than €3 €5 (price increase :( ), whereas Teensies are upwards of about €15 or above.

    - They have enough pins for a converter - Soarer's converter only requires four pins, and the Pro Micro has all of the required ones.
Why not?
  • - It's more difficult to flash: you need to short pins manually, and use a command-line tool to flash hex files. No Teensy loader here.

    - It has fewer pins than a Teensy. For something small like a Soarer Converter, or maybe a hand-wired numpad or a heavily optimised PCB, that's fine. However, if you're hand-wiring a larger board, I'd recommend a board with more pins so that you don't have to worry about wiring a complicated unintuitive physical layout.

Disclaimer:


This guide should be applicable to both GNU/Linux and Mac OS X. I wouldn't know where to start figuring some of this stuff out on Windows, but if there's demand then I'll try. I don't have any devices that run Mac OS X, so if anything is incorrect then please let me know and I'll see if I can get them fixed.


Step 1: Get a Pro Micro clone


This part is easy, but takes a lot of time. You can get them on eBay for about €6 shipped, and also on AliExpress at a slightly lower price. They will both take a long time to arrive, with the eBay link coming from Hong Kong and the BangGood one coming from China. Mine took about 3-4 weeks from eBay.


Step 2: Flash the firmware


We're going to assume that you already have a .hex file called firmware.hex that you want to flash on to your Pro Micro.

In order to flash the device, you need to figure out which "serial port" your device is attached to. First of all, identify what serial devices (including virtual ones) are currently connected to your machine with this command:

Code: Select all

ls /dev/tty*
On my machine, this produces the following:

Code: Select all

/dev/tty    /dev/tty12  /dev/tty17  /dev/tty21  /dev/tty26  /dev/tty30 /dev/tty35  /dev/tty4   /dev/tty44  /dev/tty49  /dev/tty53  /dev/tty58 /dev/tty62  /dev/ttyS0
    /dev/tty0   /dev/tty13  /dev/tty18  /dev/tty22  /dev/tty27  /dev/tty31 /dev/tty36  /dev/tty40  /dev/tty45  /dev/tty5   /dev/tty54  /dev/tty59 /dev/tty63  /dev/ttyS1
    /dev/tty1   /dev/tty14  /dev/tty19  /dev/tty23  /dev/tty28  /dev/tty32 /dev/tty37  /dev/tty41  /dev/tty46  /dev/tty50  /dev/tty55  /dev/tty6  /dev/tty7   /dev/ttyS2
    /dev/tty10  /dev/tty15  /dev/tty2   /dev/tty24  /dev/tty29  /dev/tty33 /dev/tty38  /dev/tty42  /dev/tty47  /dev/tty51  /dev/tty56  /dev/tty60 /dev/tty8   /dev/ttyS3
    /dev/tty11  /dev/tty16  /dev/tty20  /dev/tty25  /dev/tty3   /dev/tty34 /dev/tty39  /dev/tty43  /dev/tty48  /dev/tty52  /dev/tty57  /dev/tty61 /dev/tty9   /dev/ttyUSB0
I run Debian, so this will likely be different for you if you use something else. Take a note of the output, we'll need it later.


Step 3.1a - if you've never flashed your device before

Spoiler:
If this is your first time flashing the Pro Micro, this part will be easy. On the Pro Micro's first boot, instead of trying to run code (that you haven't uploaded yet!), it just sticks in bootloader mode. So if you only want to flash firmware once and forget about it - good news.

Just plug in your device and it should automatically go into bootloader mode.

Step 3.1b - if you have previously flashed your device

Spoiler:
If you've previously flashed your Pro Micro, instead of going straight into bootloader mode it will try to run the code that you uploaded to it. To go into bootloader mode, you need to quickly connect the GND + RST pins twice, just as the device powers on.
Next, plug in your device and re-run the command, the same as before:

Code: Select all

ls /dev/tty*
There should be one more output device than was seen previously. For me, it's /dev/ttyACM0.

To flash the device, you need to have AVRdude installed. On Linux, you can do this with your normal package manager. On Mac OS, I've heard from a reputable source that you need to install CrossPack.

Once it's installed, confirm that it works by just running avrdude on the command-line. It should throw some errors. If so, it works.

Once you have AVRdude set up, navigate to the directory with your .hex file in it. Then, run the following:

Code: Select all

avrdude -p atmega32u4 -P YOUR_SERIAL_PORT  -c avr109  -U flash:w:filename.hex
Of course, replace YOUR_SERIAL_PORT with your serial port's device name, and filename.hex with the appropriate filename. For me, this line looks like this:

Code: Select all

avrdude -p atmega32u4 -P /dev/ttyACM0  -c avr109  -U flash:w:Soarer_at2usb_v1.12_atmega32u4.hex
If it says ''device not in sync'' or similar, your device is no longer in bootloader mode. Unplug it, and get it back into bootloader mode like you did in the previous step, and try again.

## Step 3: Figuring out pinouts and wiring

Most guides for firmware comes with Teensy-style pinouts:

Image

Thankfully, Soarer was good enough to share a pinout diagram for the Pro Micro which matches what he uses in his own documentation:

Image

With both of these, it's easy to go between Teensy and Pro Micro pinouts for other guides that are Teensy-specific.

From the kbdbabel.org diagram of an AT/PS2 connector, we can get started with wiring the board:

Image

Bearing in mind that you'll need to flip the orientation of the pins when wiring to the back of the socket, here are the corresponding pins on the Pro Micro for a basic DIN5/PS2 converter:

Image

Here's the (jury-rigged) end result:

Image

...and it works! Aaaaah, my wonderfully chunky Model F.

Image

Acknowledgements and thanks:

- Soarer for his firmware, of course, and also the Pro Micro pinout diagrams, and help on IRC with bootloader mode on the Pro Micro.
- Muirium for pointing out CrossPack on Mac OS X.
Last edited by scottc on 11 Apr 2015, 12:18, edited 4 times in total.

User avatar
chzel

21 Jul 2014, 02:48

Great work scottc!Will come in handy!
Just a note though, the Banggood URL is for the Pro Mini (ATmega328) not the ProMicro.

User avatar
scottc

21 Jul 2014, 02:57

Thanks! Good catch, I got the link in a hurry and mustn't have realised. I'll change it now.

Edit: I changed it to an AliExpress link. It's not great, but it should be an option for people who can't or won't use eBay, at least.

User avatar
beltet

23 Jul 2014, 21:07

Thanks. Will try to get this working on Windows when I get my boards.

User avatar
scottc

23 Jul 2014, 21:29

The process should be pretty similar on Windows, I just have no idea about either WinAVR or how Windows serial ports work.

User avatar
beltet

26 Jul 2014, 17:21

scottc wrote: The process should be pretty similar on Windows, I just have no idea about either WinAVR or how Windows serial ports work.
Yeah I believe that as well. And I will look into that and post here when I have straighten it out. But I need to migrate to Linux soon... But I'm a gamer as well and Linux and games are not best pals yet, even if they have been acquaintances quite a while now.

The pro micro I have bought is in the mail. After they arrive I will post here.

User avatar
scottc

26 Jul 2014, 17:30

I agree. GNU/Linux is getting there with gaming, but Windows still has an unfortunate advantage. GNU/Linux is a far superior development platform for me, though, so that's where I spend most of my time.

GNU GNU GNU. Apparently I've taken to saying "GNU/Linux" recently.

User avatar
Hypersphere

26 Jul 2014, 17:43

@scottc: Are there any differences in specs corresponding to the color of the board? Your illustration shows a red board, whereas the ones I've seen are blue. We want the ATmega32U4 5V/16MHz variety, correct? Thanks.

Thanks also for your very helpful guide!

User avatar
scottc

26 Jul 2014, 17:52

I actually don't know of any differences. The diagram above is Soarer's, whereas mine is blue. I suppose that there are many clones floating around. What you've described sounds like the right board.

The only thing to be careful about is to avoid buying a "Pro Mini" or similarly-named boards (like I mistakenly put in the OP before chzel pointed out my mistake) - they've got a 328 and not a 32U4, so (as far as I know) they can't do USB HID.

You're very welcome for the guide! I'm glad that some people are finding it useful.

User avatar
PJE

26 Jul 2014, 17:57

Hypersphere wrote:@scottc: Are there any differences in specs corresponding to the color of the board? Your illustration shows a red board, whereas the ones I've seen are blue. We want the ATmega32U4 5V/16MHz variety, correct? Thanks.

Thanks also for your very helpful guide!
I can jump in on this...

I think the Sparkfun version uses a red PCB, whereas most of the low cost modules on eBay tend to be green or blue.

The 5V module runs twice as fast, but will also use a little more power which is not an issue if powered by USB. For a keyboard, if your only connecting to switches and LEDs you could probably use either - I went with the 5V version as I can interface to a PS/2 touchpad without needing a voltage translator. If you are connecting to components with 3.3V voltage levels then the corresponding ProMicro would be simpler.

You need access to the reset pin periodically, but in general I can do software updates without pressing the reset first. There are two logical connections via USB - the keyboard and a serial communication link which is used to reset the module.

If anyone knows of a low cost source of ProMicro modules I'd be interested - the price seems to have increased significantly over the last few months ($4 to $8).

User avatar
Hypersphere

26 Jul 2014, 18:13

PJE wrote:
Hypersphere wrote:@scottc: Are there any differences in specs corresponding to the color of the board? Your illustration shows a red board, whereas the ones I've seen are blue. We want the ATmega32U4 5V/16MHz variety, correct? Thanks.

Thanks also for your very helpful guide!
I can jump in on this...

I think the Sparkfun version uses a red PCB, whereas most of the low cost modules on eBay tend to be green or blue.

The 5V module runs twice as fast, but will also use a little more power which is not an issue if powered by USB. For a keyboard, if your only connecting to switches and LEDs you could probably use either - I went with the 5V version as I can interface to a PS/2 touchpad without needing a voltage translator. If you are connecting to components with 3.3V voltage levels then the corresponding ProMicro would be simpler.

You need access to the reset pin periodically, but in general I can do software updates without pressing the reset first. There are two logical connections via USB - the keyboard and a serial communication link which is used to reset the module.

If anyone knows of a low cost source of ProMicro modules I'd be interested - the price seems to have increased significantly over the last few months ($4 to $8).
Thanks for the additional insights. I wonder if it might be possible to negotiate a reduced unit price by contacting the seller (link from eBay or AliExpress) and buying larger lots?

User avatar
scottc

26 Jul 2014, 18:17

Thanks for the clarification, PJE!

The cost thing struck me too. I got mine for €3.50 shipped a few months ago, but now they're significantly more expensive. The cheapest I've found them was on aliexpress, where you can get small discounts for bulk orders. For a set of 5 here, it's €21 including slow free shipping: http://www.aliexpress.com/item/Free-Shi ... 57365.html

User avatar
Hypersphere

26 Jul 2014, 18:28

scottc wrote: Thanks for the clarification, PJE!

The cost thing struck me too. I got mine for €3.50 shipped a few months ago, but now they're significantly more expensive. The cheapest I've found them was on aliexpress, where you can get small discounts for bulk orders. For a set of 5 here, it's €21 including slow free shipping: http://www.aliexpress.com/item/Free-Shi ... 57365.html
The rising cost could be attributed to many factors, possibly even including improvements. Speaking of improvements or revisions, this can be rather confusing. For example, some sellers make the following note: "This latest revision corrects the silk error from the last version of the board so that pin 14 is correctly labeled. We've also added a PTC fuse and diode protection to the power circuit and corrected the RX and TX LED circuit."

It would be nice if there were revision numbers included with the part number, but buyers might want to look at various listings and choose the one that appears to have the latest revisions.

Edit: I've noticed that some sellers have a note saying "Supported under Arduino IDE v____", where the version number can vary from 1.01 to 1.05. Does this matter? Should we be looking for v1.05?

User avatar
beltet

26 Jul 2014, 20:52

I think I saw in another thread that there was low availability on atmega 32u4. Think that's the main reason for the higher price. Supply and demand you know.

User avatar
7bit

31 Jul 2014, 13:05

So, basically it is the same as the Teensy 2.0, except there are 18 instead of 25 usable pins?

User avatar
scottc

31 Jul 2014, 13:06

Yep, except you can't use the Teensy GUI application and must use avrdude on the command-line. That's not a problem for me, but some others might be afraid of terminal emulators.

Also, I compared it to my Teensy for size yesterday. Somehow, it's larger than a Teensy, yet it has fewer pins. :shock:

User avatar
7bit

31 Jul 2014, 13:17

scottc wrote: Yep, except you can't use the Teensy GUI application and must use avrdude on the command-line. That's not a problem for me, but some others might be afraid of terminal emulators.

Also, I compared it to my Teensy for size yesterday. Somehow, it's larger than a Teensy, yet it has fewer pins. :shock:
GUIs are bad anyway. But basically, it is the price that makes it attractive.

User avatar
scottc

31 Jul 2014, 13:22

I agree. It's much better value than the Teensy. Maybe you could use one for the HyperMicro!

User avatar
bitemyweewee

02 Aug 2014, 09:43

Works like an absolute champ! In fact, using it to type this message right now :D
Image
The bridging of the Ground and Reset was a little bit of a pain in the ass as a one man job, being farish away from my computer, it stopped being much of a pain in the ass when I realized I was bridging Vcc and Reset by mistake :(
All in all, works well with my AEKII and saved me a pretty penny :)

User avatar
scottc

02 Aug 2014, 13:09

You won't believe how many times I did that too! :D Glad it helped.

User avatar
acolombo

03 Aug 2014, 23:00

Very good guide, thanks Scottc!

I'm gonna do this using Windows whenever I get the Pro Micro, I bought one now on ebay and I already harvested a PS2 female port from some old trashware I had laying around. I have no idea on how to start (considering I will use Windows, so some help is appreciated), but somehow I will do it! I want to make my 11900 a personalized layout without autohotkey...

ShawnMeg

17 Aug 2014, 03:50

Can you give a link to the firmware file? This is all new for me, but I may give this a try.

Also, as I am all new to this, can someone give me a list of all the components that I will need?

It looks like:
1. Female DIN plug
2. 4 wires
3. Pro Micro
4. mini USB cable

User avatar
acolombo

17 Aug 2014, 04:57

ShawnMeg wrote: Can you give a link to the firmware file? This is all new for me, but I may give this a try.

Also, as I am all new to this, can someone give me a list of all the components that I will need?

It looks like:
1. Female DIN plug
2. 4 wires
3. Pro Micro
4. mini USB cable
point 4 is micro USB cable, not mini. And for point 2, don't buy them, just strip them from a cable you don't use anymore (any usb cable wil have 4 cables inside, but you could use old IDE cables or phone cables aswell).

ShawnMeg

17 Aug 2014, 05:58

acolombo wrote:
ShawnMeg wrote: Can you give a link to the firmware file? This is all new for me, but I may give this a try.

Also, as I am all new to this, can someone give me a list of all the components that I will need?

It looks like:
1. Female DIN plug
2. 4 wires
3. Pro Micro
4. mini USB cable
point 4 is micro USB cable, not mini. And for point 2, don't buy them, just strip them from a cable you don't use anymore (any usb cable wil have 4 cables inside, but you could use old IDE cables or phone cables aswell).
Thx. I've used linux a little bit, and have to figure out how to install avrdude. Does anyone know if it's in the Ubuntu Software Center or some other easy way to install it?

User avatar
scottc

17 Aug 2014, 11:05

Open a terminal and type this:

Code: Select all

sudo apt-get install avrdude

ShawnMeg

19 Aug 2014, 06:50

scottc wrote: Open a terminal and type this:

Code: Select all

sudo apt-get install avrdude
Thank you.

andrewjoy

09 Sep 2014, 12:09

Thanks for this, will buy one soon for when my XT arrives i has a tennsey but i manged to kill it ( dont ask).

Anyone know of a cheap source of 5 pin Female DIN in the UK?

User avatar
Muirium
µ

09 Sep 2014, 15:02

Maplin:

http://www.maplin.co.uk/p/maplin-chassi ... rees-hh34m

Cheap? Well, you can likely save a few pennies going elsewhere, but for under 2 quid it's hardly worth it.

andrewjoy

09 Sep 2014, 15:58

hmm good point , i may be able to find i little box to put the converter in there, may also get a switch of some sort ( momentary contact) as a reset switch

User avatar
chzel

09 Sep 2014, 16:17

Just don't use the USB connector of the Pro Micro as the main connector!
They are notorious for breaking off with many uses!
Use a pigtail instead (male micro ->male A) and stress relieve the cable!

Post Reply

Return to “Workshop”