2016年12月11日 星期日

機電整合[作業解答]

第1章 4 5 6 7 8
第3章 8 11 12 25 27
第4章 15 27 29 32 35
第5章 12 23 33 35 49

1.4
Identify the following as open- or closed-loop control.
a.Controlling the water height in a toilet tank
b.Actuation of street lights at 6 P.M.
c.Stopping a clothes dryer when the clothes are dry
d.Actuation of an ice maker when the supply of cubes is low
識別以下作為開迴路或閉迴路控制。
a.控制馬桶水箱中的水高度
答;開迴路,通常是用水閥控制,系統不會知道現在的水位多少
b.在6:00 PM時路燈的點亮
答:開迴路,系統不會知道燈是否已經正確點亮,僅執行點亮的動作
c.當衣物乾燥時打開乾衣機
答:開迴路,乾衣機並不知道是否真的乾衣即打開
d.當製冰機的模具中的感測元件處於LOW的時候供水
答:閉迴路,因為有感測元件提供系統是否供水


1.5
A potentiometer has a transfer function of 0.1 V/deg. 
Find the pot’s output if theinput is 45°. 
電位器具有0.1V / deg的轉換函數。 如果輸入為45°,則找出其輸出。
答 : TF = output / input , 0.1 = 45 / input ,input = 450 v

1.6
A potentiometer has a transfer function of 0.05 V/deg. 
Find the pot’s output if theinput is 89°.
電位器具有0.05V / deg的轉換函數。 如果輸入為89°,則找出其輸出。
答 : TF = output / input , 0.05 = 89 / input ,input = 445 v

1.7
A motor was measured to rotate (unloaded) at 500 rpm with a 6-V input and 1000 rpm with a 12-V input. What is the transfer function (steady state) for the unloaded motor? 
測量電動機(卸載)在6V輸入下旋轉500rpm,以12V輸入旋轉1000rpm。 空載下此電動機的轉換函數(穩態)是什麼?
答:TF = output/input,6v * TF = 500rpm,12v * TF =1000rpm,TF = 83 rpm/v

1.8
in a certain system, an electric heating element was found to increase the temper-ature of a piece of metal 10° for each ampere of current. The metal expands 0.001in./deg and pushes on a load sensor which outputs 1 V/0.005 in. of compression.
a.Find the transfer functions of the three components and draw the block diagram.
b.Calculate the overall transfer function of this system.

在某個系統中,某個電加熱元件對每安培電流增加溫度10°。 此金屬片係數0.001in./deg,且傳輸每 1 V / 0.005 in.到負載感測器。
a。查找三個組件的傳遞函數並繪製框圖。
b。計算此系統的總轉換函數。

答:
TF = 0.1A/10°C * 0.001 in./deg * 200 v/in. = 0.02 v/A

第2章 7 8 10 12 14 18
2.7
A certain microprocessor has a simple instruction set shown below.
INSTRUCTION SET
Op-codeExplanation
76           Halt the microprocessor.
C6*        Add next byte to accumulator.
D6*        Subract next byte from accumulator.
3C          Increment the accumulator.
3D          Decrement the accumulator.
3E*        Move the next byte into the accumulator.
*These instructions use two bytes.
What number would be in the accumulator after the program shown below was run?
Address          Op-code
001                 3E
002                 05
003                 D6
004                 02
005                 3C
006                 76
某個微處理器具有如下所示的簡單指令集。
指令集
76           停止微處理器。
C6            *將下一個字節添加到累加器。
D6            *從累加器下拉字節。
3C           增加累加器。
3D           減少累加器。
3E            *將下一個字節移入累加器。
*這些指令使用兩個字節。
在下面顯示的程序運行後,累加器中會有什麼數字?
答:  05 >> 03 >> 04

2.8
Temperature values from –20°F to 120°F are input data for a microprocessor com-puter.
Are 8 bits sufficient? If so, what is the resolution?
從-20°F到120°F的溫度值是微處理器計算機的輸入數據。 8位元是否足夠?
如果是,分辨率是多少?
答 : 8bit = 1~255,所以-20~120是足夠的,也就是0.549°
如果機械需要,設定為1°也是可以的。

2.10
Serial data are sent at 1200 bps using the format of Figure 2.11,
with one stop bit.How long would it take to send 1000 bytes of data?
串行數據以1200 bps使用圖2.11的格式發送,帶有一個停止位元。
發送1000字節的數據需要多長時間?
答: 1200 / [1000/8*9] = 0.88s

