Image-based closed-loop motor control

This was our final setup for the course Embedded System Laboratory, back then in summer 2013. It was always great to work in group with Prithivi Ram Duraisingam. Basically, the task is to make the red circle on the rotating wheel follow wherever the green mark moves. The problem was solved as follows. First, the movement of the green mark was captured by a webcam, which was controlled by Gumstix Overo Fire, an OMAP3530-based computer-on-module. Streaming of images from the webcam was then processed in order to track the position of the green mark. The Gumstix then told Altera DE0-Nano board to rotate the the smaller wheel, which was coupled with the larger one that has the red circle. To do its job, the Altera DE0-Nano board was programmed to have a CPU core and dedicated FPGA-based PWM controller and quadrature encoder. A digitally implemented PID controller was in charge to move the wheel as fast as possible with minimal overshoot.

It was quite a lot of pressure, considering the little time available and also the approaching of other assignment deadlines.There was an interesting experience during the work, and now that experience still remains in my mind. In the progress of our work, for unknown reasons our setup didn’t work. Debugging for days and night, but we could not find out what’s wrong. The codes and setups — everything looked fine.  But in the end it turned out that there was a very very small mistake that was hard to notice; a ‘1’ was in place of ‘I’. In some font types they looked the same. The feeling of relief after spotting the mistake was indescribable. From then on, we progressed pretty smoothly toward the end.

If you are interested, our final report can be found here.

And this post was on my FB wall after we finished our assignment. 🙂

esl-fb-post

It was not perfect. Sometimes the red circle went too far. Some tweaking was needed but we had not enough time. At least, the proof of concept had been shown. So we left it there, went home, and slept 🙂

[pictures] A wonderful week in Taiwan

These pictures tell the story of my trip to Taiwan on 17-26 June 2016. Enjoy!

Negara membiarkan

Apakah slogan ‘Negara harus hadir’ hanya tinggal slogan? Setidaknya itu yang terjadi di Jalan Baru Cisauk-Muncul, Tangerang. Kondisi jalan yang rusak parah terus dibiarkan sudah setahun ini. Semakin hari semakin parah. Jalanan cor ini patah di tengah. Akibatnya jalan jadi tidak rata, mungkin terjadi beda ketinggian sekitar 50 cm an. Kondisi diperparah lagi oleh kontur jalan yang menanjak. Apalagi waktu hujan, jalan jadi licin, dan terdapat genangan air yg cukup dalam. Mungkin bisa saya ternak ikan lele di situ.

Dalam kurun waktu 2-3 bulan ini, mungkin sudah ada 3 truk besar yang terguling. Akibatnya terjadi kemacetan panjang di jalan tersebut. Kali ini (15 Agustus 2016), terjadi lagi truk terguling dan menimpa sebuah mobil di sebelahnya. Ntah apakah ada korban jiwa atau tidak. Semoga tidak.

Sudah setahun jalan rusak tapi tidak dilakukan perbaikan. Negara sedang bangkrut, dan tidak punya uang? Entahlah. Lalu, jika jalan rusak parah seperti itu dan saat ini belum bisa perbaiki, tolonglah lakukan tindakan-tindakan antisipasi, misal dengan pengalihan jalan bagi truk-truk besar supaya tidak melintasi jalan tersebut. Pleaseeeeeee lakukan sesuatu!! Apakah harus ada korban lagi?

Negara hanya membiarkan.

#dari seorang warga yang tiap hari melintasi jalan tersebut

Mengurus Visa Taiwan

Sudah ada beberapa post yang menceritakan tentang cara apply visa berkunjung ke Taiwan, seperti di sini dan sini. Saya terbantu dari cerita kedua post tersebut.  Hanya saja ada beberapa hal lain yang saya alami.

Menurut info yang saya dapat dari website, biaya untuk visa single entry adalah sebesar Rp. 460.000. Saya juga mencoba bertanya soal biaya ke beberapa agen di area Serpong yang melayani pembuatan visa Taiwan. Kisaran harganya Rp 730.000 sampai Rp. 775.000. Saya pikir selisihnya lumayan juga dengan mengurus sendiri. Karena itu saya memutuskan untuk coba datang sendiri. Selain itu, biar ada pengalaman dan tahu seperti apa mengurus visa sendiri.

Tanggal 28 April 2016 saya berangkat menggunakan KRL. Waktu itu kira-kira jam 6.45. Dan ternyata dalam KRL luar biasa padat. Ini pertama kali saya merasakan sesak yang begitu rupa, bahkan terasa agak susah menarik nafas. Kantor TETO bertempat di lantai 12 Gedung Artha Graha. Sampai di sana, tidak ada antrian dan saya langsung menyerahkan dokumen-dokumen. Ternyata booking tiket dan penginapan tidak diminta.

Pada saat hendak membayar di kasir rupanya uang saya kurang. Di website TETO memang tertulis Rp. 460.000. Ternyata itu harga empat tahun lalu. Jadi biaya yang harus dibayar adalah Rp. 650.000. Masalah kedua adalah bahwa menurut petugas nya pasfoto yang saya pakai sudah terlalu lama. Memang itu foto tahun 2008 sih :). Untung kedua masalah tersebut bisa diselesaikan di lantai basement. Ada ATM Mandiri, dan toko yang melayani fotokopi dan pasfoto. Pembuatan pasfoto dikenakan biaya Rp. 50.000. Menurut mas yang punya toko, bahkan kadang-kadang TETO menganggap pasfoto 3 bulan tidak up to date, dan harus foto lagi.

Katanya visa saya bisa diambil tanggal 2 Mei 2016. Pengambilan visa dibuka setelah jam 13.00. Tapi saya kembali ke TETO sehari berikutnya. Dan tadaaaaaaa visa Taiwan sudah di tangan. 🙂

 

Numerically solving third-order RLC natural response

The previous post deals with a second-order RLC natural response. Whereas this one deals with a third-order RLC natural response.

page1

page2

% Numerically solving third-order RLC natural response using
% Ordinary Differential Equation (ode) solver
%% -----L---------
%  |    |        |
%  Cs   Cp      Rl
%  |    |        |
% ----------------
clear all;
Cs = 0.5 * 10^(-3);
Cp = 30 *10^-6;
L = 0.1*10^-6;
Rl = 0.1;

a = L;
b = L/(Cp*Rl);
c = (1/Cs) + (1/Cp);
d = 1/(Cp*Rl*Cs);

tspan = [0 0.00005];

init = 0;         % i(0+)
init2 = -100/L;   % di/dt(0+)
init3 = 0;        % d^2i/dt^2(0+)
y0 = [init; init2; init3];
[t, y] = ode45(@(t,y) [y(2); y(3); (-b*y(3)-c*y(2)-d*y(1))/a], tspan, y0);

i1 = y(:,1);
i1_pp = y(:,3); % i1''

% differentiating equation (3) once, we get i2
i2 = -Cp*( ((1/Cs)+(1/Cp))*i1 + L*i1_pp);
figure (2)
plot(t,i2*Rl,'r-')
grid on

X=[0 0.5];
Y=[0 0.5];
xlabel('time (s)')
ylabel('V_{RL} (volts)')

Here is the result:

thirr order RLC

I have verified the result using LTSPICE IV simulation. Here is the circuit file.

Frankly, it took me quite some time to choose which set of equations, combination of equations that will give solutions. I cannot see them immediately. It is important to choose which current (i1, i2 or i3) to be solved first because either current must be provided with its initial conditions. But not all initial conditions are available for all choice of currents. So, I did trial and error. Usually, if your differential equation is in terms of current, then you should choose the current that flows through an inductor. On the other hand, if your differential equation is in terms of voltage, then choose for voltage drop across a capacitor. By doing so, we will have the initial conditions.

If I am not mistaken, another approach using state equations provides an easier way to solve even more complex circuits.

 

Numerically solving second-order RLC natural response using Matlab

I remember that I only got a C+ for the subject of electric circuit II. It faithfully reflected my understanding of the subject. It was unclear to me, but fortunately I passed. Recently I revisited the subject of RLC natural response again because I wanted to analyze the performance of  a step up transformer based high voltage generator. For that reasons, I needed to derive RLC characteristic equations, and then solved it numerically in Matlab. After doing the problems for some time, I think now I have a better understanding.

I want to immortalize my notes in this blog. So I can look back to these notes in case I forget how to solve them in the future. Hopefully, you find them useful too 🙂

page1scan0002


% Numerically solving RLC natural response using
% Ordinary Differential Equation (ode) solver
%% -----Rp-------Rs----
%  |         |        |
%  C         L       Rl
%  |         |        |
%  --------------------
clear all;

C = 100 * 10^(-6);
L = 7 * 10^(-3);
Rl = 50;
Rs = 5;
Rp = 2;
Vc = 100;

a = (Rs+Rp+Rl)*L/(Rs+Rl);         %from equation (5)
b = (C*Rp*(Rs+Rl)+L)/(C*(Rs+Rl)); %from equation (5)
c = 1/C;                          %from equation (5)

tspan = [0 0.05];
init = 0;                             %i(0+)
init2 = ((Rs+Rl)*Vc)/((Rs+Rp+Rl)*L);  %di/dt (0+)
y0 = [init; init2];
[t, y] = ode45(@(t,y) [y(2); (-c*y(1)-b*y(2))/a], tspan, y0);
i3 = y(:,1);
i2 = y(:,2)*(L/(Rs+Rl));  %from equation (3)
i1 = -(i2+i3);            %from equation (1)

figure(2)
plot(t,i2*Rl)
grid on
xlabel('time (seconds)')
ylabel('V_{RL} (volts)')

Here is the result….

rlc natural response.png

I have verified the result by comparing with a free circuit simulation software LTSPICE IV. Here is the circuit file, if you want to check.