由於在下最近正在學習 Arduino 及 電子元件控制 ,因此經常使用 Fritzing 來協助設計原型
偶然預到需要使用元件 Fritzing 卻沒有相對元件時,在下都會嘗試到 Fritzing 社群尋找元件原型
但仍會找不到,最後還是要靠自己……
元件結構
Fritzing 的元件原型主要是由 1個 FZP 檔案 及 4個 SVG 檔案 組成FZP 及 SVG 分別是 Fritzing Part File 及 Scalable Vector Graphics
兩種檔案實際都是一種 XML 檔案,因此可以使用 純文字編輯軟件 製作,沒有製作限制
FZP 是 元件原型 的 元資料 及 設定資料
4個 SVG 分別是設計 元件原型 的 預覽圖像 (Icon) 、 麵包板圖像 (Breadboard) 、 概要圖像 (Schematic) 、 印刷電路板圖像 (PCB)
5個檔案都有一些命名要求
- FZP 為 part.filename.fzp
- 預覽圖像 為 svg.icon.filename.svg
- 麵包板圖像 為 svg.breadboard.filename.svg
- 概要圖像 為 svg.schematic.filename.svg
- 印刷電路板圖像 為 svg.pcb.filename.svg
預覽圖像檔案結構
svg標籤 後先建立 g標籤 並指定 id 為 icon結構沒有特別要求,基本圖像資料即可
1 2 3 4 5 6 | <? xml version = "1.0" encoding = "UTF-8" ?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> < svg xmlns = "http://www.w3.org/2000/svg" version = "1.2" width = "1in" height = "1in" viewBox = "0 0 100 100" > < g id = "icon" > </ g > </ svg > |
麵包板圖像檔案結構
svg標籤 後先建立 g標籤 並指定 id 為 breadboard如果 元件原型 有 引腳 或 引腳座 作為連接用途,可以將指定 SVG元素 設定 id
(id 不一定 connector-0-pin 或 connector-0-terminal ,只是清楚 元素用途)
1 2 3 4 5 6 7 8 | <? xml version = "1.0" encoding = "UTF-8" ?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> < svg xmlns = "http://www.w3.org/2000/svg" version = "1.2" width = "1in" height = "1in" viewBox = "0 0 100 100" > < g id = "breadboard" > < circle file = "none" id = "connector-0-pin" cx = "50" cy = "50" r = "5" /> < circle file = "none" id = "connector-0-terminal" cx = "50" cy = "50" r = "5" /> </ g > </ svg > |
概要圖像檔案結構
svg標籤 後先建立 g標籤 並指定 id 為 schematic如果 元件原型 有 引腳 或 引腳座 作為連接用途,可以將指定 SVG元素 設定 id
(id 不一定 connector-0-pin 或 connector-0-terminal ,只是清楚 元素用途)
1 2 3 4 5 6 7 8 | <? xml version = "1.0" encoding = "UTF-8" ?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> < svg xmlns = "http://www.w3.org/2000/svg" version = "1.2" width = "1in" height = "1in" viewBox = "0 0 100 100" > < g id = "schematic" > < circle file = "none" id = "connector-0-pin" cx = "50" cy = "50" r = "5" /> < circle file = "none" id = "connector-0-terminal" cx = "50" cy = "50" r = "5" /> </ g > </ svg > |
印刷電線板檔案結構
svg標籤 後先建立 g標籤 並指定 id 為 silkscreen 表示絲印圖案, copper0 及 copper1 表示銅板圖案正式印製 印刷電路板 時, silkscreen 會成為 印刷電路板 的絲印圖案, copper0 及 copper2 會成為銅板電路
如果 元件原型 有 引腳 或 引腳座 作為連接用途,可以將指定 SVG元素 設定 id
(id 不一定 connector-0-pad ,只是清楚 元素用途)
1 2 3 4 5 6 7 8 9 10 11 12 | <? xml version = "1.0" encoding = "UTF-8" ?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> < svg xmlns = "http://www.w3.org/2000/svg" version = "1.2" width = "1in" height = "1in" viewBox = "0 0 100 100" > < g id = "silkscreen" > < rect file = "none" x = "5" y = "5" width = "90" height = "90" /> </ g > < g id = "copper0" > < g id = "copper1" > < circle file = "none" id = "connector-0-pad" cx = "50" cy = "50" r = "5" /> </ g > </ g > </ svg > |
由於 Fritzing 主要以 英寸 計算,以麵包板為例,引腳孔之間的距離為 0.1英寸
當製作 SVG圖像 時,設定 闊 及 高 時,可以指定使用 英寸 為作單為,可以方便設計
顯示畫面與尺寸的比例為 100比1 ,即是當設定 闊 是 1英寸 時 顯示畫面 闊 應該是 100 ,可以使用 viewBox 控制
1 2 3 4 5 | < svg xmlns = "http://www.w3.org/2000/svg" version = "1.2" width = "1in" height = "1in" viewBox = "0 0 100 100" > . . . </ svg > |
FZP檔案結構
FZP 設定 元件原型 的 元資料示對應 SVG檔案 為 預覽圖像 、 麵包板圖像 、 概要圖像 、 印刷電線板
及 連接用的 引腳 、 引腳座 、 焊接通孔
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | <? xml version = "1.0" encoding = "UTF-8" ?> <!-- moduleId 是 Fritzing 元件模組 的 唯一識別碼,不能重覆 --> < module moduleId = "unique-module-id" > < views > < iconView > <!-- 預覽圖像檔案的位置, icon/... 為指向 Fritzing 元件目錄 的 相路路徑 --> < layers image = "icon/filename.svg" > <!-- 載入顯示 預覽圖像元件 的 ID --> < layer layerId = "icon" /> </ layers > </ iconView > < breadboardView > <!-- 麵包板圖像檔案的位置, breadboard/... 為指向 Fritzing 元件目錄 的 相路路徑 --> < layers image = "breadboard/filename.svg" > <!-- 載入顯示 麵包板圖像元件 的 ID --> < layer layerId = "breadboard" /> </ layers > </ breadboardView > < schematicView > <!-- 概要圖像檔案的位置, schematic/... 為指向 Fritzing 元件目錄 的 相路路徑 --> < layers image = "schematic/filename.svg" > <!-- 載入顯示 概要圖像元件 的 ID --> < layer layerId = "schematic" /> </ layers > </ schematicView > < pcbView > <!-- 印刷電線板圖像檔案的位置, pcb/... 為指向 Fritzing 元件目錄 的 相路路徑 --> < layers image = "pcb/filename.svg" > <!-- 載入顯示 印刷電線板圖像元件 的 ID --> < layer layerId = "copper0" /> < layer layerId = "silkscreen" /> < layer layerId = "copper1" /> </ layers > </ pcbView > </ views > < connectors > <!-- id 為 連接器的 ID --> <!-- name 為 連接器的 名稱 --> <!-- type 為 連接器的 類型, male 為 插頭, female 為 插孔 --> < connector id = "connector-0" name = "Pin 0" type = "male" > <!-- 連接器 的 描述內容 --> < description >Pin 0</ description > < views > < breadboardView > <!-- svgId 為 連接器 的 ID --> <!-- terminalId 為 連接器終端 的 ID ,當指示 svgId 連接時會以 terminalID 為連接點 --> <!-- legId 為 連接器引腳 的 ID ,可以改變引腳的位置, terminalId 的位置會相對改變 --> <!-- layer 為 /module/views/breadboardView/layers/layerId --> < p svgId = "connector-0-pin" terminalId = "connector-0-terminal" layer = "breadboard" /> </ breadboardView > < schematicView > <!-- svgId 為 連接器 的 ID --> <!-- terminalId 為 連接器終端 的 ID ,當指示 svgId 連接時會以 terminalID 為連接點 --> <!-- legId 為 連接器引腳 的 ID ,可以改變引腳的位置, terminalId 的位置會相對改變 --> <!-- layer 為 /module/views/breadboardView/layers/layerId --> < p svgId = "connector-0-pin" terminalId = "connector-0-terminal" layer = "schematic" /> </ schematicView > < pcbView > <!-- svgId 為 連接器 的 ID --> <!-- terminalId 為 連接器終端 的 ID ,當指示 svgId 連接時會以 terminalID 為連接點 --> <!-- legId 為 連接器引腳 的 ID ,可以改變引腳的位置, terminalId 的位置會相對改變 --> <!-- layer 為 /module/views/breadboardView/layers/layerId --> < p svgId = "connector-0-pad" layer = "copper0" /> < p svgId = "connector-0-pad" layer = "copper1" /> </ pcbView > </ views > </ connector > </ connectors > </ module > |
除了以上基本設定,還可以加入下列資料,讓元件原型的內容選擇項更加清晰
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | <!-- fritzingVersion 為 最低版本要求 --> < module fritzingVersion = "0.0.1" moduleId = "unique-module-id" > <!-- 元件版本 --> < version >1</ version > <!-- 作者名稱 --> < author >HKGoldenMr.A</ author > <!-- 元件名稱 --> < title >LED</ title > <!-- 元件標籤,會在 概要圖像 、 印刷電線板 顯示 --> < label >LED</ label > <!-- 製作日期 --> < date >2020-03-11</ date > < tags > <!-- 分類標櫼 --> < tag >THT</ tag > < tag >LED</ tag > </ tags > < properties > <!-- 屬性資料,方便相同屬性的元件隨時切換 --> <!-- name 為屬性名稱,沒有限制 --> <!-- 內容 為屬性值,沒有限制 --> < property name = "color" >Red</ property > < property name = "family" >LED</ property > < property name = "package" >THT</ property > < property name = "size" >5mm</ property > </ properties > <!-- <views> . . . </views> <connectors> . . . </connectors> --> </ module > |
匯入元件

Fritzing 能匯入 FZPZ檔案
在 Parts 分頁按滑鼠右鍵,並選擇 Import

FZPZ檔案 實際是一個 ZIP檔案 ,當以上檔案製作完成後,將 5個檔案 壓縮成 ZIP檔案 ,再修改副案名為 FZPZ檔案 即可

麵包板界面顯示

概要界面顯示

印刷電線板界面顯示

如果要保留元件,結束 Fritzing 前需要儲存元件設定

如果要保留元件在匯入的版面同樣需要儲存
總結
製作 SVG圖像 有很多方法,如果製作的元件只是直線、圓形、文字等簡單圖案,在下比較喜歡使用純文字編輯軟件製作,資料比較準確重覆使用的 SVG元素 亦可以使用 XML命名空間 (XML Namespace) 來減低文件體積,(在下認為)修改時亦比較簡單
但如果圖像涉及比較複雜的圖案,使用圖像編輯軟件則比較方便,例如 Inkscape
沒有留言 :
張貼留言