Nuffnang Ads

Thursday, February 7, 2013

Image Disappear when wrap "in line with text" (Microsoft Words)

When you place an image in Microsoft Words with wrap text option of "in line with text". The image appear to disappear or floating. When you change to other wrap text option like "square", "tight", etc. The image reappear.

To solve this issue,

  1. Highlight text and the line you wish to place the image.
  2. Right click and choose "Paragraph"
  3. Go to "Indent and Spacing" tabs, look for "Spacing" section
  4. Under "Line Spacing", pull the drop down list and select "Single", make sure it is not in "Exactly" option
The problem should be go away by now

Wednesday, February 6, 2013

5V microcontroller control 3V motor speed (Testing)

When build a motor driver for tamiya motor (3V rating), the issue comes when you have 5V operating microcontroller (PIC) to drive 3V motor rating. 

Lets say you have a 5V power source for the motor and PIC, but the motor is only 3V rating. Overdriving motor should be no problem as long as the motor not too hot (is able to dissipate the heat fast enough). 

Method #1 (Not good)
I have 1 idea to bring 5V down to 3V using PWM, by sending 60% duty cycle PWM frequency to motor driver (60/100 * 5V = 3V). Note that the 3V is average voltage not constant DC 3V. The voltage is oscillating at ON state (5V) at 60% and OFF state (0V) at 40%, making it 3V average.

So, i did an experiment in lab using function generator to generate 60% duty cycle of 5V square wave signal, through a 4A mosfet driver (UCC27424P) from Texas Instrument. Since i not controlling direction of motor, i just use connect 1 pin of motor to the output pin of driver and the other pin to ground. I test it without using flyback diode, as i don't have diode at that time (IT IS A MUST FOR MOTOR).

When I run it with 60% duty cycle, the motor run without any hot issue on the motor. However the MOSFET driver is getting hotter, not sure what is the problem, maybe the method of driving it is wrong. The motor is ran without any load, but the MOSFET driver is hot, not extremely hot that can burn finger, just hot. I think it is usual as current is drawn to turn the motor. I think the driver is not suitable in driving high power motor, this motor is quite high power and speed. I decided to change the driving to n-channel MOSFET

Method #2 (Haven try)
I plan to replace the MOSFET driver to n-channel MOSFET. When selecting MOSFET, be sure to check the Vgs(th) - threshold voltage to turn on the gate of MOSFET. Some MOSFET has higher Vgs(th) which is above the PIC operating voltage. If not turn on properly, the MOSFET will operating in linear mode (like transistor), lower Vgs(th) will make sure the MOSFET work as switch (saturated mode)

Most of the MOSFET can be controlled directly from PIC output as MOSFET is voltage controlled not current controlled. The Vgs(th) is normally low enough to turn on the MOSFET (~2-3V), suitable for most of the 5V PIC.

I have request few TO-220 package n-channel MOSFET from TI. I will perform the testing when the components arrived

Friday, December 28, 2012

Real Time Face Tracking



Detect Face Using Haar Cascade
Track Using OpenTLD


FFmpeg Installation

