Close
0%
0%

Portable ARM Device

Portable STM32F103 Hardware platform for password/bitcoin keeper, oscilloscope, data logger, game etc.

Similar projects worth following
Most of the projects I have in mind involve a microcontroller, LCD, some buttons, a power source, some I/O and optional mass storage or USB. These $2 MP3 player comes with most of these features, I'll need to replace the PCB with a STM32F103.

While shopping for parts for my next project, I came across these $2 MP3 players from China. They are about 2AA batteries in size. It has all the I/O I'll ever need in a project.  It even comes in an inconspicuous injection molded case making easy to hide your gadget/key/bitcoin keeper in plain sight.

There is already a project: China cheap MP3 player hack which uses my favorite STM32F030. It is missing some of the features that I am looking for.  I initially started off with the board outline and I/O placements from that project, but quickly realized that they are not aligned correctly with my high resolution scan of the MP3 player PCB.  This is why I have decided to start my project from scratch and try to document my design process so that others may improve upon.

I am using a far more capable STM32F103 with native USB interface, dual ADC, dual SPI and a lot more memory.  It is used in Blue Pill breakout board and can be found for around $2 from China with some minor differences.  It is a popular platform and there are a lot of open source projects for the F103.

Features

  • STM32F103 64kB FLASH, 20kB RAM, up to 72MHz.
  • Mini-USB: USB 1.1 Full Speed (12Mbps) device, charging, SWD debug using special cable.
  • 128x64 LCD
  • Micro SD slot for SD/SDHC.
  • 3.5mm Stereo - multiple I/O functions are available
    e.g. 3.3V TTL serial, ADC, PWM, I2C and serial bootstrap.
  • 5 push buttons, On/Off switch
  • ~100mA Hr LiPO battery,  LTC4054 charger.

Design

Low power design

The device is powered from internal Li-ion battery.  LTC4054 is used for charging the battery from USB. LDO is used to power the main circuits.  

The RTC and backup RAM location are backup from the battery. A pair of silicon diodes is used to drop the battery voltage down as a single diode drops might not be enough at uA range.  Diodes consume no quiescent current (vs a LDO).

From Elm-Chan: How to Use MMC/SDC

MicroSD can draw a lot of current and introduce a droop during hot-insertion.  This can reset the microcontroller or affect results of ADC.  Previously I have used a switch mode supply with a fast transient response and have seen much less droop.

The XC6206P332MR and other ultra low quiescent current LDO make compromises for low bandwidth/transient response. It has a slow recovery time for a sudden load.  While you can pile lot of passives to undo the manufacturer's design decision on $0.04 parts, it is cheaper and takes much less space to simply use 2 separate supplies for the microcontroller and the MicroSD.

I wired 2 GPIO in parallel (saving one MOSFET) to control the power to the LCD backlight (probably around 20mA).

I/O

A few of the I/O peripherals are wired together in parallel to provide different functions.  

Here are the mappings to the peripherals.

The I/O can be programmed in the following modes.

When they are programmed as Analog, the input buffers are turned off and output disconnected.  This allows the other 2 digital GPIOs...

