Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,27 @@ The target for this project was to create an all-in-one simpleFOC board with hig
# Building

- Install [platformio core](https://docs.platformio.org/en/latest/core/installation/methods/index.html)
- Run `pio run`
- Run `pio run --environment aioli-foc`

Alternately you can use the vscode integration

# Flashing

There are two options for flashing - DFU mode, and with stlink hardware

## DFU Mode

DFU mode can be done via the USB port, but due to the st32's default settings, pin PB8 will conflict with the CAN XCVR line, causing the st32 to boot to DFU mode every reset, losing the firmware and requiring recompilation. This is fine for testing but you'll need to use stlink to change that setting, and to program the st32 without being in DFU mode.

To program in DFU mode, set `upload_protocol` to `dfu` in `platformio.ini`.

You can then use `pio run --target upload --environment aioli-foc` or press `Upload` in vscode.

Note that `Upload and Monitor` may not work because `dfu-util` tends to think the upload failed even if it didn't.

## stlink Mode
- Acquire an [stlink v3 minie](https://www.st.com/en/development-tools/stlink-v3minie.html) or equvalent
- Connect the stlink to the 1.27mm 2x7 header on the board labeled `stm32g431`. This will require either soldering a header in (it is not in the JLBPCB BOM), or just jamming it in and holding it long enough to make contact.
- Once per board you will have to use `STM32CubeProgrammer` or `STM32 ST-LINK Utility` to set the Option Byte under User Configuration named `nSWBOOT0` to unchecked. This will prevent the st32 from going into DFU mode on every reset.
- Make sure to set `upload_protocol` back to `stlink` in `platformio.ini`
- Run `pio run --target upload --target monitor --environment aioli-foc` or click `Upload and Monitor` in vscode
1 change: 1 addition & 0 deletions mechanical/motor_parametric/IterateSTLs/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PYTHONPATH=C:/Users/vitaminmoo/AppData/Local/Autodesk/webdeploy/production/2f98b3925294fb88cbae05383e953941ed5106e7/Api/Python/packages
10 changes: 10 additions & 0 deletions mechanical/motor_parametric/IterateSTLs/IterateSTLs.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"autodeskProduct": "Fusion",
"type": "script",
"author": "Graham Forest",
"description": {
"": ""
},
"supportedOS": "windows|mac",
"editEnabled": true
}
56 changes: 56 additions & 0 deletions mechanical/motor_parametric/IterateSTLs/IterateSTLs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import adsk.core, adsk.fusion, traceback
import csv
import time
import os

def run(context):
ui = None
dir = "C:\\Users\\vitaminmoo\\repos\\aioli-foc\\mechanical\\motor_parametric\\"
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = app.activeProduct
rootComp = design.rootComponent

screwTable = {
# motorScrewHoleDiameter, motorScrewHeadHeight, motorScrewHeadDiameter
'1.6': (1.8, 1.6, 3.14),
'2.0': (2.4, 2.0, 3.98),
'2.5': (2.9, 2.5, 4.68),
}

with open(os.path.join(dir, 'motors.csv'), mode='r') as motorsFile:
reader = csv.DictReader(motorsFile)
for row in reader:
for key in row:
if key == 'motorScrewM':
i = 0
for a in ('motorScrewHoleDiameter', 'motorScrewHeadHeight', 'motorScrewHeadDiameter'):
p = design.userParameters.itemByName(a)
value = screwTable[row['motorScrewM']][i]
p.expression = str(value)
i += 1
if key == 'motorMagnetDiameter':
row['motorMagnetDiameter'] = str(max(float(row['motorMagnetDiameter']), 13)) # arbitrary minimum
if key == 'motorMagnetLength':
row['motorMagnetLength'] = str(max(float(row['motorMagnetLength']), 3.5)) # clear a molex connector

p = design.userParameters.itemByName(key)
try:
float(row[key])
p.expression = row[key]
except:
p.comment = row[key]

exportMgr = design.exportManager

allBodies = rootComp.bRepBodies
for body in allBodies:
filename = os.path.join(dir, 'stls', row['motorModel'] + '_' + body.name + '.stl')
stlExportOptions = exportMgr.createSTLExportOptions(body, filename)
stlExportOptions.sendToPrintUtility = False
exportMgr.execute(stlExportOptions)
ui.messageBox('Complete')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
20 changes: 20 additions & 0 deletions mechanical/motor_parametric/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generic 3-screw mounting hardware

![render](render.png)

This directory contains a parametric design compatible with many 3 screw
motors. If the wiring output from the motor takes up physical space, it just
needs to be between two of the screws somewhere and it should be fine.

The PCB-side screw holes are sized to allow M3 bolts to thread in from the
back, through the PCB. Two holes will be available unused in the corners if
you're looking to panel mount.

It should be pretty print settings agnostic, but you should probably print it
from at least PETG or other filament with proper heat tolerance as some motors
can get a bit warm for PLA if you're still tuning them or you're driving them
hard.

motors.csv contains parameter overrides to use with the Fusion 360 script in
IterateSTLs. Note that you will have to hardcode new paths in that python
script for it to work.
4 changes: 4 additions & 0 deletions mechanical/motor_parametric/motors.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
motorModel,motorDiameter,motorScrewHoleFromCenter,motorMagnetLength,motorScrewM,motorMagnetDiameter
EM3215,32,10.5,3.3,1.6,11.5
PTZ2204,27.90,10.265,2.25,2.0,5
GB2804,34.5,14.434,7.1,2.0,12.5
Binary file not shown.
Loading