Labels

07/12/2009

Create library in CadSoft (Eagle) by using existing library

(利用原有的元件库创建新的元件库)
*** Thanks for Kevin Bolding ***

Copying a Symbol from another Library


The first step in copying a symbol is to open up the library that has the existing part.  Use File/Open to open the 74XX-US.lbr library.  Choose the Edit Symbol tool  and select the symbol 7400.  We are going to copy this into our library to make a new gate called the 999.  First, make sure all layers are visible by choosing the Layers button and selecting All.  Now, make the entire symbol into a group by using the Group tool  and drawing a rectangle around everything visible.  Finally, select the Cut tool  to and click on the group to copy the group onto the clipboard.

Now we can copy the symbol into our own library.  Open up your custom library.  Click on Edit Symbol  and enter “999” for the new symbol name.  Now, use the Paste tool  to paste a copy of the 7400 Nand gate into the new symbol.  You may now edit it as you like (for instance, change one of the input pins to be inverted by using the Change tool  to change the function from None to Dot.  Click one of the pins and it will change as shown below:

You may now save your symbol and use it as part of other devices.

Copying a Package  from another Library

Most common packages (such as the DIL8 we just made) already are defined in some library or another.  You’ll find it easiest to copy them rather than re-make them.  Copying packages is the same as copying symbols.  You might want to try copying the DIL8 package from the 74XX-US library into your new library.  (Of course, you won’t want to copy over your existing DIL8, so name the copy DIL8A.)

Ps: Select all layers before group select, and cut group then.

Putting Gates and Packages Together Into Devices

The final task in making a part is to create a device that has information on how symbols are placed inside of a package.  For many devices, there will be only one symbol.  However, many devices contain multiple symbols, as well as hidden power pins.  This is the case for the Gizmo device, which contains three Gizmogates and hidden power pins.

Make a new device by clicking on the Device button .  Enter “GIZMO” in the New field.  Now, add three copies of the Gizmo symbol, since the Gizmo device will contain three Gizmo gates.  Change the names of the three Gizmos to “A”, “B” and “C” by clicking the Names tool .

Since the Gizmo package will have Power and Ground pins, but the symbols don’t include the pins explicitly, we need to add a Power/Ground symbol to the device as well.  To save some time, we’ll copy thePWRN symbol from another library and use it instead of creating a new symbol.  Follow the directions for copying a symbol from another library above and copy the symbol PWRN from the library 74XX-US.lbr.  Give the new symbol the name PWRN in your library.  Now you can put the PWRN symbol in the Gizmo package by using the Add tool .  Give the symbol the name PWR by using the Name tool.

Since there are multiple symbols in this package, we need to specify how they are added to a schematic.  Normally, we just add the next symbol as needed.  In other words, the first symbol is Gizmogate A, then Gizmogate B, and so on.  To specify this, change the Add level to “Next” by using the Change tool  and selecting AddLevel Next.  Click on the three Gizmogates to change their Add levels to Next. The PWRN symbol usually is hidden on a schematic, so we don’t want to add it like we add the Gizmogates.  Change its Add level to Request to indicate that it will only be added if specifically requested by the designer.  It will still be in the gate, but it won’t appear on the schematic.

The final step in making a device is to specify a package and the connections from symbol pins to package pads.  First, we’ll want to specify the package we just designed, the DIL8.  Click on the NEW button at the bottom of the screen under the package variant window. Select your new package, the DIL8.  You may also want to assign a prefix of “GZ” to the symbols in this package - that way the first symbol you add will be GZ1, the next GZ2, and so on.  Use the Prefix button to change the prefix.

Now we can complete the device by assigning symbol pins to package pads.  Click on the Connect button  and a window will pop up to allow you to connect pins to pads.  Since there are three Gizmogates, you’ll see three sets of IN and OUTB pins for gates A, B, and C.  There are also the GND and VCC pins as well.  Start by connecting A.IN to pad P$1 by selecting both and pressing Connect. Connect the remaining pins to pads as follows:

Pin
Pad
A.IN
P$1
A.OUTB
P$2
B.IN
P$3
B.OUTB
P$5
C.IN
P$6
C.OUTB
P$7
PWR.GND
P$4
PWR.VCC
P$8

Your final device should look like the following diagram: 

We’re finally done with the device.  Save it!



27/11/2009

Linux search command

Ubuntu:
$ apt-cache search xxx

Fedora:
$ yum search xxx

Install eGalax touch screen in Linux (Ubuntu)

Linux *Ubuntu 下安装触摸屏驱动
** special thanks to Kekezu **
(Install on Fedora: http://oestudyard.blogspot.com/2010/02/install-egalax-touch-screen-in-linux.html)

I made this touch screen (8" 800Y-Y-V USB control) works on Ubuntu 9.04 2.6.28-16-generic.

Step1) Download required packages and TouchKit utility
$ sudo apt-get install linux-source
$ cd ~
$ wget http://shop-on-line.tvielectronics.com/download/TouchKit-2.06.2905-32b-k26.tar.gz


Step2) Installing TouchKit utility
$ sudo chmod -x TouchKit-2.06.2905-32b-k26.tar.gz
$ sudo tar -xzvf TouchKit-2.06.2905-32b-k26.tar.gz
$ cd eGalaxTouch32
$ sudo sh setup.sh

Utility will be installed to /usr/local/eGalaxTouch32/

Step3) Building the tkusb module

