Nugroho's blog.

Thursday, March 26, 2015

Modifikasi Flasher Lampu Sein LED


Seminggu ini berusaha me-LED-kan semua lampu (kecuali lampu utama). Berguna untuk meringankan kerja aki dan alternator, :)

Seperti biasa, tak sulit, hanya tinggal ‘plug-n-play’. Lampu rem, lampu senja, semua jadi memiliki watt yang kecil.

(saya lihat spek dari lampu stock-nya adalah 24 watt untuk satu lampu rem saja, waduh berarti satu lampu menghabiskan dua ampere!)

Seperti biasa juga, ada masalah. Kedipan lampu sein jadi lebih cepat karena flasher dirancang untuk dialiri arus yang besar. Flasher memang dirancang sedemikian sehingga jika ada lampu sein yang putus maka kedipan akan lebih cepat (karena arus yang mengalir lebih kecil) untuk memperingatkan kita agar segera mengganti dengan lampu baru.



Tapi LED kan tahan lama bertahun-tahun.

Saya juga tak begitu memerlukan “fitur peringatan dini” bahwa lampu sein saya putus. Yeah, tak ada peringatan dini untuk lampu rem atau lampu senja putus kan? Kita harus selalu mengecek mereka secara manual.

Nah, fitur ini di-disable saja.

Paling mudah dengan menambahkan resistor 6 Ohm yang dipasang secara paralel dengan LED. Dengan demikian arus yang mengalir akan tetap 2 Ampere (LED hanya membutuhkan beberapa miliampere) dan flasher tetap bekerja normal, kedipan lampu sein juga normal, namun plastik batok lampu kita akan bisa leleh karena resistor melepaskan banyak panas. (yeah, cara tersebut memang mudah, lampu sein akan menyala terang karena menggunakan LED, namun arus yang mengalir akan tetap, tidak ada penghematan energi dari aki)

Yang efektif adalah dengan mengotak-atik Flashernya.

Caranya,…, DuckDuckGoing,…, dan waduh…

Banyak sekali caranya, tergantung jenis flashernya.

Secara umum, fitur untuk deteksi lampu mati terbuat dari resistor yang berbentuk kawat lengkung.

Jika flasher kita seperti ini, tinggal diamplas saja kawat lengkungnya sedikit, pasang lagi, cek, jika kedipan kurang lambat, amplas lagi, cek lagi, … dst.

Jika tidak ada resistor berbentuk kawat maka cari resistor bernama R1 kemudian ganti dengan resistor bernilai 1M Ohm. Jika Flashernya menggunaka IC, potong sambungan di kaki IC nomor 7, …. (dan banyak lagi hasil DuckDuckGo yang lain)

Saya punya dua flasher, dengan nomor kode komponen yang sama, 81980-22070, namun ketika saya buka ternyata sangat beda sekali. Satu memiliki Resistor lengkung (yeah…) dan satunya hanya terdiri dari rangkaian resistor, dioda, kapasitor dan transistor.

Cara paling mudah sebenarnya adalah dengan mengamplas Flasher saya yang punya resistor model kawat. Namun cara demikian kurang cocok bagi saya karena jika suatu saat saya ingin mengganti lagi LED dengan lampu stock maka kedipan akan jadi sangat lama atau malah tidak berkedip sama sekali.

Akhirnya saya otak-atik flasher kedua. Ganti R1 dengan resistor 1M Ohm dan,…., gagal…

Ada forum lain yang mengatakan R2 yang diganti, ok, coba lagi dan gagal, ….

Penasaran, saya balik PCB-nya, urut rangkaiannya

Tidak sulit karena tidak ada IC-nya, ini hanya semacam timer sederhana. Timer semacam ini waktunya ditentukan oleh kapasitor dan resistor yang terhubung seri sehingga saya hanya perlu cari resistor yang seperti itu dan ternyata ketemu dua yang semacam itu!

Yang satu pastilah untuk kedipan normal, yang satu untuk kedipan cepat, disable saja untuk yang kedipan cepat, yaitu yang terangkai seri dengan kapasitor yang bernilai kecil

(dalam hal ini ternyata resistor dengan label R5 yang harus saya copot, bisa disambung dengan resistor 1M Ohm atau dibiarkan copot saja)


Tes, ganti semua lampu sein kanan dengan LED, waktu kedipan ternyata sama dengan yang kiri. OK, ganti semuanya dengan LED, :)


(lampu sein = sen = reting = riting = liting, tergantung kebiasaan menyebut di masing-masing daerah, :)  )








Modified LED Turn Signal Light Flasher

This week I tried to light all the lights (except the main lights). Useful to ease the work of batteries and alternators, :)

As usual, it's not difficult, just stay 'plug-n-play'. Brake lights, dusk lights, all have a small wattage.

