TRIAC and Opto TRIAC Driver Curcuit

Triac is designed to be suitable for general purpose AC switching. They can be used as an ON/OFF function in applications such as static relays, heating regulation, induction motor starting circuits... or for phase control operation in light dimmers, motor speed controllers,...

It's quite common to use Opto Triac driver to switch Triac.

In my project, I need to switch two heating elements on and off every half second. Each heating element is 1.5 kw. 

1500/230 = 6.5A

If I switch two heating element in the same time, the current consumption will be 6.5x2=13A.
The normal house power plug only provides 10A. Therefore, I have to swith one element each time.

Here is my parts list:

Triac: LITTELFUSE - Q6008L5,  Element14-1304759
Triac driver: FAIRCHILD SEMICONDUCTOR - MOC3022-M, Element14-1021366

PS: the middle leg of triac should not connec to live.
Here is the reason: the junction, or die, sometime is connected to A2.

In the meantime, need to calculate the area of heat sink which attaches on the triac.

Uninstall Security Tool 2010

One of my colleague installed "Security Tool 2010" on her personal pc (vista) by mistake.
I googled about this virus, found it's a very clever rogue.

During installation, Security Tool configures itself run automatically every time when you start an application. The rogue also uses this method of running to block the ability to run any programs, including security applications.

Immediately after launch, it will start to scan your computer and reports a lot of various infections that will not be fixed unless you first purchase the software. Important to know, all of these infections are a fake and do not actually exist on your computer. What is more, the rogue will also hijack Internet Explorer and Firefox and display fake warnings when you opening a web site.

As you can see, Security Tool is a scam and should be removed from your computer upon detection.
Do not be fooled into buying the program! It will steal your credit card account, and keep on billing you every month!!

Many website mentioned some methods to kill it. For example, delete files, which call "security tool',  from registration.  I have search the whole registration folders. I couldn't find any file called 'security tool'. Take a look the date of these posts. All of them were in 2009. Hmm, this smart rogue has been updated.

What I have done:
- Restarted pc, and went to safe mode (with network);
- Type 'run' in 'Start'. Then type 'msconfig' to open up 'system configuration' window;
- disabled ALL startup items;
- deleted all .exe (eg. 576544.exe )files in 'C:\users\AppData\Local
- download "Malwarebytes" or copy installation file from other pc.
- install it and do full scan.
- kill this bloody Security Tool;
- reboot pc;


To remove System Tool virus:


Eagle PCB 3D Tutorial


Mercedes Benz A-Class DIY Information

A very useful website:

How to reset Mercedes Benz A-Class Service Indicator

Turn the key to position 2 in the ignition lock and immediately press button 000.0 twice within the space of one second.

Turn the key to position 0 in the ignition lock.

Press and hold button 000.0 Turn the key to position 2 in the ignition lock. Keep button 000.0 pressed.

Service message with current remaining distance or remaining time appears.

After about 10 seconds, an acoustic signal will sound and the service display with the new starting distance or starting time appears for about 10 seconds.

Release button 000.0
Thats it youve reset your service indicator.


Add RTC DS1037 in to gumstix Kernel

Need to add an external real time clock chip on Gumstix to make the time correct.

Overo (I am using Air) has two i2c devices. First all of, add i2c driver in kernel.

Every time when I try to modify kernel, I need to re-source the kernel profile by using:
overo-oe$ source build/profile

overo-oe$ bitbake -c  menuconfig virtual/kernel


PS: the virtual/kernel means the default build kernel in overo directory. or, I still can use:
overo-oe$ bitbake -c menuconfig overo-omap3

take a look at:


in 'device drivers' --- 'real time clock'
add 'y' in front of 'Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025'

ps: y: build into kernel
     m: add a module

save it.

$ cd /build/czhang/overo-oe/
$ cp deconfig deconfig.old
$ cp /build/czhang/overo-oe/tmp/work/overo-angstrom-linux-gnueabi/linux-omap3-2.6.34-r90/git/.config /build/czhang/overo-oe/

take a look at the "deconfig"
# I2C Hardware Bus support

# I2C system bus drivers (mostly embedded / system-on-chip)
# CONFIG_I2C_GPIO is not set
# CONFIG_I2C_OCORES is not set

# I2C RTC drivers
# CONFIG_RTC_DRV_DS1374 is not set
# CONFIG_RTC_DRV_DS1672 is not set

rebuild kernel:
overo-oe$ bitbake -c clean virtual/kernel
overo-oe$ bitbake virtual/kernel

New kernel image is in /build/czhang/overo-oe/tmp/deploy/glibc/images/overo
copy new kernel (uImage) to SD card FAT partition.
start Gumstix, I can see i2c-1 and i2c-3 in /dev.

I2C-1 is the power chip. If you want to alter power settings use this.
I2C-3 is the external connection port. If you want to communicate to
external circuits use this.

I am using DS1338 rtc chip.
power supply votage Vcc is 1.8V
logic VH = Vcc x 0.7
logic VL = 0.3V
Therefore, I don't need a logic converter.

connect rtc to overo, try command:
$ i2cdetect -y -r 3
      0 1 2 3 4 5 6 7 8 9 a b c d e f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50:50-- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

the address of ds1338 is 0x68, not 0x50.
Googled around, found the 0x50 is address of eeprom on the overo. That means the rtc chip has not been detected in the i2c bus.
Then, I thought I need to change to i2c bus speed to be 100khz. The overo i2c bus' default speed is 400khz. I am sure the ds1338 can run at hight speed mode. But I could not talk to rtc at the mement. So, give it a try.

