Thursday, November 29, 2012

Pointers in C++

int *p;

p is a pointer to an integer quantity

int *p[10];

p is a 10 elements array of pointers to integer quantities

int (*p)[10];

p is a pointer to a 10 element integer array

int *p(void);

p is a function that returns pointer to an integer quantity and accepts nothing

int p(char *a);
p is function that accepts an argument which is a pointer to a character  and returns an integer quantity
int *p(char *a);
p is a function which accepts an argument which is a pointer to a character and returns a pointer to an integer quantity

int (*p)(char *a);
p is a pointer to a function which accepts an argument as a pointer to a character and returns an integer quantity
int (*p(char *a))[10];
p is function that accepts argument which is pointer to a character and returns a pointer to a 10 element integer array
int p(char (*a)[]);
p is a function which accepts an argument which is a pointer to a character array and returns an integer quantity

int p(char *a[]);
p is a function which accepts an argument which is an array of pointers to characters and returns an integer quantity
int *p(char a[]);
p is a function which accepts a character array as argument and returns a pointer to an integer quantity
int *p(char (*a)[]);
p is function which accepts an argument which is a pointer to an array of characters and it returns a pointer to an integer quantity
int *p(char *a[]);
p is a function which accepts argument as an array of character pointers and returns a pointer to an integer quantity
int (*p)(char (*a)[]);
p is a pointer to a function which takes an argument which is a pointer to character array and  returns an integer quantity
int *(*p)(char (*a)[]);
p is a pointer to a function which takes argument which is pointer to a character array and returns a pointer to an integer quantity
int *(*p)(char *a[]);
p is a pointer to a function which takes argument which is an array of pointers to characters and returns pointer to an integer quantity
int (*p[10])(void);
p is a 10 element array of pointers to functions which does not take anything as argument and each function returns an integer quantity 

int (*p[10])(char a);
p is 10 element array of pointers to functions; each function accepts a character as argument; and each function returns an integer quantity

int *(*p[10])(char a);
p is a 10 element array of pointers to functions; each function takes a character as argument; and each function returns a pointer to an integer quantity
int *(*p[10])(char *a);
p is a 10 element array of pointers to functions; each function takes a character pointer as argument; and each function returns a pointer to an integer quantity








Saturday, November 24, 2012

Windows Driver Kit (WDK)/Windows Driver Development Kit(Win DDK)

Initially it was known as Windows Driver Development Kit, now it has been superseded by Windows Driver kit i.e. WDK.
As the name suggests it is a framework to develop drivers on Windows Platform.
You can either instal it directly from internet or you can download the file to install in another system
Here is the link

http://msdn.microsoft.com/en-us/library/windows/hardware/gg487428.aspx

I am installing WDK because I need to work on SORA which is a SDK to develop Software Radio applications. It has been developed by Microsoft Research Asia center.

To install WIN DDK you can follow this link 

http://www.tenouk.com/windowsddk/windowsdriverdevelopmentkit.html

Details are here

http://research.microsoft.com/en-us/projects/sora/

Tuesday, October 23, 2012

When to use Genetic Algorithms vs. when to use Neural Networks?

A genetic algorithm (GA) is a search technique used in computing to find exact or approximate solutions to optimization and search problems.A genetic algorithm, despite its sexy name, is for most purposes just an optimisation technique. It primarily boils down to you having a number of variables and wanting to find the best combination of values for these variables. It just borrows techniques from natural evolution to get there.

Neural networks are non-linear statistical data modeling tools. They can be used to model complex relationships between inputs and outputs or to find patterns in data.Neural networks are useful for recognising patterns. They follow a simplistic model of the brain, and by changing a number of weights between them, attempt to predict outputs based on inputs.

If you have a problem where you can quantify the worth of a solution, a genetic algorithm can perform a directed search of the solution space. (E.g. find the shortest route between two points)

When you have a number of items in different classes, a neural network can "learn" to classify items it has not "seen" before. (E.g. face recognition, voice recognition)

Execution times must also be considered. A genetic algorithm takes a long time to find an acceptable solution. A neural network takes a long time to "learn", but then it can almost instantly classify new inputs.