(I see the spec from the stock light is 24 watts for just one brake light, it means that one lamp consumes two amperes!)

As always, there is a problem. Turn on the turn signal is faster because the flasher is designed to flow large currents. Flasher is designed so that if there is a broken turn signal, the flicker will be faster (due to smaller flowing currents) to warn us to immediately replace it with a new lamp.

But LEDs last a long time.

I also don't really need the "early warning feature" that my turn signal breaks. Yeah, there's no early warning for the brake lights or the dusk lights right? We must always check them manually.

Well, this feature is disabled only.

It's easiest to add a 6 Ohm resistor installed in parallel with the LED. Thus the current flowing will remain 2 Ampere (LEDs only need a few milliamperes) and the flasher will still work normally, the flashing of the turn signal is also normal, but our light shell plastic will melt because the resistor releases a lot of heat. (yeah, this method is easy, the turn signal lights up brightly because it uses LEDs, but the current flowing will remain, there is no energy savings from the battery)

What is effective is by tinkering with the Flasher.

The trick, ..., DuckDuckGoing, ..., and oh my ...

There are lots of ways, depending on the type of flasher.

In general, the feature for detection of dead lights is made of resistors in the form of curved wire.

If our flasher is like this, just sand the curved wire a little, plug it in again, check, if it blinks slowly, sandpaper again, check again, etc.

If there is no wire-shaped resistor, look for a resistor named R1 then replace it with a resistor worth 1M Ohm. If the Flasher uses IC, cut the connection at the foot of IC number 7, ... (and many other DuckDuckGo results)

I have two flasher, with the same component code number, 81980-22070, but when I open it it is very different. One has a curved resistor (yeah ...) and the other only consists of a series of resistors, diodes, capacitors and transistors.

The easiest way is actually to sand my Flasher which has a wire model resistor. However, this method is not suitable for me because if one day I want to replace the LED with the stock lights, the flashing will be very long or not even blink at all.

Finally I tweaked the second flasher. Replace R1 with a 1M Ohm resistor and, ..., fail ...

There is another forum that says R2 is replaced, ok, try again and fail, ...

Intrigued, I flipped to look the back of the circuit board, manually routing the sequence with my finger.

It's not difficult because there's no IC, it's just a simple timer. This kind of timer is determined by a series of capacitors and resistors so I only need to find a resistor like that and it turns out that I found two of them!

One must be for normal blinking, one for fast blinking, just disable it for the fast blinking, which is coupled with a series of small-value capacitors

(in this case it turns out that the resistor with the R5 label that I have to dislodge, can be connected with a 1M Ohm resistor or just left  it open/disconnected)


Test, replace all the right turn signal with the LED, the flashing time is the same as the left one. OK, replace everything with LED, done, :)








Monday, February 16, 2015

Scripting in SwishMax

The movies below's result of my tinkering with SwishMax this morning; consist of me abusing the script to force the project done in just one frame, :)

Moving a Box using Script on SwishMax





Move a Box by a Click of Button on SwishMax


Increasing the Width of a Box using Script on SwishMax


Toggling the Move Direction of a Box using Script on SwishMax


Control the Speed (using Text Input) of a Box Moved by Script on SwishMax

Tuesday, December 30, 2014

Gnome 3 on Freebsd (self documentation)

install it using

#pkg install gnome3

/etc/fstab 

proc           /proc       procfs  rw  0   0

/etc/rc.conf

gdm_enable=“YES”
gnome_enable="YES"

The menu is missing

install Parallel Tools

#cd /usr/ports/emulators/parallels-tools/ && make install clean

but it need kernel source. 

Install via svn

#pkg install devel/subversion

# svnlite checkout http://svn0.eu.freebsd.org/base/releng/10.0/ /usr/src

run it again

#cd /usr/ports/emulators/parallels-tools/ && make install clean











Playing with FreeBSD


Got boot-only iso and managed to install it on my Parallel Desktop on my Macbook Air with Yosemite. 

Of course it just CLI.

Strange, the root shell have tab completion feature, but the normal users didn’t.

(DuckDuckGo-ing)

The answer come from 2003 and 2005 Mailing-List, :)

To enable tab completion
 
$chsh -s /bin/tcsh
 
(it didn’t enable tab completion actually , it change shell with tab completion feature :) )
We could so use
 

$chsh -s /bin/csh 

 
tcsh shell support tab completion too.

 
Another thing is, normal user can’t use sudo command (because it’s not installed, :P )
So,  install sudo first (I used pkg command instead of pkg_add)
 
#pkg install sudo 
 
 
edit /usr/local/etc/sudoers as root and visudo command (don’t edit it using regular vi editor, or ANY editor)

%visudo

add this

username ALL=(ALL) ALL

 
and life become more easier...


 
 

Monday, December 22, 2014

Compare Native Loop Time in Python with "homemade" Fortran Module

