Tuesday, May 23, 2017

Chaotic fractals of mandelbrot

f(z) = z^2 + C
where z is a complex number (vector)
and C is a complex constant (vector of a constant norm)

output from my Xcode project:


for(i=0; i <iter;i++){
        float x = (z.x * z.x - z.y * z.y) + c.x;
        float y = 2.0 * (z.x * z.y) + c.y;

if((x * x + y * y) > 40.0break//distance from the origin>2 ==> done!!
        z.x = x;
        z.y = y;

}
After 355 iterations:




PCB Inspector with pytrack

One of my friends gently asked me to help them on automatic inspection of PCBs (xray).

I used pytrack to investigate and report soldering failures (bad bubbles). 

# -*- coding: utf-8 -*-
# 07.05.2017
# porsuk
from __future__ import division, unicode_literals, print_function  # for compatibility with Python 2 and 3
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from pandas import DataFrame, Series  # for convenience
from scipy import ndimage
from skimage import morphology, util, filters
import pims
import trackpy as tp
def crop(img):
    """
    Crop the image to select the region of interest
    """
    x_min = 20#745
    x_max = -25#850
    y_min = 50#225
    y_max = -250#300
    
    return img[y_min:y_max,x_min:x_max]
def rgb2gray(rgb):

    r, g, b = rgb[:,:,0], rgb[:,:,1], rgb[:,:,2]
    gray = 0.2989 * r + 0.5870 * g + 0.1140 * b

    return gray
def preprocess_pcb(img):
    img=rgb2gray(img)
    """
    Apply image processing functions to return a binary image
    """
    # Crop the pictures as for raw images.
    img = crop(img)
    print(img)
    # Apply thresholds
    img = filters.threshold_adaptive(img, 57)
    threshold = 0.9
    idx = img > img.max() * threshold
    idx2 = img < img.max() * threshold
    img[idx] = 0
    img[idx2] = 3
    img = ndimage.binary_dilation(img)
    img = ndimage.binary_dilation(img)
    return util.img_as_int(img)
frames = pims.ImageSequence('*.jpg',process_func=preprocess_pcb)
for frame in frames:
     f = tp.locate(frame, percentile=10,diameter=77, minmass= 3.0e+07,separation=80,threshold=1/30)
     print('frame = ',f['frame'][0] )
     print(f)
     print('max bubble percentage: ', 20 * max(f['size']) / 250 )
     plt.figure(f['frame'][0])  # make a new figure
     tp.annotate(f,frame,plot_style={'markersize':35});

DIY 4-way vacuum valve to engage 4wd(subaru justy oem 4wd valve failure)




 Broken oem 4-way valve: Tried epoxy but did not fixed it. Actually epoxy sealed the vacuum leak but most probably solenoid was gone.

Monday, May 22, 2017

DIY forester rear wheel bearing replacement

was very ezy and straight forward except breaking the brake line (obtain propper wrench to loose yours). Bleeding alone may be another challenge but i used pipe and bottle method w/o any problem.





 final and true drum brake instrument re-installation (above pics was taken during unsuccessful attempts):



 Thanx to helpful machinist for installing new bearing in press. (so DIY except pressing)

 ready to install:


91 MY LN130 Hilux Surf A/C Condenser Relocation

Relocation of the underslung a/c condenser of hilux surf to in front of the radiator. 
Tested against highway and city speeds w/o any increase in coolant temp. btw oem rad. fan re-wired in-order to start manually. and always kicked on city speeds. But not sure if needed to start or not since i did not installed digi temp gauge so i was  monitoring just analog oem one. At the end, it was a successful project. Could be better if i had alu welder.
But for those thinking about carrying the a/c condenser to behind of the grill, i can exactly say that suspicious ln130 radiator was not blocked (to overheat) by the a/c condenser.







DIY 2nd Gen 4runner (Hilux Surf) grab handle installation

91 MY 2nd gen 4runner (ln130 hilux surf actually) front driver and passenger side vertical grab handle installation:
1 - nice front prado grab handles from wrecker.
2 - back grab handles from 98MY vx80.
3 - M6 15mm alu rivet nuts. The only option was novus from bauhaus.
4 - 9mm drill bit.
5 - pictures tell the remaining. (btw my homemade rivet nut installation tool worked great for me)

was great fun...