<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3190099342152377967</id><updated>2026-09-15T16:57:28.819-07:00</updated><category term="microbit"/><category term="robot"/><category term="programming"/><category term="photography"/><category term="3dprinting"/><category term="arduino"/><category term="biking"/><title type='text'>pengtoh&#39;s blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>21</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-7670564567554838242</id><published>2025-11-24T19:53:00.000-08:00</published><updated>2026-09-14T16:55:49.603-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Fast Reed Solomon erasure code in Go</title><summary type="text">Go versionHere&#39;s the Go (golang) version. It is about one third slower than the C version. It uses unsafe pointers to do 64-bit load and stores.Go version, M2 MacBook Air:K=16, N=24, L=64KB (1MB) encoding time 0.0023s. Input rate: 430 MB/s.K=16, N=24, L=1MB (16MB) encoding time 0.037s. Input rate: 430 MB/s.K=17, N=20, L=64MB (1088MB) encoding time 1s. Input rate: 1070 MB/s.K=17, N=20, L=1MB (17MB</summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/7670564567554838242/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2025/11/fast-reed-solomon-erase-code-in-go.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/7670564567554838242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/7670564567554838242'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2025/11/fast-reed-solomon-erase-code-in-go.html' title='Fast Reed Solomon erasure code in Go'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-2463106523075342392</id><published>2025-11-18T21:55:00.000-08:00</published><updated>2025-11-22T17:54:15.788-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Fast Reed Solomon erasure code in C</title><summary type="text">C versionClearly, the Python Reed Solomon erasure code library in the previous post isn&#39;t meant to be fast.&amp;nbsp;Now, let&#39;s build a fast C version.Convert the code to C line by line.Inline calls to&amp;nbsp;gf256_add() and gf256_sub() functions. They are just xors.Optimize the multiplication in compute_chunks() into a table lookup.&amp;nbsp;One output byte now requires only&amp;nbsp;K table lookups and K&amp;</summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/2463106523075342392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2025/11/fast-reed-solomon-erasure-code-library.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/2463106523075342392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/2463106523075342392'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2025/11/fast-reed-solomon-erasure-code-library.html' title='Fast Reed Solomon erasure code in C'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-4855441615767270366</id><published>2025-11-09T15:49:00.000-08:00</published><updated>2025-11-24T19:55:57.175-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Systematic Reed Solomon erasure code in Python</title><summary type="text">In part 1, I&#39;ve visually demonstrated a version of the Reed Solomon erasure code.Let&#39;s turn that into a little library to encode and decode chunks of data. It should be something that can be used in a large scale cloud data storage system with millions of storage devices.APIencode_chunks(K, N, chunks)K is the number of input chunks.&amp;nbsp;N is the total number of chunks wanted.chunks is a </summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/4855441615767270366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2025/11/reed-solomon-erasure-code-library.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/4855441615767270366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/4855441615767270366'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2025/11/reed-solomon-erasure-code-library.html' title='Systematic Reed Solomon erasure code in Python'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-7164882571392395152</id><published>2025-11-03T09:48:00.000-08:00</published><updated>2025-11-18T21:58:21.522-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="programming"/><title type='text'>Systematic Reed Solomon erasure code</title><summary type="text">ProblemGiven K bytes (message), compute N bytes (encoded message or codeword) such that the original K bytes can be recovered from any K subset of the N bytes. Assume we are only dealing with missing data, not corrupted data.MotivationWhy is this useful? There are many practical applications of for this. It can be used to build a data storage system that tolerates N-K storage node failures with </summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/7164882571392395152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2025/11/systematic-reed-solomon-erasure-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/7164882571392395152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/7164882571392395152'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2025/11/systematic-reed-solomon-erasure-code.html' title='Systematic Reed Solomon erasure code'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgflboA5fK5e7_X62ezQ9Z1ckguu9t_hNoDfD_N8k9z-EzC5xQ12KlxZprHGUEJzQb2myzUL5aanDYF2TotQxfcoojRsTgSBn6EyKyFfmWKTQc4kwOCldejqm3Cxx_5-2OMNoW-btC7plotlzCU6NC-r-6NQuFSUbII-DO4YzQBmDmg0WHszHrk-mK-elw/s72-c/figure1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-1527005080262654996</id><published>2025-03-17T10:54:00.000-07:00</published><updated>2026-09-14T17:18:12.650-07:00</updated><title type='text'>Put your monitor 5 feet away</title><summary type="text">If we use our computer or laptop screen for 10 hours a day for decades, our eyes are going to optimize for that distance (1 to 1.5 feet). Over time, we are going to lose our distance vision and near vision.This is the &quot;use it or lose it&quot; theory of how our body works. This happens for many muscles in our body so why wouldn&#39;t it happen with our eyes?So, I set out to find out.A few months ago, I set</summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/1527005080262654996/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2025/03/put-your-monitor-5-feet-away.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/1527005080262654996'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/1527005080262654996'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2025/03/put-your-monitor-5-feet-away.html' title='Put your monitor 5 feet away'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-682904564907543925</id><published>2024-11-01T23:19:00.001-07:00</published><updated>2024-11-11T09:49:57.431-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="arduino"/><category scheme="http://www.blogger.com/atom/ns#" term="robot"/><title type='text'>Arduino balancing bot</title><summary type="text">I built an Arduino version of the balancing bot from old parts in my parts bin:Arduino Mega2560Motor Shield V13v-to-5v level converterMPU-9255toy DC motors and wheels9V battery holder for Arduino4x AA battery holder for the motorsThe Motor Shield V1 is really obsolete. The I2C pins are not passed through. That makes using it with the Arduino UNO impossible. So I switched to the Mega2560 that has </summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/682904564907543925/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2024/11/arduino-balancing-bot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/682904564907543925'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/682904564907543925'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2024/11/arduino-balancing-bot.html' title='Arduino balancing bot'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzZ-nwBS6iktWj9PuhokyEybDfOEqcan_yXhZ3iNzXrB7GqBlopuaytsjw_9vKAAjGP6E3ZZMMYUp05EO9czt0J2_chUbzZoAdlcrn8541uaqz6ViWTPaBgsQ11pt44lVcHGzSQZ-oIQ9ifQbA21wMX2Qa5DO-Fg4von5ZHlsnXVUleDRhqfK8ncqLUhM/s72-w300-h400-c/new%20dc%20motor%20bot.jpeg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-5862620480632958525</id><published>2024-10-31T17:03:00.001-07:00</published><updated>2024-11-01T18:35:41.562-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="3dprinting"/><category scheme="http://www.blogger.com/atom/ns#" term="microbit"/><category scheme="http://www.blogger.com/atom/ns#" term="robot"/><title type='text'>Balancing bot 2024</title><summary type="text">Recently, I bought a new 3D printer. My 10+ year old printer was long gone. Getting it to print properly was hard, so hard that I stopped using it. Is the new printer any better?Well, since my balancing bot from 2017 has fallen apart, let&#39;s rebuild it!It has been interesting coming back to this toy after seven years. Surprisingly, all the electronics on the bot still worked. The soldered daughter</summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/5862620480632958525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2024/10/balancing-bot-2024.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/5862620480632958525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/5862620480632958525'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2024/10/balancing-bot-2024.html' title='Balancing bot 2024'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/a/AVvXsEh3wtB4mTRmZ1WabXW3zT9kSosqYUiZa7hjsnrwBbxnrXSLxc15dCNl9pzh5ZsfXd2xfyITlSoPc0NTgILWTH_I4dYlwuHX6cXgMKjl5YgeTsAHdT_B2Uoy9ahMod19qBh1GdK8mKZCtdFZCDRhQXjV1rW1KZuTRzE2tyZUYQb6iT-FdP6bDqIF-iGOB1c=s72-w400-h300-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-2206160171812148635</id><published>2020-11-01T19:13:00.004-08:00</published><updated>2024-11-11T09:52:16.267-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="microbit"/><category scheme="http://www.blogger.com/atom/ns#" term="robot"/><title type='text'>Balancing Bot Update 2020</title><summary type="text">EDIT: See 2024 update and Arduino version!Since the last post three years ago, Micro:bit MakeCode has been updated.


