Wednesday, November 8, 2006

Software Engineer's songs

My brother forwarded these songs to me. I've read them before somewhere, but still smiled when read it.

YESTERDAY
By : Beatles

Yesterday,
All those backups seemed a waste of pay
Now my database has gone away
Oh I believe in yesterday... ..

Suddenly,
There's not half the files there used to be
And there's a milestone hanging over me
The system crashed so suddenly
I pushed something wrong What it was I could not say Now all my data's gone and I long for yesterday-ay- ay-ay

Yesterday,
The need for back-ups seemed so far away
I knew my data was all here to stay Now I believe in yesterday



IMAGINE
by : John Lennon

Imagine there's no Windows
It's easy if you try
No fatal errors or new bugs
To kill your hard drives
Imagine Mr. Bill Gates
Leaving us in peace!

Imagine never ending hard disks
It isn't hard to do
Nothing to del or wipe off
And no floppy too
Imagine Mr. Bill Gates
Sharing all his money

You may say I'm a hacker
But I'm not the only one
I hope someday you'll join us
And your games will fit in RAM

Imagine 1-Giga RAM
I wonder if you can
No need for left-shifts or setups
And no booting again and again

Imagine all the systems
Working all life-time!

You may say I'm a hacker
But I'm not the only one

Maybe someday I'll be a cracker
And then I'll make Windows run.....



LET IT BE
By : Beatles

When I find my code in tons of trouble
Friends and colleagues come to me
Speaking words of wisdom: Write in C

As the deadline fast approaches
And bugs are all that I can see
Somewhere, someone whispers: Write in C

Write in C, Write in C
Write in C, oh, Write in C

LOGO's dead and buried
Write in C

I used to write a lot of FORTRAN
For science it worked flawlessly
Try using it for graphics!
Write in C

If you've just spent nearly 30 hours
Debugging some assembly
Soon you will be glad to Write in C
Write in C, Write in C

Write in C, yeah, Write in C
BASIC's not the answer
Write in C

Write in C, Write in C
Write in C, oh, Write in C
Pascal won't quite cut it
Write in C

Saturday, October 28, 2006

The Future of Router

Nowadays, internet routers are much smarter than they were years ago. More and more features are added to this boxes in such that packets can be delivered faster and managing them easier. What do you think a router will be in next decade?

Currently, with Resilient Packet Ring, traffic can be rerouted to other paths in milliseconds response, close to SONET ADM. Processor used in the router box is also much better than we saw a few days ago. Probably they are already a dual-core RISC processor or something like that.

Friday, October 27, 2006

It is Ready to rock

The interface connectors on my embedded kit is now ready. I've wired them (darned, I had to hand-solder more than 30 tiny wires on a tiny board without zooming lense or microscope). I had tested the connectors, they were working OK.

First I tested the ADC connection with 10k potensiometer module. All ADCs (eight of them) could measure the analog inputs. The next one, I tested the output port, all the 8 LEDs worked. I've had a chance to test the last port (supposedly for GPIO), because it requires disabling interrupts on some of the lines and I still need to read the documentation.

I still have problem making the Real Time Clock (RTC) on board to work. I did not check the out signal coming of RTC data out, but I already verified the power connection were wired OK. There are 3 possibilites: my test program does not work, the I2C line is broken or the RTC chip is bad.

Will post again once everything works OK.

Wednesday, October 18, 2006

Digital Drug

A friend sent me about this about "Digital" drug:

As part of our dedication to being an open, transparent organization, here are the frequencies utilized in the production of the Digital Drug CD:

0.5 - 1.5 Hz - Endorphin release
0.9 Hz - Euphoric feeling
2.5 Hz - Production of endogenous opiates (pain killers, reduce anxiety)
4.0 Hz - Enkephalin release for reduced stress
10 Hz - Enhanced serotonin release. Mood elevation, arousal, stimulant
14 Hz - Awakeness, alert. Concentration on tasks
20.215 Hz - Brings about safe LSD-25 effects
30 Hz - Used for safe marijuana effects
33 Hz - Hypersensitivity, C. consciousness
38 Hz - Endorphin release
46.98 Hz - Visualization effects, when used with 62.64 & 70.47 Hz
Carriers: 90 - 110 Hz - Pleasure-producing beta-endorphin rise
111 Hz - Constant beta endorphin release

Sunday, October 15, 2006

CDMA (2)

Here is an improvement of the previous code. To simulate bit stream, I add a function to generate random number generator for each node.



#include <stdio.h>
#include <stdlib.h>

