tag:blogger.com,1999:blog-31900993421523779672024-03-08T09:43:00.139-08:00pengtoh's blogpengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-3190099342152377967.post-22061601718121486352020-11-01T19:13:00.003-08:002020-11-01T19:41:26.696-08:00Balancing Bot Update 2020Since 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 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 integers. MakeCode v3 also includes pengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com1tag:blogger.com,1999:blog-3190099342152377967.post-10289232652325929902017-11-18T09:40:00.000-08:002017-11-28T01:06:23.424-08:00Self-balancing robot version 3 update!
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. pengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com0tag:blogger.com,1999:blog-3190099342152377967.post-68430096116803173822017-11-16T03:56:00.000-08:002017-11-18T09:55:53.259-08:00Self-balancing robot version 3
Version 1 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 Feetech FS90R 360 degrees servo motors
InvenSense MPU-9255 9-axis gyroscope, accelerometer, compass.
Pololu Wheel for FEETECH FS90R/FT90R Micro Servo 60x8mm
2x AAA batterypengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com0tag:blogger.com,1999:blog-3190099342152377967.post-53047349548763291062017-11-12T18:57:00.003-08:002017-11-13T21:57:22.896-08:00Trig module for micro:bitI'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 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: numberpengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com0tag:blogger.com,1999:blog-3190099342152377967.post-33966678211621254132017-11-09T22:58:00.000-08:002017-11-09T22:58:01.848-08:00Microbit serial to file scriptHow 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's a handy little script. It looks for the first connected micro:bit and then copies the serial output to stdout. You can tee or pipe it to a filepengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com0tag:blogger.com,1999:blog-3190099342152377967.post-16448182180578018522017-11-09T00:27:00.002-08:002017-11-16T03:09:54.417-08:00Micro-bit logging moduleOne 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 pengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com0tag:blogger.com,1999:blog-3190099342152377967.post-41571527111725901882017-11-08T00:28:00.001-08:002017-11-13T19:31:29.773-08:00Code for self-balancing micro:bit robot with DC motors
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.pengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com0tag:blogger.com,1999:blog-3190099342152377967.post-68001922095139720202017-11-07T19:41:00.001-08:002017-11-13T19:20:15.059-08:00Code for self-balancing micro:bit robot with FS90R servo motors
Ok, here's the code for version 1 of the self-balancing robot. I tried to make this work in block 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 pengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com0tag:blogger.com,1999:blog-3190099342152377967.post-89035687178814253852017-11-07T06:42:00.002-08:002021-01-17T11:03:19.462-08:00InvenSense MPU-9255/MPU-9250/MPU-6500 gyroscope accelerometer and compass
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 are:
MPU-6500: gyroscope and pengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com3tag:blogger.com,1999:blog-3190099342152377967.post-11616530670426523472017-11-07T00:32:00.000-08:002017-11-13T19:29:57.127-08:00Self-balancing robot version 2
Every project must include something new.
I wasn't happy with version 1.
Here'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 Dagu Magician Chassis.
2xAAA battery holder for the micro:bit
4xAA battery holder for the DC motors
Homemade L293D motor controller board
InvenSensepengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com0tag:blogger.com,1999:blog-3190099342152377967.post-57183236774451249342017-10-28T10:43:00.000-07:002017-11-18T09:59:42.016-08:00Self-balancing robot version 1
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's the easiest way to get something working? Repurpose parts from the buggy, add Lego and some code!
Here's version 1. It is fragile and wobbly. With a simple PID controller written in Javascript using makecode/PXT, it pengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com0tag:blogger.com,1999:blog-3190099342152377967.post-57358966888384748262017-01-25T00:38:00.003-08:002023-10-27T15:38:28.980-07:002016 Bicycle Tour of the Alps
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's detailed trip report for the whole tour.
Day 1, July 6th
83km, 1240m climb.
Luzern, Sarnen, Melchtal, Stockalp, half way up Melchee-Frutt, pengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.comtag:blogger.com,1999:blog-3190099342152377967.post-84478713413573676472015-11-05T10:28:00.004-08:002015-11-06T04:25:58.133-08:00Hyperfocal distance with cropped image cheatsheetTLDR: 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"/36mm = 8.47. Circle of confusion = pengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com0tag:blogger.com,1999:blog-3190099342152377967.post-58178483193561753572012-09-12T02:17:00.000-07:002012-09-12T02:17:01.472-07:00Hyperfocal Distance Cheat
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 hyperfocal distance. For each given focal length, aperture and size of pengtohhttp://www.blogger.com/profile/07893644890723733498noreply@blogger.com0