XOR Gate

The exclusive-OR gate performs modulo 2 addition of its inputs.

When you cascade q two-input exclusive-or gates, with the output of the first one feeding one of the inputs of the second one, the output of the second one feeding one of the inputs of the third one, etc., the output of the last one in the chain is the modulo-two sum of the q + 1 inputs.  This could be used as a parity detector.


Friis transmission equation

Path loss = 20 log (4 * pi * r / lambda)

[Note: use log base 10]


Path loss = signal attenuation. Unit: dB

pi = 22 / 7

r = distance between transmitter and receiver. Unit: m

lambda = wavelength of signal. Unit: m

Wavelength = C/f


C = speed of electromagnetic waves in free space

= 299792458. Unit: m / s

f = frequency of signal. Unit: Hz

Let r = R * (2 ^ x)

Path loss = 20 log (4 * pi * R * L / lambda)

= 20 log (4 * pi * R / lambda) + 20 log (2 ^ x)

= 20 log (4 * pi * R / lambda) + 6x

The above derivation implies range(R) doubles every 6dB of path loss.

The path loss is +8.519dB more over a given range for the 2.4 GHz compared to 900MHz for the same range. In other words operating at 900 MHz exhibits a significantly longer range than is possible at 2.4 GHz.

links for 2007-03-14

links for 2007-03-03

Pointers in C – Easy way to remember

//          pointer_example.c
#include <stdio.h>
int main(void)
int k;                 // variable type declaration
k = 2;                // assignment statement
//          2 is rvalue (value in the right hand side of "=")
//          k is lvalue (value in the left hand side of "=")
int *ptr;              // pointer to store integer values
ptr = &k;           // address of k
//          *ptr is rvalue
//          ptr is lvalue
printf("value stored in k is %d\n", *ptr);
//          k is name of variable;  k is an unmodifiable lvalue
//          ptr is name of address; ptr is a modifiable lvalue
//          value stored in k is 2

/* The size of memory required to store an address depends on the system. Some computers might require special handling to hold a segment and offset under certain circumstances. The actual size required is not too important so long as we have a way of informing the compiler that what we want to store is an address. Such a variable is called a pointer variable.

1) To store a variable, we need to know how many bits/bytes would be required to hold the value.

2) To store address of a variable, we need not know the number of bits/bytes would be required to hold the address. It is machine dependent.

3) Type declaration for a pointer indicates what type of variable will be stored in that address.


/* Pointers vs Arrays

// In C a string is an array of characters terminated with a binary zero character

(written as slash0.JPG).

char my_string[40];

my_string[0] = ‘T’;

my_string[1] = ‘e’;

my_string[2] = ‘d’:

my_string[3] = ‘slash0.JPG‘;

// C permits

my_string[40] = “Ted”;

/* In the above example, my_string has 37 null characters in it, since the size of the array is 40 which is a constant. Here the lvalue is unmodifiable.

This can be avoided if a pointer is used instead. Here the lvalue is modifiable.


//	Pointers to structures
typedef struct student
 int age;
 int studentNumber;
 float averageGrade;
 char name[32];
int main()
 //a STUDENT variable
 STUDENT mary;
 //a pointer to a STUDENT variable
 STUDENT *pupil;
//assign some values
 mary.age = 14;
 mary.studentNumber = 5678;
 mary.averageGrade = 73;
//tell pupil to point at mary
 pupil = &mary;
//Notice in the examples below the use of -> instead of (*pupil).age
//we can now access members of the mary structure using the pupil pointer
 printf("Mary's student number is %d\n", pupil->studentNumber);
//we can also do assignment and all other normal variable operations
 pupil->averageGrade = 86.2;
printf("Mary's average grade is %f\n", mary.averageGrade);
return 0;

Download here.