Commit c58120a5 authored by Jake Read's avatar Jake Read

open loop 6-step commutation

parent c757089a
......@@ -18,7 +18,9 @@ This perhaps means I need to run that SPI cable with a differential driver, to b
## Notes
- body diode? https://www.youtube.com/watch?v=uqzOQGiwGnE or pwm sigs to freewheel? check deadtime?
- capacitors should be able to live sticking topside-up, we're going to want to pull heat out of the top ! small space penalty
- small FET re-jiggering to get all 12 under two 21.1x21.1mm heatsinks on the topside as well
- and mount with sideways fan 1570-1162-ND across both from fet-side
Fan
- 1053-1210-ND
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -9,9 +9,12 @@ AutoSaveProject=1
UsedLibraryUrn="urn:adsk.eagle:library:217"
UsedLibraryUrn="urn:adsk.eagle:library:325"
UsedLibraryUrn="urn:adsk.eagle:library:371"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/fab.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries_jake/eagle/jake/tag-connect-2050.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries_jake/eagle/sparkfun/SparkFun-Connectors.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries_jake/eagle/marekr/borkedlabs-passives.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/comm.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/connector.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/fab.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/lights.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/microcontrollers.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/motors.lbr"
......@@ -19,23 +22,20 @@ UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/passives.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/power.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/sensor.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/tag-connect-2030.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries_jake/eagle/sparkfun/SparkFun-Connectors.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries_jake/eagle/jake/tag-connect-2050.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries_jake/eagle/marekr/borkedlabs-passives.lbr"
UsedLibrary="D:/Dropbox (Personal)/CBA/doc/libraries_jake/eagle/sparkfun/SparkFun-DiscreteSemi.lbr"
[Win_1]
Type="Library Editor"
Number=2
File="D:/Dropbox (Personal)/CBA/doc/libraries/eagle/power.lbr"
View="-4.8143 -9.77493 4.96211 9.82573"
WireWidths=" 0.0762 0.1016 0.15 0.2 0.2032 0.3048 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.1524 0.254 0.127"
Type="Schematic Editor"
Number=3
File="atkbldcdriver.sch"
View="-44.9342 -57.8843 305.205 101.038"
WireWidths=" 0.0762 0.1016 0.127 0.15 0.2 0.2032 0.254 0.3048 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.1524"
PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
PadDrills=" 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6"
ViaDiameters=" 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1 1.05 1.1 1.15 1.2 1.3 0"
ViaDrills=" 0.2 0.25 0.3 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35"
HoleDrills=" 0.2 0.25 0.3 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35"
TextSizes=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.4224 1.6764 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.778 1.27"
TextSizes=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.778"
PolygonSpacings=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.27"
PolygonIsolates=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
MiterRadiuss=" 0.254 0.3175 0.635 1.27 2.54 1 2 2.5 5 7.5 10 0"
......@@ -45,9 +45,9 @@ DimensionExtLengths=" 1.27 2.54 1 2 3 0"
DimensionExtOffsets=" 1.27 2.54 1 2 3 0"
SmdSizes=" 0.3048 0.1524 0.4064 0.2032 0.6096 0.3048 0.8128 0.4064 1.016 0.508 1.27 0.6604 1.4224 0.7112 1.6764 0.8128 1.778 0.9144 1.9304 0.9652 2.1844 1.0668 2.54 1.27 3.81 1.9304 5.08 2.54 6.4516 3.2512 1.27 0.635"
WireBend=0
WireBendSet=0
WireBendSet=31
WireCap=1
MiterStyle=1
MiterStyle=0
PadShape=0
ViaShape=1
PolygonPour=0
......@@ -66,58 +66,15 @@ SwapLevel=0
ArcDirection=0
AddLevel=2
PadsSameType=0
Layer=21
Package="HTSSOP-56"
Layer=97
Views=" 1: -44.9342 -57.8843 305.205 101.038"
Sheet="1"
[Win_2]
Type="Board Editor"
Number=1
File="atkbldcdriver.brd"
View="-15.1007 14.1863 109.925 37.5249"
WireWidths=" 0.127 0.15 0.6096 2.54 1.27 0.3048 0.254 0.2 0.1016 1.016 0.508 0.4064 0.2032 0.8128 0.0762 0.1524"
PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
PadDrills=" 0.2 0.25 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6 0.3"
ViaDiameters=" 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 0.95 1 1.05 1.1 1.15 1.2 1.3 0"
ViaDrills=" 0.2 0.4 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.5 0.25 0.35 0.45 0.3"
HoleDrills=" 0.2 0.25 0.4 0.45 0.5 0.55 0.6 0.65 0.7 0.75 0.8 0.85 0.9 1 0.35 0.3"
TextSizes=" 0.254 0.3048 0.4064 0.8128 1.016 1.27 1.4224 1.6764 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.778 0.6096"
PolygonSpacings=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 5.08 6.4516 1.27"
PolygonIsolates=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
MiterRadiuss=" 0.254 0.3175 0.635 1.27 2.54 1 2 2.5 5 7.5 10 0"
DimensionWidths=" 0 0.127 0.254 0.1 0.26 0.13"
DimensionExtWidths=" 0.127 0.254 0.1 0.13 0.26 0"
DimensionExtLengths=" 1.27 2.54 1 2 3 0"
DimensionExtOffsets=" 1.27 2.54 1 2 3 0"
SmdSizes=" 0.3048 0.1524 0.4064 0.2032 0.6096 0.3048 0.8128 0.4064 1.016 0.508 1.27 0.6604 1.4224 0.7112 1.6764 0.8128 1.778 0.9144 1.9304 0.9652 2.1844 1.0668 2.54 1.27 3.81 1.9304 5.08 2.54 6.4516 3.2512 1.27 0.635"
WireBend=1
WireBendSet=0
WireCap=1
MiterStyle=0
PadShape=0
ViaShape=1
PolygonPour=0
PolygonRank=3
PolygonThermals=1
PolygonOrphans=0
TextRatio=10
DimensionUnit=1
DimensionPrecision=2
DimensionShowUnit=0
PinDirection=3
PinFunction=0
PinLength=2
PinVisible=3
SwapLevel=0
ArcDirection=0
AddLevel=2
PadsSameType=0
Layer=1
[Win_3]
Type="Schematic Editor"
Number=3
File="atkbldcdriver.sch"
View="-343.782 -295.52 910.832 273.925"
View="7.5732 40.6204 26.1449 54.993"
WireWidths=" 0.0762 0.1016 0.127 0.15 0.2 0.2032 0.254 0.3048 0.4064 0.508 0.6096 0.8128 1.016 1.27 2.54 0.1524"
PadDiameters=" 0.254 0.3048 0.4064 0.6096 0.8128 1.016 1.27 1.4224 1.6764 1.778 1.9304 2.1844 2.54 3.81 6.4516 0"
PadDrills=" 0.2 0.25 0.3 0.35 0.4 0.45 0.5 0.55 0.65 0.7 0.75 0.8 0.85 0.9 1 0.6"
......@@ -133,14 +90,14 @@ DimensionExtWidths=" 0.127 0.254 0.1 0.13 0.26 0"
DimensionExtLengths=" 1.27 2.54 1 2 3 0"
DimensionExtOffsets=" 1.27 2.54 1 2 3 0"
SmdSizes=" 0.3048 0.1524 0.4064 0.2032 0.6096 0.3048 0.8128 0.4064 1.016 0.508 1.27 0.6604 1.4224 0.7112 1.6764 0.8128 1.778 0.9144 1.9304 0.9652 2.1844 1.0668 2.54 1.27 3.81 1.9304 5.08 2.54 6.4516 3.2512 1.27 0.635"
WireBend=0
WireBendSet=31
WireBend=1
WireBendSet=0
WireCap=1
MiterStyle=0
MiterStyle=1
PadShape=0
ViaShape=1
PolygonPour=0
PolygonRank=0
PolygonRank=1
PolygonThermals=1
PolygonOrphans=0
TextRatio=8
......@@ -155,11 +112,9 @@ SwapLevel=0
ArcDirection=0
AddLevel=2
PadsSameType=0
Layer=97
Views=" 1: -343.782 -295.52 910.832 273.925"
Sheet="1"
Layer=1
[Win_4]
[Win_3]
Type="Control Panel"
Number=0
......@@ -168,4 +123,3 @@ Screen="3840 1080"
Window="Win_1"
Window="Win_2"
Window="Win_3"
Window="Win_4"
......@@ -38,4 +38,5 @@ Got this running, feels pretty mediocre. I need to understand commutation a bit
# Notes
- read shane colton's pdf on sensorless field oriented control, and his park-transform free FOC solution: sounds cool. finish phase search algorithm.
\ No newline at end of file
- read shane colton's pdf on sensorless field oriented control, and his park-transform free FOC solution: sounds cool. finish phase search algorithm.
- FOC is basically finding the right phase offset to correct for inductance... with the inputs of current current vector, current position, we should be able so search for the optimum voltage vector. 2D.
\ No newline at end of file
......@@ -41,7 +41,7 @@
</framework-data>
</AsfFrameworkConfig>
<avrtool>com.atmel.avrdbg.tool.atmelice</avrtool>
<avrtoolserialnumber>J41800086407</avrtoolserialnumber>
<avrtoolserialnumber>J41800087098</avrtoolserialnumber>
<avrdeviceexpectedsignature>0x1E9842</avrdeviceexpectedsignature>
<com_atmel_avrdbg_tool_atmelice>
<ToolOptions>
......@@ -51,11 +51,22 @@
<InterfaceName>PDI</InterfaceName>
</ToolOptions>
<ToolType>com.atmel.avrdbg.tool.atmelice</ToolType>
<ToolNumber>J41800086407</ToolNumber>
<ToolNumber>J41800087098</ToolNumber>
<ToolName>Atmel-ICE</ToolName>
</com_atmel_avrdbg_tool_atmelice>
<avrtoolinterface>PDI</avrtoolinterface>
<avrtoolinterfaceclock>4000000</avrtoolinterfaceclock>
<com_atmel_avrdbg_tool_simulator>
<ToolOptions xmlns="">
<InterfaceProperties>
</InterfaceProperties>
<InterfaceName>PDI</InterfaceName>
</ToolOptions>
<ToolType xmlns="">com.atmel.avrdbg.tool.simulator</ToolType>
<ToolNumber xmlns="">
</ToolNumber>
<ToolName xmlns="">Simulator</ToolName>
</com_atmel_avrdbg_tool_simulator>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<ToolchainSettings>
......
......@@ -27,7 +27,7 @@ void bldc_shutdown(bldc_t *bldc){
void bldc_setDuty(bldc_t *bldc, uint32_t duty){
// blind pwm duty 0-512
// hard stop at 256 to avoid breaking things
(duty > 256) ? duty = 256 : (0);
(duty > 512) ? duty = 512 : (0);
bldc->comDuty = (uint16_t) duty;
}
......
......@@ -118,7 +118,7 @@ void putReading(uint16_t reading){
readIndex ++;
}
void getReadAverage(uint16_t &avg){
void getReadAverage(uint16_t *avg){
uint8_t numReads = readIndex; // sloppy, but makes this interrupt safe
uint32_t readSum = 0;
for(uint8_t i = 0; i < numReads; i ++){
......@@ -200,12 +200,11 @@ void tickers_init(void){
// set cca interrupt on
TCD0.INTCTRLA = TC_OVFINTLVL_HI_gc;
// this ticker for search
// another timer runs 'acceleration'
uint16_t perAccelRate = 2048;
uint8_t perAl = (uint8_t) perAccelRate;
uint8_t perAh = (uint8_t) (perAccelRate >> 8);
// another ticker to execute accel
TCD1.CTRLA = TC_CLKSEL_DIV64_gc;
TCD1.PERBUFL = perAl;
TCD1.PERBUFH = perAh;
......@@ -215,6 +214,7 @@ void tickers_init(void){
int main(void)
{
// boilerplate atk things
clock_init();
uarts_init();
atkps_init();
......@@ -228,18 +228,20 @@ int main(void)
pin_set(&stlerr);
pin_set(&stlclk);
// startup encoder
encoder_init();
// start timers for commutation, accel tickers
tickers_init();
// startup encoder (currently borked)
// encoder_init();
// start pwm system
pwm_init();
// initialize the bldc state structure
bldc_init(&bldc);
// on startup, speed (if clcomm) and duty
//bldc_setTargetSpeed(&bldc, 1000);
// bldc_setDuty(&bldc, 10);
bldc_setTargetSpeed(&bldc, 1000);
bldc_setDuty(&bldc, 45); // MAX 512, dangerous above ~ 120
// start the timers that do work
tickers_init();
bldc_setSpeed(&bldc, 100);
// startup the driver
drv_init();
// and enable the gate
......@@ -263,8 +265,22 @@ int main(void)
// commutation timer
ISR(TCD0_OVF_vect){
// CL 6-step Commutate
// open-loop commutation
(bldc.comDir) ? (bldc.comState ++) : (bldc.comState --);
if(bldc.comState > 5){
bldc.comState = 0;
}
pwm_by_offset( comTable[bldc.comState][0] * bldc.comDuty,
comTable[bldc.comState][1] * bldc.comDuty,
comTable[bldc.comState][2] * bldc.comDuty
);
/*
// CL 6-step Commutate
// get encoder reading
ams5047_read(&ams5047, &enc_reading);
// reversal if
......@@ -272,20 +288,23 @@ ISR(TCD0_OVF_vect){
// target phase expressed in 0 - 2PI, where 2PI in terms of an encoder counts' worth of ticks
// we add the encoder's resolution here so that we can safely have negative encoder offsets
phase_target = (enc_resolution + enc_reading + enc_offset + pi_enc) % twoPi_enc;
// we need to compute the respective pwm positions given the phase target
pwm_by_sin_duty(phase_target, 0.05);
pwm_by_sin_duty(phase_target, 0.75);
*/
}
static uint16_t lastRead = 0;
static uint16_t thisRead;
ISR(TCD1_OVF_vect){
// search timer
// get new pos: whoop, average speeds, derive from sequence!
getReadAverage(&thisRead);
if(bldc.currentSpeed != bldc.targetSpeed){
if(bldc.currentSpeed < bldc.targetSpeed){
bldc.currentSpeed ++;
bldc_setSpeed(&bldc, bldc.currentSpeed);
} else {
bldc.currentSpeed --;
bldc_setSpeed(&bldc, bldc.currentSpeed);
}
}
}
ISR(USARTE1_RXC_vect){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment