Posts filed under 'Software'

MATLAB Error Integer too large in context

I recently experienced this error while using MATLAB. Error using maple… Error integer too large in context … This happens when I try to simulate an ESPRIT DOA estimation using atan function with symbolic expressions. The solution is to use:

clear maplemex % this works for me, this basically clears the Maple workspace
% and reinitializes the Maple kernel

Add comment April 18th, 2009

Microcontroller App. Freq and Period Measurements

A simple app. using PIC18F4520 to display frequency and period measurement of an analog square wave input. Code is written in C, interrupts and internal timer1 are utilized. Display is on 2 lined LCD screen.

dsc00022

dsc00023

Schematic:

pic18f4520-freq-period-measurement-schematic

Add comment March 18th, 2009

Adaptive Median Filtering using MATLAB

MATLAB is a great tool. I recently wrote a code to perform an adaptive median filtering on a somewhat noisy image. The code works great in removing noise on an image…. It is a simple code that I wrote in a few minutes using MATLAB… for simplification the code does not render regions near the edges… the spatial mask which is a three by three window could not process the edges since it is out of bound…. I could have use padding and pad the edges so that the spatial mask can process the edges…. but you get the idea…and the code…Adaptive Filter

Adaptive median filtering is not the only way to remove noise on an image. It depends on the what kind of noise exists in the image. For example, if the image has a salt noise only, then using contraharmonic mean filter with Q=-1.5 probably will do the job, or if you have a pepper noise only, then using contraharmonic mean filter with Q=1.5 probably will do the job.

Also, extracting noise from an image, not necessarily we have to use time domain or spatial domain. We can also use the frequency domain such as by using band reject filter or notch filter to reject noises at certain region of the fourier spectrum.

29 comments May 27th, 2007

Internet Sharing in Windows XP

Tried to share internet connection from windows xp to nokia 6680 mobile phone. Spend two hours, and fail. The window applications that I tried on are bluesoil bluetooth on my desktop and bluetooth stack on my notebook. Enabled internet sharing, and setup modem port. Application used in my mobile phone is gnubox. I have not figure out yet what is the problem. The computer and phone is able to establish connection both ways, but somehow my phone is not getting any IP. I will try again when I got a chance…. I don’t need the internet sharing that badly either… If anyone successfully shared their internet connection to their nokia 6680 mobile phone please shine some light :)

Add comment March 17th, 2007

All About Reset

In verilog, there are two types of reset, synchronous reset and asynchronous reset. In synchronous reset, reset is sampled with respect to clock, whereas in asynchronous reset, reset is not sampled with respect to clock. There are advantages and disadvanteges of using asynchronous reset and they are it requires less gates to implement, does not requires clock to be active always and it is fast. However it suffers from metastability problem.

An asynchronous D Flip Flop:

module dff_async_reset(data,clk,reset,q);
input data, clk, reset;
output q;
reg q;

always @(posedge clk or negedge reset) //for asynchronous
if (~reset) begin
q = 1′b0;
end else begin
q = data;
end

endmodule

A synchronous D Flip Flop:

module dff_sync_reset(data,clk,reset,q);
input data, clk, reset;
output q;
reg q;

always @ (posedge clk)
if (~reset) begin
q = 1′b0;
end else begin
q = data;
end
endmodule

Notice the always block which distinguishes between asynchronous and synchronous reset.

Add comment September 20th, 2006

Linux Shell Scripting

This is a simple shell script that i used often to search and replace a string when I have multiple files within multiple folders. It is very useful when you need to search and replace a text in a folder with multiple files. Feel free to use and modify it to suit your need.

cd $1
for folder in *
do
echo “$folder”
cd “$folder”
echo -n “Your current dir is ”
pwd
for fl in *.htm;
do
mv $fl $fl.old;
sed ’s/string-to-search/replace-with-this-string/g’ $fl.old > $fl;
done
rm -rf *.old
chown owner.owner *.htm
cd ..
echo “Done … getting next folder”
sleep 5s
done

To use the code, create a file named changer, insert the above code. Then, chmod 755 the created file. Place the file outside the folder that you are trying to work on. Then execute, ./changer foldername, where foldername is the folder you are working on.

