Airbag crash data reset

After a collision and the airbags are deployed, the airbag controller stores information such as speed, RPM, seat belt, accelerometer, pre-tensioner that can be used for investigation. These crash data need to be replaced, if the vehicle is rebuilt. Otherwise the airbag light will stay solid and the vehicle might not perform correctly. The crash data is stores in the EEPROM chip, which can be read/write via a cheap programmer. A virgin data is copied from another vehicle's controller, which then will be used to replaced the crash data inside the EEPROM.

/pic/airbag/L56R_EEPROM.jpg

L56R EEPROM

The closest datasheet to the L56R EEPROM I found was BR93L56F, the Microwire BUS 2Kbit(128x16bit) EEPROM.

/pic/airbag/Pin_configurations.PNG

Pin configurations

The programmer is MiniPro TL866A from Aliexpress. Reading the EEPROM in circuit using SOP8 clip was not successful even the crystal was shorted out. So the EEPROM has to be removed from the board to be able to read/write with the SOP8 socket.

/pic/airbag/programer.jpg

The programmer with SOP8 socket

The virgin data is copied from the good EEPROM and replaced into the bad EEPROM.

/pic/airbag/good-bad-board.jpg

Copying good data to replace crash data.

Connect the programmer to a computer and open the software MiniPro Programmer. Select IC the click Read

/pic/airbag/MiniPro.PNG

Select IC and Read

Successfully reading the EEPROM from the good board.

/pic/airbag/MiniPro_Read.PNG

Read success

Read several time to make sure the read data is correct. Insert the bad EEPROM to the programmer and click Program

/pic/airbag/MiniPro_Data.PNG

Good data ready for writing into bad EEPROM

Programming successful!! Read data back to verify the data is all correct. Install the EEPROM back to the board

/pic/airbag/MiniPro_Write.PNG

Programming successful

After installing the controller back to the vehicle, the airbag light should now turned off.

Adding an existing project to GitHub

  1. Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub.

  2. Initialize the local directory as a Git repository.:

    git init
    
  3. Add the files in your new local repository. This stages them for the first commit. '.' means all files:

    git add .
    
  4. Commit the files that you've staged in your local repository.:

    git commit -m "First commit"
    
  5. add the URL for the remote repository where your local repository will be pushed.:

    git remote add origin remote repository URL
    git remote -v
    
  6. Push the changes in your local repository to GitHub.:

    git push origin master
    

My github workflow

Select branch e.g. master branch. the current branch is called HEAD:

git checkout master

check HEAD:

cat .git/HEAD

modify the code then commit:

git commit -m "leave some note here"

we might want to undo commit:

git reset --hard HEAD~1

or undo to specified commit:

git reset --hard commit_sha

check your local branch with the remote:

git status

push the local commits to remote branch e.g. remote name "origin", branch name "master":

git push origin master

more common command check:

git help everyday

grep searches for PATTERN.

grep searches for PATTERN in each FILE. A FILE of “-” stands for standard input. If no FILE is given, recursive searches examine the working directory, and nonrecursive searches read standard input. By default, grep prints the matching lines.:

grep -rnw '/path/to/somewhere/' -e 'pattern'
  • -r or -R is recursive,
  • -n is line number, and
  • -w stands for match the whole word.
  • -l (lower-case L) can be added to just give the file name of matching files.

Along with these, --exclude, --include, --exclude-dir flags could be used for efficient searching.

  • This will only search through those files which have .c or .h extensions:

    grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
    
  • This will exclude searching all the files ending with .o extension:

    grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"
    
  • For directories it's possible to exclude a particular directory(ies) through --exclude-dirDocuments parameter. For example, this will exclude the dirs dir1/, dir2/ and all of them matching .dst/:

    grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"
    

For more options check man grep.


References

rakib_

Github Fork, Sync Fork

Fork

In the top-right corner of the page, click Fork. That's it! Now, you have a fork of the original repository. You can now modified your fork without effecting the original repo. New commits from the main repo won't effect your fork. You need to manually sync your fork with the original repo.

Sync Fork

Create a local clone of your fork:

git clone https://github.com/YOUR-USERNAME/YOUR-FORK.git