#define NUMBER_OF_SEQUENCES 8
#define IS_ORTHOGONAL 0
#define IS_NOT_ORTHOGONAL -1
#define N_NODES 4

typedef struct {
int chip[NUMBER_OF_SEQUENCES];
} ChipSeq;


void PrintChipSeq(ChipSeq *X);

int Add(ChipSeq *X, ChipSeq* Y, ChipSeq *R)
{
int i;
for (i=0; ichip[i] = X->chip[i] + Y->chip[i];
}
return 0;
}


int DotProduct(ChipSeq *X, ChipSeq *Y, ChipSeq *Res)
{
ChipSeq temp;
int i;

if (!X || !Y)
return -1;

for(i=0; ichip[i] = X->chip[i] * Y->chip[i];
return 0;
}

void InitChip(ChipSeq *A, int initVal)
{
int i;

for(i=0; ichip[i] = initVal;
}


int CheckOrthogonality(ChipSeq *X, ChipSeq *Y)
{
int i;
int sum = 0;

for (i=0; ichip[i] * Y->chip[i];

if (sum/NUMBER_OF_SEQUENCES == 0)
return IS_ORTHOGONAL; // it is orthogonal
else
return IS_NOT_ORTHOGONAL;
}


int RecoverBit(ChipSeq *S, ChipSeq *SenderSeq)
{
int i;
int sum=0;

for(i=0; ichip[i] * SenderSeq->chip[i];

return (sum/NUMBER_OF_SEQUENCES <= 0 ? 0 : 1); } int Negative(ChipSeq *A, ChipSeq *Comp) { int i; for(i=0; ichip[i] = -(A->chip[i]);
}


void PrintChipSeq(ChipSeq *X)
{
int i;

printf("[ ");
for (i=0; ichip[i]);
printf("]");
}

void CopySeq(ChipSeq* src, ChipSeq* dest)
{
if (src && dest)
memcpy(dest, src, sizeof(ChipSeq));
}


void ConvertToBipolar(ChipSeq *A, ChipSeq *Bip)
{
int i;

for(i=0; ichip[i] == 1)
Bip->chip[i] = 1;
if (A->chip[i] == 0)
Bip->chip[i] = -1;
}
}


void Send(int n, int bit[], ChipSeq node[], ChipSeq *S)
{
ChipSeq bp[N_NODES], temp;
int i,j;

if (n>N_NODES) return;
for(i=0; i if (bit[i]==1)
CopySeq(&node[i], &bp[i]);
else
Negative(&node[i], &bp[i]);
}
memset(S, 0, sizeof(ChipSeq));
for(i=0; i Add(S, &bp[i], S);
}
}


int GenerateRandom(void)
{
return random() % 2;
}


int main(int argc, char *argv[])
{
int i,j;
ChipSeq node[4] = { {{0, 0, 0, 1, 1, 0, 1, 1}},
{{0, 0, 1, 0, 1, 1, 1, 0}},
{{0, 1, 0, 1, 1, 1, 0, 0}},
{{0, 1, 0, 0, 0, 0, 1, 0}}
};
ChipSeq temp, b[N_NODES], s;
int bit[N_NODES];
time_t t;

for(i=0; i printf("Node[%u] = ", i);
PrintChipSeq(&node[i]);
printf("\n");
ConvertToBipolar(&node[i], &b[i]);
printf("Bipolar(node[%u]) = ", i);
PrintChipSeq(&b[i]);
printf("\n");
}

for (i=0; i for(j=i+1; j if (CheckOrthogonality(&b[i], &b[j])==IS_ORTHOGONAL)
printf("Node[%u] & node[%u] is orthogonal\n", i, j);
else {
printf("Node[%u] & node[%u] is NOT orthogonal\n", i, j);
exit(0);
}
}
}

time(&t);
srandom(t);
for (i=0; i<100; i++) {
bit[0] = GenerateRandom();
bit[1] = GenerateRandom();
bit[2] = GenerateRandom();
bit[3] = GenerateRandom();
printf("Send: A=%u B=%u C=%u D=%u\n", bit[0], bit[1], bit[2], bit[3]);
Send(N_NODES, bit, b, &s);
printf("S = !A + !B + !C + !D = ");
PrintChipSeq(&s);
printf("\n");

printf("Recover bit from A: S*A\n");
printf("Bit sent from A was: %d\n", RecoverBit(&s, &b[0]));
printf("\n");

printf("Recover bit from B: S*B\n");
printf("Bit sent from B was: %d\n", RecoverBit(&s, &b[1]));
printf("\n");

printf("Recover bit from C: S*C\n");
printf("Bit sent from C was: %d\n", RecoverBit(&s, &b[2]));
printf("\n");

printf("Recover bit from D: S*D\n");
printf("Bit sent from D was: %d\n", RecoverBit(&s, &b[3]));
printf("\n");
}
}

CDMA

I developed this simulation just for fun and only in a few minutes:


#include
#include


#define NUMBER_OF_SEQUENCES 8
#define IS_ORTHOGONAL 0
#define IS_NOT_ORTHOGONAL -1



typedef struct {
int chip[NUMBER_OF_SEQUENCES];
} ChipSeq;


int Add(ChipSeq *X, ChipSeq* Y, ChipSeq *R)
{
int i;

for (i=0; i
chip[i] = X->chip[i] + Y->chip[i];

return 0;
}


int DotProduct(ChipSeq *X, ChipSeq *Y, ChipSeq *Res)
{
ChipSeq temp;
int i;

if (!X || !Y)
return -1;

for(i=0; i
chip[i] = X->chip[i] * Y->chip[i];
return 0;
}

void InitChip(ChipSeq *A, int initVal)
{
int i;

for(i=0; i
chip[i] = initVal;
}


int CheckOrthogonality(ChipSeq *X, ChipSeq *Y)
{
int i;
int sum = 0;

for (i=0; i
chip[i] * Y->chip[i];

if (sum/NUMBER_OF_SEQUENCES == 0)
return IS_ORTHOGONAL; // it is orthogonal
else
return IS_NOT_ORTHOGONAL;
}


int RecoverBit(ChipSeq *S, ChipSeq *SenderSeq)
{
int i;
int sum=0;

for(i=0; i
chip[i] * SenderSeq->chip[i];

return sum/NUMBER_OF_SEQUENCES;
}


int Negative(ChipSeq *A, ChipSeq *Comp)
{
int i;
for(i=0; i
chip[i] = -(A->chip[i]);
}


void PrintChipSeq(ChipSeq *X)
{
int i;

printf("[ ");
for (i=0; i
chip[i]);
printf("]");
}

void CopySeq(ChipSeq* src, ChipSeq* dest)
{
memcpy(&dest, &src, sizeof(ChipSeq));
}


void ConvertToBipolar(ChipSeq *A, ChipSeq *Bip)
{
int i;

for(i=0; i
chip[i] == 1)
Bip->chip[i] = 1;
if (A->chip[i] == 0)
Bip->chip[i] = -1;
}
}


int main(int argc, char *argv[])
{
ChipSeq A = { {0, 0, 0, 1, 1, 0, 1, 1}};
ChipSeq B = { {0, 0, 1, 0, 1, 1, 1, 0}};
ChipSeq C = { {0, 1, 0, 1, 1, 1, 0, 0}};
ChipSeq D = { {0, 1, 0, 0, 0, 0, 1, 0}};
ChipSeq temp, ba, bb, bc, bd, ca, cb, cc, cd, sum;

printf("A = ");
PrintChipSeq(&A);
printf("\n");
ConvertToBipolar(&A, &ba);
printf("Bipolar(A) = ");
PrintChipSeq(&ba);
printf("\n");

printf("B = ");
PrintChipSeq(&B);
printf("\n");
ConvertToBipolar(&B, &bb);

printf("C = ");
PrintChipSeq(&C);
printf("\n");
ConvertToBipolar(&C, &bc);

printf("D = ");
PrintChipSeq(&D);
printf("\n");
ConvertToBipolar(&C, &bd);

// A + B + C sends 0 bits
Negative(&ba, &ca);
printf("!A = "); PrintChipSeq(&ca); printf("\n");
Negative(&bb, &cb);
printf("!B = "); PrintChipSeq(&cb); printf("\n");
Negative(&bc, &cc);
printf("!C = "); PrintChipSeq(&cc); printf("\n");

// now add
Add(&ca, &cb, &temp);

Add(&temp, &cc, ∑);
printf("S = !A + !B + !C = ");
PrintChipSeq(∑);
printf("\n");

printf("Recover bit from A: S*A\n");
printf("Bit sent from A was: %d\n", RecoverBit(∑, &A));
printf("\n");

printf("Recover bit from B: S*B\n");
printf("Bit sent from B was: %d\n", RecoverBit(∑, &B));
printf("\n");

printf("Recover bit from C: S*C\n");
printf("Bit sent from C was: %d\n", RecoverBit(∑, &C));
printf("\n");

}