From the beginning please

Hi there. Summer over and so is my work with the company RENKO ITH.  IHR. LTD. STI.. Worked for peanuts doing lots. Proud of it. Paid my school tuition with the peanuts. I think this makes my school a three ring circus :D .

Work was good and honest in RENKO. I wore three hats at all times ;

Continue reading

Fork me on GitHub

Summer Project “OpenIntelligentRobot” and Help Needed!

I’ve been mulling over an idea all winter. Trying to come up with different projects that could be done using Beagle-board and Arduino. The project is (you hear drum-roll here) “Building An Intelligent Robot”. I know it’s already been done however I have some additional ideas to put in project. All code will be open source. So if you want to build your own you could read up in this site.Oh and I really do need help. Especially financially. So if you are interested please drop me a line. My doodling is as below to give you an idea.

Changing size of array in C programming language

It’s been a long time since I coded in C. I needed to change the size of an array within the program. At first I just simply tried;

int ab=10;
int array[ab];

And surprisingly it didn’t work. (I mean it works in C++ and C#)
Anyway I was thinking of ways on how to do this thought of using malloc() however I really didn’t know how hence I did some Google’ing around. And found this neat piece of code.

int *resize_array(int *a, size_t new_size)
{
  int *save;

  save = realloc(a, new_size);
  if (save == NULL) {
    fprintf(stderr, "Memory exhausted\n");
    exit(EXIT_FAILURE);
  }
  return save;
}

int *user_old_array; // the array
int new_array_size=10;
user_old_array = malloc(initial_array_size * sizeof *user_old_array); //resized array

Quite neat isn’t it. I thought I should probably write this somewhere so I won’t forget. Hence the post.

Enjoy!

AM and DSB-SC Modulation and Demodulation of a Periodic Square Wave (Matlab)

We once had a homework way back when decided to share it. I edited this script which is in Matlab. I hope you like it. It simply is an analysis of AM and DSB-SC Modulation and Demodulation of a Periodic Square Wave.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
%Amplitude Modulation with a periodic sqare wave and its spectrum analysis
%Show the time domain and frquency domain representation of DSB-AM and
%DSB-SC modulations
%By : John Roach – 6 March 2009
%visit my site at http://johnroach.info
N = 1024; %N point FFT N>fc to avoid freq domain aliasing
fs = 4096; % Sample frequency
t = (0:N-1)/fs;
fc = 600; %Carrier Frequency
fm2 = 80; %Message Frequency
Ec = 20; %Carrier Amplitude
Em2 = 5; %Messagae Amplitude
% Try changing the message and carrier amplitudes to see the effect in
% DSB-AM modulation
%———Double SideBand Full Carrier Modulation (DSB-FC(AM))
A = Ec + Em2*square(2*pi*fm2*t);%Envelope/eliminate the carrier amplitude
m = A.*sin(2*pi*fc*t); %to convert DSB-AM to DSB-SC
Mf = 2/N*abs(fft(m,N));
f = fs * (0 : N/2) / N;%Since the fft result is symmetrical, only the
%positive half is sufficient for spectral representation
close all;
figure(’Name’,'Time/Fequency domain representations of DSB-AM signals’);
subplot(2,1,1); %Time domain plot
plot(t(1:N/2),m(1:N/2),t(1:N/2),A(1:N/2),’r',t(1:N/2),-A(1:N/2),’r');
title(’Time Domain Representation’);
xlabel(’Time’); ylabel(’Modulated signal’);
subplot(2,1,2); %Frequency Domain Plot
plot(f(1:256),Mf(1:256));
title(’Frequency Domain Representation’);
xlabel(’Frequency (Hz)); ylabel(’Spectral Magnitude’);
%———-Double SideBand Suppressed Carrier DSB-SC———-
A = Em2*square(2*pi*fm2*t) ; %Envelope/eliminate the carrier amplitude
m = A.*sin(2*pi*fc*t); %to convert DSB-AM to DSB-SC
Mf = 2/N*abs(fft(m,N));
figure(’Name’,'Time/Fequency domain representations of DSB-SC signals’);
subplot(2,1,1); %Time domain plot
plot(t(1:N/2),m(1:N/2),t(1:N/2),A(1:N/2),’r',t(1:N/2),-A(1:N/2),’r');
title(’Time Domain Representation’);
xlabel(’Time’); ylabel(’Modulated signal’);
subplot(2,1,2); %Frequency Domain Plot
plot(f(1:256),Mf(1:256));
title(’Frequency Domain Representation’);
xlabel(’Frequency (Hz)); ylabel(’Spectral Magnitude’);
text(15,60,’Carrier’);
%——————————————————————–

The BeagleBoard Has Arrived!!

The long awaited Beagle board has arrived.


Even tough the team’s enthusiasm was up the roof we were not able to try it out. More on this later. I would also like to inform all people who is following this blog religiously that our project is now hosted on SourceForge.net at http://sourceforge.net/projects/theblackbox/ . And I have also set up a CVS so those who want to follow the code will be able to follow it from the net.

The CVS code is as follows

cvs -d:pserver:anonymous@theblackbox.cvs.sourceforge.net:/cvsroot/theblackbox login

cvs -z3 -d:pserver:anonymous@theblackbox.cvs.sourceforge.net:/cvsroot/theblackbox co -P modulename

I am sorry to say due to some weird problem you can not view the CVS modules from Sourceforge. You will need to use some kind of client. I am currently using Eclipse as my development IDE hence all my CVS materials comes from that. I have heard that TortoiseCVS is quite neat in its own way (for Windows) but I’d rather use Eclipse your choice.

Continue reading