FFmpeg Installation for Windows

  1. Open command line prompt on Windows by typing "cmd" at run (Start Menu)
  2. At Command Prompt Windows, type cd/ (Change to C:\)
  3. mkdir FFmpeg (Make a new folder name FFmpeg at C:\)
  4. Extract FFmpeg file to C:\FFmpeg (DL Link : http://ffmpeg.zeranoe.com/builds/)
  5. Edit Windows System Path to \bin (Refer to OpenCV tutorial on how to add environment system path)
  6. After done, restart command prompt windows by reopen it again 
  7. Type "ffmpeg -version" to check whether ffmpeg successfully link
  8. Create a "FFmpeg_Example" folder
  9. Put all your file inside the folder created
  10. cd FFmpeg_Example directory
  11. ffmpeg -i....... Start using ffmpeg library
Reference : http://www.wikihow.com/Use-FFmpeg

To change video to image frame
ffmpeg -i video.mpg Pictures%d.jpg

Reference: http://ubuntuforums.org/showthread.php?t=1141293 

Wednesday, December 12, 2012

Generate list of function dependency in MATLAB


For newer releases of Matlab (eg 2007 or 2008) you could use the built in functions:
  1. mlint
  2. dependency report and
  3. coverage report
Another option is to use Matlab's profiler. The command is profile, it can also be used to track dependencies. To use profile, you could do
>> profile on   % turn profiling on
>> foo;         % entry point to your matlab function or script
>> profile off  % turn profiling off
>> profview     % view the report
If profiler is not available, then perhaps the following two functions are:
  1. depfun
  2. depdir
For example,
>> deps = depfun('foo');
gives a structure, deps, that contains all the dependencies of foo.m.

Quote from http://stackoverflow.com/questions/95760/how-can-i-generate-a-list-of-function-dependencies-in-matlab

Tuesday, December 4, 2012

Matlab 2012 link with opencv VS2010 (mex setup)

To use OpenCV library

Download mexopencv library from https://github.com/kyamagu/mexopencv

Prerequiste Components:
VC++ Compiler      (included in VS2010)
Microsoft SDK 7.1 (included in VS2010)
Matlab
  1. Open Matlab, type mex -setup in command windows
  2. Check whether there is any default compiler
  3. If no default compiler, choose a compiler from the list
  4. Type command cv.make('opencv_path','your\opencv\path')- replace your opencv path with your opencv directory (E.g. 'C:\OpenCV2.4')
  5. Let it compile
  6. After compiled, type addpath('mexopencv_path') - This must be called first for every project that used opencv library
  7. Type 'help cv' to display list of opencv command
  8. Can start using opencv library
Tutorial
http://www.cs.stonybrook.edu/~kyamagu/mexopencv/
https://github.com/kyamagu/mexopencv/blob/master/README.markdown

List of opencv function
http://www.cs.stonybrook.edu/~kyamagu/mexopencv/matlab/

OpenCV 2.4.2 Visual Studio 2010 (VS2010) Windows 7 64bit setup

Installation of OpenCV 2.4.2 for Visual Studio 2010 (Windows 7 x64)

Download the latest OpenCV library from sourceforge (2.4.2 or 2.4.3)

  1. Right Click My Computer -> Properties -> Advance System Setting -> Environment Variables -> Path -> Type in OpenCV dir ("C:\OpenCV2.4\build\x64\bin")
  2. Open Visual Studio 2010. Click New Project -> Select Win32 Console Application -> Check Empty Project -> Finish
  3. Click Property Manager Tab (Bottom right) -> Create 2 New Property Sheets with preference name ( OPENCV_DEBUG & OPENCV_RELEASE)
  4. Open OPENCV_DEBUG Property Sheet
    1. For C/C++ - Add path for Additional Include Directories (OpenCV2.4\build\include)
    2. For Linker/General - Add path for Additional Library Directories (OpenCV2.4\build\x64\vc10\lib)
    3. For Linker/General - Add the following lib file (For OpenCV2.4.3). The list of lib file can be found in OpenCV2.4\build\x64\vc10\lib:

      opencv_core243d.lib
      opencv_imgproc243d.lib
      opencv_highgui243d.lib
      opencv_ml243d.lib
      opencv_video243d.lib
      opencv_features2d243d.lib
      opencv_calib3d243d.lib
      opencv_objdetect243d.lib
    4. Repeat the steps for OPENCV_RELEASE, and change the lib file for Linker/General to:

      opencv_core243.lib
      opencv_imgproc243.lib
      opencv_highgui243.lib
      opencv_ml243.lib
      opencv_video243.lib
      opencv_features2d243.lib
      opencv_calib3d243.lib
      opencv_objdetect243.lib

      same filenames with 'd' - debug version removed
  5. To run x64 environment
    Go Build -> Configuration Manager -> Active Solution Platform -> New -> Change Itanium to x64
  6. Compile and run opencv code
  7. If tbb_debug.dll not found (for OpenCV 2.4.2), (OpenCV2.4.3 does not has this problem). Go download the tbb_debug.dll file from Intel Threading Building Blocks. extract x64 version and place into OpenCV\build\x64\bin
  8. if 32-bit win, extract x86 version out and place into OpenCV\build\x86\bin
  9. Compile your opencv code

Note: 
For some PC there will be Illegal Instruction Error when running cvHaarDetectObjects library (2.4.3 version). (Rare case). 
Solution: Use 2.4.2 version