Posts

Showing posts from 2020

ESP-07 flashing issue on PlatformIO and solution

Recently, I decided to port the ESPClock project to PlatformIO , and kept encountering an intermittent error during flashing:  A fatal error occurred: Timed out waiting for packet header Took me a long time to research the issue and making no headway,  until I stumbled upon this rare gem . The file I needed to modify is:   C:\Users\<Username>\.platformio\packages\tool-esptoolpy\esptool.py I changed the values to:  DEFAULT_TIMEOUT = 100  START_FLASH_TIMEOUT = 40  CHIP_ERASE_TIMEOUT = 240  MD5_TIMEOUT_PER_MB = 8  ERASE_REGION_TIMEOUT_PER_MB = 60  DEFAULT_SERIAL_WRITE_TIMEOUT = 20 Originally, DEFAULT_TIMEOUT was set to 10. That made flashing the code reliable, but flashing the filesystem was still problematic. After increasing the value all the way to 100, I never encountered the error again.

ESPCLOCK3, Runtime Upate #3

Image
So the ESPCLOCK started on 22 Aug 3:50pm on a fresh set of batteries and ended this morning 19 Nov at 4:30am. 89 days in total, or about 3 months, just like last time. But this time, it went through daylight saving in Oct . Each battery had an average of 0.9V left on it. Once I have time, I plan to start work on adapting the ESPCLOCK to a $3 STOMMA Ikea clock with silent clock movement.

Drivinator Direct Drive Mod for Ender 3

Image
I recently tried printing and installing the Drivinator , which is a direct drive mod for the Creality Ender 3. It makes use of all existing parts, so there is nothing extra to purchase (the stepper motor wire needs to be lengthened, which is easy done by a little splicing; an even easier route is to purchase an extension cable online). It is also compatible with the FreeABL bed levelling mod. Besides FreeABL, this is easily the best mod I have installed for the Ender 3, well worth the 1 hour or so I spent on the job. This was the YouTube video which helped me install the mod: Where before the extruder would sometimes skip and grind under the Bowden tube setup, the extrusion after the upgrade is just smooth as butter. The extra weight on the print head also doesn't seem to affect print quality or speed. With the enhanced extrusion, I was now able to crank up the print speed. But at higher print speeds, I discovered sharp corners were showing signs of over extrusion, so I needed to

ESPCLOCK3, Runtime Upate #2

There is something magical about waking up the morning after daylight saving and finding your analog ESPCLOCK at the exact right time without requiring any adjustment!  The clock started with a fresh set of rechargeables on 22 Aug, and has been running since then, just in time for the October daylight saving change, which sets the clock one hour ahead at 2am. I am glad now there is one fewer clock around the house that requires adjustment after daylight saving!

Windows 10: Remove execution permission from all files created in user "Downloads" folder

From Administrative command prompt: cd \Users\<User> icacls Downloads /deny <User>:(CI)(OI)(X) /t User will no longer be able to run any EXE in his "Downloads" folder. To revert: cd \Users\<User> icacls Downloads /remove <User> /t

Compiling Marlin 2.x for the Creality Ender 3 using PlatformIO

Image
 I had previously modded my Ender 3 to use the FreeABL for auto bed-leveling. This requires compiling and uploading a custom version of Marlin firmware with  AUTO_BED_LEVELING_BILINEAR enabled. Since this takes quite a quite of extra storage, it requires  SLIM_LCD_MENUS to be enabled. This removes the function to configure E-steps from the control panel.  As mentioned in my previous post , setting the right E-steps value is one of the most important operation to perform when changing filament or print nozzle. As a result of enabling  SLIM_LCD_MENUS , I can only configure E-steps by hooking up the Ender 3 to my laptop and issuing raw G-codes. This was getting old pretty fast. So the other day, I started poking around to see if there is a way to fit both  AUTO_BED_LEVELING_BILINEAR  and  SLIM_LCD_MENUS  in the limited storage on the plain-vanilla Ender 3. After much research and tinkering, I am glad to report this is indeed possible. Here are 2 links I found most useful in helping me

PC Logger: AutoIt3 script for PC activity monitoring

Image
Due to COVID-19, the kids had to do online learning for a couple of months. Unfortunately, they were constantly tempted to play games or watch YouTube during class time. Sometimes they became so immersed that they missed lessons, or forget to complete assigned tasks. I tried various solutions, such as parental control software, or lock down the router. None of them worked for me. There were just too many things to configure. Furthermore, some potential avenues for distraction (eg. YouTube) might sometimes be necessary for schoolwork (eg. YouTube being used for information or research by the teacher). The solution I eventually settled upon turned out to be quite simple. I hacked together an AutoIt script that logs details about the active window (title and executable) to a Google form periodically. By looking at the logs from time-to-time, it gives me a pretty good picture of what they have been doing on their computers, and have a chat with them when things get out-of-hand. Github repo

ESPCLOCK3, Runtime Upate

