Saturday, December 10, 2011

Romantic motorbike trip in Ireland

East_of_Cork_20294

Thursday, November 10, 2011

ROMBot - first run

Robot build using CD-ROM parts including motors, couple screws, mouse as displacement sensor and IR receiver form old TV, L293D H-bridge, 5x R6 (1.2V) batteries and Arduino UNO. This was its first run.

Saturday, August 20, 2011

Source code optimization tips for Atmel AVR programmers also Arduino and clones

Eighteen Hints to Reduce Code Size
  1. Compile with full size optimization.
  2. Use local variables whenever possible.
  3. Use the smallest applicable data type. Use unsigned if applicable.
  4. If a non-local variable is only referenced within one function, it should be declared static.
  5. Collect non-local data in structures whenever natural. This increases the possibility of indirect addressing without pointer reload.
  6. Use pointers with offset or declare structures to access memory mapped I/O.
  7. Use for(;;) { } for eternal loops.
  8. Use do { } while(expression) if applicable.
  9. Use descending loop counters and pre-decrement if applicable.
  10. Access I/O memory directly (i.e., do not use pointers).
  11. Declare main as C_task if not called from anywhere in the program.
  12. Use macros instead of functions for tasks that generates less than 2-3 lines assembly code.
  13. Reduce the size of the Interrupt Vector segment (INTVEC) to what is actually needed by the application. Alternatively, concatenate all the CODE segments into one declaration and it will be done automatically.
  14. Code reuse is intra-modular. Collect several functions in one module (i.e., in one file) to increase code reuse factor.
  15. In some cases, full speed optimization results in lower code size than full size optimization. Compile on a module by module basis to investigate what gives the best result.
  16. Optimize C_startup to not initialize unused segments (i.e., IDATA0 or IDATA1 if all variables are tiny or small). If possible, avoid calling functions from inside the interrupt routine.
  17. Use the smallest possible memory model.

Five Hints to Reduce RAM Requirements
  1. All constants and literals should be placed in Flash by using the Flash keyword.
  2. Avoid using global variables if the variables are local in nature. This also saves code space. Local variables are allocated from the stack dynamically and are removed when the function goes out of scope.
  3. If using large functions with variables with a limited lifetime within the function, the use of subscopes can be beneficial.
  4. Get good estimates of the sizes of the software Stack and return Stack (Linker File).
  5. Do not waste space for the IDATA0 and UDATA0 segments unless you are using tiny variables (Linker File).

Checklist for Debugging Programs
  1. Ensure that the CSTACK segment is sufficiently large.
  2. Ensure that the RSTACK segment is sufficiently large.
  3. Ensure that the external memory interface is enabled if it should be enabled and disabled if it should be disabled.
  4. If a regular function and an interrupt routine are communicating through a global variable, make sure this variable is declared volatile to ensure that it is reread from RAM each time it is checked.

Sunday, August 7, 2011

Harald Haas: Wireless data from every light bulb



More technical data can be found here.

I will have to try to replicate this using my new Power LEDs and my ATmega microcontroller. Cool stuff.

Sunday, May 8, 2011

ActionScript 3 and Flex 4.5 optimization

Recently I'm spending a lot of time optimizing my face recognition library in ActionScript 3.
Since I've started my adventure with AS couple of years ago FlashPlayer's performance increased a lot, but still it is not enough for calculation intensive tasks. There is also a good news. Many performance issues can by fixed with source code optimizations. Without further ado here are some of my AS3 optimization tips.

  1. Use Vectors instead of Arrays if possible.
  2. If you know length of Vector before you create one in code pass it to Vector constructor.
  3. If you know that length of Vector will be constant then pass true to Vector constructor as second argument making it fixed vector.
  4. When you loop through Vector elements use variable of uint type. It is faster than int in FlashPlayer 10.2.
  5. When you want acces Vector element like that for example vector[i+1] change it to vector[uint(i+1)].
  6. If it is possible try to do as small number of operations using 2D Vectors by which I mean Vectors accessible like that vector[i][j] they are at least 2x slower then 1D vectors. If for example you are looping through 2D vector then good practice is to assign every vector[i] to local variable and than access value for every "j". By doing that you should see at least 50% performance increase in data access from 2D Vector.
  7. When incrementing value use ++i instead of i++ wherever possible.
  8. Remove all nonessential code from loops.
  9. When operating on uint or int variables whenever possible use bit operators for example instead i*4 use i<<2. More info about bitwise operators.
  10. When you loop through vector elements don't use vector.length in loop condition instead assign this value to local uint variable and use it instead.
  11. When using && or || operators don't mix types like that Number && int or uint || int. Instead if possible use that same type like that int && int or uint || uint it is up to 3,5x faster.
  12. Using nested if statements is faster than using && operators in single if statement.
  13. Assigning variable of type Number to variable of type int or uint is 2x slower than assignments of int to int or uint to uint or even uint to int.
  14. When creating empty Array don't do this like that var arr:Array = new Array() instead do it like that var arr:Array = [] it's faster.
  15. Using switch is about 15% slower on Windows XP and 10% slower on Mac OS X than if else statements. Beware of switches in performance-critical code!


    I hope those tips will help you with you optimizations.

Friday, January 21, 2011

AIRTrans - friendly translator living on your desktop

If you often find yourself translating text to and from English here is an app for you.

AIRTrans:

1. Works on Windows, Mac OS X and Linux.
2. Supports over 40 languages.
3. Translates to and from any of over 40 languages.
4. Reads English text aloud.
5. Takes small space on your screen.
6. User Interface colors are customizable
7. Can remember last position on screen and app window size so you don't have to move it to that spot where you want it to be every time you start app.
8. AutoStart functionality
9. Can by resized by dragging one of bottom window corners.





You can download it from here.
Mirror 1 -Softpedia
Mirror 2 - download.cnet.com

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

Sunday, January 16, 2011