2.12
The binary data from the computer in a certain application are expected
to go from00000000 to only 00111111. These data are the input of a DAC.
The analog outputshould go 0-5 V. Find the DAC reference voltage
necessary to make this happen.
在二進位系統中從00000000到00111111.
這些數據是DAC的輸入。 模擬輸出應為0-5 V。
找到使此發生所必需的DAC參考電壓。
答: 0-5 = 63 * Verf / 256
Verf = 0-20V
2.14
The binary output of an ADC should have the range 00000000-11111111
corre-sponding to an input of 0-6 V. Find the necessary reference voltage.
ADC的二進制輸出應該具有範圍00000000-11111111,
對應於0-6 V的輸入。找到必要的參考電壓。
答: 0-6 = 256 * Verf/256
Verf = 0-6V
2.18
A program contains 150 instructions, and the average execution time
per instruc-tion is 2 μs. Find the sample rate of this program.
程序包含150個指令,每條指令的平均執行時間為2μs。
查找此程序的採樣率。
答:1/2μs=0.5Msps

第3章 8 11 12 25 27




2016年10月12日 星期三

2016 電腦視覺筆記

10/12 電腦視覺 筆記 p.29
V translate scaling rotate
V* = R ( S ( TV ) )
處理順序 >
Geometric Transforms
input > 特殊轉換 > 灰階內差 > output
 灰階內差
1. 找四點中最近的 (會有問題)
2.加起來平均值 (會有問題)
3.在用一次Bildinear  translate (比較不會有問題)

CH 4 image enhancement
spatial domain (數學簡單)
frequency damain (富麗葉) : 影像分析 (警察鑑識科 , 太空科學家)

增強一點,但附近也會影響
因為影像有很高的Correlation (相關性)
人為影像 vs 自然影像
這個狀況稱之為 Filtering (濾波)

例如 : 相對應的係數 乘 三乘三的象素
除了這個狀況以外 通稱為non-linear spatial filtering(非線性濾波)

>n變得更亮  <n變的更黑
這種濾波稱為 binart image

power-law  transformations(幂次方)
以前的東西
Compression of Dynamic Range(對比度/動態範圍  壓縮)
強度越大 壓越大 強度越小 壓越小
T(r) = clog( 1 + | r | ) 數值大的必須用到log
手機相機加了太多自動化的東西
要求出c多少 才能壓縮成可以用

gray-level slicing
提高 A 到 B 之間的灰階
bit-plane slicing
8bit > 因式分解 > b0~b7

比如象素 10001001
=             b76543210
             MSB        LSB
   最重要位元         最不重要位元

壓縮 >  把 b0 - b3 去掉

histogram processing
統計長方圖 : 例如統計灰階
可以預測影像的亮度變化

high contrast = Dynamic Range

histogram Equalization (研究生才說明的)

discrete histogram equalization (離散 直方圖)


2016年10月11日 星期二

2016 機電整合筆記

10/12 第三次上課
上禮拜講過開迴路/閉迴路
區別類比控制/數位控制

Feedback會加入Sensor( 感測器 )
通常會加入ADC在control裡面 (類比轉數位)
TF (非時變穩態轉移函式) > 增益(gain)
ex1.4 0.01V/deg

補充 : 並列傳輸,8 bit 並列 > UART(串轉並or並轉串)
串列傳輸 優:距離傳輸較長      
     缺:傳輸速度較慢
並列傳輸 優:距離距離較短      
     缺:傳輸速度較快

早期印表機 > 線越長干擾越大
串列傳輸只需要 2 條線
電話線 > 數位訊號 > MODEM


in >>> O >>> G >>> Out
↑                                   ↓
↑                                   ↓
<<<<          H          <<<

TF = G/(1+GH)
(X - HY ) G = Y
GX - GHY = Y)
Y/X = G / (1+GH) = TF
馬達的轉數跟紐力成反比
要分析系統 > 分開成系統(define and counter) >

1.2 類比與數位控制系統