sync your fork with the original repository:

git remote -v
git remote add upstream https://github.com/ORIGINAL-OWNER/ORIGINAL-REPO.git
git remote -v
git fetch upstream

Check out your fork's local branch.:

git checkout edge

Merge the changes from upstream/edge into your local edge branch. This brings your fork's edge branch into sync with the upstream repository, without losing your local changes.:

git merge upstream/edge

push commits made on your local branch to a remote repository.:

git push  <REMOTENAME> <BRANCHNAME>

As an example, you usually run git push origin edge to push your local changes to your online repository.


Double-sided PCB milling

Export Gerber files from Eagle

From your pcb eagle's project, open your board. Then export Gerber files following these 4 steps. Make sure you are working on Metric unit. We need to unselect cutouts as they are included in Excellon file already. Unzip your output file. That's it we are done with Eagle.

export gerber.

Eagle export Gerber.

CAM process with Flatcam

Previous post Flatcam installing . Today, I'll show you the process of making 2-layer PCB.

Configuring the project

Trailing Zeros

Eagle uses Trailing Zeros in its Excellon number format but does not properly report this format in the Excellon file. To tell FlatCAM to use this format by default set this system option excellon_zeros to T by using the set_sys command in the Shell Command Line Interface as shown below:

set_sys excellon_zero T

Note

2018-05-18 : Current Flatcam source is having problem with this command. If need this functionality, use stable version.

System unit

From options tab, select Units as mm.

Units: mm

Units: mm

Create mirror axis and alignment pins

Tip

Each object can be moved to arbitrary location. Select object and go to selected tab then find offset tool.

Load Gerber files:

copper_top.gbr
copper_bottom.gbr
soldermask_top.gbr
soldermask_bottom.gbr
profile.gbr

Load Excellon file:

drills.xln

Mirror axis for bottom layer stuff, from menu bar, Tool -> Double-sided PCB Tool. Create mirror axis around Y axis at location x = 50 mm:

Mirror Axis: Y
Axis Location: Point
Point/Box: (50,0)

Mirror bottom layer objects one by one from the drop-down menu and click "Mirror Object":

copper_bottom.gbr
soldermask_bottom.gbr
profile.gbr
drills.xln

Alignment Holes help align the pcb when we flip it over. Create holes with 6 mm in diameter at desired locations. Then click "Create Alignment Drill":

Alignment Holes: (110, -5),(110, 60)
Drill diam: 6

You can generate gcode to cut Alignment Holes following similar process of the next section below. You can skip this for now and do it later.

flatcam

Double-sided PCB Tool

Top-side non-copper area

Hide all other layer except copper_top.gbr. Select this object then navigate to "Non-copper regions" section and generate geometry:

Boundary Margin: 0.1

New geometry "copper_top.gbr_noncopper" is created. Navigate to "Paint Area" and generate paint area:

Tool dia:  0.1
Overlap:   0.05
Margin:    0.1
Method:    standard
Connect:   yes
Contour:   yes
Selection: All

New geometry "copper_top.gbr_noncopper_paint" is created. Navigate to "Create CNC Job" and generate toolpath:

Cut Z:        -0.05
Travel Z:      1.0
Feed Rate:     250.0
Tool dia:      0.1
Spindle speed: 24,000
Multi-Depth:   No

New geometry "copper_top.gbr_noncopper_paint_cnc" is created. Navigate to "Export G-Code" and export gcode.

Top-side isolation

Select "copper_top.gbr" and navigate to "Isolation Routing". Then generate geometry:

