Some time ago I commented on this post a project I was working recently and I've finally done and I would like to share with you as always. It is a thing I have called Microgame and is basically a small portable game console with a graphical display of 128x64 pixels supplied with a rechargeable battery and is compatible with the Arduino environment. It is a project that it seemed very interesting to me and has made me to learn a lot of things about conducting plates with surface components (SMD) and at the level of the necessary software and requirements for loading a bootloader that makes compatible with the environment Arduino and avoid using an external programmer.
In my previous post I mentioned, I have written a fair amount of technical information and requirements, so this time I will comment on the part of the final assembly, software, and of course the final video performance with its conclusions. How could it be otherwise, the project is completely open and I leave also available for download all the files of the PCB as well as the source of small game I've scheduled, in case any of you want ride yours. Of course and as always, do not hesitate to leave your comment with your opinions!
Microgame: Final assembly of the plate
From the original design of the plate, I made some changes as the battery position and I have also removed the voltage regulator because the screen already includes one so why not use it. I also added a few holes in the four corners later to try to make some sort of box.
PCB Microgame
Although it seems quite the opposite, the board is quite simple and is based almost entirely on the Pro Micro 3.3V Sparkfun, which was the one I used for the prototype. Simply a microcontroller ATmega32U4that incorporates a USB system and to avoid using a FTDI converter, with quartz crystal 8 MHz and some passive components for operation. To charge the battery, I used a very interesting integrated, theMCP73831 Microchip that does all this and works perfectly with a rechargeable 3.6V button CR2405 I have used. The regulated 3.3V supply and provides me the screen itself that has integrated. Then push buttons and LEDs to generate some joy and voialĂ !
I have some photos of the assembly process that took a couple of hours taking it patiently. I have used lead-free solder paste and hot air station. The hardest thing is to let the right amount of paste on the pads, otherwise it was pretty funny. I have to say that the most problematic part was definitely the USB connector that had to quarrel because of its data pins are so small that constantly had bridges between them, having to tweak with the soldering fine point and much tino ! If you want to see more images of good quality, I leavean album of Flickr with all the pictures I've taken.
Caterina bootloader
The idea is that the plate is programmable from the Arduino environment and this requires incorporating a bootloader to not require an external programmer, as do all Arduino boards. The bootloader is just a small program at the beginning of memory that is always microntrolador ejectuta we connect the power. Its role is to check whether the port UART (pin TX / RX) a secuenta specifically indicating that the Arduino tries to set a new program in the microcontroller memory is received. If the string matches, the bootloader reads the data and auto program. If it does not detect anything, just it makes a jump to the beginning of the program to run, which is usually located right after the same bootloader.
This actually sounds wonderful and is extremely comfortable, but ironically to benefit from all the advantages of the bootloader, we first need to use an external programmer to load it into the microcontroller. I used the generic Pololu AVR programmer allows you to program without the bootloader problem or whatever we want.
This type of programmers use a type of connector called ICSP ( In Circuit Serial Programming ) consisting simply more power 4 pin: MOSI, MISO, CLOCK and RESET. There are two variants, one 6-pin and a 10 it is the same but space is rarely used much. All Arduino platform uses the 6-pin (2x3 pins).
ISCP - Picture: Wikipedia
This connector is directly connected to the corresponding pins on the microcontroller, which is my case is a ATmega32U4. Returning to the bootloader, each microcontroller needs of your own and have chosen to use well-known one called Caterina and is the same as using the Arduino LilypadUSB as it has the same chip. I used a variant of Sparkfun and I initially made the prototype on a plate Sparkfun Pro Micro 3.3V , but really you can use the bootloader LilypadUSB no problems. Because of this, you need to download driversfor the computer to detect it as such and create a virtual COM port that can be selected from the Arduino environment. SparkFun has an excellent guide which explains everything in detail. By using the bootloader Sparkfun and to work the plate from the Arduino environment, you must also download and install the addon for Arduino SparkFun . If we want to avoid this step, you can simply load the bootloader LilypadUSB yas default one in the IDE, but it's basically the same.
Well, what we're going, it's time to connect the controller to the plate, considering that the programmer does not feed the plate , therefore, it is necessary to take simultaneously connected via USB (and lit!) to receive food.
At this point, we have two options, load the bootloader from the Arduino programmer and selecting the "Load startup sequence" or used directly avdude with the correct command line. Specifically the line to send would be this:
- m32u4 avrdude -p -c -P usb flash avrispv2 -U -P COM2: w: Caterina-promicro8.hex -U eFUSE: w: 0xfe: m -U hfuse: w: 0xd8: m -U lfuse: w: 0xff: m
This controller is identified as avrispv2 and on the same line fuses for the correct configuration of the microcontroller are sent (by the way, I recommend this site on the fuses. You also have to indicate the virtual port programmer which in my case is the COM2 and . After a few seconds, the micro is programmed, or at least in theory because here I had some problems with avrdude timeout I soon discovered This is what he showed process:
For some obscure reason, the programmer seems he did what he had to do but it took an excessively large time and also timeout messages constantly appearing. Although it takes 3 or 4 minutes to program the bootloader, which normally would be little more than 15 or 20 seconds, once the plate was not detected correctly as a virtual COM port done. After twists and turns taking several days, I decided to try the same process to grasp on another computer and it worked correctly and the first. Both programming bootloader as the creation of virtual COM indicating that the bootloader is alive have worked perfectly. So why it has not worked from the beginning? Well, I came to the conclusion that on my PC I connected the whole system on USB 3.0 ports and even should not have any problems because now almost all new computers come this port, it is my workshop team is something old and not on the motherboard USB 3.0 ports, but I have connected a PCIe controller that gives me 4 USB 3.0 ports. To not go directly into the motherboard, it is possible that the controller becomes a mess, well not detect the device and that communication errors with Microgame. To find out for sure, I returned to do the same process in the workshop PC, but using the conventional USB 2.0 ports and everything worked properly since the first!
The conclusion is that I lost a few days investigating this issue and actually came to think that the small plate had any problems either in terms of design or hardware. And finally confirmed that at this point, we can say that all design works great as expected!
Galaxian: Game
Perhaps much pretend call Galaxian since my version does not do any glory and only remotely resembles, but is a little test to see how everything works and incidentally have the opportunity to play a game and enjoy a game by recalling old days! The game is very simple and is based on a ship with slightly phallic shape that is capable of shooting up to 3 simultaneous shots. The game works in scroll mode with a small field of background stars to give the impression of movement. On the right side appears "evil". There are a total of 5 different enemies each with a different way to get to give a little excitement to the matter. We have a total of 3 lives to kill every living creature that appears ahead. The highest score will be stored in the internal EEPROM permanently and displayed every time the plate turns. I have primarily used the GFX Adafruit library that is generic for almost all screens and specific for which I used called Adafruit_SSD1306 .
Of course the game is not perfect and have some bugs here and there but is structured in classes to configure a taste of each. An important thing if you look in the code is that the OLED display is initialized by SPI Software , not hardware. That's much slower and makes this game now walk about 19 or 20 fps, however further testing I've done with the prototype hardware SPI showed that the same game works perfectly to about 40fps. This was certainly a serious design flaw that I could not solve because they had already sent the plate to make when I realized that evidence. It's a shame but hey, it goes a little slower than it may give you but I also forces might do in the future a second version of the hardware to improve this aspect and make better use of hardware. Who knows!
At the time I posted a couple of videos while developing the game, which you can see here in case you want to take a look.
Conclusions
Concluding there are many. Of course now I have much more clear how the whole issue of the bootloader, its advantages and disadvantages and the process of making a plate from scratch surface components work. It's tenioso and requires some patience but it is an adventure that I like a lot. I might add that porfin to see everything working, I realize many improvements that could be done, such as leave a "test point" (test points) to be able to debug if necessary. That's what I missed when I thought the plate was not working on the issue of USB. Or switch on and off should be no vertical side and is quite fragile. Also I have to point out that the idea was to place a small piece above the covering it screen leaving only pass the buttons to the surface but unfortunately the buttons are not high enough to do, so just I left a piece of methacrylate by under cover electronic minimal.
Of course you will find them all design files and source code on Github in case you want to gossip, copy, or make your own version. And while I have left for last a short video of the entire working invention. I hope you liked it and I hope your comments! :)
Post a Comment