類比 > face out
MP == CPU (ALU(Arithmetic Logic Unit)
+ A-Register(暫存器)
+ Control Unit
+ PC(progrem conter)
von Neumann > 當progrem跟data都放在ram當中

補充 : GPS計算 > 經緯度計算 > 串列傳輸 > 對稱 or 非對稱

伺服系統
太陽能 > 追光系統
夾距 (尾端工具) 不算軸
機器手臂 > 6軸 (>6可以避障)

Chaoter 2
可编程序控制器(Programmable Logic Controller,简称PLC)
RAM ROM
ADRESS
     1.adress bus
     2.data bus
     3.control bus
64位元CPU是指CPU內部的data bus的寬度為64位元

Number system
    1. positional number system ex 123 = 一百二十三
           a.signed
           b.unsigned
                  *inteagen
                  *real
    2. non - positional number system ex 羅馬數字

超碼 127
超碼 1023

http://w3.iams.sinica.edu.tw/lab/wbtzeng/labtech/roman_number.htm
EX 2.1

2016年9月23日 星期五

visual studio 環境架設 boost c++ libraries

作業系統 : windows 7 sp1 x64

編譯程式 : visual C++ 12.0 (使用 visual studio 2013)

1.首先到boost的官網下載最新的lib,並解壓縮到C:\Boost Library\
 http://www.boost.org/users/download/
筆者使用的版本是 boost_1_61_0

2.然後前往這個位址
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts
使用系統管理員權限執行
VS2013 x64 Cross Tools 命令提示字元

3.執行指令
bootstrap
生成b2.exe後
b2.exe -j8 address-model=64 link=static threading=multi toolset=msvc-12.0 variant=release stage

-j8用8核心
address-model=64 在64位元指定
link=static在./static的資料夾下編譯lib檔多核心運算
threading=multi多核心運算
toolset=msvc-12.0 Visual C++ 12板,可參考https://en.wikipedia.org/wiki/Visual_C%2B%2B
這個步驟會花比較多一點的時間 大概30分鐘左右

4.然後我們建立一個專案輸入程式
#include <boost/lambda/lambda.hpp>
#include <iostream>
#include <iterator>
#include <algorithm>

int main()
{
using namespace boost::lambda;
typedef std::istream_iterator<int> in;

std::for_each(
in(std::cin), in(), std::cout << (_1 * 3) << " ");
}

5.對著專案名稱按滑鼠右鍵

左邊點選VC++ Directories 
include Directories 的地方輸入C:\Boost Library\boost_1_61_0
Library Directories 則輸入 C:\Boost Library\boost_1_61_0\stage\lib
PS : 不能直接鍵入 要用資料夾的方式瀏覽路徑
完成後如上圖所示

6.
左邊點選Linker
Additional Library Directoris的地方輸入 C:\Boost Library\boost_1_61_0\stage\lib

7.


左邊選擇Precompiled Headers
Percompiled Hearder的地方選擇Not Using Precompiled Headers

8.執行並編譯程式 成功







參考
http://www.boost.org/doc/libs/1_60_0/doc/html/bbv2/reference.html
http://www.boost.org/doc/libs/1_60_0/more/getting_started/windows.html
https://www.ptt.cc/bbs/Windows/M.1242287062.A.27C.html
https://msdn.microsoft.com/en-us/library/8f8h5cxt.aspx
https://www.ptt.cc/bbs/C_and_CPP/M.1455637005.A.3C0.html
http://littlej1990.blogspot.tw/2015/05/boost-c-library.html

2014年5月13日 星期二

DEBUG - DEBMIRROR

DebianSOURCE=ftp://ftp.tw.debian.org
DIST_SOURCE=$DebianSOURCE/debian/dists
POOL_SOURCE=$DebianSOURCE/debian/pool

DIST_DEST=/mnt/dists
POOL_DEST=/mnt/pool

#dd if=/dev/zero of=deb_mirror.img bs=2G count=1

#mkfs.ext4 deb_mirror.img

#mount deb_mirror.img /mnt

#mount /opt/iso/debian-7.2.0-amd64-netinst.iso /media

#cp -av /media/* /mnt

#cd /mnt/dists

for i in `echo squeeze wheezy wheezy-updates jessie oldstable stable testing unstable sid`; do

wget -N $DIST_SOURCE/$i/Release -P $DIST_DEST/$i
wget -N $DIST_SOURCE/$i/Release.gpg -P $DIST_DEST/$i

done

wget -N $DIST_SOURCE/wheezy/main/binary-amd64/Packages.gz -P $DIST_DEST/wheezy/main/binary-amd64/
wget -N $DIST_SOURCE/wheezy/main/binary-amd64/Packages.bz2 -P $DIST_DEST/wheezy/main/binary-amd64/
----------------
 這一行有問題
wget -N $DIST_SOURCE/wheezy/main/binary-amd64/Packages -P $DIST_DEST/wheezy/main/binary-amd64/
----------------
wget -N $DIST_SOURCE/wheezy/main/debian-installer/binary-amd64/Packages.gz -P $DIST_DEST/wheezy/main/debian-installer/binary-amd64/
wget -N $DIST_SOURCE/wheezy/main/debian-installer/binary-amd64/Packages.bz2 -P $DIST_DEST/wheezy/main/debian-installer/binary-amd64/
wget -N $DIST_SOURCE/wheezy/main/debian-installer/binary-amd64/Packages -P $DIST_DEST/wheezy/main/debian-installer/binary-amd64/

# Grab Missing files

for i in `cat filelist.txt`;do
wget -N $POOL_SOURCE/main/l/linux/$i -P $POOL_DEST/main/l/linux/
done


wget -N $POOL_SOURCE/main/p/pcre3/libpcre3-udeb_8.30-5_amd64.udeb \
       -P $POOL_DEST/main/p/pcre3/
wget -N $POOL_SOURCE/main/i/ispell/ispell_3.3.02-6_amd64.deb \
       -P $POOL_DEST/main/i/ispell/
wget -N $POOL_SOURCE/main/i/ispell/ienglish-common_3.3.02-6_all.deb \
       -P $POOL_DEST/main/i/ispell/
wget -N $POOL_SOURCE/main/i/ispell/iamerican_3.3.02-6_all.deb \
       -P $POOL_DEST/main/i/ispell/
wget -N $POOL_SOURCE/main/i/ispell/ibritish_3.3.02-6_all.deb \
       -P $POOL_DEST/main/i/ispell/
wget -N $POOL_SOURCE/main/t/tasksel/task-english_3.14.1_all.deb \
       -P $POOL_DEST/main/t/tasksel/
wget -N $POOL_SOURCE/main/t/tasksel/task-chinese-t_3.14.1_all.deb \
       -P $POOL_DEST/main/t/tasksel/
wget -N $POOL_SOURCE/main/u/unicon/unicon-imc2_3.0.4-13_amd64.deb \
       -P $POOL_DEST/main/u/unicon/
wget -N $POOL_SOURCE/main/u/util-linux/util-linux-locales_2.20.1-5.3_all.deb \
       -P $POOL_DEST/main/u/util-linux/
wget -N $POOL_SOURCE/main/z/zhcon/zhcon_0.2.6-10_amd64.deb \
      -P $POOL_DEST/main/z/zhcon/

wget -N -nH -m $DIST_SOURCE/wheezy-updates/main/i18n -P /mnt
wget -N -nH -m $DIST_SOURCE/wheezy/main/source -P /mnt
wget -N -nH -m $DIST_SOURCE/wheezy-updates/main/binary-amd64 -P /mnt


#http://ftp.tw.debian.org/debian/pool/main/e/eglibc/libc6-udeb_2.13-38_amd64.udeb





2014年5月8日 星期四

test

所有的relles要改成666

chmod 666 /var/www/debian/dists/jessie/Release
chmod 666 /var/www/debian/dissts/sid/Release
chmod 666 /var/www/debian/dists/squeeze/Releasechmod 666 /var/www/debian/dists/wheezy/Release


desktop下執行

mkdir -p /mnt/dists/wheezy/main/binary-amd64/

wget -P /mnt/dists/wheezy/main/binary-amd64/ ftp://ftp.debian.org/debian/dists/wheezy/main/binary-amd64/Release

wget -P /mnt/dists/wheezy ftp://ftp.debian.org/debian/dists/wheezy/Release.gpg

<附錄> wget 參數

# -t0: 設定重試次數。當連結中斷或超時,wget會重新連接。-t0代表把重試次數設為無窮多。
# -c:  設定續傳功能。
# -nH: 不建立該網站名稱的子目錄 /example.com/,而直接在當前目錄下建立鏡像的目錄結構。
# -np: 不遍歷父目錄,如果有連結連到目標資料夾的parent或其他目錄,不下載。
# -m:  鏡像,相當同時使用-r和-N。
# -r:  遞迴下載,把文件中所有的連結都下載回來。
# -N:  下載時檢查timestamp,只下載有更新的文件,如果檔案大小和最修改日期都一樣就不下載。
# -P:  指定下載到本機的某個目錄下