網頁

2016年1月27日 星期三

PowerMeter

電壓表
SW 電壓 分壓電阻 放大倍數 放大阻值
0



1 200V (100k)+900k+9M *1
2 20V (100k+900k)+9M *1
3 2V 100k+900k+9M *1
4 200mV 100k+900k+9M *10 11k
5 20mV 100k+900k+9M *100 1.02k

電流表
SW 電流 串聯電阻 放大倍數 放大阻值
0



1 10A 0.05ohm/5W *5 24.9k
2 1A(0.5) 0.1ohm/0.5W *20 5.23k
3 200mA 1ohm *10 11k
4 20mA 10ohm *10 11k
5 2mA 10ohm *100 1.02k

LCD1602
工作電壓:4.5~5.5V
PIC16F877 0V 5V 10kVR D1(p20) D3(p22) D2(p21)



D4(p27) D5(p28) D6(p29) D7(p30) 5V+10ohm 0V
LCD1602 VSS(p1) VDD(p2) VL(p3) RS(p4) R/W(p5) E(p6) D0(p7) D1(p8) D2(p9) D3(p10) D4(p11) D5(p12) D6(p13) D7(p14) BLA(p15) BLK(p16)

A2D
AN0 AN1 AN2 Vref AN4
p2 p3 p4 p5 p7

A2D選擇判斷
AN0 B2(p35) B1(p34) B0(p33)
AN1 B5(p38) B4(p37) B3(p36)
AN2 C2(p17) C1(p16) C0(p15)
AN4 E2(p10) E1(p9) E0(p8)

其他
Tx(p25) Rs232
Rx(p26) Rs232
C3(p18) LED
C4(p23) 累積
C5(p24) 清除

電源
5V: 6.6-(0.83*2)=4.93
TL431: (6.6-2.57)/1k=3.85mA

TL431
Vout = (R1+R2)*2.5/R2
1mA < (Vcc-Vout)/R3 < 500mA

Rsup R1 R2
5V 220 27.4k 27.4k
2.5V 1k 0ohm 0ohm