I started running the final version of ESPCLOCK3 on 22 May at 11:10pm on 4 x Ikea's LADDA AA 2450mAH rechargeables.  The clock ran flawlessly until 19 Aug 9:10am. So total runtime was just a few days shy of the calculated 4-month duration. The batteries were all depleted and measuring ~1V each. The clock was mounted in front of my desk, and it stayed accurate to the second throughout the entire time. The voltage level during the end of battery life seems to bounce around the 2.8V threshold level. So I will make some minor code change to stop the clock until input voltage level rises above some upper threshold level eg. 3.0V. I plan to run it for another test cycle. This test cycle should allow me to test clock adjustment for daylight saving.

DIY Roomba Virtual Wall, Part 5

After using the DIY Roomba Virtual Walls for a week now, I found something interesting that is rarely mentioned by the folks who have made this. The only mention I could find is from this blog post : "After examining the original virtual wall, with a webcam, I was able to see that it emits infrared light from its top round transparent ring and from a small hole above the switches. The light coming from the top ring prevents the robot from colliding with the virtual wall , if it comes from its sides or from behind. The front hole emits light as a beam. This beam of light is directional and stops at the nearest obstacle, probably a real wall, preventing the robot from crossing it to the other side." Indeed, when using the DIY version, the first thing I noticed is that the unit has to be strategically placed because the Roomba will knock into it more often than expected.  So a more robust DIY version will need to have another IR LED pointing at some kind of conical reflector mo

DIY Roomba Virtual Wall, Part 4

Image
So I went ahead and made another Roomba Virtual Wall. Everything else is pretty much the same as before , except I made each mounting layer one single ring, instead of 2 separate pieces. The single-piece design makes them easier to align and attach, at the expense of slightly longer print time and more filament used. When soldering the proto-board, I tried moving the 3 resistors to the bottom of the board. Bad move. It was too crowded. In the end, I moved 2 of them back to the top. I found that the IR LED that I used for this unit is actually the one I salvaged from the broken Roomba Virtual Wall because it has a very narrow degree of projection (2 ~ 3° at most). I thought the first unit had it. What happened was, I was testing out the IR LED from the virtual wall and the old TV remote on the breadboard, and somehow got them mixed up. So I thought the first unit was using the IR LED from the broken virtual wall, but actually it had the TV remote IR LED, which makes sense now, because i

DIY Roomba Virtual Wall, Part 3

Image
I created an enclosure for the ATtiny85-based Roomba virtual wall prototype board using FreeCAD . A couple of design goals: The LED is positioned about 7cm from ground level. The 3 x AA battery holder is 3D-printed, completed by battery clips salvaged from old toys (or readily available online ). The parts are designed to print with as little support as possible, and attached together using superglue and screws. I printed the parts using 0.8mm nozzle to save time, so they look a little rough. It takes about 7 hours to print all the parts on my Creality Ender 3. Nine M2.5 screws are required, one for the battery cover, eight for holding the body together. Superglue can be used for the latter, but I like the option to easily take the body apart for repair. Here is the battery box with battery clips inserted: JST male connector wire soldered at the back: Mounting clips attached with superglue. When working with superglue, move the parts in position and hold down with pressure for 60 secon

DIY Roomba Virtual Wall, Part 2

Image
Following on the success of the test circuit , I added a status LED and a pushbutton to the breadboard.  A summary of the connections: IR LED connected to pin 3 (PB4) of the ATtiny85 (100ohm current- limiting resistor). Pin 3 is where the tiny_IRremote library sends its output to by default. Normal LED connected to pin 2 (PB3, 220ohm current-limiting resistor). We will use this LED as a status indicator to 1) signal power-on 2) signal battery low Pushbutton connected to pin 6 (PB1, 10Kohm pull-up resistor). We will use this as a soft switch to turn the virtual wall on/off. The Arduino source code is available here . Note: I configured ATtiny85 to run at 1MHz for additional power saving. Correspondingly, in  tiny_IRremoteInt.h , I had to change  #define SYSCLOCK  from 8000000 to 1000000 . Some highlights of the code: Pin change interrupt is used to monitor when the pushbutton is pressed to turn on the unit. In normal operation, status LED flashes every second. Watchdog timer interrup

DIY Roomba Virtual Wall

Image
Recently, my Roomba virtual wall broke. Not sure what happened. I did a battery change, and the darn thing will not power up after the new batteries were inserted. Anyway, while looking online for a new virtual wall to buy, I came across info on people making their own virtual walls. Here is a links dump: https://petezah.com/category/development/roomba/ https://www.thingiverse.com/thing:3104027 http://blog.batmule.dk/posts/2019/Roomba_Virtual_Wall_part1/ http://www.robotreviews.com/chat/viewtopic.php?p=65658&mobile=on https://misc.ws/2014/02/27/diy-virtual-wall-for-roomba/ https://misc.ws/2014/08/09/diy-virtual-wall-for-roomba-part-two/ http://www.enide.net/webcms/index.php?page=virtual-wall-for-roomba http://eka.tomeczko.pl/index.php/diy-roomba-virtual-wall http://gregthielen.me/blogstuff/2017/06/27/roomba-virtual-wall/ https://github.com/MKme/Roomba http://forkthings.com/2016/11/25/diy-an-irobot-roomba-virtual-wall/ Turns out it is extremely easy to produce the IR signal emitted