This code print d and e as result of two matrix addition, e's using python native code, d's using fortran module compiled with F2PY

The code
import numpy as np
import aravir as ar
import time

n = 1000

u = np.ones((n,n))
v = np.ones((n,n))
e = np.ones((n,n))

t = time.clock()
d = ar.add3(u,v)
tfortran= time.clock()-t

t = time.clock()
for i in range (n):
for j in range (n):
e[i,j] = u[i,j]+v[i,j]
tnative = time.clock()-t

print 'fortran ', d
print 'native', e
print 'tfortran = ', tfortran, ', tnative = ', tnative


The fortran module I imported to python
        subroutine add3(a, b, c, n)
double precision a(n,n)
double precision b(n,n)
double precision c(n,n)

integer n
cf2py intent(in) :: a,b
cf2py intent(out) :: c,d
cf2py intent(hide) :: n
do 1700 i=1, n
do 1600 j=1, n
c(i,j) = a(i,j)
$ +b(i,j)

1600 continue
1700 continue
end

save it as aravir.f and compile using
$ f2py -c aravir.f -m aravir

And here the result
$ python cobamodul.py 
fortran [[ 2. 2. 2. ..., 2. 2. 2.]
[ 2. 2. 2. ..., 2. 2. 2.]
[ 2. 2. 2. ..., 2. 2. 2.]
...,
[ 2. 2. 2. ..., 2. 2. 2.]
[ 2. 2. 2. ..., 2. 2. 2.]
[ 2. 2. 2. ..., 2. 2. 2.]]
native [[ 2. 2. 2. ..., 2. 2. 2.]
[ 2. 2. 2. ..., 2. 2. 2.]
[ 2. 2. 2. ..., 2. 2. 2.]
...,
[ 2. 2. 2. ..., 2. 2. 2.]
[ 2. 2. 2. ..., 2. 2. 2.]
[ 2. 2. 2. ..., 2. 2. 2.]]
tfortran = 0.069974 , tnative = 1.202547

The Desktop, :)


Friday, December 19, 2014

Using 'Home-Made' Fortran Binary as Python module

Python is easy to use, but it's slow, especially for loop computation. So I compute it using fortran like this

        subroutine subs(a, b, n)
double precision a(n)
double precision b(n)
integer n
cf2py intent(in) :: a
cf2py intent(out) :: b
cf2py intent(hide) :: n
! b(1) = a(1)
do 100 i=2, n
b(i) = a(i)-1
100 continue
end


save it as aravir.py and do the following command
$ f2py -c aravir.f -m aravir

To use the module on the python I use the code below
import numpy as np
import aravir as ar

a = np.linspace(0,1,100)

b = ar.subs(a)

print a
print b

:)


3D Waterwave Simulation using Python

I used Numpy  Matplotlib with Animation and 3d Plot module on my OS X Yosemite.

