• ghetto captured nut - how I made a mount for the gyrostick

    K.C. Lee05/13/2021 at 18:56 0 comments

    Just when you needed a captured nut...  

    need: FR4 PCB with undersized hole, small file, C clamp

    • File the hole as close to the right shape for the nut.  The mismatched FR4 hole will be expanded and provide grip.
    • Put it in a C-clamp or a vise or hammer
    • Apply extreme pressure
    • File/trim the FR4.  

    You get a captured nut!  The FR4 provides a large surface area to be superglued behind a screw hole.

    Here is what's what it is used for in a more refined manner.  This is my 2nd try with the "captured nut". I cut a small piece of plexiglass with a saw blade attached to a Dremel tool.  I used a hand drill to drilled 2 holes - one for the screw and a larger one the nut.

    Note the edge of the plexiglass is flush with the module and this helps to prevent the PCB assembly from spinning.

    The plexiglass is then superglued to the captured nut PCB to form a mount.  I screwed in the PCB assembly to show how things fitted together. Notice the white stress points on the FR4 at the corner of the nut.  That's what holding the nut in place (along with the superglue).  FR4 can handle stress a lot better than plexiglass.  The thickness is just right for the M3 screw and clears the PCB assembly.  Luck or math? :)

    The mount can then be superglued to the base of the controller.  Mine has a label area.

    The inside of the game controller case has a Li-ion batter pack pushed against it, so it is not safe to simply drill a hole to mount a standoff.  Like they said "look before you drill!"

    Here is what it looks like with everything in place.  The PCB components are protected by the back side.  The PCB assembly can be easily removed for easy access.

  • Yet another STM8 USB project

    K.C. Lee05/13/2021 at 16:58 5 comments

    I made a USB HID game controller using a MPU6050 module.  It was inspired by Cemu Gyro Joystick project that uses a dongle to supplement motion data for CEMUhook used in emulators.

    Except mine is built with a STM8S003 with VUSB library.  The STM8S003 is under the programming header.  T he module is surface mounted without Castellated Edges.

    There were some problems with I2C errata and interference from USB traffics, but that was all resolved by adding a delay.

    It is a USB low speed device and as such limited to 7 byte HID reports (1 byte by Report ID).  How to send 12 bytes of data? Group the Accelerometers and Gyroscopes under separate report ID and alternating their reports.  Let the PC figure them out.

    Windows recognizes the new device as a game controller with 6-axis (X/Y + 4).

     Let's say I don't have a clue with setting up  Node.JS and figure out how to compile stuff.  I have to figure out what programs to use as an alternative. 

    Github: https://github.com/FPGA-Computer/STM8-Gyrostick

    My project page: https://hw-by-design.blogspot.com/2021/05/stm8-gyrostock.html

  • 2021 update

    K.C. Lee03/08/2021 at 23:39 0 comments

    I replaced the guts of my old alarm clock, so one less clock to set for Daylight saving time.

    I used recycled 7 segments displays from old cable converter and pair them with 2 smaller ones. The vintage displays use a lot more current than the green ones. 50mA vs 20mA. 

    Both versions on github: https://github.com/FPGA-Computer/LED-Clock

    STM8 USB library - Last lower level library removed and save some more space.


    Timer is updated to V2: https://github.com/FPGA-Computer/Timer

    I added a connector for a nRF24 module as part of  the V2 overhaul. I might not need it now, but it is much less work later when I do want one.

  • STM8 HID-Multimedia-Dial is now on github

    K.C. Lee09/17/2020 at 03:36 0 comments

    I made a port of my old ATMega8 HID Multimedia Dial project to the STM8.  It is now on github

    The multimedia dial can control volume and mute.  When I double click the switch, it changes mode for media playback Next/Prev.

    This version uses the STM8S003.  I have included a SWIM hardware debugger connector and soldered down the micro USB. (lost my bag of breakout PCB)

    Also upgraded to a couple of RGB LED.

    This project uses HID, so it is a good way for testing the changes I made to the STM8 VUSB. I have also recompiled USB2LCD with the new VUSB library and it seems to be working.

  • STM8 version of LCD2USB is now on github

    K.C. Lee08/18/2020 at 17:29 1 comment

    STM8 version of LCD2USB (AVR) is available on github

    It is a modification of a working STM8 VUSB library from STM8S-VUSB-KEYBOARD.  The  Russian comments are "google translated" to English.

    I have done some additional changes in the USB stack for the Vendor Request packets needed by LCD2USB.  I have changed the device library files to bare metal, refractor the code. etc.  I have taken the packet processing core from AVR LCD2USB, but used my own code for the I/O.

    A general purpose schematic and PCB for Eagle is available.  The serial, I2C pins are broken out with spare footprints for a tiny crystal (available on aliexpress) and caps.

    I am using 3.3V for the character LCD panel.  See ELM's article for details.  Contrast is controlled by PWM that drives the charge pump.

    I am not sure if/how the buttons (S1 and S3) works with LCD Smarties.  LCD2USB.dll doesn't seem to an entry for them.

    LCD2USB works with LCD Smarties LCD2USB.dll plugin as a info display.  It should work with lcdproc in Linux (not tested).

  • Simple things in life: hacks, recipe

    K.C. Lee05/11/2020 at 14:25 0 comments

    Some of my recent activities during soft lock down.

    Quick and simple recipe:



  • Recent stuff

    K.C. Lee01/27/2020 at 22:13 0 comments

    My STM8 LED clock project is also hosted here on HaD.io  My timer was also updated with the latest features from the clock project.  i.e. all the latest goodies such as NCO tolerance trimming, Daylight saving time and as part of the deal: Date, day of week, leap year.  It would be interesting to see how temperature affects the accuracy clock on the timer as it is next to a window that leaks cold air and heated by a baseboard heater with a not so accurate bang-bang thermostat.  Previously the timer was trimmed to about +/-0.6sec/day just by playing with the 16-bit divider.

    I had to repair my very old Weller WESD51 soldering iron.  Let's say I am not impressed at the overall build quality.   It did last a very long time, but obviously not long enough for me.  :P

    They used a trimpot for the knob and a few corners were cut in this model and making it unreliable. More details on my blog.

    I replaced it with a cheap chinese pot -  I got a bag of 5 for less than $1.  It may not be the greatest quality, but at least it has some metal parts in the bushing and shaft.

    A bit of improvised molten hot glue casting, I modified the existing knob for the new pot.

  • STM8 timer

    K.C. Lee11/01/2018 at 00:46 0 comments

    This is a simple project:  STM8S003 timer for watering plants and LED lighting   It is essentially an clock project with a user interface for setting the alarms. The user interface is a missing piece in my microcontroller library and will be ported to my other projects.

    Here is the UI for trimming the RTC by adjusting the values of the timer reload.


  • Portable F103 - LCD

    K.C. Lee08/19/2018 at 20:29 0 comments

    Doing some reverse engineering of the LCD as I don't trust unknown 3rd party source code without knowing where they came from and more important how they got it and what LCD are they for.  Some of the low level settings are for a specific LCD type.

    Anyway, this is a quick test without the proper timing delays modified from my own Nokia 5110 LCD code.  That's a good start.

    Detail waveforms here: https://hw-by-design.blogspot.com/2018/08/portable-f103-lcd.html

    Main project page: https://hw-by-design.blogspot.com/2018/08/portable-stm32f103.html

    Sadly it is a blogging site, not project oriented.

  • Projects update quickies

    K.C. Lee08/16/2018 at 22:21 0 comments

    Cheap Xilinx Virtual Cable Alternative?

    Made a JTAG dongle using ESP8266 module.  Based on https://github.com/gtortone/esp-xvcd, but I made some changes to GPIO pins and added proper level translation.

    Haven't started with the firmware.  At some point I'll be removed the Arduino digitalwrite() junk as the abstraction are badly and sloooooooow for bitbanging.  

    Sneak peek at the 1 sq. inch layout if and when I am happy with the design.

    The $20 FPGA board has arrived (18th Aug) from China.  It took a bit of damage with the JTAG pin sticking out and slightly bent.  Canada Post put the package in a a big Canada Post plastic bag.

    The PCB side by side with a "credit card".

    portable f103

    PCB arrived from OSH Park a couple of days ago.

    Aside from the stereo connector a bit longer pushing into a couple of parts and a bunch of soldering mishaps,  things are looking okay.  I am in the middle of writing driver code.

    Smart bench supply

    A couple of modules and some plastic knobs showed up in the last couple of days.

    The C$ 2.58 buck-boost one has a possibly XL6019 (180kHz) relabelled as XL6009 (400kHz).  I saw 180kHz switching waveforms on my scope.

    Compare the texture of the one on the left vs the one on the right hand side (fake).  The fake one has some fine scan lines vs the textured surface on the left

    There are a couple of possibly fake or obsoleted ELNA labelled cap.  The ripple (lol 200mV) does not match their claim of 30mV even at low load.  They do have decent inductors.

    The C$ 1.78 XL6015 (180kHz) buck module is probably using real part as I see 188kHz on my scope and the ripple is actually decent.  The inductor is getting warm - they probably use the wrong type of core that is too lossy.  Might move inductor from the buck boost module here.