Skip to content
Snippets Groups Projects
README.md 9.05 KiB
Newer Older
Jingyan Ling's avatar
Jingyan Ling committed
## ENGINEERING JOURNAL
### Jingyan Ling
Jingyan Ling's avatar
Jingyan Ling committed
### 06/27/2019 (Thur)
Jingyan Ling's avatar
Jingyan Ling committed
- Compile `OldRoCo` [repo](https://git.uclalemur.com/mehtank/oldroco)
  - Record of modification:
    - ++line 8 of `vstart.sh`
    - --> `pip install -r requirements.txt --user`
- Export `paperbot` dxf file : `graph-silhouette.dxf` to `OnShape`
  - Record of Tips:
    - Onshape does not read dxf file as its own saved unit. Manual settings needed when import.
Jingyan Ling's avatar
Jingyan Ling committed
    - ![onshape_dxf_unit](journal_media/onshape_dxf_unit.png)
Jingyan Ling's avatar
Jingyan Ling committed
- Draw circuit diagram as CAD on `Onshape`
  - Multiple connection approaches:
    - `Cross` shape of `0.039 in`
    - `Cross` shape of `0.049 in`
    - `Octangular` shape of `0.049 in`
Jingyan Ling's avatar
Jingyan Ling committed
    - ![connection_approaches.png](journal_media/connection_approaches.png)
    - ![actual_connection_cuts.JPG](journal_media/actual_connection_cut.JPG)
Jingyan Ling's avatar
Jingyan Ling committed
  - Note and issue:
   - `Octangular` shape is the best connection approach so far, but none of approach has stable conductivity. More research is needed.
    - Scratches can be made easily when attaching microcontroller to the sheet. Potential disconnection may occur due to such scratches on metal layer.
- Export 2D CAD drawing with PCB to SVG for silhouette cameo 
  - Record of Tips:
    - `OnShape` unit need to be consisted with unit setting in `Inkscape` (default: mm)
  - Plugin `Inkscape-silhouette` cannot take multiple types of trace for cutting. 
Jingyan Ling's avatar
Jingyan Ling committed
    - Different trace (especially cut and etching) need to be sent separately. Use `coordinate tool` of `Inkscape` to ensure separated cuts have same origin. 
  - TODO:
    - Cut and etching from same `Inkscape` file

Jingyan Ling's avatar
Jingyan Ling committed
###  06/28/2019 (Fri)
##### Connection and fabrication approach confirmed !
Jingyan Ling's avatar
Jingyan Ling committed
- Confirm that copper tape has better conductivity than aluminum sheet when attaching microcontroller pins through `H-shape` cut
  - Copper tape is harder to be scratched, which provides less risk of disconnection during assembly.
- Etching on copper type isolates connections
  
Jingyan Ling's avatar
Jingyan Ling committed
- Research on PCB editor
  - EAGLE
    - EAGLE cannot import `.pcb` file
    - `svg` can be exported but not imported
    - Custom library needed if doing schematic design
  - KiCad
    - Can import `.pcb` file
    - `svg` can be exported but not imported
  - LayoutEditor
    - support multiply file type
    - `svg` can be exported with different color makers as multiple layers
    - include open-sourced auto-router `freerouting`
Jingyan Ling's avatar
Jingyan Ling committed
- Auto-routing package:
  - TopoR
  - Python-PCB
  - FreeRouting
Jingyan Ling's avatar
Jingyan Ling committed

Jingyan Ling's avatar
Jingyan Ling committed

- Approaches:
  - `A`. convert SVG/DXF file to schematic/board design of PCB.  Use KiCAD or EAGLE to do auto routing.
Jingyan Ling's avatar
Jingyan Ling committed
  - `B`. develop algorithm on auto routing for single layer svg/dxf file. (path finding problem)
Jingyan Ling's avatar
Jingyan Ling committed
##### Approach `A`
-  Use regular shape board for PCB in EAGLE/KiCAD
   - image processing: divide the shape of `paperbot` to multiple rectangles (ezdxf)
Jingyan Ling's avatar
Jingyan Ling committed
   
Jingyan Ling's avatar
Jingyan Ling committed
   - Pull required connections and place additional header pins around edges of each rectangle
Jingyan Ling's avatar
Jingyan Ling committed

- Make each connection pin to be two parallel connections so auto-router does parallel trace for each wiring.
Jingyan Ling's avatar
Jingyan Ling committed
  - Etching a pair of parallel trace provides isolation, and leave the space between traces to be conductible.

- Build Library for schematic design
  - Schematic design helps with router to know desired connection
Jingyan Ling's avatar
Jingyan Ling committed
  - Additional header pins at each side of kink mark

### 06/29 & 06/30/2019 (Sat & Sun)
Jingyan Ling's avatar
Jingyan Ling committed
##### Approach `B`
- Potential needed functions of packages
  
  - A package draws on DXF file through script
Jingyan Ling's avatar
Jingyan Ling committed
  - A script that pulls out pins' coordinate on paper chassis
    - Or a image process package (OpenCV) that reads pins' coordinate on paper chassis
  - A package solves multi-node path finding problem*

##### Record of Research  
Jingyan Ling's avatar
Jingyan Ling committed
- Python Pathfinding package:
  - [pathfinding](https://pypi.org/project/pathfinding/#description)
- Python DXF editor:
  - [ezdxf](https://pypi.org/project/ezdxf/)
  - [dxfgrabber](https://pypi.org/project/dxfgrabber/)
    - `Note`: able to grab simple geometry from file 
  - [sdxf](http://www.kellbot.com/sdxf-python-library-for-dxf/)
- Going through tutorials of `ezdxf`
  - All lines on paper space`layer0`

### 07/01/2019 (Mon)
- Continue the dxf processing with `'graph-silhouette.dxf'`
##### Record of tips:
  -  Put circuit design on a new layer of dxf drawing
     -  [check doc about layers here](https://ezdxf.readthedocs.io/en/latest/tutorials/layers.html)
  - Use block feature to draw similar pattern
    - [check doc about block here](https://ezdxf.readthedocs.io/en/latest/tutorials/blocks.html)
  - Blocks are `symbol` in Inkscape. Convert `symbol` to `path`
    -  Edit > Clone > Unlink Clone (Shift+Alt+D), and you have a group, ungroup (Object > Ungroup, or Shift+Ctrl+G) and edit
  - Convert `text` to `path`
    - Path combine (Ctrl+K)
  - msp.delete_enetity('__') to remove existing entity

- Test fabrication with different drawing settings
  - Layers can be cut separately by toggling visibility
  - Set cuts with same `intensity` and `feedrate` on same layer
  - Entities' layer can be changed through `Entity.dxf.layer`

### 07/02/2019 (Tue)
- Continue the dxf processing
- Following tasks can be completed by running the code:
  - Able to detect pin center coordinate
  - Able to draw arbitrary shape around the pin center
  - ![isolation_circuit.png](journal_media/isolation_circuit.gif)
  
- - Issue & TODO
  - Convert dxf image to matrix
  - Explore `pathfinding` package

  - `pathfinding` package solve path finding problem by shortest path algorithm, one point to another
  - To solve multiple nodes problem, use concept from reinforcement learning
    - Build Q function that represents total reward of choosing certain path to be solved first
    - Update Q function in a loop with certain amount of episodes   
    - Choose the order of solving paths randomly, and add possibility of choosing it from Q function
    - Exploration-exploitation method
- To solve the problem "convert dxf to matrix" for pathfinding:
  - Have tried:
    - Export to `png` and read file by `OpenCV`
      - Resolution problem: single point does not represented as a pixel in `png`
    - TODO:
      - create an empty matrix and fill in numbers with the information of each lines' start and end point
### 07/03/2019 (Wed)
- dxf processing completed

- Convert dxf to matrix with resolution (270X210) (mm)
  - Potential issue:
    - the `pathfinding` package is based on pixel 
    - When round up the line's start and end point, the accuracy of pin position is low

- Apply single point to point path finding
  - Able to draw the path on matrix
  - Able to draw the path on original dxf file
Jingyan Ling's avatar
Jingyan Ling committed
- ![matrix](journal_media/matrix_to_img.png)
Jingyan Ling's avatar
Jingyan Ling committed
  - Write out algorithm for multi-node path finding 
  - break single circuit trace to parallel traces
Jingyan Ling's avatar
Jingyan Ling committed
  - solve the accuracy problem

### 07/05/2019 (Fri)
Jingyan Ling's avatar
Jingyan Ling committed
- Write out algorithm for multi-node path finding 
  - pseudo code:
Jingyan Ling's avatar
Jingyan Ling committed
  	
~~~~
 for (episode in E):
    set initial state s (choose first pair of nodes to connect randomly)
    while not every connection is built:
      choose next connection
      find a path 
      update matrix
      retrieve cost (length of path)
    update Q (as sum of all cost)  
	
~~~~  
  - Q here represents total cost of certain choice of path finding order.
    - Cost defined by length of path
Jingyan Ling's avatar
Jingyan Ling committed
    - If path cannot be found, cost 1000
  - Input: NX2X2 array specifies desired pin connections
Jingyan Ling's avatar
Jingyan Ling committed
  
Jingyan Ling's avatar
Jingyan Ling committed

- Research on KiCAD import needs and python API

### 07/08/2019 (Mon)

- Debug multi-node path finding:
  - some obstacles are ignored
  - too close to each other
- Able to show the learning process:
  - Trying different combination of solving order
  - Try to give the best order of solving multiple path
##### Auto-routing learning process:
  - ![path_learning.gif](journal_media/path_learning.gif)

- Comparison between episodes and choose best combo of paths
- ![learning_episodes.gif](journal_media/learning_episodes.gif)

##### Issues and TODO
- Path export from optimization is messed up
- Obstacles setting are incorrect

### 07/09/2019
- Finish up path-finding approach (Approach B)
- Only draw the best path on `dxf` when solution is found for every route.
- ![circuit_dxf](journal_media/dxf_circuit.png)
- Throw warning once a route cannot be found
- ![fail_solution](journal_media/path_fail.gif)

- Research on Approach A
  - KiCAD 5 does not have built-in auto-router
    - Have to use `FreeRouting`

  - `FreeRouting` does not have python API
  - Parent package of `FreeRouting`, `LayoutEditor` has multiple editions
    - Part of `LayoutEditor` is open- source
    - A large amount of of its website are broken, source and interface are unavailable

- Other auto-routers are not open-source

##### Approach A
- 1. Use `LayoutEditor` python API to use `FreeRouting`
- 2. Use `KiCAD 5` python API to sue `FreeRouting` 
- 3. Use `KiCAD 4` python API to use builtin auto-routing

Jingyan Ling's avatar
Jingyan Ling committed
###### 1 
- `FreeRouting` input format: `dsn`, `lef`, `def`
- `FreeRouting` output format: `ses`, `def`
- `FreeRouting` can take arbitrary board outlines shape
Jingyan Ling's avatar
Jingyan Ling committed

- Edit `library` manually and test routing
- ![dxf_import](journal_media/dxf_import_kicad.png)

- TODO:
  - If can run KiCAD 4 from python
  - Check `FreeRouting` API, see if a acceptable file can be generated from things on hand