Read more »

  • PCB rev 6

    K.C. Lee3 days ago 3 comments

    Maybe this is the one?  I'll procrastinate a little longer and hope to find some fault or better routing than this. 

    When the lead time is 4+ weeks, a few extra days of thinking over is better than rushing things only to respin again.  I rarely have a board that need a few simple mods to get running.

    Here is the top stop mask showing that the buttons pads are indeed free of resist.


    Silicon Labs: AN0046.pdf

    I won't be able to match impedance due to the lack of space for wide tracks needed. 17cm is a lot of leeway.

    I have done skew matching because of skew introduced by routing swap that was needed to match the connector pin orientation.  It was within the limit, but was easy enough to fix.

  • Mini USB breakout PCB

    K.C. Lee3 days ago 5 comments

    The connectors arrived a while back, but I have been procrastinating.  The space of the connector pins are such that you don't want to solder it free hand.  So I layout a PCB for it, but some of the mechanical dimensions are not easily measurable until you made one.  And of course you don't expect to find the mechanical drawings for something on Aliexpress that easily.

    So forward to today, I finally made the PCB using toner transfer while doing a batch for a flashlight mod.  I used the drill holes for aligning the paper for the second pass of the toner transfer and etching process..

    Here is the back side.  I have to bend the pins slightly so that it straddles the PCB.  (need a thinner PCB).  There is a gap between the connector and the PCB to accommodate a plastic bit in the housing.  I even file the curvy outline to match the housing.

    I stagger the breakout to 0.05" spacing to make it easier to solder.  The spacing is such that it would line up with a ribbon cable broken into two rows.

    This is how it looks fitting into the the other half of the housing.

    Still have no clue how what I need to do on the PCB outline to get boards fabbed.  It is small and violates a few of the DRC for copper to outline spacing and a few manufacturing rules.  I managed to make on with very primitive hand tools.  I guess I'll procrastinate a bit more.

    BTW this breakout connector is only need for SWD debugger.  A regular Mini-USB can be used for normal operation.


    I messed up.  I should have made a new footprint for the male side of the connector, but instead I used the female pin ordering.  It is a mirror image so the left/right ordering are flipped.  I am going to patch this PCB as is.  As for the SWD side, I'll fix the layout for the main PCB.

    I have spent too much time thinking about round cables vs ribbon cables.  I have both types and even the right size, but settled on ribbon cables.

    General warning:

    Ribbon cables are designed for IDC (Insulation Displacement Connector) and not meant to be soldered.  Solder wicks up inside the cable and where flexible part meets non-flexible can create stress points for failures.  The staggering helps the front row, but not the back.  There isn't much space left, so can't extend the PCB.  :(

    I separate the wires and work on the short ones first. When that's done, solder down the row of long ones.  The cables I have aren't very solderable even with a very aggressive flux and extra flux applied.

    There are 2 pairs of 4 conductor ribbon cables.  I could have folded a set of 8, but these came from my  scrap pile already broken out. 

    This is how they fit into the housing.  The opening is just wide enough.  There are two slots on the connector housing meant for a metal strain relief to hold the cable in place.  They don't come with one.  

    I could have cut a tin can or some transformer cores, but settled for 3/8" heat shrink tubing instead.  I carefully roll up the heat shrink like a pair of socks with a pair of needle nose pliers.  It is not easy, but the tubing is soft so you'll eventually get it.  I use low heat (100C) on my hot air tool to shrink the tubing.  The fold is slightly wider than the opening, so it would help to retain it.  The tubing protect the cable against the sharp corner at the opening and the extra stiffness of the heatshrink helps to spread the flexing point more evenly.

    The two halves of the housing snapped together almost seamlessly.  I had to pied open this...

    Read more »

  • Masks and other useful tricks in Eagle CAD

    K.C. Lee04/29/2018 at 14:57 0 comments

    The default DRC file for OSH Park does not have solder mask for pads or vias. If you want to have a solder mask over your vias, you can change "limit" to the maximum via size that you want solder mask:

    Here are some of the layers in Eagle that you might not have cared about:

    Stop MasktStop, bStopArea without solder mask. e.g. pads, contacts
    RestricttRestrict, bRestrictArea not copper pours/traces allowed.
    Keep outtKeepout, bKeepoutArea with no components allowed.
    Cream masktCream, bCreamArea where solder paste is applied
    (for making SMT footprints)

    Here is how I use them for making PCB footprint for a Dome momentary buttons.

    I normally have all my vias with solder mask on, so I want to selectively override the vias inside the dome footprint.  To change the option, simply select the via and right click for "Properties"

    Select the "Stop" to add a stop mask for the via (i.e. leave the copper bare).  Notice the difference between my regular vias (without the shade areas) and the highlighted one.

    Eagle complains if I draw a via directly over the center of the dome button as it overlaps the "pin" for the footprint.  So I place a via off center and move it afterwards.

    Misc

    • I draw a donut circle (in tDocument layer)over my vias so that I know how much clearance I need to leave around it.
    • I define my cream layer to reduce the amount of solder paste (60-70%) for my QFN footprints.  This fixes the issue of the QFN package floating on the solder paste of the center pad.
    • Draw a thick line in Restrict layer for high voltage vs low voltage circuit isolation.  The width of the line should the creepage requirement for the working voltage.  DRC will warn you about violation and copper pour would avoid the area.
    • Clearly label the high voltage and low voltage areas on your PCB.  It might save a life.

    See here for an explanation

    • Add the Restrict in your opto-isolators/relays/Ethernet transformer footprints. This help DRC flag your isolation violations.  Don't run traces between rows of pins between a high voltage and low voltage circuit.

  • Schematic Layout V6

    K.C. Lee04/28/2018 at 13:18 0 comments

    Not a whole lot have been done as I had a lot of bad luck lately.  I am procrastinating about working on my tax return (due end of the month), so that's why I am working on this layout instead. This is the 6th iteration of the layout.  I don't know if this will be the last.  Here is what it looks like right now before final DRC and clean up.

    It is not an easy layout as I have little freedom on the parts placement.  There are some congested areas around the microcontroller. I have to use OSH Park with their denser 10 mils via for the uC breakout even though their 0.031" board is a bit too thick to match the original PCB. 

    I opted to remove one of the alignment post from the 10-pin mini-USB connector because it is in a different location than the regular one and it interferes with the right button.

    Maybe it is just me as I don't simply route traces until all the air wires disappears and call it a day.  I try to preserve signal quality by minimizing the return current loop areas.  i.e. making sure that there is a ground or power very near where the high speed signal traces are going.  So what it means is that I am routing on one layer as much as I can.

    This project is no longer a fork from a similar one on HaD as I have reworked all the PCB outlines, specific parts placement from scratch based on my own PCB high resolution scan.  The push buttons have the proper stop mask to expose the ENIG plating for the contacts.

    Looks like summer this year is going to be bad too for working on projects. They are going to be a lot of jack hammering on the outside wall of my apartment building again for at least 9 weeks.  They hammered out the concrete, added extra rebars and repoured my bedroom wall last summer.  There are still a bit of work left on the other wall.

  • 10 pins Mini-USB connector

    K.C. Lee02/02/2018 at 03:10 0 comments

    SWD is one of the things I would like to have available without having to open up the case all the time. One way to do that is to fool around with the ID pin and share pins with USB.

    I am tempted to use those 10 pin Mini-USB connectors which are used in some cameras for composite video and audio.  They are backwards compatible with regular 5-pin USB plugs. 

    I have ordered 10 receptacle from here and 10 plugs from here. I found a datasheet for something that matches the receptacle here. Unfortunately that means pushing back this project for quite a bit as I want to confirm the footprints before committing to a final PCB design.  I guess I could work a bit on the firmware for the time being.

    Aliexpress called receptacle a Type-B while the datasheet call it Philips style.  

    Looks like the receptacle could be a Mini-AB which could accommodate the Mini-B plug which is the only style still used.

    The plastic panel needs to be filed.

  • Teardown of 2nd batch MP3 player

    K.C. Lee01/30/2018 at 19:26 0 comments

    The 2nd batch of MP3 players arrived via Kyrgyzstan.  Canada Post have decided to raise the postage fee from China Post starting from 2018, so I would expect to see a lot more creative logistic shipping routes in the future.  Canada Post service has deteriorated over the past few years.

    This MP3 player is a lot easier to disassemble.  There are two self tapping screws holding down the plastic panel in the right side.

    Two pegs from the panel latches down the button wheel. The button wheel can then be popped out from the front.

    The PCB assembly slides out from the right hand side.

    It uses the same PCB design as before.  The LiPo pack is about half the size ~50mAHr.  The overall build quality is slightly better.   

    Some of the cheaper PCB house only have silkscreen on the top layer which is on the back side of the PCB.  The LCD position no longer lines up with the silkscreen as it is shifted lower to accomodate the curvature of the case.

  • PCB High Res scans

    K.C. Lee01/28/2018 at 21:38 0 comments

    I made a couple of high resolution (2400DPI) scans of the bare PCB with my flatbed scanner.  I am going to be using the scans for the measurements. I'll have to wait for the second batch from the different supplier.  

    • The standoff keepout areas are marked with a Sharpie. They are in different location than the silkscreen.
    • Two of the pins covered by silk screen are not connected.  They are probably using I2C mode to access the MicroSD.  
    • One of the Mini-USB non-plated through holes encroaches into the "Next" button pad.  I'll resize the hole to try to minimize the effects and also might have to play around with the DRC to reduce the void.

    I imported the bitmap into Eagle CAD and overlay it on top on the layout template from github and there seems to be a lot of discrepancies on the placements.

    As I have learnt many times before, most of the freebies from someone else ended up costing me a lot.  I will be doing my own from scratch.

    This is what the layout should look like.  The scanned image has the right X/Y scaling and aligns with the placement holes.

    This is what I have done:

    • measure the PCB with a caliper
    • (previously done) rotate the scan to align with X/Y axis
    • reduce colour depth to 4. This make things goes faster while retaining details.
    • import into Eagle PCB as .BMP and 2400DPI
    • overlay measured board outline and main components

    I'll probably round the coordinates to inches or mm whichever one that gives a round number.  I am guessing the original layout was done in mm as it was designed in China.  I'll try to align the buttons on a grid.

  • First impressions

    K.C. Lee01/26/2018 at 21:45 2 comments

    One MP3 player arrived today.  The LCD doesn't have the ugly yellow/blue filter from the description.

    The plastic case is held together with 4 tabs near each of the corners and 2 on each end.  I broke all of 4 corners tabs when I pried it opened with a knife.  I think I'll have better luck with the 2nd batch from a different supplier as they are supposed to have screws and come with belt clip. 

    The PCB thickness is 0.026" (0.6mm).  The stereo connector (0.2") and the LCD (0.086") are the tallest components on each side of the PCB.

    The battery is a LiPo pack without any protection circuits nor a proper charger chips.  There is a silicon diode (CD1) in series from the VUSB as the charge circuit.  

    VUSB has a loose tolerance of 4.4V to 5.25V while a silicon diode drop is around 0.7V, so you might be charging the LiPO with up to 4.55V!  There are no current limiting other than the internal resistance of the USB cable, LiPO and power source. What can possibly go wrong?  (Cue Mission Impossible OP).

    The battery ( 0.831" x 0.860" x 0.113") is held above the Micro SD connector with a piece of double sided tape. I estimate the battery capacity to be around 100mAHr based on size.

    The LCD and the dome buttons are on the back side of the PCB.  The Red/Blue wires are the LCD backlight.  I measured 2.85V.  It is driven directly from pin 16 of the chip without a series resistor.

    The back side of the LCD diffuser is taped to the PCB with a piece of double sided tape.  There are two sets of footprints to accommodate modules with different cable lengths.

  • Multifunction I/O and buttons

    K.C. Lee12/18/2017 at 17:38 0 comments

    I thought about adding an analog MUX to select the signals as digital I/O pins do not like the intermediate voltages between '0' and '1'.  

    It turns out that there is a way of skipping the MUX in the STM32F10x family. There is an On/Off control that can be used to shutdown the "TTL Schmitt trigger" in the "Input Analog" mode (CNF[1:0]= "00", Mode[1:0]="00").  I have not yet confirmed if it is implemented in all of the GPIO pins or that it is specific to the ones with ADC.

    I have tied 3 pairs of GPIO together and connect them to the 3.5mm stereo connector giving access to GPIO, UART, Timer function, ADC and I2C.

    • Tip: PA10 (UART0 RXD/TIM1 CH3), PB0(ADC IN8/TIM3 CH3), PB6 (I2C SCI1)
    • Ring: PA9 (UART0 TXD/TIM1 CH2), PB1(ADC IN9/TIM3_CH4), PB7 (I2C SDA)

    I am hoping to implement diode clamps on the I/O for some protection.  The Ring/Tip pin assignments are consistent with FDTI 3.3V serial cable.

    Bootstrap key

     UART0 is used in the ROM bootstrap mode.  My intention is to hold down one of the keys (e.g. "Down") key during power on for entering the bootstrap mode.

    Battery backup

     I have hooked up the battery backup supply to the Li-ion battery directly.  This allows for 84 bytes of battery backed RAM as well as a Real Time Clock.

  • Initial PCB placement

    K.C. Lee12/16/2017 at 19:15 2 comments

    I took the PCB template from China cheap MP3 player hack, my STM32F103 breakout board and added a few parts. This is a preliminary placement.  I have not added the support circuit for the LCD or the random generator, but they should fit in the space.

    I can't do much until the MP3 players arrives in the new year.  I'll try to do my own measurement of the MP3 component placements on the PCB and confirm the footprints. I have no idea what the keep out areas and height restrictions are.  I like to get my PCB done right the first time.

    That could take a couple of weeks to a couple of months depending on the mood of the Canada Post and Canada Custom.  My recent packages seem to arrive very quickly.  May be the temp workers fired for the holiday season ignore Canada Post's rule to intentionally slow down packages from China.

View all 11 project logs

Enjoy this project?

Share

Discussions

Jarrett wrote 3 days ago point

Just read through to doublecheck, I see you're planning on using an STM32F103. Have you tried running one off the battery provided?

I've been vaguely putting together something like this using an ESP8266, and, using a TPS63001 buck-boost, the battery keeps it alive for, like, 4 minutes D:

https://photos.app.goo.gl/w9efbxZxFsQpWzRp6

This is without attempting any kind of power saving techniques, though, just running full-bore

  Are you sure? yes | no

K.C. Lee wrote 2 days ago point

I code bare metal and use DMA whenever I can.  Sometimes I even do power profiling.   I have not done anything on the F103 yet.

https://hackaday.io/project/12703-alarm-detection-for-hearing-impaired   STM32F030 (reduced clock speed) less than 10mA from 2 AAA.  I got it below 7mA by dropping supply voltage.

https://hackaday.io/project/5903-sonar-for-the-visually-impaired/log/24602-firmware-progress-power   single AA and spend most of its time below 20mA.  I ran it under RTOS there.  I had additional hardware and my power management code tracking dependeny to shut off external peripheals.

Bare in mind the end applications tends to be tethered too: Bitcoin hardware wallet, mooltipass, Google Authenticator, AVR debugger.  I see the battery for RTC and may have to do a lot of power saving for offline use e.g. data logging.  With PLL multiplier at reduced speed, 2 external crystals etc I think there are many ways to save power.

  Are you sure? yes | no

Thomas wrote 01/27/2018 at 08:35 point

Really sweet. I'd like to have one, too.

One more use case: a CAN monitor (CAN shares USB pins and on-chip peripherals)

  Are you sure? yes | no

davedarko wrote 12/15/2017 at 18:09 point

I was about to point to a link but then saw it was the first in your reference :D Looking forward to see how this turns out, the other one was quite good :)

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates