initial commit
This commit is contained in:
commit
1894f0a024
2 changed files with 128 additions and 0 deletions
97
k2n.py
Executable file
97
k2n.py
Executable file
|
@ -0,0 +1,97 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
# This is a version of szczys's kicad-to-neoden, modified for use by the FemtoStar Project, so as to output the
|
||||||
|
# format expected by the Neoden 3V we use. We admit - it's kind of hackish, and remains a work in progress.
|
||||||
|
|
||||||
|
# Right now, this is not likely to work with negative X coordinates in the inputs, but will handle negative Y, which
|
||||||
|
# KiCAD's .pos files use for objects in the +X/YY quadrant of the board in KiCAD's coordinate system.
|
||||||
|
# This matches the quadrant KiCAD displays the page layout in, and so should usually be correct.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
|
#Translator for converting KiCAD .pos files to .csv files for a NEODEN pick and place machine
|
||||||
|
#Paste relevant rows of the .pos files below and chance the trailing_letter
|
||||||
|
#to be "T" for top or "B" for bottom
|
||||||
|
|
||||||
|
import fileinput
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def transrotate(value):
|
||||||
|
if value <= 180:
|
||||||
|
return int(value)
|
||||||
|
else:
|
||||||
|
value -= 180
|
||||||
|
return int(0-(180-value))
|
||||||
|
|
||||||
|
def process_pos_lines(pos_lists, min_y):
|
||||||
|
output_string = "Designator,Footprint,Mid X,Mid Y,Layer,Rotation,Comment\n"
|
||||||
|
output_string += ",,,,,,\n"
|
||||||
|
for line in pos_lists:
|
||||||
|
if line[0][0] == '#':
|
||||||
|
continue
|
||||||
|
|
||||||
|
# fix to output package instead of value, matching order expected by machine
|
||||||
|
outline = line[0] + "," + line[2] + ","
|
||||||
|
outline += line[3].split('.')[0] + "." + line[3].split('.')[1][:2] + "mm,"
|
||||||
|
|
||||||
|
# fix to force all Y coordinates to be above zero
|
||||||
|
line[4] = str(float(line[4]) + abs(min_y) + 1)
|
||||||
|
|
||||||
|
outline += line[4].split('.')[0] + "." + line[4].split('.')[1][:2] + "mm,"
|
||||||
|
if line[-1] == "top":
|
||||||
|
outline += "T,"
|
||||||
|
else:
|
||||||
|
outline += "B,"
|
||||||
|
|
||||||
|
# fix to output value instead of package, matching order expected by machine
|
||||||
|
outline += str(transrotate(float(line[5]))) + "," + line[1]
|
||||||
|
output_string += outline + '\n'
|
||||||
|
return output_string
|
||||||
|
|
||||||
|
# for above fix
|
||||||
|
def find_min_y(pos_lines):
|
||||||
|
min_y = 0
|
||||||
|
for line in pos_lines:
|
||||||
|
if line[0][0] == '#':
|
||||||
|
continue
|
||||||
|
print(float(line[4]))
|
||||||
|
if float(line[4]) < min_y:
|
||||||
|
min_y = float(line[4])
|
||||||
|
|
||||||
|
return min_y
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print("Syntax error!")
|
||||||
|
print("Usage: python kicad_to_neoden.py your_position_file_from_kicad.pos")
|
||||||
|
return
|
||||||
|
#Turn input .pos file into a list of lists
|
||||||
|
pos_lines = list()
|
||||||
|
for line in fileinput.input():
|
||||||
|
pos_lines.append(line.strip('\n').split())
|
||||||
|
|
||||||
|
cur_dir = os.getcwd()
|
||||||
|
filename = fileinput.filename()
|
||||||
|
if filename[-4:] != ".pos":
|
||||||
|
print("WARNING: Input file doesn't have expected '.pos' extension")
|
||||||
|
print("Parsing " + filename)
|
||||||
|
|
||||||
|
# get the minimum Y coordinate on the board, to shift components up later
|
||||||
|
min_y = find_min_y(pos_lines)
|
||||||
|
print("Minimum Y coordinate on board: " + str(min_y))
|
||||||
|
|
||||||
|
neoden_format = process_pos_lines(pos_lines, min_y)
|
||||||
|
#Strip trailing newline character
|
||||||
|
if neoden_format[-2:] == '\n':
|
||||||
|
neoden_format = neoden_format[:-2]
|
||||||
|
|
||||||
|
print("Writing CSV file")
|
||||||
|
output_file = os.path.splitext(os.path.join(cur_dir,filename))[0]+"_neoden.csv"
|
||||||
|
|
||||||
|
with open(output_file, 'w') as ofile:
|
||||||
|
ofile.write(neoden_format)
|
||||||
|
print("Successfully wrote:",output_file)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
31
readme.md
Normal file
31
readme.md
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#kicad_to_neoden for Neoden 3V
|
||||||
|
Converter for automated PCB assembly from a KiCad POS file on the Neoden 3V pick-and-place machine
|
||||||
|
|
||||||
|
This is a version of szczys's kicad-to-neoden, modified for use by the FemtoStar Project, so as to output the format expected by the Neoden 3V we use. We admit - it's kind of hackish, and remains a work in progress.
|
||||||
|
|
||||||
|
|
||||||
|
NOTE: This currently expects your board to be in the +X/+Y or +X/-Y quadrant in the POS file. Most boards will be in +X/+Y in Pcbnew and +X/-Y in the POS file
|
||||||
|
|
||||||
|
USAGE: k2n.py some-kicad-file-top.pos (will create some-kicad-file-top_neoden.csv)
|
||||||
|
|
||||||
|
Notes on coordinates:
|
||||||
|
- In KiCad editor, 0,0 is the top left, down is +Y
|
||||||
|
- In KiCad POS file, 0,0 is still the top left, but down is -Y and your board is in the +X, -Y quadrant if it was in +X/+Y in KiCAD
|
||||||
|
- On Neoden, in machine space, 0,0 is the front left corner of the machine.
|
||||||
|
- The Neoden does not allow negative coordinates, even in board space, and will not let you enter them in the UI.
|
||||||
|
- In POS files and on the machine, but NOT in the editor, higher-value Y coordinates are further UP the board - no "flipping" from the pos file is needed
|
||||||
|
|
||||||
|
Conversion involves:
|
||||||
|
- Finding minimum Y value in input POS file
|
||||||
|
- Taking the absolute value of this
|
||||||
|
- Adding this to all Y coordinates
|
||||||
|
|
||||||
|
When setting up the Neoden:
|
||||||
|
- The "first chip" coordinate you're supposed to set is NOT a fiducial even though it lets you optically align it, unless a fid is your first component
|
||||||
|
- It's literally the first component in order to be placed, and it has to be set to this in machine space
|
||||||
|
- Most component footprints cannot be easily aligned to using the Mark Align feature of the machine - do this manually
|
||||||
|
- It's okay if you're a little off - placement of your board is still based on your fiducials, this is only used to find the fiducials to begin with
|
||||||
|
- The CSV file this generates is NOT the CSV you can import from the Neoden's file manager - that includes feeder information, etc, not just components
|
||||||
|
- To import this CSV file, create or copy a file, then click Edit on it, and import the CSV into the last tab - ensure components are added.
|
||||||
|
- You will need to set fiducial coordinates manually, and mark fiducials as "Skip - Yes" to avoid "placing" them.
|
||||||
|
- Pay attention to component heights, which you set on the machine itself - don't want to slam your parts into the board too hard.
|
Loading…
Reference in a new issue