Add comment July 11th, 2006

Back Link

Do people really click on their browser’s back icon? Yes, they probably do. Would adding a link that brings a user back to the previous page a smart idea? Yes, maybe it is a smart idea. The reason is because in most occasion the user’s mouse pointer would usually be around the area of the page but not at the top left hand corner of the browser. Therefore, a back link on the page makes going back to the previous page much easier. Below is a short code snippet that I have been using if I am to write a PHP script on my own and I think it is very effective.

if (isset($HTTP_REFERER)) {
echo “<a href=’$HTTP_REFERER’>Back</a>”;
} else {
echo “<a href=’javascript:history.back()’>Back</a>”;
}

The above PHP code basically says that if the predefined variable HTTP_REFERER is set, then print a back link to the previous page, else use the java script method history.back(). Simple as that and it is fun.

Add comment May 9th, 2006

Fixing Apache’s “Could Not Determine FQDN” Alert

I ran into this alert or error message almost all the time after installing a new Apache server. Everytime I do a restart on the apache server, it will say:

[alert] httpd: Could not determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName

Since this is just an alert and Apache try to fix this issue automatically by assigning the server’s fully qualified domain name to 127.0.01 for servername. But you can always fix this by defining the ServerName within the http.conf file. So for example you have a hostname named stereo, then you will add the following to your httpd.conf:

ServerName stereo

You can always find out your server’s hostname by typing hostname. Then you might also want to speficy the following in your /etc/hosts file:

127.0.0.1 stereo localhost localhost.localdomain

1 comment April 15th, 2006

New 50 Mbits Server

Time for a new project. A new 50 Mbits server that I ordered last monday is up and running. It took about 5 days for the server setup. Tried to login as root and got this message.. “Password auth with the SSH2 server failed”…

sercurecrt-boo-boo

So what is wrong.. I did double check the username and password and still can’t log in. Next, time to contact the network administrator. They responded to me saying they did make a boo-boo. They gave me the wrong IP address the first time and appologized to me. Thats ok.. people do make a mistake once in a while hehe :) Now, that I have the correct IP address… time to mess with the server… first move is to check on system information..

ssh2-server-titanium-check1

Those commands executed as shown in the picture confirm that the server is an Intel P4 2.8 Ghz CPU with 1MB L2 Cache, 1024 MB of DDR RAM, and 80 GB of disk space. That is about all the information I need to know for now. Maybe execute the command to confirm the Linux distribution as well using cat /etc/issue and it says CentOS release 4.2 (Final). That is what I expected.

ssh2-server-titanium-check2

A speed test done using wget to kernel.org shows us that the download speed is about 1.86 Mbps, which is a significantly good download speed within the continental U.S. The rest would be to fix the machine time, hostname, services, speed and other things to suit the usage. Time to mess with it again..

Add comment April 15th, 2006

Autostart your Shoutcast Server

I have not been using shoutcast for long. But here is the unix shell script to autostart your shoutcast server or any other services once it is down. First create a blank file on your shell command like this

touch autostart-shoutcast

Then use your favorite text editor program such as nano, pico or vi and insert the following unix shell script:

#!/usr/bin/perl

@a=qx{ps x | grep -i shoutcast-radio};
$b=1;

foreach (@a) {
  if ($_ =~ /grep/) {
  $_ =~ s/.*/blah/g;
  }
  if ($_ =~ /shoutcast-radio/) {$b=0;}
}

if ($b == 1) {
  print “Starting up\n”;
  qx{cd ~/shoutcast/ ; ./shoutcast-radio &> /dev/null &};
}

Make sure it is executable, using the chmod command like below:

chmod 755 autostart-shoutcast

Finally setup your crontab like below:

0,10,20,30,40,50 * * * * /home/shoutcast/autostart-shoutcast &> /dev/null

Add comment April 6th, 2006

Previous Posts


 

March 2010
M T W T F S S
« May    
1234567
891011121314
15161718192021
22232425262728
293031  

Pages

Blogroll

Categories