不論 PIC16F877 或 PIC16F877A 在使用 20MHz 時,
A/D 模組不能使用 Vref`,其轉換結果會失去2-3位的精確度,
b2, b1, b0 皆為零。

AD623
R-C濾波器-3dB時的截止頻率
1/(6.28*R*C) = f
R1=R2=330k C1=C2=0.022uF f=21.9
R1+R2=660k C3=1uF f=0.2

每個輸入與接地線之間加入高量的電阻,可以提供必要的偏壓電流回流路徑。
Ground Returns for Input Bias Currents
訊號接地電阻22M
未接22M
接上22M,或以示波器連接AD623的地和代測訊號

未接去耦電容

接上去耦電容

過多的去耦電容似乎沒有用



MAX232 會造成電源不穩定,使用磁珠隔離可以有效抑制,
但最後發現,MAX232相關電路的地和電源,分別連結後,
再與系統的地和電源連結,效果比磁珠好
電源不穩定 Pk-Pk 90-120mV,常有突波 160mV
 電路整理後 Pk-Pk 40-70mV,但偶而還是有突波 120mV

2016年1月26日 星期二

二 VideoLAN Compile 完成篇

成功的媽媽有好幾個!
媽媽教的智慧可不能忘!

進入 BIOS 在 Security/Virtualization 開啟 VT-x
download ubuntu-15.04-desktop-amd64.iso
使用 VMware 開啟 iso 檔
使用 Firefox 確認可以上網
點選左上角 Search your computer and online sources
填入 terminal,點選 Terminal
點選右上角的齒輪,選擇 Shutdown
sudo passwd root
先輸入自己密碼,再輸入 root 密碼
su - root

git clone https://github.com/videolan/vlc.git vlc

For the 64-bit version Mingw-w64
apt-get install gcc-mingw-w64-x86-64
apt-get install g++-mingw-w64-x86-64
apt-get install mingw-w64-tools
For the 32-bit version Mingw-w64
apt-get install gcc-mingw-w64-i686
apt-get install g++-mingw-w64-i686
apt-get install mingw-w64-tools

apt-get install lua5.2
apt-get install libtool
apt-get install automake
apt-get install autoconf
apt-get install autopoint
apt-get install gettext

apt-get install pkg-config
apt-get install qt4-dev-tools
apt-get install qt5-default
apt-get install subversion
apt-get install cmake
apt-get install cvs
apt-get install wine-dev
apt-get install zip
apt-get install bzip2
apt-get install p7zip-full
apt-get install nsis
apt-get install yasm
apt-get install ragel
apt-get install ant
apt-get install default-jdk
apt-get install protobuf-compiler

  • i686-w64-mingw32 for Windows 32-bits, using the Mingw-w64 toolchain
  • x86_64-w64-mingw32 for Windows 64-bits, using the Mingw-w64 toolchain
cd /root/vlc
mkdir -p contrib/win32
cd contrib/win32
../bootstrap --host=i686-w64-mingw32
../bootstrap --host=x86_64-w64-mingw32
make prebuilt
或者使用下列命令,但是失敗了
make fetch
make

cd /root/vlc
./bootstrap
mkdir win32 && cd win32

../extras/package/win32/configure.sh --host=i686-w64-mingw32
../extras/package/win32/configure.sh --host=x86_64-w64-mingw32

make package-win32-zip
產生 /root/vlc/win32/vlc-3.0.0-git-win64.zip
make package-win32-exe
產生 /root/vlc/win32/vlc-3.0.0-git-win64.exe
雖然可以安裝,但是不能執行

使用
vlc/share/lua/intf/telnet.lua
vlc/share/lua/intf/cli.lua
vlc/share/lua/intf/modules/host.lua
vlc/share/lua/modules/common.lua
原始檔,覆蓋下列被編譯過的 Object 檔
lua/intf/telnet.luac
lua/intf/cli.luac
lua/intf/modules/host.luac
lua/modules/common.luac
因為在 modules/lua/vlc.c 中的 luaL_dofile 無法使用 Object 檔
至於錯誤的原因是什麼?是個謎!
幸好 luaL_dofile 可以使用原始檔


    一 VideoLAN Compile 失敗篇

    進入 BIOS 在 Security/Virtualization 開啟 VT-x
    download
    ubuntu-14.04.3-desktop-i386.iso
    ubuntu-14.04.3-desktop-amd64.iso
    ubuntu-15.04-desktop-amd64.iso
    使用 VMware 開啟 iso 檔
    使用 Firefox 確認可以上網
    點選左上角 Search your computer and online sources
    填入 terminal,點選 Terminal
    點選右上角的齒輪,選擇 Shutdown
    sudo passwd root
    先輸入自己密碼,再輸入 root 密碼
    su - root

    root@ubuntu:~/vlc/win32# for i in `find . -name 'Makefile*' -print`
    > do
    > echo $i
    > grep LTLIBgme $i
    > done

    apt-get install git
    git clone https://github.com/videolan/vlc.git vlc
    或直接下載 http://www.videolan.org/vlc/download-sources.html

    ftp://ftp.videolan.org/pub/videolan/contrib/

    For the 64-bit version Mingw-w64
    apt-get install gcc-mingw-w64-x86-64
    apt-get install g++-mingw-w64-x86-64
    apt-get install mingw-w64-tools
    For the 32-bit version Mingw-w64
    apt-get install gcc-mingw-w64-i686
    apt-get install g++-mingw-w64-i686
    apt-get install mingw-w64-tools

    dpkg -l
    apt-cache showpkg gcc-mingw-w64-i686
    sudo apt-cache madison ^gcc-mingw-w64

    apt-get install lua5.2
    apt-get install libtool
    apt-get install automake
    apt-get install autoconf
    apt-get install autopoint
    apt-get install gettext

    apt-get install pkg-config
    apt-get install qt4-dev-tools
    apt-get install qt5-default
    apt-get install subversion
    apt-get install cmake
    apt-get install cvs
    apt-get install wine-dev
    apt-get install zip
    apt-get install bzip2
    apt-get install p7zip-full
    apt-get install nsis
    • i686-w64-mingw32 for Windows 32-bits, using the Mingw-w64 toolchain
    • x86_64-w64-mingw32 for Windows 64-bits, using the Mingw-w64 toolchain
    編輯 /usr/bin/x86_64-w64-mingw32-pkg-config 內容
    編輯 /usr/bin/i686-w64-mingw32-pkg-config 內容
    PKG_CONFIG_LIBDIR=/usr/lib/${triplet}/pkgconfig:/usr/${triplet}/lib/pkgconfig pkg-config $@
    改成
    if [ -n "$PKG_CONFIG_LIBDIR" ]; then
    EXISTING=":$PKG_CONFIG_LIBDIR"
    fi
    PKG_CONFIG_LIBDIR=/usr/lib/${triplet}/pkgconfig:/usr/${triplet}/lib/pkgconfig${EXISTING} pkg-config $@
    並注意此檔連結到 /usr/share/pkg-config-crosswrapper
    cd /root/vlc
    mkdir -p contrib/win32
    cd contrib/win32
    ../bootstrap --host=i686-w64-mingw32
    ../bootstrap --host=x86_64-w64-mingw32
    make prebuilt

    rm -f ../i686-w64-mingw32/bin/moc ../i686-w64-mingw32/bin/uic ../i686-w64-mingw32/bin/rcc

    cd /root/vlc
    ./bootstrap
    mkdir win32 && cd win32

    export PKG_CONFIG_LIBDIR=$HOME/vlc/contrib/i686-w64-mingw32/lib/pkgconfig
    ../extras/package/win32/configure.sh --host=i686-w64-mingw32 --disable-taglib --disable-x265
    export PKG_CONFIG_LIBDIR=$HOME/vlc/contrib/x86_64-w64-mingw32/lib/pkgconfig
    ../extras/package/win32/configure.sh --host=x86_64-w64-mingw32 --disable-taglib --disable-x265 --disable-skins2

    export LIBVLC_CFLAGS="-I/root/vlc/win32/_win32/include"
    export LIBVLC_LIBS="-L/root/vlc/win32/lib -lvlc"
    make package-win32-7zip
    產生 /root/vlc/win32/vlc-3.0.0-git-win64.7z
    make package-win32-zip
    產生 /root/vlc/win32/vlc-3.0.0-git-win64.zip
    make package-win32-exe
    產生 /root/vlc/win32/vlc-3.0.0-git-win64.exe

    vi /root/vlc/win32/modules/Makefile
    #LTLIBgme = libgme_plugin.la
    #LTLIBsid = libsid_plugin.la
    #LTLIBmkv = libmkv_plugin.la
    #LTLIBtaglib = libtaglib_plugin.la

    vi /root/vlc/win32/modules/misc/Makefile
    #LTLIBgnutls = libgnutls_plugin.la
    vi /root/vlc/win32/modules/visualization/Makefile
    #LTLIBprojectm = libprojectm_plugin.la
    vi /root/vlc/win32/modules/stream_out/Makefile
    #LTLIBstream_out_chromaprint = libstream_out_chromaprint_plugin.la

    vi /root/vlc/win32/Makefile
    修改
    git clone git://git.videolan.org/npapi-vlc.git npapi-vlc ;
    成為

    出現如下錯誤
    i686-w64-mingw32-strip /root/vlc-2.2.1/win32/vlc-2.2.1/NSIS/UAC.dll
    make: *** No rule to make target `extras/package/win32/NSIS/nsProcess/nsProcess.c', needed by `/root/vlc-2.2.1/win32/vlc-2.2.1/NSIS/nsProcess.dll'.  Stop.
    使用 vlc-3.0.0/extras/package/win32/NSIS 下的檔案 替換 vlc-2.2.1

    出現如下錯誤
    !include: closed: "languages/welsh.nsh"
    Goto: EndLanguageCmp
    !include: could not find: "languages\albanian.nsh"
    Error in script "/root/vlc-2.2.1/win32/vlc-2.2.1/vlc.win32.nsi" on line 690 -- aborting creation process
    make: *** [package-win32-exe] Error 1

    編輯 /root/vlc-2.2.1/win32/extras/package/win32/NSIS/vlc.win32.nsi
    註解掉不支持的語系


    不論是用 32/64 位元的 ubuntu,其操作過程和結果似乎一致。

    直接 git clone https://github.com/videolan/vlc.git vlc 下來的版本
    從 make 完成產生的檔名看出,是3.0.0

    vlc-3.0.0-git-win64.exe 無法安裝,即使使用以系統管理員執行
    vlc-3.0.0-git-win64.zip 解壓縮後可以執行,但他不會產生圖形介面,需使用如下命令操作
    vlc.exe c:\path\filename.avi
    telnet 介面無法使用
    vlc.exe --intf telnet --telnet-host=0.0.0.0 --telnet-port 4212 --telnet-password 1234

    vlc-3.0.0-git-win32

    vlc-2.2.1-win64.exe 無法安裝,即使使用以系統管理員執行
    vlc-2.2.1-win64.zip 解壓縮後可以執行,但他不會產生圖形介面,需使用如下命令操作
    vlc.exe c:\path\filename.avi
    telnet 介面正常
    vlc.exe --intf telnet --telnet-host=0.0.0.0 --telnet-port 4212 --telnet-password 1234

    vlc-2.2.1-win32.exe 無法安裝,即使使用以系統管理員執行
    vlc-2.2.1-win32.zip 解壓縮後可以執行,但他不會產生圖形介面,需使用如下命令操作
    vlc.exe c:\path\filename.avi
    telnet 介面正常
    vlc.exe --intf telnet --telnet-host=0.0.0.0 --telnet-port 4212 --telnet-password 1234



    建立 vlc-3.0.0-git-win32 時產生的錯誤
      CXX      demux/adaptative/playlist/libadaptative_plugin_la-Segment.lo
      CXX      demux/adaptative/playlist/libadaptative_plugin_la-SegmentBase.lo
    In file included from /usr/include/c++/4.8/i686-w64-mingw32/bits/gthr-default.h:35:0,
                     from /usr/include/c++/4.8/i686-w64-mingw32/bits/gthr.h:148,
                     from /usr/include/c++/4.8/ext/atomicity.h:35,
                     from /usr/include/c++/4.8/bits/basic_string.h:39,
                     from /usr/include/c++/4.8/string:52,
                     from ../../extras/package/win32/../../../modules/demux/adaptative/playlist/Segment.h:28,
                     from ../../extras/package/win32/../../../modules/demux/adaptative/playlist/SegmentBase.h:28,
                     from ../../extras/package/win32/../../../modules/demux/adaptative/playlist/SegmentBase.cpp:25:
    ../../extras/package/win32/../../../include/vlc_fixups.h:165:38: error: expected unqualified-id before ‘char’
     char *strtok_r(char *, const char *, char **);
                                          ^
    ../../extras/package/win32/../../../include/vlc_fixups.h:165:38: error: expected ‘)’ before ‘char’
    ../../extras/package/win32/../../../include/vlc_fixups.h:165:38: error: expected ‘)’ before ‘char’
    ../../extras/package/win32/../../../include/vlc_fixups.h:165:38: error: expected initializer before ‘char’
    ../../extras/package/win32/../../../include/vlc_fixups.h:195:12: error: expected unqualified-id before ‘{’ token
     struct tm *gmtime_r (const time_t *, struct tm *);
                ^
    ../../extras/package/win32/../../../include/vlc_fixups.h:199:12: error: expected declaration before ‘}’ token
     struct tm *localtime_r (const time_t *, struct tm *);
                ^
    make[5]: *** [demux/adaptative/playlist/libadaptative_plugin_la-SegmentBase.lo] Error 1
    make[5]: Leaving directory `/root/vlc-3.0.0/win32/modules'
    make[4]: *** [install-recursive] Error 1
    make[4]: Leaving directory `/root/vlc-3.0.0/win32/modules'
    make[3]: *** [install] Error 2
    make[3]: Leaving directory `/root/vlc-3.0.0/win32/modules'
    make[2]: *** [install-recursive] Error 1
    make[2]: Leaving directory `/root/vlc-3.0.0/win32'
    make[1]: *** [install] Error 2
    make[1]: Leaving directory `/root/vlc-3.0.0/win32'
    make: *** [package-win-install] Error 2

    2015年12月16日 星期三

    meshmixer

    產生樹狀支柱的利器

    放大縮小:滑鼠旋鈕。
    旋轉:按住滑鼠右鍵,再移動滑鼠
    移動視角:按下滑鼠中間旋鈕,再移動滑鼠

    Tip Diameter為支撐材與3D物件的接觸面。
    數字越大接觸面就越大,建議參數為0.2~1mm之間。

    Post Diameter支撐材的粗細,建議的參數為0.8~3mm之間。

    Density為支撐材生成的密度多寡,常用的參數為10~30。

    Base Diameter為地面底座的大小設定,2mm以上。


    2015年12月9日 星期三

    Arduino SPI 12864 OLED

    經實際測試,只要使用 Digital pin 即可
    查詢對映 SPI 是沒必要的



    文件
    網路查詢
    實際測試

    SPI 12864 OLED Arduino UNO SPI MEGA 2560 SPI MEGA 2560
    1 CS D10 SS D53 SS D31
    2 RST D8
    D50 MISO D29
    3 CD D9
    D51 MOSI D27
    4 D1 D11 MOSI D46 PWM D25
    5 D0 D13 SCK D52 SCK D23
    6 VDD 5V



    7 GND GND



    8 X




    2015年12月8日 星期二

    MPLAB

    為了解決下列問題
    試了好多東西
    更新了 IDE 從 MPLAB IDE 到 MPLAB X IDE
    試著安裝不同的 Language Toolsuite
    從 HI-TECH 之 PICC_16_9_80 到 PICC_18_9_80
    發現 PIC16F877 使用 PICC_16_9_80,PIC18F4520 使用 PICC_18_9_80
    還安裝過 mplabc18-v3.47-windows-lite-installer
    安裝 xc8-v1.35-full-install-windows-installer
    最後發現 function name 開頭使用底線造成如
    void _LcdWriteCmdHi(unsigned char cmd);


    以下是其中的一些過程,雖然對這個解決問題沒有直接幫助
    但是以後可能會用到吧!

    MPLAB 開發環境分為 MPLAB IDE 和 MPLAB X IDE

    ICD3 更新驅動程式軟體
    瀏覽電腦上的驅動程式軟體
    讓我從電腦上的裝置驅動程式清單中挑選
     for MPLAB X IDE
    C:\Program Files (x86)\Microchip\MPLABX\v3.10\Switcher\64Bit\winusb\amd64
    Microchip Tools\MicrochipWinUSB Device
     for MPLAB IDE
    C:\Program Files (x86)\Microchip\MPLAB IDE\ICD3
    Microchip Tools\Microchip Custom USB Device



    使用 MPLAB IPE 挑選 IC

    The programmer could not be started: Could not acquire hardware tool communications resources: ICD3PlatformTool SN#JIT104139330

    1. Right Click on the project > Click properties.
    2. Select ICD3 on the left side.
    3. Click the reset button on the right side.


    MPLAB X Simulator
    1. Select Simulator as the Hardware Tool1. 
    1.a Right Click on the project > Click properties.
    1.b. Click Conf:[default]
    1.c Under “Hardware Tools”, verify that Simulator is selected
    1.d Click Simulator setting Instruction Frequency(Fcyc)
    2. Setting the Simulator to start at the beginning of main() function
    2.a From the “Tools” pull down menu select “Options”
    2.b Select the Embedded icon
    2.c Select the “Generic Settings” tab
    2.d Ensure the “Debug startup” is set to ‘Halt at Main’
    3. Menu/Window/Debugging/Stopwatch

    MPLAB IDE Simulator
    1. Debugger/Select tool/MPLAB SIM
    2. Debugger/Settings
    3. Debugger/Stopwatch


    安裝 picc_18_9_80_win 使用 Lite 版
    MPLAB IDE
    選擇 Microchip C18 Toolsuite

    At safe mode of Windows 8 64bit, you could install XC8 v1.35

    MPLAB IDE
    在 Set Language Tool 中登記 Microchip XC8 Toolsuite
    regsvr32 /s "C:\Program Files (x86)\Microchip\xc8\v1.35\bin\MPLABXC8.dll"

    2015年10月22日 星期四