$ cd /usr/src
$ uname -r  # Checks linux kernel version
$ sudo chmod -x linux-source-2.6.xx.tar.bz2  # Change xx
$ sudo tar -xjvf linux-source-2.6.xx.tar.bz2 
$ sudo cp ./linux-headers-`uname -r`/Module.symvers ./linux-source-2.6.xx   
$ sudo ln -s linux-source-2.6.xx /usr/src/linux
$ cd /usr/src/linux
$ sudo make oldconfig
$ sudo make prepare
$ sudo make modules SUBDIRS=scripts/mod/
$ cd /usr/local/eGalaxTouch32/USBSrc

$ sudo gedit Makefile


Around line 16, find

KDIR := /lib/modules/$(shell uname -r)/build

Replace this line with

KDIR := /usr/scr/linux


$ sudo gedit tkusb.h
around line 25, find
include ams/semaphore.h

Replace this line with

include

$ sudo make all
$ sudo cp tkusb.ko /lib/modules

Step4) Modifying file /etc/X11/xorg.conf

$ sudo gedit /etc/X11/xorg.conf

Change Option "Device" to "usbauto" in InputDevice section of touch screen

Part of the file xorg.conf

...
Section InputDevice
Identifier "EETI"
Option    "Device"    "usbauto"
...
EndSection
...

PS: someone told me that the xorg.conf file has been deprecated in favor of a more XML type configuration on his Ubuntu 9.10. He ended up to create an empety xorg.conf file.


Step5) Making startup script to load the module

$ sudo gedit /etc/init.d/addTouchKit

Content of file addTouchKit

#! /bin/sh
rmmod /lib/modules/'uname -r'/kernel/drivers/hid/usbhid/usbhid.ko
insmod /lib/modules/tkusb.ko
sleep 1
insmod /lib/modules/'uname -r'/kernel/drivers/hid/usbhid/usbhid.ko


$ sudo update-rc.d addTouchKit defaults
$ sudo chmod 441 /etc/init.d/addTouchKit

Now panel is installed. Reboot your computer.

Step6) Starting utility and calibrating the panel

$ cd /usr/local/eGalaxTouch32
$ ./eGalaxTouch

Here are some screen shots of the touch screen calibration window





~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I am a student. If you feel this page is quite useful, 
do you mind click the ad (just once) on the right hand side :)
I appreciate your support ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

24/11/2009

Install Adobe Flash player on Linux Fedora & Firefox

To install Adobe Flash player on Fedora Linux, so that you can view Flash movies in Firefox on your Linux machine, simply follow these easy steps:

Step 1- rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm

Step 2- rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux

Step 3- mkdir -p /usr/lib/mozilla/plugins /usr/lib64/mozilla/plugins

Step 4- yum install flash-plugin

Step 5- mozilla-plugin-config -i -g -v

Then just restart your Firefox browser and Flash will be available.

Auto mount network partition in linux

open /etc/fstab under root, add:

//10.0.0.4/share /media/c-drive cifs gid=myname,uid=myname,user=myname,pass=mycode 0 0