The latest version is MakeCode v3 2020 Update. The balancing bot code was written using&amp;nbsp;MakeCode v0. MakeCode v3 is not compatible with MakeCode v0.


The big incompatible change is that numbers in MakeCode v3 are now floating point while numbers in MakeCode v0 were 16 bit </summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/2206160171812148635/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2020/11/balancing-bot-update-2020.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/2206160171812148635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/2206160171812148635'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2020/11/balancing-bot-update-2020.html' title='Balancing Bot Update 2020'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-1028923265232592990</id><published>2017-11-18T09:40:00.000-08:00</published><updated>2017-11-28T01:06:23.424-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="microbit"/><category scheme="http://www.blogger.com/atom/ns#" term="robot"/><title type='text'>Self-balancing robot version 3 update!</title><summary type="text">


It works! Now it balances on hard or soft floors for more than 30 minutes!





What changed?

Firstly, 2xAA rechargeable Eneloop batteries are insufficient to power those FS90R motors. The specification of the motor allows up to 6V. Two cells provide only around 2.7V total. I switch to 4xAA Eneloop batteries, providing around 5.4V. The motors were much much faster, more than twice as fast. </summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/1028923265232592990/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2017/11/self-balancing-robot-version-3-update.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/1028923265232592990'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/1028923265232592990'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2017/11/self-balancing-robot-version-3-update.html' title='Self-balancing robot version 3 update!'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiSBKG-JabKN639_1WnPIUy1BI-AnR5XLfu9-DvW6FnEPCNkjg-rKBbmvo1GAO6hy5AqLf6Boz-W99G5erlwLdAT2I3XJwf1yWp4QHTZ2fc_5_PRRoNskPkar3v7Oe4A4147-kvehSVAT1/s72-c/IMG_4576.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-6843009611680317382</id><published>2017-11-16T03:56:00.000-08:00</published><updated>2017-11-18T09:55:53.259-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="microbit"/><category scheme="http://www.blogger.com/atom/ns#" term="robot"/><title type='text'>Self-balancing robot version 3</title><summary type="text">


