Saturday, March 30, 2013

Arduino Function Optimization

Adventures with Arduino: From 41 instructions to 1
http://www.rorydriscoll.com/2011/02/01/adventures-with-arduino-from-41-instructions-to-1/

I/O Operation for AVR

AVR ports are labeled port A though port D on most DIP packages (look at the datasheet for your AVR to find the right port.) For instance, for port B:

You write to port B with the PORTB register
You read (input) port B with the PINB register

The input or output status of each bit in the port can be controlled with the DDR (Data Direction Register), so that each pins in a single port can serve different purposes.

Set port B, pin 2 for input (this clears bit DDB2 in the DDR):

DDRB &= ~_BV(DDB2);

To get the value on port B, pin2:

val = PINB & _BV(PB2);

This ANDs the PINB register with the bit value of pin 2 (PB2)--masking out the other unwanted bits. 



Dr. Dobbs,
Al Williams 
DigtialWrite Optimization
http://v4.drdobbs.com/blogs/embedded-systems/240148309

Friday, March 29, 2013

Prototyping board soldering techniques


http://www.instructables.com/id/How-to-Prototype-Without-Using-Printed-Circuit-Boa/

Good practice for soldering
http://lbw.axe-man.org/solder/thumb.html

Progressive Prototyping techniques
http://elm-chan.org/docs/wire/wiring_e.html


http://electronics.stackexchange.com/questions/2215/how-do-i-connect-components-when-using-a-circuit-board-with-pads-but-no-traces

Wednesday, March 27, 2013

Define macro through command line

http://www.thegeekstuff.com/2012/05/c-macros/


$ gcc -Wall -DMACRO2 macro.c -o macro

Defining macros with values from command line

Not only the macros can be defined from command line (as shown in one of the sections above) but also they can be given values from command line. Lets take the following example :
#include <stdio.h>

int main(void)
{
#ifdef MACRO1 // test whether MACRO1 is defined...
    printf("\nMACRO1 Defined with value [%d]\n", MACRO1);
#endif

    return 0;
}
In the code above, the macro MACRO1 is being tested and its value is being used but it is not defined anywhere. Lets define it from the command line :
$ gcc -Wall -DMACRO1=25 macro.c -o macro
$ ./macro

MACRO1 Defined with value [25]

Tuesday, March 26, 2013

Arduino Data logging (with SD)

http://www.mauroalfieri.it/en/elettronica/data-logging-con-arduino.html

A note on "const"

A Note On const

Many users bring up the idea of using C's keyword const as a means of declaring data to be in Program Space. Doing this would be an abuse of the intended meaning of the const keyword.
const is used to tell the compiler that the data is to be "read-only". It is used to help make it easier for the compiler to make certain transformations, or to help the compiler check for incorrect usage of those variables.
For example, the const keyword is commonly used in many functions as a modifier on the parameter type. This tells the compiler that the function will only use the parameter as read-only and will not modify the contents of the parameter variable.
const was intended for uses such as this, not as a means to identify where the data should be stored. If it were used as a means to define data storage, then it loses its correct meaning (changes its semantics) in other situations such as in the function parameter example.

Daily Reading Stack and heap

http://stackoverflow.com/questions/79923/what-and-where-are-the-stack-and-heap


stack and heap:
http://www.learncpp.com/cpp-tutorial/79-the-stack-and-the-heap/

What is recursion and when should i use it?
http://stackoverflow.com/questions/3021/what-is-recursion-and-when-should-i-use-it?page=2&tab=votes#tab-top

Arduino memory usage optimization

http://liudr.wordpress.com/2011/02/04/how-to-optimize-your-arduino-memory-usage/


Arduino Memory Space Discussion
http://arduino.cc/forum/index.php?topic=40586.0


AVR RAM structure
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=98806&start=0


AVR memory organization
http://www.mikroe.com/download/eng/documents/compilers/mikroc/pro/avr/help/avr_memory_organization.htm


Putting data in flash on the Arduino
http://www.sjbaker.org/wiki/index.php?title=Putting_data_in_flash_on_the_Arduino

SRAM usage -> AVR Program
http://stackoverflow.com/questions/960389/how-can-i-visualise-the-memory-sram-usage-of-an-avr-program

Sunday, March 17, 2013

Choose gcc and g++ version

http://askubuntu.com/questions/26498/choose-gcc-and-g-version

cuda 5, 12.10

Installation guide:
http://sn0v.wordpress.com/2012/12/07/installing-cuda-5-on-ubuntu-12-04/

cannot find -lxi:
ibxi6/libxi-dev.

http://ubuntuforums.org/showthread.php?t=1290597

install MPI:
sudo apt-get install libcr-dev mpich2 mpich2-doc

http://jetcracker.wordpress.com/2012/03/01/how-to-install-mpi-in-ubuntu/


Linux: 'cc1plus': execvp: No such file or directory:

CUDA incompatible with my gcc version:

Solution
http://stackoverflow.com/questions/6622454/cuda-incompatible-with-my-gcc-version






Modify  soft link point to g++ version 4.6
sudo ln -s /usr/bin/g++-4.6 /usr/local/cuda/bin/gcc


https://devtalk.nvidia.com/default/topic/523910/unsupported-compiler-/




 

Thursday, March 14, 2013

Reason to initialize (not reset) signal in VHDL (Verilog)