Encode with Handbrake without slowing your machine to a crawl

Recently found out about this useful option when encoding using Handbrake . Add " pools=x " to "Advanced Options" under the "Video" tab. It will make your machine less laggy during encoding.

Re: How to enable SMB1 on Windows 10

Hit by this issue again, after a recent update to Windows 10, which I think disabled SMB1 silently. Look, I know SMB1 is dated and has security issues and all, but we all have old equipment that we need to connect to and don't always have the means or resources to replacement them. Quick reminder to self on how to enable SMB1: Launch PowerShell in Administrator mode Run " Enable-WindowsOptionalFeature -Online -FeatureName smb1protocol " Will be prompted to restarts Windows (sucks, I know..)

Wakey Wakey - Network Alarm Clock

Image
I repurpose old Android mobile phones (from the KitKat/Lollipop era) to use as alarm clocks in my 3 young kids' rooms. After a while, it gets pretty tiresome syncing up the alarm clocks (eg. when the next day is a public holiday and you want to disable the alarm just for that day so that everyone can get a bit more sleep). I thought it would be pretty cool if I could update all the alarm clocks remotely from a webapp. I couldn't find any alarm clock app that can be remotely controlled on the app store, so I decided to implement my own. For the webapp, I repurposed another project of mine called Shopping Buddy . This turned out to be relatively easy, because it basically involved stripping away features like bookmarks and history, and trying not to break things along the way. It was done pretty quickly, and I called it Wakey Wakey .  The production site can be found at: https://wakey.randseq.org The Github repository can be found at: https://github.com/victor-chew/wakey-wakey Sc

Hacking a USB-C to slim tip adapter cable to charge the Thinkpad T450s

Image
This hack is inspired by this post . A year ago, I bought an adapter cable for my wife's Thinkpad X1 Carbon (2nd Gen) that allows her to power her laptop with a 60W-capable portable battery (20V x 3A). A USB-C cable goes from the battery into the adapter, which converts it to the slim tip output required by the laptop. Everything works out of the box, so I didn't give much thought about it. Recently, I decided to buy a similar cable for my Thinkpad T450s. I know technically it should work because the T450s can go as low as 45W (20V x 2.25A) in terms of charging (though I have the 65W charger - 20V x 3.25A).  I went with another adapter cable because it was cheaper and also I prefer the single cable design. So imagine my surprise when the cable came and I plugged it into my laptop and it didn't work! The power manager just cycle in and out of charging mode before giving up with an error message saying there is not enough power. After much research and reading the Thinkwiki

Important calibration when loading new 3D printer filament

Note to self: The most important calibration to do when loading new 3D printer filament (even if it's the same brand and type, because the formulation may have changed) is to calibrate the extruder steps/mm (also called E-steps/mm). Details of this calibration is given here . The (simplified) steps I take are: Power up the 3D printer and hook it up to the laptop via a USB cable. Install and run a program that is able to talk to the 3D printer via the virtual serial port (eg. Prointerface ). Mark 10cm of filament, starting from the hole where the filament enters the extruder stepper mechanism and work backwards. An extra piece of filament that is measured to exactly 10cm helps here. Use the following G-Code to find out your current E-step value. M503 The current E-step value is the last value ( 96.5 ) on this line: Steps per unit:     M92 X80.00 Y80.00 Z400.00 E96.5 Issue the following G-Code: // Set nozzle temp to 190c. Set to temperature you'd be printing the filament at. M104

Downmux to 2-channel AAC without recoding video stream

Get Win64 build of ffmpeg here . ffmpeg.exe -i input.mp4 -c:v copy -ac 2 -c:a aac -vbr 3 output.mp4

ESPCLOCK3 - The Final Version

Image
Overview This is the latest, and probably final iteration of my ESPCLOCK project. You can find ESPCLOCK1 here , and ESPCLOCK2  here . The main differences between ESPCLOCK3 and ESPCLOCK2 are: Use barebones ESP-07 instead of WeMOS D1 Mini to reduce deep sleep power draw. Use  PCF8563 RTC to clock the ATtiny85. PCF8563 is chosen over the more popular DS3231 RTC  due its vastly lower power consumption. Using a RTC to clock the ATtiny85 allow us to use the POWER_DOWN instead of IDLE sleep mode, which minimizes power draw. As a result, the ATtiny85 code is also vastly simplified because we don't have to play with Timer1 to get an accurate 1Hz signal. Use diode clamp to limit the voltage pulsing the analog clock. Connecting to the analog clock directly using the ATtiny85 pins running at ~3V requires the clock pulse to be longer (~200ms) and increases power draw (due to reduced MCU sleep time). In addition, the higher voltage causes ticks to miss occasionally. The diode cl