Tool dia:       0.145
Width(#passes): 1
Pass overlap:   0.0
Combine Passes: No

New geometry "copper_top.gbr_iso" is created. Navigate to "Create CNC Job" and generate toolpath:

Cut Z:        -0.05
Travel Z:      1.0
Feed Rate:     250.0
Tool dia:      0.145
Spindle speed: 24,000
Multi-Depth:   No

New geometry "copper_top.gbr_iso_cnc" is created. Navigate to "Export G-Code" and export gcode.

Top-side solder mask

Select "soldermask_top.gbr" and navigate to "Isolation Routing". Then generate geometry:

Tool dia:       0.0
Width(#passes): 1
Pass overlap:   0.0
Combine Passes: No

New geometry "soldermask_top.gbr_iso" is created. Navigate to "Paint Area" and generate paint area:

Tool dia:  0.1
Overlap:   0.05
Margin:    0.1
Method:    standard
Connect:   yes
Contour:   yes
Selection: All

New geometry "soldermask_top.gbr_iso_paint" is created. Navigate to "Create CNC Job" and generate toolpath:

Cut Z:        -0.05
Travel Z:      1.0
Feed Rate:     400.0
Tool dia:      0.1
Spindle speed: 24,000
Multi-Depth:   No

New geometry "soldermask_top.gbr_iso_paint_cnc" is created. Navigate to "Export G-Code" and export gcode. That's it for the top layer. Now flip over the PCB. The alignment holes helps keep PCB in correct position. The bottom-side non-copper area, isolation, soldermask are identical to the top layer.

Drilling

In drills.xln's Tools selection, choose hole sizes needed for drilling, excluding those large holes which need milling. Holes larger than 1 mm in diameter, I will use milling process instead. So select:

0.406
0.61
0.95
1.016

In Create CNC Job section:

Cut Z:        -1.95
Travel Z:      1.0
Feed Rate:     150.0
Tool change:   yes
Tool change Z: 50
Spindle speed: 24,000

New geometry "drills.xln_cnc" is created. Navigate to "Export G-Code" and export gcode. Next, select drills.xln again and choose hole sizes for milling:

2.2
3.2
3.302

At Mill Holes section, generate geometry:

Tool dia: 1.5

New geometry "soldermask_top.gbr_iso_paint" is created. Navigate to "Create CNC Job" and generate toolpath:

Cut Z:        -1.95
Travel Z:      1.0
Feed Rate:     150.0
Tool dia:      1.5
Spindle speed: 24,000
Multi-Depth:   yes
Depth/pass:    1

New geometry "drills.xln_mill_cnc" is created. Navigate to "Export G-Code" and export gcode.

Cutouts

This is a bit tricky. We need the cut edges pass right through the middle of profile lines. The measurement tool indicates 0.254 mm line thickness. For 1.5 mm tool dia, we set Tool dia = 1.5 - 0.254 mm. In Isolation Routing, generate geometry with the calculated Tool dia:

Tool dia:       1.246
Width(passes):  1
Pass overlap:   0.0
Combine Passes: No

New geometry "profile.gbr_iso" is created. Delete the interior part by Edit Geometry > Add Rectangle on inner line > With Select tool, press CTRL and select Geometry and box respectively > Cut Path > Delete Shape both box and inner line > Update Geometry.

/pic/nikola-tut/pcbmilling/flatcam3.JPG

Add Rectangle > Cut Path > Delete Shape

/pic/nikola-tut/pcbmilling/flatcam4.JPG

Only outter profile left.

For small size PCB, you might need tabs to hold PCB in place while cutting. To do so, edit geometry > draw boxes on where you want tabs> cut path > delete boxes. This PCB is big enough so I will move on to Create CNC Job. Note that Tool dia is 1.5 mm this time:

Cut Z:        -1.95
Travel Z:      1.0
Feed Rate:     150.0
Tool dia:      1.5
Spindle speed: 24,000
Multi-Depth:   yes
Depth/pass:    1
/pic/nikola-tut/pcbmilling/flatcam5.JPG

A closer look.

/pic/nikola-tut/pcbmilling/flatcam6.JPG

Cutting edges are on the middle of the profile.gbr's lines now.

New geometry "profile.gbr_iso_cnc" is created. Export G-Code. Now we are done with Flatcam.

Machine specific G-code

Now we combine exported Gcode into a single file if they share the same cutting tool. A 0.1mm engrave bit is used for noncopper paint and isolation. A 0.6 and 0.9 mm drill bits are used for drilling. A 1.5 mm endmill is used for large holes and profile milling. This is example of my Gcode header:

G17
G54
G21
G90
$H
G00 X7.999700Y75.7321
M03 S24000
G4 P1
G00 Z1.0000
G01 Z-0.0500 F200.00
G01 X8.045600Y75.7418
.....

My CNC has Surface grid-probing feature which helps compensate uneven surface automatically. Simply specify area you wanna probe with G32. M374 save probe results for next time usage.:

G32 X-143.790000 Y-77.1287 A105. B55.
M374
G4 P1
G17
G54
G21
G90
$H
G00 X7.999700Y75.7321
M03 S24000
G4 P1
G00 Z1.0000
G01 Z-0.0500 F200.00
G01 X8.045600Y75.7418
...

Also Tool length probe with G38.2 and G10 for work coordinate. M500 save the settings for next time usage.:

G32 X-143.790000 Y-77.1287 A105. B55.
M374
G4 P1
G17
G54
G21
G90
G00 X4.000000Y74.000F2000.
G4 P1
G38.2 Z-20.
G4 P2
G10 L20 P1 Z0.
M500
G4 P1
$H
G00 X7.999700Y75.7321
M03 S24000
G4 P1
G00 Z1.0000
G01 Z-0.0500 F200.00
G01 X8.045600Y75.7418

Important

G32 utilize Machine coordinate system (G53 values)

/pic/nikola-tut/pcbmilling/flatcam7.JPG

Gcode visualization of top layer isolation.

/pic/nikola-tut/pcbmilling/flatcam8.JPG

Gcode visualization of top layer soldermask.

/pic/nikola-tut/pcbmilling/flatcam9.JPG

Gcode visualization of bottom layer isolation.

/pic/nikola-tut/pcbmilling/flatcam10.JPG

Gcode visualization of bottom layer soldermask.

/pic/nikola-tut/pcbmilling/flatcam11.JPG

Gcode visualization of holes and profile milling.

Milling the PCB

/pic/nikola-tut/pcbmilling/flatcam12.JPG

Milling top layer.

/pic/nikola-tut/pcbmilling/flatcam13.JPG

Milling top layer soldermask.

/pic/nikola-tut/pcbmilling/flatcam14.JPG

Milling bottom layer.

/pic/nikola-tut/pcbmilling/flatcam15.JPG

Finshed PCB top side.

/pic/nikola-tut/pcbmilling/flatcam16.JPG

Finshed PCB bottom side.

Flatcam installing from source

Create new Python 2.7 environment and install dependencies.

Follow this tutorial Using Python virtual environment with Anaconda. Then open up your new environment terminal. Make sure it is python 2.7 by:

python -V

Install packages:

pip install --upgrade matplotlib pypiwin32 svg.path scipy

note : Numpy already existed in the Anaconda environment. Use this command to check available package:

pip freeze

These packages are for Windows user. The .whl file is a pre-compiled package with its dependencies included. Simply download the following Python 2.7 64-bit packages and navigate your terminal to the containing folder.

Run this command to install the packages:

pip install <package's name>

From original requirements , it suggests Python 2.7 32-bit. I have not found any problem using Python 2.7 64-bit version.

Clone Flatcam repository and run it

navigate your terminal to where you want to put the clone and run this:

git clone https://bitbucket.org/jpcgt/flatcam
cd flatcam
python flatcam

Enjoy the Flatcam ! This is not stable release and may contain bugs, use it at your own risk.

Using Python virtual environment with Anaconda

Anaconda is an easier way for beginner to lean Python. We can create Python virtual environments for both 2.7 and 3.6 without messing around with the system PATH. In fact, you don't even need Administrator privilege. Moreover, you can manage Python modules through the GUI package manager. There are other useful tools such as Spyder IDE and Jupyter Notebook which we will talk about in the future. In Introduction to Nikola , I created an environment using virtualenv and virtualenvwrapper-win packages which is fine, but there is a simpler method. Let's get started.

Download and install

Download latest version of Anaconda . I installed the Python 3.6 version. However, you still can create Python 2.7 environment.

Anaconda Navigator.

Anaconda Navigator.

Create new environment

From the left, select Environments tab and create new environment with python 3.6 as show in figure below.

Creating new environment.

Creating new Python 3.6 environment.

Install desired package in the environment

Start the environment terminal

Terminal with Python virtual environment

Terminal with Python virtual environment.

Install Nikola package:

pip install --upgrade "Nikola[extras]"