30/09/2009

Add Serial Port Communication Lib in Qt

Down load "qextserialport", unzip it.


Two ways to compile it. It depends on the source code I download.
1) qmake  // or qmake-qt4 in fedora
2) make
3) Open project (qextserialport.pro) in Qt, build it.

After compile the files, I got four files in 'build' folder:


libqextserialport.so
libqextserialport.so.1
libqextserialport.so.1.0
libqextserialport.so.1.0.0




copy all link files to /usr/lib
$ cp -a libq* /usr/lib


Add the lib in .pro file:

LIBS += -lqextserialport
Publish Post
unix:DEFINES = _TTY_POSIX_
win32:DEFINES = _TTY_WIN_ \
QWT_DLL \
QT_DLL
INCLUDEPATH += /home/czhang/Documents/software/qextserialport

14/08/2009

Reset Window origin coordination

设置窗口原点坐标



by default, window / frame's origin coordination is (0,0). it can't be changed in the property window, but can be set up in code.



after create a new window, add following code after "m_ui->setupUi(this)"



QPoint pos; // relocate window

pos.setX(240); // x

pos.setY(100); // y

move(pos);





07/08/2009

Resizing pictures in batch in Linux

批量修改图片大小

Software: imagemagick

install: $ sudo apt-get install imagemagick

command:

$ mogrify -resize 50% *.jpg or
$ convert -resize 50% *.jpg (don't over write original photos)

16/07/2009

Message box

(系统提示对话框)

switch(QMessageBox::warning(this, "Warning",
"Database file is opened,\n"
"please close it first.\n"
"Close database file?",
"Yes", "No", 0, 1)) {
case 0:
ui->label_temp->setText("yes");
db.close(); // close database
dbOpened = false;
openFile(); // open file dialog
showTable(curtTable);
break; // pay attention to here
case 1:
ui->label_temp->setText("no");
break; // and here

Timer event

(定时发生器函数)

#include “qtimer.h”

in main.cpp main function add:
startTimer(100) //start timer, and timer event triggered every 100 ms

PS: it is a little bit strange here. i don't need to declare a QTimer class. i may find the reason in the future since i am a just beginner in Qt

in main.h add:
void timerEvent(QTimerEvent *event);


in main.cpp add:
void MainWindow::timerEvent(QTimerEvent *event

-----------------------
Edit:

my concern was right, my previous code was wrong. i actually calling the system timer event, not the timer which i created.

here is the correct code:
#include

in main.h add:

QTimer *timer1;
void timerEvent();

in main.cpp add:

timer1 = new QTimer(this); // start timer event
connect(timer1, SIGNAL(timeout()), this, SLOT(timerEvent()));
timer1->start(250);

MainWindow::timerEvent()
{
........
}

Find application icon

(寻找系统图标)

in KDE:

$ kde-config --path icon
will list all icon directory.

in GNONE:

$ gnome-config –datadir

will list a path which contains a folder called “pixmaps”.

Get total record count (SQLite)


my_sqlModel = new QSqlQueryModel(); //define a new sql model
my_sqlModel.setQuery(“select * from item”);
int cols = my_sqlModel.rowCount();

Qt Installation in Linux

(Qt 在Linux上的安装)

1.download Qt SDK
2.go to the downloaded file folder:
On Linux/Unix, need to make the file executable in order to run it. You can either do this with your desktop's file manager or, at the command line, type:

$ chmod u+x qt-sdk-linux-x86-opensource-2009.02.bin

should now be able to execute the file as normal. to do this from the command line by typing:

$ ./qt-sdk-linux-x86-opensource-2009.02.bin

3.install GNU C++ compliler:

$ sudo apt-get install g++
$ sudo apt-get install build-essential

Create second window/form/dialog

(新建窗口)

Add New.. Qt – Qt Designer Form Class
Need to include newform.h in mainwindow.cpp file where has slot to open this new window;
Add "extern newDialog *newdialog" in mainwindow.cpp;
Add
"newDialog *newdialog" in newwindow.cpp;

Then, in click-button which open new window slot, add:

void MainWindow::on_pushButton_clicked()
{
   if (!newdialog)

      newdialog
=  new newDialog (NULL);
   newdialog->exec();
}

The above method creates dialog in heap,  so when i click close(), i don't delete it from memory. To close dialog or window completely, the code needs to be changed as:

void MainWindow::on_pushButton_clicked()
{
     newDialog newdialog(NULL);
     newdialog.exec();
}

we can not use:

cyclescrdialog.show();

show() does not block, so you'll only see a quick flash of your dialog, as it'll be destroyed immediately after calling show() ( when exiting the method ). Using exec() blocks until dialog is closed by the user. 

if create new a window/dialog by using code, and did not pre-create window/dialog from “add new.. QT Designer form class”, the new window/dialog may be no shows on the top. This is because that the new window/dialog does not have a parent window/dialog. In order to make sure the new window/dialog shows on the top, use “add new.. QT Designer form class” create a new window/dialog first.

Globle variabal definition

(全局变量定义)

Assume I have a.cpp b.cpp c.cpp and I need use integer i in all three of them.

I declare extern int i in globvar.h file;

Define int i in globevar.cpp file;

#include globvar.h file in all three .cpp files.

Varible definition


(变量定义)
parameter definition should be in .h file. If this variable is used in this window/form (qqWidget.h), just declare in “private:”. But if used in anther window/form, should declare in “public:”.

// globalvar.h
#ifndef MYGLOBALS
#define MYGLOBALS

extern int variable1;
extern int variable2;

#endif
...

// globalvar.cpp implementation

int variable1= 0;
int variable = 0;

Qt is not qute

my qt program's gui looks like normal...

need to add style header in the including file:

#include
#include
#include "mainwindow.h"

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
a.setStyle(new QPlastiqueStyle); //this command must be in front of ”return a.exec()”
return a.exec();
}

西西今天回成都了,很想她,心里老惦记着妞妞

Qt4.5 Installation in Windows

(Qt4.5 安装)
to install Qt, need to download and install all three files from Qt website:
-qt-creator-win-opensource-1.1.0.exe
-qt-win-opensource-4.5.1-mingw.exe
-qt-sdk-win-opensource-2009.02.exe


after drag and drop component, no need to declare it again in project.
but need to add ui-> in front of each used component if you wanna to use/edit it.

09/07/2009

2D barcodes creator/decoder -- Libdmtx

(2维条码生成/解码软件)



Libdmtx is a 2D barcode, or Data Matrix barcodes, creator and decoder.

it took me a while to install it. here is mainly procedure of installation:

download libdmtx-0.7.0.tar.gz from http://www.libdmtx.org/
$ tar -zxf libdmtx-0.7.0.tar.gz


go to new libdmtx folder
$ ./configure

i got an error message:
checking for MAGICK... no
configure: error: dmtxread/dmtxwrite requires Wand >= 6.2.4
 
that's because i am using ubuntu. alright, i need to install ImageMagick from the source.
download ImageMagick source file, unpacked,
$ ./configure
$ make
$ sudo make install

(edit: I may need this:
$ sudo apt-get install libmagick++-dev
$ sudo apt-get install libgraphicsmagick1-dev
)

i may need to install g++ before install ImageMagick
$ sudo apt-get install g++

got anther error when i ran ./configure:
/usr/bin/ld: cannot find -lperl

ok, need to install libperl
$ sudo apt-get install libperl-dev

then, go back to install ImageMagick, and libdmtx.

all done..



To read a 2D barcode:
$ dmtxread /~/Desktop/image.png  
$ dmtxread -N 1 /home/czhang/mypro/UIM.jpg >> /home/czhang/mypro/UIM.txt
read barcode and export code to text file.

PS: This command will take a while (maybe 5 to 15 seconds) to finish decoding a 2D barcode image.

To speed up decoding, take a look command option. 


To create a 2D barcode:
$ dmtxwrite <(echo -n 2dbarcodecontent) -o image.png


Edit:
get web-cam capture software from here:
http://www.firestorm.cx/fswebcam/

Fedora install:
root$ yum install fswebcam

may need to install GDlib:
http://www.libgd.org/Downloads

take a photo with webcam:
$ fswebcam -F 15 -r 352x288 --no-banner --save /mnt/cdrive/UIM.jpg