Version 1&amp;nbsp;was made out of Lego. It keeps breaking into pieces, the motors were not secured and it also contained the unnecessary Kitronic servo:lite board. So, I rebuilt it.

Parts:

BBC micro:bit
2x&amp;nbsp;Feetech FS90R&amp;nbsp;360 degrees servo motors
InvenSense MPU-9255&amp;nbsp;9-axis gyroscope, accelerometer, compass.
Pololu Wheel for FEETECH FS90R/FT90R Micro Servo&amp;nbsp;60x8mm
2x AAA battery</summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/6843009611680317382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2017/11/self-balancing-robot-version-3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/6843009611680317382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/6843009611680317382'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2017/11/self-balancing-robot-version-3.html' title='Self-balancing robot version 3'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4XPrmK9jf9iEsjCl5sAYl7ROO8KfAW4CCPnZ_WmEJgDkl1d_nhfqRze5hbCJaRtlwwdcBiy0MzsPhW2tZ6bMP4FXVPdjXC3aQBnp9VPfthG-3RWP-ljMQ6ADPJtvVcSgN05vNbL_n0JtR/s72-c/IMG_4575.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-5304734954876329106</id><published>2017-11-12T18:57:00.003-08:00</published><updated>2017-11-13T21:57:22.896-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="microbit"/><title type='text'>Trig module for micro:bit</title><summary type="text">I&#39;ve updated the Trig module for micro:bit.

Now includes atan2(), sin(), cos(), rotate2d() and test code for the trigonometry functions.