Saturday, October 20, 2012

UHD

Stands for "Universal Hardware Driver"

Prior to UHD, there were two distinct APIs -- one for USRP1, the other  for USRP2, and the "classic" USRP2 API used raw-ethernet frames for carrying data/control. 

In UHD, all the platforms are supported (USRP1, USRP2, N2XX, and E1XX),  and for ethernet-connected platforms, the protocol is based on VITA-49-over-UDP.

Older example applications, which would have used one or the other of the USRP1 or USRP2 "classic" API, need to be lightly worked-over to be compatible with the UHD API.  

The N2XX platforms are *only* UHD capable, and many of the newer daughtercards are only accessible using the UHD API.

The UHD API also enables some of the fancier synchronization paradigms that weren't available in the "classic" interface, and also allows things like dual-DDC on the USRP2 and N2XXX platforms.

Thursday, October 18, 2012

gr.probe_avg_mag_sqrd_cf

gr.probe_avg_mag_sqrd_cf : This function can be used to find the average power on a channel.

Details can be found at /usr/local/include/gnuradio/gr_probe_avg_mag_sqrd_cf.h

http://gnuradio.org/doc/doxygen/gr__probe__avg__mag__sqrd__cf_8h.html

http://gnuradio.org/doc/doxyge/gr__probe__avg__mag__sqrd__cf_8h_source.html

http://gnuradio.org/doc/doxygen/classgr__probe__avg__mag__sqrd__cf.html

The implementation file can be located in :

gnuradio/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.cc





Example :

#!/usr/bin/python2.6
#!/usr/bin/env python

from gnuradio import gr
from gnuradio import uhd
import sys, time

class rx_cfile_block1(gr.top_block):
    def __init__(self):
        gr.top_block.__init__(self)

                self.uhd_usrp_source = \
                uhd.usrp_source(device_addr="serial=1R270DU1",stream_args=uhd.stream_args('fc32'))

                self.gr_file_sink = gr.file_sink(gr.sizeof_float ,"/home/sumit/first_app_data1")

                self.uhd_usrp_source.set_subdev_spec("A:0", 0)

                self.uhd_usrp_source.set_antenna("RX2", 0)

                self.uhd_usrp_source.set_samp_rate(1000000)

                self.uhd_usrp_source.set_gain(45)

                treq = uhd.tune_request(2450000000)

                self.uhd_usrp_source.set_center_freq(treq)

                self._head = gr.head(gr.sizeof_float, int(4))
        
                self.c2mag = gr.probe_avg_mag_sqrd_cf(0.01, 0.001)

                self.connect(self.uhd_usrp_source, self.c2mag, self._head, self.gr_file_sink)

def main():
    tb = rx_cfile_block1()   

    while not tb.c2mag.unmuted():

        tb.run()

        print tb.c2mag.unmuted() #show exceed threshold or not
        print tb.c2mag.level()        #show power
        print tb.c2mag.threshold()
        time.sleep(3)
                     


if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        pass



CIC passband compensation

Q: Does the HB filter response compensate for the non-flat passband of the CIC?

A: No [CIC non flat response] compensation filter is available.

Reference : http://gnuradio.4.n7.nabble.com/CIC-passband-compensation-tt15653.html#a15654


Q: Hi Firas,

Thanks for your response. In an earlier thread you had posted a matlab script called usrpddc.m that calculates the overall frequency response of the usrp rx chain and plots it. This would be very useful to me however, when I try to run it I find it is missing mfilt.cicdecim() function. If you still have this and could make it available it will be a great help.

Thanks
Nirali

A: Hi Nirali

The function mfilt.cicdecim() is a standard MATLAB function. Check Filter design tool.

Regards,
Firas

   

Linux or Windows

Reference : http://gnuradio.4.n7.nabble.com/Vista-Xp-or-Linux-tt15028.html#a15029


One advantage of Windows is that you can set the priority of the thread that
processes USRP data to eliminate overruns and data processing hiccups caused
by window management and display events without noticeable impact on GUI
responsiveness.  I think the only option on Linux is to use realtime
priority, which requires root access.