Change i2c bus speed:
(followed steps from

i2c bus speed can be changed by passing a kernel boot argument to the driver in the u-boot startup script.

To modify u-boot, start your system, stop the u-boot process by hitting a key, and make the following change to either nandargs or mmcargs depending how you boot. The nandargs/mmcargs variables are just gumstix conventions for initializing bootargs which is the value u-boot cares about.

Using mmc booting as the example, the old value should look SOMETHING like this:

Overo # printenv
mmcargs=setenv bootargs console=${console} ...

So a add new variable so you can easily change the speed again and then modify mmcargs and save your changes.
Overo # setenv i2cspeed 3,100
Overo # setenv mmcargs setenv bootargs console=\${console} i2c_bus=\${i2cspeed} ...
Overo # saveenv
After reboot gumstix, i got errors:

Root-NFS: No NFS server available, giving up.
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "(null)" or unknown-block(2,0)
Please append a correct "root=" boot option; here are the available partitions:
1f00             512 mtdblock0 (driver?)
1f01            1792 mtdblock1 (driver?)
1f02             256 mtdblock2 (driver?)
1f03            4096 mtdblock3 (driver?)
1f04          255488 mtdblock4 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)

Where did I do wrong?!!
Read the instruction again...
Pay attention to these RED words. I was using exact command (copy and paste), even includes the "..." .
How stupid I am : (

I can not remember my mmcargs argument. So, I went to internet, search a printevn to find a similar print out. here is what i found quit similar:

mmcargs=setenv bootargs console=${console} vram=${vram} omapfb.mode=dvi:${dvimode} omapfb.debug=y omapdss.def_disp=${defaultdisplay} root=/dev/mmcblk0p2 rw rootfstype=ext3 rootwait
nandargs=setenv bootargs console=${console} vram=${vram} omapfb.mode=dvi:${dvimode} omapfb.debug=y omapdss.def_disp=${defaultdisplay} root=/dev/mtdblock4 rw rootfstype=jffs2
Re-do the 'setenv', reboot, all good. It can boot from mmc again. Thank goodness.
The speed has been changed. But the rtc still can not been found.
Do I need two pull up resisters for SDA and SCL? No, the overo already has them on board. 
I had a close look the chip... It is ds133833!!  this is running at 3.3v! Wrong chip!

*waiting for new chip*

Got a correct rtc ds1338c-18
$ i2cdetect -y -r 3
root@overo:~# i2cdetect -y -r 3
     0 1 2 3 4 5 6 7 8 9 a b c d e f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50:50-- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- --68-- -- -- -- -- -- --
70: -- -- -- -- -- -- -- -- 

0x68, yeah, found it.

Here are two command to read and write time from/to rtc:
root@ i2cget -y 3 0x68 0x01              // read from address 0x01 from rtc
root@ i2cset -y 3 0x68 0x02 0x11      // set rtc address 0x02 to be 0x11

after used i2cset command to set time and date correctly, then used command 'hwclock -w' to write clock to system from rtc.
Check system clock:
root@ date

the data and time are different from what i just set in rtc.

then do:
root@ hwclock
this clock time is as same as the system clcok, but different from rtc.


the 'hwclock' is supposed to read hardware clock (rtc). Does that mean the overo has on board rtc?

Google around, yes, it has a 'twl4030' on board rtc.
when i do:
root@ ls /dev
i can see rtc and rtc0
the rtc0 is on board twl4030.

on the internet, most people recommended to get the external rtc clock time from their program code. that's hard~~

use on board rtc and get battery charged.


Install Qwt for Gumstix

(Install Qwt in Ubuntu)

After I finished program in Ubuntu, I want to compile the program for gunstix.
In the beginning, I copied the qwt-5.2.1 folder to my build machine (fc13). When I do
$ make distcleam
cd src/ && make -f Makefile distclean
make[1]: Entering directory `/build/czhang/qt-everywhere-opensource-src-4.7.0/projects/qwt-5.2.1/src'
make[1]: *** No rule to make target `/usr/share/qt4/mkspecs/linux-g++/qmake.conf', needed by `Makefile'.  Stop.
make[1]: Leaving directory `/build/czhang/qt-everywhere-opensource-src-4.7.0/projects/qwt-5.2.1/src'
make: *** [sub-src-distclean-ordered] Error 2

I tried many time. It looks like the "distcleam" command is not working very well. The qwt-5.2.1 folder is copied from Ubuntu machine. That means it has already been build for i386 system. The "distcleam" command supposes to clean all make files, and return to original file.

The easiest way to fix is download qwt source file to FC13, copy folder to:
$ qmake
$ make

error occur:

compiling resources-release-shared/qrc_qwt_designer_plugin.cpp
rm -f
linking plugins/designer/
/build/czhang/overo-oe/tmp/sysroots/x86_64-linux/usr/armv7a/lib/gcc/arm-angstrom-linux-gnueabi/4.3.3/../../../../arm-angstrom-linux-gnueabi/bin/ld: cannot find -lQtDesigner
collect2: ld returned 1 exit status
make[1]: *** [plugins/designer/] Error 1
make[1]: Leaving directory `/build/czhang/qt-everywhere-opensource-src-4.7.0/projects/qwt-5.2.1/designer'
make: *** [sub-designer-make_default-ordered] Error 2

It tried to install qwt plugin for qt-designer.
We can disable it by comment out make option in 'qwtconfig.pri'

$ make

Do not need "make install". This command install qwt library to current machine. I am not going to run the program in my FC13.


Next, compile and copy m4 and qwt library to gumstix.

$ rsync -av czhang@
ce-src-4.7.0/projects/qwt-5.2.1/lib/* /usr/lib