Union Microscope

microscope1

I picked up a Union microscope on an auction site for about 80USD including P&P. I got it just to look at the die of a CCD I’ve been playing with. Being so cheap I hardly expected it to work at all, but although there seem to be illumination issues it did the job (turns out the CCD is a Sony ICX495).

I was particularly excited by the Mitutoyo micrometer heads… hmmmmm…. Check below for video can more photos:

microscope2

microscope3

microscope4

microscope5

Notes

The illumination issues noted above were caused by two things. Firstly, there were indeed yellow filters installed. One inside the eye piece, another on the solenoid shown in the pictures above, and a third in the underside illumination path. I removed the filtered. However the jig with the micrometers on it was also faulty. That jig has two sets of sliding pieces of metal in it. They block the path of the of the light coming in at the back. This allows you to illuminate a rectangle region only. However, one of the “windows” was jammed, so only a small band could ever be illuminated. I removed this jig so everything is always illuminated.

IBM Laptop Supervisor (BIOS) password reset

There a few tools available to reset the BIOS passwords on IBM/Lenovo laptops they attach to the I2C lines of the EEPROM to reprogram it. However, there’s a lower tech way to reset the BIOS passwords, though it takes a bit of persistence.

This site has handy diagrams showing all the EEPROM locations. To reset the password you can just short the SDA and SCL lines on the IC. The problem is you have to short them at /exactly/ the right time. This is sometime after boot, but before the boot logo appears (I think). If you short the pins at boot the system just wont power up. If you short them too soon it’ll just halt. I also removed the RTC battery when I was doing this (just in case).

If you get everything right the system will say “Press F1 to enter setup”. Once in setup you can stop shorting the pins. From setup you should be able to enter a new supervisor password from there. If you don’t get the timing just right you’ll enter restricted setup (user?). Good luck!

STM32-Discovery on Linux

stm32

The following instructions should work for the STM32-Discovery (STM32F101 based device) and STM32f4-discovery (STM32F4 based device). The support tools are the same, the code obviously needs to be different. The instructions assume Debian Jessie.

#get compilers, a other reqs.
sudo apt-get install gdb-arm-none-eabi gcc-arm-none-eabi libstdc++-arm-none-eabi-newlib libnewlib-arm-none-eabi
sudo apt-get install autoconf pkg-config libusb-1.0 git

# get stlink, compile and install
git clone https://github.com/texane/stlink.git
cd ~/stlink
./autogen.sh
./configure
make
sudo make install
#install the modprobe exceptions
sudo cp stlink_v1.modprobe.conf /etc/modprobe.d
sudo modprobe -r usb-storage && modprobe usb-storage

# Grab the code example (originally from <a href="http://gostm32.blogspot.jp/2010/09/blinky-ii.html">this useful blog post</a>)
cd ~
git clone https://github.com/new299/stm32vl_blinky.git
cd stm32vl_blinky
make
sudo make burn

st-link seems a bit flakey, and I never get 100% of flashes to verify correctly. However it mostly seems to program correctly. Ocassionally it reports the incorrect amount of flash. I’ve found that hitting reset during a flash sometimes seems to kick it into functioning correctly again.

Slippy maps

I’ve been looking at Javascript, googlemap-like maps. It seems that these are called “slippy maps”.

There’s some useful information of the Openstreetmap wiki here.

They recommend a few Javascript libraries, including LeafletJS and OpenLayers. I tried OpenLayers first, but it’s pretty big, just to get the examples working from github I’d need node.js/JVM etc…

I decided to play with LeafletJS, it was a lot quicker to get the examples working!

The LeafletJS demo pulls tile images from URLs that look like this:

https://c.tiles.mapbox.com/v3/examples.map-i875mjb7/13/4094/2724.png

I sptent some time trying to figure out how coordinates are translated into the URL. The above representing a tile near [51.505, -0.09] at zoom level 13. The 13 is obvious enough. However the latitude and longitude took some googling.

It seems that pretty much all mapping services use the Spherical Mercator projection (see wikipedia and openstreetmap ). There are a bunch of tools for making tile sets (particularly from flat images).

Anyway, I wanted to make my dataset manually at first to try things out. I created a directory structure that looks like this:

./13/4094/2723.png
./13/4094/2724.png
./13/4095/2723.png
./13/4095/2724.png
./13/4092/2723.png
./13/4092/2724.png
./13/4093/2723.png
./13/4093/2724.png

And used a modified version of the LeafletJS example, telling it to pull data from my server:

<!DOCTYPE html>
<html>
<head>
        <meta charset="utf-8" />

        <meta name="viewport" content="width=device-width, initial-scale=1.0">

        <link rel="stylesheet" href="leaflet.css" />
</head>
<body>
        <div id="map" style="width: 600px; height: 400px"></div>

        <script src="leaflet.js"></script>
        <script>

                var map = L.map('map').setView([51.505, -0.09], 13);

                L.tileLayer('http://192.168.0.12/maptest/{z}/{x}/{y}.png', {
                        maxZoom: 18,
                        attribution: '41j',
                        id: 'example'
                }).addTo(map);


                var popup = L.popup();

                function onMapClick(e) {
                        popup
                                .setLatLng(e.latlng)
                                .setContent("You clicked the map at " + e.latlng.toString())
                                .openOn(map);
                }

                map.on('click', onMapClick);

        </script>
</body>
</html>

This worked pretty well, and gives me a basis for trying other stuff out.

Notes

The C code which performs this conversion replicated from the OSM wiki is as follows:

#include <math.h>
#include <iostream>

using namespace std;

int long2tilex(double lon, int z) 
{ 
	return (int)(floor((lon + 180.0) / 360.0 * pow(2.0, z))); 
}
 
int lat2tiley(double lat, int z)
{ 
	return (int)(floor((1.0 - log( tan(lat * M_PI/180.0) + 1.0 / cos(lat * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, z))); 
}
 
double tilex2long(int x, int z) 
{
	return x / pow(2.0, z) * 360.0 - 180;
}
 
double tiley2lat(int y, int z) 
{
	double n = M_PI - 2.0 * M_PI * y / pow(2.0, z);
	return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
}

int main() {
  cout << long2tilex(-0.09,13) << endl;
  cout << lat2tiley(51.505,13) << endl;
}

Some data sources I’ve been thinking about look at.

OSM Data:
http://planet.openstreetmap.org/

Oil GIS Data:
https://www.gov.uk/oil-and-gas-offshore-maps-and-gis-shapefiles#offshore-gis-data