http://stackoverflow.com/questions/6363130/is-there-a-reason-to-initialize-not-reset-signals-in-vhdl-and-verilog



signal, object declaration

Used to define an identifier as a signal object.
No explicit initialization of an object of type T causes the default
initialization at time zero to be the value of T'left

 signal identifier : subtype_indication [ signal_kind ] [ := expression ];

 signal a_bit : bit := '0';
 a_bit <= b_bit xor '1';    -- concurrent assignment

 signal my_word : word := X"01234567";
 my_word <= X"FFFFFFFF";           -- concurrent assignment

 signal foo : word register; -- guarded signal
 signal bar : word bus;      -- guarded signal
 signal join : word  wired_or; -- wired_or must be a resolution function

signal_kind may be register  or  bus.

A simple signal of an unresolved type can have only one driver.
Note that "bit" is an unresolved type as is "std_ulogic", but,
"std_logic" is a resolved type and allows multiple drivers of a
simple signal.



Initializing Signal
http://fpga-dsp-scratch.blogspot.com/2008/08/vhdl-part-18-initializing-signals.html

Daily Reading: Difference between rising_edge(clk) and (clk'event and clk='1')

http://vhdlguru.blogspot.com/2010/04/difference-between-risingedgeclk-and.html

FFT windowing Xilinx

http://tumblr.tristesse.org/post/3193756352/fft-windowing

Xilinx CoreGen Block Memory Generator

Memory Initialization:
http://cseweb.ucsd.edu/classes/sp08/cse141L/lab4/coregen-tutorial.html


Memory Initialization
http://www.xilinx.com/support/documentation/ip_documentation/blk_mem_gen/v7_3/pg058-blk-mem-gen.pdf


The memory contents can be optionally initialized using a memory coefficient (COE) file or
by using the default data option. A COE file can define the initial contents of each individual
memory location, while the default data option defines the initial content of all locations.

Hints for creating COE files


How to open Memory Editor:
http://forums.xilinx.com/t5/Installation-and-Licensing/problem-in-memory-editor-in-ise-12-3/td-p/187608

Use Memory Editor:  

In ISE 10.1.03, Memory Editor can be accessed from the CORE Generator interface by selecting Tools -> Memory Editor.  

In ISE 11.1 and later, Memory Editor can be accessed from a script file. Use mem_edit.bat (Windows platforms) or mem_edit (Linux platforms). This script is available in the $XILINX/bin/&ltOS&gt directory. 

The Memory Editor can be used to create COE files in two ways: 
  1. Enter your memory data values directly into the Memory Editor GUI and then select File -> Generate -> COE files(s) to create the COE files. 
  2. Enter your memory data into Excel (use whatever formulas you need there), export to CSV format, and then Import the CSV into Memory Editor (File -> Import -> CSV file). When a CSV file is imported, Memory Editor prompts you to specify the Memory Depth, Word Width, Data and Address Radix, and Start Address. 

After the CSV file has been imported, you should inspect the Memory Content window for accuracy, and then select File -> Generate -> COE files(s) to create the COE files.


Creating a Memory
http://www.xilinx.com/itp/xilinx10/isehelp/cgn_p_memed_single_block.htm



Wednesday, March 13, 2013

How to delete zero components in a vector in Matlab


If you just wish to remove the zeros, leaving the non-zeros behind in a, then the very best solution is
a(a==0) = [];
This deletes the zero elements, using a logical indexing approach in MATLAB. When the index to a vector is a boolean vector of the same length as the vector, then MATLAB can use that boolean result to index it with. So this is equivalent to
a(find(a==0)) = [];
And, when you set some array elements to [] in MATLAB, the convention is to delete them.
If you want to put the zeros into a new result b, while leaving a unchanged, the best way is probably
b = a(a ~= 0);
Again, logical indexing is used here. You could have used the equivalent version (in terms of the result) of
b = a(find(a ~= 0));
but mlint will end up flagging the line as one where the purely logical index was more efficient, and thus more appropriate.
As always, beware EXACT tests for zero or for any number, if you would have accepted elements of a that were within some epsilonic tolerance of zero. Do those tests like this
b = a(abs(a) >= tol);
This retains only those elements of a that are at least as large as your tolerance.

Sunday, March 10, 2013

malloc.h no such file or directory mac


#include "sys/malloc.h" 

#include "malloc.h" 

Tuesday, March 5, 2013

Go to in System code

http://blog.regehr.org/archives/894

Unsigned Logic Vector Addition

http://stackoverflow.com/questions/5690750/unsigned-logic-vector-and-addition-how



In brief, you can add the ieee.numeric_std package to your architecture (library ieee; use ieee.numeric_std.all;) and then do the addition using:
Output <= std_logic_vector(unsigned(Output) + 1);

Monday, March 4, 2013

Daily reading: Signal VHDL explanation

Concept: delta delay

http://en.wikipedia.org/wiki/Delta_delay

Signal assignment and delta delay


Signals values are changed by signal assignment statements. The simplest form of a signal assignment is:
signal_name <= value;  -- assigned after delta delay


http://www.pldworld.net/_hdl/1/www.ireste.fr/fdl/vcl/lesd/les_4.htm
When no explicit delay time is provided, the default time is a delay called delta delay.




Friday, March 1, 2013

National Instruments In Vehicle Acquisition Table

Shared Variable and Single Process Techniques for programming NI LabView

https://decibel.ni.com/content/docs/DOC-19097