The code is still messy and clearly not efficient (there's slow loop here and there) but it works, :)
Here The Result
The Code
import numpy as np

n = 8;
g = 9.8;
dt = 0.02;
dx = 1.0;
dy = 1.0;

h = np.ones((n+2,n+2))
u = np.zeros((n+2,n+2))
v = np.zeros((n+2,n+2))

hx = np.zeros((n+1,n+1))
ux = np.zeros((n+1,n+1))
vx = np.zeros((n+1,n+1))

hy = np.zeros((n+1,n+1))
uy = np.zeros((n+1,n+1))
vy = np.zeros((n+1,n+1))

nsteps = 0
h[1,1] = .5;

def reflective():
h[:,0] = h[:,1]
h[:,n+1] = h[:,n]
h[0,:] = h[1,:]
h[n+1,:] = h[n,:]
u[:,0] = u[:,1]
u[:,n+1] = u[:,n]
u[0,:] = -u[1,:]
u[n+1,:] = -u[n,:]
v[:,0] = -v[:,1]
v[:,n+1] = -v[:,n]
v[0,:] = v[1,:]
v[n+1,:] = v[n,:]

def proses():
#hx = (h[1:,:]+h[:-1,:])/2-dt/(2*dx)*(u[1:,:]-u[:-1,:])
for i in range (n+1):
for j in range(n):
hx[i,j] = (h[i+1,j+1]+h[i,j+1])/2 - dt/(2*dx)*(u[i+1,j+1]-u[i,j+1])
ux[i,j] = (u[i+1,j+1]+u[i,j+1])/2- dt/(2*dx)*((pow(u[i+1,j+1],2)/h[i+1,j+1]+ g/2*pow(h[i+1,j+1],2))- (pow(u[i,j+1],2)/h[i,j+1]+ g/2*pow(h[i,j+1],2)))
vx[i,j] = (v[i+1,j+1]+v[i,j+1])/2 - dt/(2*dx)*((u[i+1,j+1]*v[i+1,j+1]/h[i+1,j+1]) - (u[i,j+1]*v[i,j+1]/h[i,j+1]))

for i in range (n):
for j in range(n+1):
hy[i,j] = (h[i+1,j+1]+h[i+1,j])/2 - dt/(2*dy)*(v[i+1,j+1]-v[i+1,j])
uy[i,j] = (u[i+1,j+1]+u[i+1,j])/2 - dt/(2*dy)*((v[i+1,j+1]*u[i+1,j+1]/h[i+1,j+1]) - (v[i+1,j]*u[i+1,j]/h[i+1,j]))
vy[i,j] = (v[i+1,j+1]+v[i+1,j])/2 - dt/(2*dy)*((pow(v[i+1,j+1],2)/h[i+1,j+1] + g/2*pow(h[i+1,j+1],2)) - (pow(v[i+1,j],2)/h[i+1,j] + g/2*pow(h[i+1,j],2)))

for i in range (1,n+1):
for j in range(1,n+1):
h[i,j] = h[i,j] - (dt/dx)*(ux[i,j-1]-ux[i-1,j-1]) - (dt/dy)*(vy[i-1,j]-vy[i-1,j-1])
u[i,j] = u[i,j] - (dt/dx)*((pow(ux[i,j-1],2)/hx[i,j-1] + g/2*pow(hx[i,j-1],2)) - (pow(ux[i-1,j-1],2)/hx[i-1,j-1] + g/2*pow(hx[i-1,j-1],2))) - (dt/dy)*((vy[i-1,j]*uy[i-1,j]/hy[i-1,j]) - (vy[i-1,j-1]*uy[i-1,j-1]/hy[i-1,j-1]))
v[i,j] = v[i,j] - (dt/dx)*((ux[i,j-1]*vx[i,j-1]/hx[i,j-1]) - (ux[i-1,j-1]*vx[i-1,j-1]/hx[i-1,j-1])) - (dt/dy)*((pow(vy[i-1,j],2)/hy[i-1,j] + g/2*pow(hy[i-1,j],2)) - (pow(vy[i-1,j-1],2)/hy[i-1,j-1] + g/2*pow(hy[i-1,j-1],2)))

#dh = dt/dt*(ux[1:,:]-ux[:-1,:])+ dt/dy*(vy[:,1:]-vy[:,:-1])
reflective()
return h,u,v
'''
for i in range (17):
#print h
proses(1)
'''

import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
from mpl_toolkits.mplot3d import Axes3D
a = n
x = np.arange(n+2)
y = np.arange(n+2)
x,y = np.meshgrid(x,y)

fig = plt.figure()

ax = fig.add_subplot(111, projection='3d')

def plotset():
ax.set_xlim3d(0, a)
ax.set_ylim3d(0, a)
ax.set_zlim3d(0.5,1.5)
ax.set_autoscalez_on(False)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))
cset = ax.contour(x, y, h, zdir='x', offset=0 , cmap=cm.coolwarm)
cset = ax.contour(x, y, h, zdir='y', offset=n , cmap=cm.coolwarm)
cset = ax.contour(x, y, h, zdir='z', offset=.5, cmap=cm.coolwarm)

plotset()

surf = ax.plot_surface(x, y, h,rstride=1, cstride=1,cmap=cm.coolwarm,linewidth=0,antialiased=False, alpha=0.7)

fig.colorbar(surf, shrink=0.5, aspect=5)


from matplotlib import animation


def data(k,h,surf):
proses()
ax.clear()
plotset()
surf = ax.plot_surface(x, y, h,rstride=1, cstride=1,cmap=cm.coolwarm,linewidth=0,antialiased=False, alpha=0.7)
return surf,

ani = animation.FuncAnimation(fig, data, fargs=(h,surf), interval=10, blit=False)
#ani.save('air.mp4', bitrate=512)
plt.show()

and the snapshot






323f (5) amp (1) android (12) apple (7) arduino (18) art (1) assembler (21) astina (4) ATTiny (23) blackberry (4) camera (3) canon (2) cerita (2) computer (106) crazyness (11) debian (1) delphi (39) diary (286) flash (8) fortran (6) freebsd (6) google apps script (8) guitar (2) HTML5 (10) IFTTT (7) Instagram (7) internet (12) iOS (5) iPad (6) iPhone (5) java (1) javascript (1) keynote (2) LaTeX (6) lazarus (1) linux (29) lion (15) mac (28) macbook air (8) macbook pro (3) macOS (1) Math (3) mathematica (1) maverick (6) mazda (4) microcontroler (35) mountain lion (2) music (37) netbook (1) nugnux (6) os x (36) php (1) Physicist (29) Picture (3) programming (189) Python (109) S2 (13) software (7) Soliloquy (125) Ubuntu (5) unix (4) Video (8) wayang (3) yosemite (3)