Just cut and paste these into your custom.ts&amp;nbsp;in MakeCode and you can skip the test code (control.assert).


/**
 * Public domain. Use at your own risk!
 * Trigonometry functions
 */
//% weight=90 color=#00A040
namespace Trig {
    const atan_table: number</summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/5304734954876329106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2017/11/trig-module-for-microbit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/5304734954876329106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/5304734954876329106'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2017/11/trig-module-for-microbit.html' title='Trig module for micro:bit'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-3396667821162125413</id><published>2017-11-09T22:58:00.000-08:00</published><updated>2017-11-09T22:58:01.848-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="microbit"/><title type='text'>Microbit serial to file script</title><summary type="text">How do you save thousands of lines from the micro:bit connected via the serial port to a file?

screen? Cut and paste from the terminal?

That gets tiring after a while. Furthermore, the name of the serial device on OS X keeps changing.

Well, here&#39;s a handy little script. It looks for the first connected micro:bit and then copies the serial output to stdout. You can tee&amp;nbsp;or pipe it to a file</summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/3396667821162125413/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2017/11/microbit-serial-to-file-script.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/3396667821162125413'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/3396667821162125413'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2017/11/microbit-serial-to-file-script.html' title='Microbit serial to file script'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-1644818218057801852</id><published>2017-11-09T00:27:00.002-08:00</published><updated>2017-11-16T03:09:54.417-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="microbit"/><title type='text'>Micro-bit logging module</title><summary type="text">One more utility package.

When trying to balance the robot, it is hard to know what is going on without logging the numbers from every iteration of the control loop. However, there is no straightforward way to log 6 data points 100 times per seconds for 10 seconds. Bluetooth and radio are too slow and lossy. Attaching a serial line affects the balance of the robot. Try the simple way of adding </summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/1644818218057801852/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2017/11/one-more-utility-package.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/1644818218057801852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/1644818218057801852'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2017/11/one-more-utility-package.html' title='Micro-bit logging module'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-4157152711172590188</id><published>2017-11-08T00:28:00.001-08:00</published><updated>2017-11-13T19:31:29.773-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="microbit"/><category scheme="http://www.blogger.com/atom/ns#" term="robot"/><title type='text'>Code for self-balancing micro:bit robot with DC motors</title><summary type="text">



The DC motors version of the code is similar to the servo version except for the motor control code and the tuning parameters.

This works with version 2 of the self-balancing robot.



See the code for version 1 for more info.


/**
 * Public domain. Use at your own risk!
 * Self-balancing robot controller, controlling a pair of FS90R servos.
 * Requires InvMPU and Trig package in custom.ts.</summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/4157152711172590188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2017/11/code-for-self-balancing-microbit-robot.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/4157152711172590188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/4157152711172590188'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2017/11/code-for-self-balancing-microbit-robot.html' title='Code for self-balancing micro:bit robot with DC motors'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjx60i_iK1IrFPmU6W6R8mf8o16pf38b9DfllsI7E9CdCjEdtbkSMPbALcxRYG6QIwWodbWQelkKG6_wNPA4fC6z9sC17kXV-OQxM2VKImBrNsAZrF4zLFtpqUmU36T1PoHa_8SucVnrLxC/s72-c/IMG_4544.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-6800192209513972020</id><published>2017-11-07T19:41:00.001-08:00</published><updated>2017-11-13T19:20:15.059-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="microbit"/><category scheme="http://www.blogger.com/atom/ns#" term="robot"/><title type='text'>Code for self-balancing micro:bit robot with FS90R servo motors</title><summary type="text">



Ok, here&#39;s the code for version 1 of the self-balancing robot. I tried to make this work in&amp;nbsp;block&amp;nbsp;mode in MakeCode. The result was unreadable.

Only 80 lines of code. It implements the most primitive PID control algorithm. Clearly Segway and other self-balancing single wheel devices use far better algorithms.

To use this, you neeed to:


Build a robot with one of three InvenSense </summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/6800192209513972020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2017/11/self-balancing-robot-code-for-microbit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/6800192209513972020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/6800192209513972020'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2017/11/self-balancing-robot-code-for-microbit.html' title='Code for self-balancing micro:bit robot with FS90R servo motors'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiT0cIp6G2s8M8TTeZxnmEK8DAyDVdoYHiO2ETcedL61vIo6oRPScJs89KSFxKmTl_x1JMgigb9ew0XbglJo3xCe-tW6uDkinJt4SybX0crTWYo0vxLvdklSX_CtdD2NK_5LCjcpPeJWuRw/s72-c/IMG_4567.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-8903568717881425385</id><published>2017-11-07T06:42:00.004-08:00</published><updated>2024-11-09T10:41:03.641-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="microbit"/><category scheme="http://www.blogger.com/atom/ns#" term="robot"/><title type='text'>InvenSense MPU-9255/MPU-9250/MPU-6500 gyroscope accelerometer and compass</title><summary type="text">



EDIT:&amp;nbsp;Arduino version of here.

The BBC micro:bit does not have a builtin gyroscope and the self-balancing robot requires one.

Among the many options, the MPU-6500/MPU-9250/MPU-9255 based breakout boards are probably among the cheapest motion sensors available. The MPU-6500 costs SGD9.90 from a local retail shop and is available online for much less. The differences between the models </summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/8903568717881425385/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2017/11/invensense-mpu-9255mpu-9250mpu-6500.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/8903568717881425385'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/8903568717881425385'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2017/11/invensense-mpu-9255mpu-9250mpu-6500.html' title='InvenSense MPU-9255/MPU-9250/MPU-6500 gyroscope accelerometer and compass'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7c51iOb7A4y3UgxolOQsK2z4rXVoE9t4KnD2SucrxVA17h1JQSRbreWQfesEFH8acAaRQQ-AbiARureWNOhhj2AH8BRb1Wb_zhPXZkMWIsiPEzGadFLqgrf1UBFdwSqj3czngbiA_u3tf/s72-c/IMG_4474.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-1161653067042652347</id><published>2017-11-07T00:32:00.000-08:00</published><updated>2017-11-13T19:29:57.127-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="microbit"/><category scheme="http://www.blogger.com/atom/ns#" term="robot"/><title type='text'>Self-balancing robot version 2</title><summary type="text">
Every project must include something new.

I wasn&#39;t happy with version 1.

Here&#39;s version 2, completely different:




Parts:


BBC micro:bit
Kitronic micro:bit edge connector breakout board
Blue plastic parts, hobby DC motors and wheels from a&amp;nbsp;Dagu Magician Chassis.
2xAAA battery holder for the micro:bit
4xAA battery holder for the DC motors
Homemade L293D motor controller board
InvenSense</summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/1161653067042652347/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2017/11/self-balancing-robot-version-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/1161653067042652347'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/1161653067042652347'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2017/11/self-balancing-robot-version-2.html' title='Self-balancing robot version 2'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_xAFpoGv3rh03oql6nrsHaIYoDG-Q9DA1O09Ms3CdH6yk-nB6kQH9N6tl0nwBEjzi-6vMAK4Or01ACz7sd7lzUx_Iay4hvo6zz5EH00zBWBHflh23xLoMhXQLGhyphenhypheniMMqj_udX7NKAarlj/s72-c/IMG_4544.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-5718323677445124934</id><published>2017-10-28T10:43:00.000-07:00</published><updated>2017-11-18T09:59:42.016-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="microbit"/><category scheme="http://www.blogger.com/atom/ns#" term="robot"/><title type='text'>Self-balancing robot version 1</title><summary type="text">


I got my hand on a few micro:bits and a Kitronic :MOVE mini buggy. They were meant for my kids. But I had always wanted to build a remote controlled self-balancing robot. What&#39;s the easiest way to get something working? Repurpose parts from the buggy, add Lego and some code!

Here&#39;s version 1. It is fragile and wobbly. With a simple PID controller written in Javascript using makecode/PXT, it </summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/5718323677445124934/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2017/10/self-balancing-robot-version-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/5718323677445124934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/5718323677445124934'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2017/10/self-balancing-robot-version-1.html' title='Self-balancing robot version 1'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBIkONevwIH-mepHLIIoJtnuXWt7jS162uK0G6pB-D9-jvo90mXGjOMNkCv86JcLwA7MhesYufOkASzFweWa49mU5iAQ5XE81feboFjCRRaqrbC8NnAO-79FBndnf-ld7rlz6UbihyphenhyphenGFlY/s72-c/IMG_4532.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-5735896688838474826</id><published>2017-01-25T00:38:00.003-08:00</published><updated>2026-03-26T09:39:54.790-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="biking"/><title type='text'>2016 Bicycle Tour of the Alps</title><summary type="text">






July 6th to July 16th

11 days

900km

15 mountain passes

18,000m of climb

To remind myself to do something crazy once in a while.


Many thanks to my wonderful wife for taking care of the kids while I was away.





Check out Piaw&#39;s detailed&amp;nbsp;trip report&amp;nbsp;for the whole tour.



Day 1, July 6th

83km, 1240m climb.
Luzern, Sarnen, Melchtal, Stockalp, half way up Melchee-Frutt, </summary><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/5735896688838474826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/5735896688838474826'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2017/01/2016-bicycle-tour-of-alps.html' title='2016 Bicycle Tour of the Alps'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj8xQD32PNs6A0838d-HPMCgz4PYj7Zi9Uaya4HAa6fyp-OmfPhG2Nt_4H6DwdXJ6rRbWey5VfGc2SbZLjXwFp5ssx5YC4FXm4NuNgpjlapdXJ6lB77CnOlRXzns0UFXCI3_x3CPhOlkD3m/s72-w640-h454-c/IMG_1104.jpg" height="72" width="72"/></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-8447871341357367647</id><published>2015-11-05T10:28:00.004-08:00</published><updated>2015-11-06T04:25:58.133-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="photography"/><title type='text'>Hyperfocal distance with cropped image cheatsheet</title><summary type="text">TLDR: Hyperfocal distance is proportional to enlargement.

What happens to the hyperfocal distance if you intend to print a crop at the same size for the same viewing distance?



Back to basic assumptions:


Visual acuity of 5lp/mm at 25cm viewing distance. This is equivalent to a final print circle of confusion of 0.2mm.
Print size is 8x12. Enlargement = 12&quot;/36mm = 8.47. Circle of confusion = </summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/8447871341357367647/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2015/11/hyperfocal-distance-with-cropped-image.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/8447871341357367647'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/8447871341357367647'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2015/11/hyperfocal-distance-with-cropped-image.html' title='Hyperfocal distance with cropped image cheatsheet'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3190099342152377967.post-5817848319356175357</id><published>2012-09-12T02:17:00.000-07:00</published><updated>2012-09-12T02:17:01.472-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="photography"/><title type='text'>Hyperfocal Distance Cheat</title><summary type="text">
This post was from before the big reset. I keep coming back to this post to recompute the magic number for various lenses. I hope somebody finds this useful.

The magic number for Canon 5D mk II with 40mm 2.8 STM is 53 which is twice that of X100 with 23mm.

------

Once upon a time, I stumbled upon this concept called&amp;nbsp;hyperfocal distance. For each given focal length, aperture and size of </summary><link rel='replies' type='application/atom+xml' href='http://pengtoh.blogspot.com/feeds/5817848319356175357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://pengtoh.blogspot.com/2012/09/hyperfocal-distance-cheat.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/5817848319356175357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3190099342152377967/posts/default/5817848319356175357'/><link rel='alternate' type='text/html' href='http://pengtoh.blogspot.com/2012/09/hyperfocal-distance-cheat.html' title='Hyperfocal Distance Cheat'/><author><name>pengtoh</name><uri>http://www.blogger.com/profile/07893644890723733498</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>